Author: cito
Date: Sat Nov 21 07:45:26 2015
New Revision: 567
Log:
Add a custom dir() method to the DB wrapper
Seems this is necessary now after the underlying connection object
has been changed to use tp_getattro instead tp_getattr.
Modified:
trunk/module/pg.py
Modified: trunk/module/pg.py
==============================================================================
--- trunk/module/pg.py Sat Nov 21 06:55:01 2015 (r566)
+++ trunk/module/pg.py Sat Nov 21 07:45:26 2015 (r567)
@@ -300,12 +300,19 @@
# * to any other true value to just print debug statements
def __getattr__(self, name):
- # All undefined members are same as in underlying pg connection:
+ # All undefined members are same as in underlying connection:
if self.db:
return getattr(self.db, name)
else:
raise _int_error('Connection is not valid')
+ def __dir__(self):
+ # Custom dir function including the attributes of the connection:
+ attrs = set(self.__class__.__dict__)
+ attrs.update(self.__dict__)
+ attrs.update(dir(self.db))
+ return sorted(attrs)
+
# Context manager methods
def __enter__(self):
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql