
Micaiah
02.04.2017
01:16:54
len("bla")
I worded that poorly, I meant the max length. For example, if you had a field last_name = Required(str, 15)

Richie
02.04.2017
01:23:09
I neeg to learn english more , it's hard to understand about the discussion was telling
need*-
the sun begin raise here and going sunset there...he2, sorry, out of the topic

Google

Richie
02.04.2017
01:28:40
anyway, in the case of making GUI Desktop applications. so, I have to call the pony instances object and put it in my GUI event ?
example
@db_session
def myproductName(iproduct):
prdt = product[iproduct]
print prdt.name
def eventhandlercase(self,event):
iproduct = self.getvalue(onbuttonclick)
myproductName(iproduct)
is that correct?

Alexey
02.04.2017
01:37:23

Micaiah
02.04.2017
01:38:04
What is stored in converters?

Alexey
02.04.2017
01:38:26
functions that convert value from py to sql and back

Micaiah
02.04.2017
01:38:46
Gotcha, thanks
Is length consistant between converters?

Alexey
02.04.2017
01:41:31
it is equal to the number of columns which are required to store an attribute
for the most cases it is 1
but in Pony you can have attributes that require more than one column in the database to store it

Micaiah
02.04.2017
01:42:44
Like composites?

Alexey
02.04.2017
01:42:50
yes

Micaiah
02.04.2017
01:47:32
Still trying to work out the best way to convert an Entity to a FlaskForm subclass, I was just going to go through each of the fields and iterate through a conversion function, but there are so many things to keep track of that the function becomes pretty crazy after just a few field types. I think I might be better off subclassing PrimaryKey, Required, Optional, and Set

Cristian
02.04.2017
03:24:17
i am working with pony to read data from existing sqlite db, i got this error (comment has models) https://gist.github.com/ovnicraft/ccf6800a551d3cf67ffc7b5460be71fc

Google

Cristian
02.04.2017
03:24:34
so my Q is: Entity always need id attribute _
?

Alexander
02.04.2017
11:13:29
@b00t5tr4p no, it is not necessary for entity to have id attribute, but it should have a primary key. If no primary key defined, default primary key attribute with id name added automatically. You can explicitly specify another attribute as a primary key


Richie
02.04.2017
11:29:56
okay. , I l try your suggest. Do you have any documentation that is refer to db_session for many users access in the same database?

Alexander
02.04.2017
11:31:59
db_session documentation is here: https://docs.ponyorm.com/transactions.html
db_session specifies transdaction boundaries. If multiple users are working with the same database, each should work in a separate transaction

Richie
02.04.2017
11:33:05
okay,, thanks. I ll read it right away..
so db_session will accumulate objects before they are being committed, am I right?
and I could just use commit() between transactions in the same db_session, (if i don't want to separate the transactions)

Alexander
02.04.2017
11:51:08
yes. If you use manual commit(), you can continue working with the same objects, but they may become out-of-date if another user did some changes
And then Pony will check upon save that the object in the memory have the same data as the object in the database

Richie
02.04.2017
11:58:06
ah...I see

Micaiah
02.04.2017
22:14:42
Can you programmatically get the mypy types from the parameters of a function?

Cristian
02.04.2017
22:22:12

Richie
03.04.2017
03:15:36
I wonder if there is some tools to convert from sql script into pony orm instantly..
so I don't have to write new schema in the online editor once I had already got the sql version

Alexander
03.04.2017
07:50:36
Right now there are no such a tool, maybe we will add it in the future

Richie
03.04.2017
07:52:08
Okay , . I hope

Google

Richie
03.04.2017
07:52:12
so

Manuel
05.04.2017
16:10:46
Hi all, I'm having a hard time trying to get a sql like with multiple percentage signs: %str1%str2%str3%. I have this: users = select( u for u in User if user_input.join("%") in u.name ) but it doesn't work the way I expect.

Alexander
05.04.2017
16:13:59
Hi Manuel, what database do you use?

Manuel
05.04.2017
16:14:14
sqlite

Alexander
05.04.2017
16:17:11
You can embed raw_sql fragment into your query:
like_str = '%str1%str2%str3%'
users = select(u for u in User
if raw_sql('u.name like $like_str'))

Manuel
05.04.2017
16:18:07
thanks! that will do
Does the % character suffers any special escaping?

Alexander
05.04.2017
16:22:48
In the variant I suggested, no

Manuel
05.04.2017
16:22:53
my first query was wrong, this is the right one: users = select( u for u in User if "%".join(user_input.split()) in u.name )
so a alex ko string would be %alex%ko%

Alexander
05.04.2017
16:24:27

Manuel
05.04.2017
16:33:17
Thanks, the raw_query variant seems perfect. Nice work with Pony!

Luckydonald
06.04.2017
17:30:47
I suspect get_current_user() to return nothing.
>>> repr(orm.get_current_user())
'None'

Alexander
06.04.2017
17:32:25
_get_schema_dict returns only a subset of entities whch current_user has rights to see

Luckydonald
06.04.2017
17:32:56
>>> repr(orm.core.local.current_user)
'None'
But I don't understand why that user is None. I can query the database.

Alexander
06.04.2017
17:34:51
You need to call set_current_user before

Luckydonald
06.04.2017
17:35:41
with what input? The database user I gave at db.bind?

Google

Luckydonald
06.04.2017
17:36:18
like orm.set_current_user('postgres_user')?

Alexander
06.04.2017
17:39:35
No, typically a user is an entity instance from the database.
If you want to show all entities to any unregistered user, just set permissions accordingly
with db.permissions_for(Entity1, Entity2, ...):
allow('view', group='anybody')

Luckydonald
06.04.2017
17:39:38
Oh, this is the has_perm stuff from ponyJS

Alexander
06.04.2017
17:39:43
yes

Luckydonald
06.04.2017
17:40:17
Ah, I thought that would only be checked in .to_json()
AttributeError: 'Database' object has no attribute 'permissions_for'

Alexander
06.04.2017
17:44:53
Sorry, it's set_perms_for

Luckydonald
06.04.2017
17:46:17
>>> with db.set_perms_for(Sticker):
... orm.core.can_view(POSTGRES_USER, Sticker)
...
False
Oh never mind
I'm stupid :D
not my postgres user anymore.
>>> with db.set_perms_for(Sticker):
... orm.allow('view', group='anybody')
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
AttributeError: module 'pony.orm' has no attribute 'allow'
Can't find that method either.

Alexander
06.04.2017
18:04:19
Try this:
with db.set_perms_for(Sticker):
orm.perm('view', group='anybody')

Luckydonald
06.04.2017
18:04:52
Seems working: <pony.orm.core.AccessRule object at 0x7f46437e41d0>
And db._get_schema_dict() too

Alexander
06.04.2017
18:05:56
cool

Luckydonald
06.04.2017
20:27:13
What's the difference of ._attrs_ and ._new_attrs_?

Alexander
06.04.2017
20:28:25
If one entity inherits from another entity, _new_attrs_ contains new attributes only

Luckydonald
06.04.2017
20:37:25
Ah, thanks.
Also, where can I find the size attribute of an int type Attribute?
(Or something else to be able to distinguish between long, int, short, etc., and float, double)

Google

Luckydonald
06.04.2017
20:46:51
Got it.
>>> Class.field.kwargs['size']
64

Alexander
06.04.2017
21:36:42
I recommend to use the following:
attr.converters[0].size

Micaiah
07.04.2017
15:06:13
What would be the best way to catch for different transaction errors and turn them to JSON
For example:
with db_session:
try:
return TestEntity.get(id=id).to_dict()
except Exception as e:
# what to do with e?

Alexander
07.04.2017
18:04:22
may be
return jsonify({'status': 'error', 'class': type(e).__name__, 'msg': str(e)})
?

Micaiah
08.04.2017
01:21:44

Luckydonald
08.04.2017
11:32:35
How do I do unit tests with Pony?
is there a way to use it without actual database?

Alexander
08.04.2017
11:58:31
You can have a separate test database, and call db.bind(...) in test setup with parameters of that database. If you don't use any logic specific to your main database engine, you can use SQLite in-memory database for tests

Richie
09.04.2017
04:33:24
what does pony seems to be fit in web frameworks with?
does it only flask which gives a nice integrated ?

Micaiah
09.04.2017
06:22:27

Richie
09.04.2017
08:59:11
What about Odoo or ERP5?Have you tried to those frameworks?

Luckydonald
09.04.2017
09:52:06

Richie
09.04.2017
10:00:57
Yeap I knew it..I hope Pony will have tool to migrate data

Maxim
09.04.2017
11:20:46
Alexander, do u plan to extend lambda syntax in Pony? I hope in the future pony will support all types of operations == without lambdas...Where is Russian telegram :)

Richie
09.04.2017
11:27:22
Pony has give big improvement some years ago, and I can't wait for another one....?Love pony

Alexander
09.04.2017
11:54:48
I realy hope we will finish migration tool soon
Maxim, what do you mean by extending lambda syntax, can you give an example?