<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Nice to hear that. <br>
<br>
As far as i know Pony ORM can't work in async mode with deferred
objects?<br>
Some of our projects need to be implemented using fast orm with
async calls, and we'd prefer to use Pony, so we are curious about
plans for async mode in Pony. Please provide if there are no plans
for implementing this feature.<br>
<br>
<br>
<div class="moz-cite-prefix">12.08.2014 20:09, Alexey Malashkevich
пишет:<br>
</div>
<blockquote
cite="mid:CABuFHj40eTCmu0BgM5S1mOP_XjKVFL6OsM4cWxFnbQBwL-+H-w@mail.gmail.com"
type="cite">
<div dir="ltr">Hi all,
<div><br>
</div>
<div>Pony ORM Release 0.5.3 is out!</div>
<div><br>
</div>
<div>This release includes preliminary changes required for
Python 3 support, fixes using lambdas in query filters and
adds the new entity instance method 'to_dict()': </div>
<div><br>
</div>
<div>to_dict(only=None, exclude=None, with_collections=False,
with_lazy=False, related_objects=False)<br>
</div>
<div><br>
</div>
<div>
<div>Returns a dictionary with attribute names and its values.
This method can be used when you need to serialize an object
to JSON or other format.</div>
<div><br>
</div>
<div>By default this method doesn’t include collections
(relationships to-many) and lazy attributes. If an
attribute’s values is an entity instance then only the
primary key of this object will be added to the dictionary.</div>
<div><br>
</div>
<div>only – use this parameter if you want to get only the
specified attributes. This argument can be used as a first
positional argument. You can specify a list of attribute
names obj.to_dict(['id', 'name']), a string separated by
spaces: obj.to_dict('id name'), or a string separated by
spaces with commas: obj.to_dict('id, name').</div>
<div><br>
</div>
<div>exclude – this parameter allows to exclude specified
attributes. Attribute names can be specified the same way as
for the only parameter.</div>
<div><br>
</div>
<div>related_objects – by default, all related objects
represented as a primary key. If related_objects=True, then
objects which have relationships with the current object
will be added to the resulting dict as objects, not their
primary keys. It can be useful if you want to walk the
related objects and call the to_dict() method recursively.</div>
<div><br>
</div>
<div>with_collectionsTrue, then the relationships to-many will
be represented as lists. If related_objects=False (which is
by default), then those lists will consist of primary keys
of related instances. If related_objects=True then to-many
collections will be represented as lists of objects.</div>
<div><br>
</div>
<div>with_lazy – if True, then lazy attributes (such as BLOBs
or attributes which are declared with lazy=True) will be
included to the resulting dict.</div>
<div><br>
</div>
<div>For illustrating the usage of this method we will use the
eStore example which comes with Pony distribution. Let’s get
a customer object with the id=1 and convert it to a
dictionary:</div>
<div><br>
</div>
<div> >>> from pony.orm.examples.estore import
*</div>
<div> >>> c1 = Customer[1]</div>
<div> >>> c1.to_dict()</div>
<div><br>
</div>
<div> {'address': u'address 1',</div>
<div> 'country': u'USA',</div>
<div> 'email': <a moz-do-not-send="true"
href="mailto:u%27john@example.com">u'john@example.com</a>',</div>
<div> 'id': 1,</div>
<div> 'name': u'John Smith',</div>
<div> 'password': u'***'}</div>
<div><br>
</div>
<div>If we don’t want to serialize the password attribute, we
can exclude it this way:</div>
<div><br>
</div>
<div> >>> c1.to_dict(exclude='password')</div>
<div><br>
</div>
<div> {'address': u'address 1',</div>
<div> 'country': u'USA',</div>
<div> 'email': <a moz-do-not-send="true"
href="mailto:u%27john@example.com">u'john@example.com</a>',</div>
<div> 'id': 1,</div>
<div> 'name': u'John Smith'}</div>
<div><br>
</div>
<div>If you want to exclude more than one attribute, you can
specify them as a list: exclude=['id', 'password'] or as a
string: exclude='id, password' which is the same as
exclude='id password'.</div>
<div><br>
</div>
<div>Also you can specify only the attributes, which you want
to serialize using the parameter only:</div>
<div><br>
</div>
<div> >>> c1.to_dict(only=['id', 'name'])</div>
<div><br>
</div>
<div> {'id': 1, 'name': u'John Smith'}</div>
<div><br>
</div>
<div> >>> c1.to_dict('name email') # 'only'
parameter as a positional argument</div>
<div><br>
</div>
<div> {'email': <a moz-do-not-send="true"
href="mailto:u%27john@example.com">u'john@example.com</a>',
'name': u'John Smith'}</div>
<div><br>
</div>
<div>By default the collections are not included to the
resulting dict. If you want to include them, you can specify
with_collections=True. Also you can specify the collection
attribute in the only parameter:</div>
<div><br>
</div>
<div> >>> c1.to_dict(with_collections=True)</div>
<div><br>
</div>
<div> {'address': u'address 1',</div>
<div> 'cart_items': [1, 2],</div>
<div> 'country': u'USA',</div>
<div> 'email': <a moz-do-not-send="true"
href="mailto:u%27john@example.com">u'john@example.com</a>',</div>
<div> 'id': 1,</div>
<div> 'name': u'John Smith',</div>
<div> 'orders': [1, 2],</div>
<div> 'password': u'***'}</div>
<div><br>
</div>
<div>By default all related objects (cart_items, orders) are
represented as a list with their primary keys. If you want
to see the related objects instances, you can specify
related_objects=True:</div>
<div><br>
</div>
<div> >>> c1.to_dict(with_collections=True,
related_objects=True)</div>
<div><br>
</div>
<div> {'address': u'address 1',</div>
<div> 'cart_items': [CartItem[1], CartItem[2]],</div>
<div> 'country': u'USA',</div>
<div> 'email': <a moz-do-not-send="true"
href="mailto:u%27john@example.com">u'john@example.com</a>',</div>
<div> 'id': 1,</div>
<div> 'name': u'John Smith',</div>
<div> 'orders': [Order[1], Order[2]],</div>
<div> 'password': u'***'}</div>
</div>
<div><br>
</div>
<div>P.S. Also the this release fixes the Release 0.5.2 which
had problems with the setup.py file.</div>
<div><br>
</div>
<div>Regards,</div>
<div>Pony ORM Team</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
ponyorm-list mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ponyorm-list@ponyorm.org">ponyorm-list@ponyorm.org</a>
<a class="moz-txt-link-freetext" href="/ponyorm-list">/ponyorm-list</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
С уважением,
Бажов Вадим,
Инженер отдела технической поддержки,
Компания Айдеко
--
Телефоны: +7 (495) 987-32-70; +7 (495) 662-87-34 (тех. поддержка); +7 (343) 345-15-75; Факс: +7 (343) 383-75-13
Электронная почта:
Вопросы по приобретению: <a class="moz-txt-link-abbreviated" href="mailto:sales@ideco.ru">sales@ideco.ru</a>
Технические вопросы: <a class="moz-txt-link-abbreviated" href="mailto:support@ideco.ru">support@ideco.ru</a>
Партнерство: <a class="moz-txt-link-abbreviated" href="mailto:partners@ideco.ru">partners@ideco.ru</a>
Общие вопросы: <a class="moz-txt-link-abbreviated" href="mailto:info@ideco.ru">info@ideco.ru</a>
Сайт: <a class="moz-txt-link-freetext" href="http://www.ideco.ru/">http://www.ideco.ru/</a>
Форум: <a class="moz-txt-link-freetext" href="http://www.ideco.ru/forum/">http://www.ideco.ru/forum/</a>
</pre>
</body>
</html>