<div dir="ltr"><div><div>Hi all,</div><div><br></div><div>Pony ORM Release 0.5.4 is out!</div><div><br></div><div>New functions and methods:</div><div>--------------------------------------</div><div><br></div><div>pony.orm.serialization module with the to_dict() and to_json() functions </div><div>was added. Before this release you could use the to_dict() method of an </div><div>entity instance in order to get a key-value dictionary structure for a </div><div>specific entity instance. Sometimes you might need to serialize not only </div><div>the instance itself, but also the instance’s related objects. In this case </div><div>you can use the to_dict() function from the pony.orm.serialization module.</div><div><br></div><div>to_dict() – receives an entity instance or a list of instances and </div><div>returns a dictionary structure which keeps the passed object(s) and </div><div>immediate related objects</div><div><br></div><div>to_json() – uses `to_dict()` and returns JSON representation of the </div><div>to_dict() result Query.prefetch() – allows to specify which related </div><div>objects or attributes should be loaded from the database along with </div><div>the query result . Example:</div><div><br></div><div>      select(s for s in Student).prefetch(Group, Department, Student.courses)</div><div><br></div><div>obj.flush() – allows flush a specific entity to the database</div><div><br></div><div>obj.get_pk() – return the primary key value for an entity instance</div><div><br></div><div>py_check parameter for attributes added. This parameter allows you to specify </div><div>a function which will be used for checking the value before it is assigned to the </div><div>attribute. The function should return True/False or can raise ValueError exception </div><div>if the check failed. Example:</div><div><br></div><div>    class Student(db.Entity):</div><div>        name = Required(unicode)</div><div>        gpa = Required(float, py_check=lambda v: v >= 0 and v <= 5)</div><div><br></div><div><br></div><div>New types:</div><div>---------------</div><div><br></div><div>time and timedelta – now you can use these types for attribute declaration. </div><div>Also you can use timedelta and a combination of datetime + timedelta types </div><div>inside queries.</div><div><br></div><div><br></div><div>New features:</div><div>-------------------</div><div><br></div><div>after_insert, after_update, after_delete - hooks added. These hooks are </div><div>called when an object was inserted, updated or deleted in the database </div><div>respectively.</div><div><br></div><div>Added support for pymysql – pure Python MySQL client. Currently it is used </div><div>as a fallback for MySQLdb interface</div><div><br></div><div><br></div><div>Other changes and bug fixes:</div><div>----------------------------------------</div><div><br></div><div>obj.order_by() method is deprecated, use Entity.select().order_by() instead</div><div>obj.describe() now displays composite primary keys</div><div>Fixes #50: PonyORM does not escape _ and % in LIKE queries</div><div>Fixes #51: Handling of one-to-one relations in declarative queries</div><div>Fixes #52: An attribute without a column should not have rbits & wbits</div><div>Fixes #53: Column generated at the wrong side of "one-to-one" relationship</div><div>Fixes #55: obj.to_dict() should do flush at first if the session cache is modified</div><div>Fixes #57: Error in to_dict() when to-one attribute value is None</div><div>Fixes #70: EntitySet allows to add and remove None</div><div>Check that the entity name starts with a capital letter and throw exception </div><div>if it is not then raise the 'ERDiagramError: Entity class name should start with </div><div>a capital letter' exception</div><div><br></div><div>Here is the link to the blog post which includes links to the updated documentation:</div><div><a href="http://blog.ponyorm.com/2014/09/22/pony-orm-release-0-5-4/">http://blog.ponyorm.com/2014/09/22/pony-orm-release-0-5-4/</a></div><div><br></div><div>Regards,</div><div>Alexey</div></div></div>