[melbourne-pug] python question

Brian May brian at microcomaustralia.com.au
Tue Apr 3 06:16:43 CEST 2012


On 3 April 2012 13:41, Andreux Fort <andrew.fort at gmail.com> wrote:
> Agreed. The global keyword is never be needed in readable code. (Modules are
> singletons, after all)

In my case, I need my module to work both with Django, using Django
settings - and without Django using settings that are passed to the
module. The variables in question need to be global (I think) so that
the (optional) Django middleware layer can access them.

I have now uploaded the module in question to github -
https://github.com/VPAC/python-tldap - Fakes transaction support for
LDAP, by manually queuing and rolling back LDAP requests as required.
Designed so that Placard - our user management tool won't leave LDAP
database inconsistent with db database if an error occurs (the db
database supports transactions, but the LDAP doesn't). e.g. what
happens is that the operator tries to create a user, which creates an
LDAP entry then an error occurs. The db is rolled back, but the LDAP
entry still exists. The operator repeats the operation, and gets an
LDAP error that the entry already exists.

The optional middleware means that code doesn't have to be modified to
take advantage of this, all HTTP requests turn on transaction support.
-- 
Brian May <brian at microcomaustralia.com.au>


More information about the melbourne-pug mailing list