Changeset 567


Ignore:
Timestamp:
Nov 21, 2015, 7:45:26 AM (4 years ago)
Author:
cito
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/module/pg.py

    r563 r567  
    301301
    302302    def __getattr__(self, name):
    303         # All undefined members are same as in underlying pg connection:
     303        # All undefined members are same as in underlying connection:
    304304        if self.db:
    305305            return getattr(self.db, name)
    306306        else:
    307307            raise _int_error('Connection is not valid')
     308
     309    def __dir__(self):
     310        # Custom dir function including the attributes of the connection:
     311        attrs = set(self.__class__.__dict__)
     312        attrs.update(self.__dict__)
     313        attrs.update(dir(self.db))
     314        return sorted(attrs)
    308315
    309316    # Context manager methods
Note: See TracChangeset for help on using the changeset viewer.