<div dir="ltr"><div>Pony ORM 0.5-beta is released!</div><div><br></div><div>New transaction model</div><div>---------------------</div><div><br></div><div>Before this release Pony supported two separate transaction </div><div>
modes: standard and optimistic. In this release we’ve combines </div><div>both of them into one. Now user can choose which locking </div><div>mechanism should be use for any specific object. By default </div><div>Pony uses the optimistic locking. This means, that the database </div>
<div>doesn’t lock any objects in the database. In order to be sure </div><div>that those objects weren’t updated by a concurrent transaction, </div><div>Pony checks the corresponding database rows during update.</div><div>
<br></div><div>Sometimes a user might want to go with the pessimistic locking. </div><div>With this approach the database locks the corresponding rows </div><div>for the exclusive access in order to prevent concurrent modification. </div>
<div>It can be done with the help of “for update“ methods. In this </div><div>case there is no need for Pony to do the optimistic check. </div><div>You can use any of the following methods:</div><div><br></div><div> prod_list = select(p for p </div>
<div> in Product if p.price > 100).for_update()</div><div> prod_list = Product.select(lambda p: p.price > 100).for_update()</div><div> p = Product.get_for_update(id=123)</div><div> </div>
<div>Pony ORM transaction processing is described in more detail in </div><div>the newly created documentation chapter Transactions.</div><div><br></div><div><br></div><div>Documentation</div><div>-------------</div><div>
<br></div><div>In this release we have added the ability to add comments to our </div><div>online documentation, please leave your feedback, questions, comments. </div><div>We need you in order to make Pony ORM documentation better.</div>
<div><br></div><div><br></div><div>Filtering the query results</div><div>---------------------------</div><div><br></div><div>With this release we introduce a new method of the “Query“ object: </div><div>“filter()“. It can be convenient for applying conditions for an </div>
<div>existing query. You can find more information in the documentation</div><div><br></div><div><br></div><div>Database late binding</div><div>---------------------</div><div><br></div><div>Pony ORM users were asking us to provide a way to bind the database </div>
<div>at a later stage. This is convenient for testing. The goal of </div><div>Pony ORM team is to provide a convenient tool for working with </div><div>databases and in this release we’ve added such a possibility.</div><div>
<br></div><div>Before this release the process of mapping entities to the database </div><div>was as following:</div><div><br></div><div> db = Database('sqlite', 'database.sqlite')</div><div><br></div><div>
class Entity1(db.Entity):</div><div> ...</div><div><br></div><div> # other entities declaration</div><div><br></div><div> db.generate_mapping(create_tables=True)</div><div><br></div><div>Now besides the approach described above, you can use the following way:</div>
<div><br></div><div> db = Database()</div><div><br></div><div> class Entity1(db.Entity):</div><div> ...</div><div><br></div><div> # other entities declaration</div><div><br></div><div> db.bind('sqlite', 'database.sqlite')</div>
<div> db.generate_mapping(create_tables=True)</div><div><br></div><div><br></div><div>Other features and bugfixes</div><div>---------------------------</div><div><br></div><div>- Added method Query.page() for pagination</div>
<div>- Added count() method for collections. E.g. Customer[123].orders.count()</div><div>- Added ORDER BY RANDOM(): MyEntity.select_random(N), </div><div> MyEntity.select(…).random(N), select(…).random(N) – where N is the number </div>
<div> of elements to be selected</div><div>- Bugfix in exists() subquery</div><div>- Bugfix when the same item was added and removed within the same transaction</div><div>- Aggregations bugfix</div><div>- The support of PyGreSQL is discontinued. Using psycopg2 instead</div>
<div>- Added pony.__version__ attribute</div><div>- Stability and performance improvements</div><div><br></div><div>Regards,</div><div>Alexey Malashkevich</div></div>