[storm] Catching errors and LDAP support
James Henstridge
james at jamesh.id.au
Tue Jul 8 21:32:55 BST 2008
On Tue, Jul 8, 2008 at 8:39 PM, Morten Siebuhr <sbhr at sbhr.dk> wrote:
> Hey 'yall,
>
> I'm trying to catch some errors from the DB in my application - but I
> get the underlying DB's error directly, so I get different errors
> depending on what DB I run on. Is there a way to catch these in some
> generic way, while I will still be able to return a reasonable message
> to the user?
If you look in the storm.exceptions module, there are analogues of the
standard DB-API exceptions. Storm patches these classes in as base
classes of the database adapter's exception objects. This means that
you can catch storm.exceptions.DatabaseError and also get
psycopg2.DatabaseError, for instance.
>
> i.e.:
> try:
> storm.this()
> storm.that()
> storm.commit()
> except SomeGenericStormError, e:
> print "Could not bla bla bla: %s" % e
> storm.rollback()
>
>
> And while playing around with LDAP/AD, it struck me that Storm actually
> fits quite nicely with a lot of common LDAP uses; AFAIK, you usually
> have a sub-tree for users, another for groups, then computers, DNS,
> etc., and it would be quite nice to package these in Storm classes. Is
> this possible at all, or is Storm tied too closely to SQL?
Storm is pretty heavily focused on SQL databases. I don't know if
it'd make sense to extend it to something like LDAP. That said, a
number of the concepts in Storm might be usable in an LDAP library.
> On a related note: does anybody know of *any* Python ORM for LDAP?
James.
More information about the storm
mailing list