On 23/06/10 08:35 +0200, Cédric Krier wrote:
> Hi,
>
> I will start the developpement of the contextualisation of cursor, user and
> context inside a threading locale [1].
> I would like to use the with statement (available in Python 2.6 by default and
> 2.5 (with "from __future__ import with_statement")) for this kind of purpose:
>
>
> from trytond import transaction
> with transaction.set('user', 0):
> ...
>
> The 'user' will be restored at exit of the with statement.
> I'm starting this implementation and I'm facing an issue with "context". I would like also to put context in the transaction but there is some problems: - the context has been most of the time put as last keyword (except for some methods like search). So it is complicated to find it in the args list. But we can change those methods and put the context as first argument for external calls (this will change the API). - if we remove the context from the methods then the signature of each method will be different between external call and internal. It is already the case with cursor and user but one goal of this change is to fix it. So is there someone knows an other framework that has the same context-like behavior and how they solve it? Or perhaps the solution will be to drop the context for a better solution as I always found it is not an elegant one. -- Cédric Krier B2CK SPRL Rue de Rotterdam, 4 4000 Liège Belgium Tel: +32 472 54 46 59 Email/Jabber: [email protected] Website: http://www.b2ck.com/
pgpmGTFAiosby.pgp
Description: PGP signature
