| |
- Propertied(object)
-
- DBSpecifier
class DBSpecifier(Propertied) |
|
Class specifying database connection using a DBDriver
The DBSpecifier provides specification of a connection to
a given database. The format of the specifier mimics
the DBAPI 2.0 connect function's recommended parameter
names.
The drivername property specifies (as a string) a particular
registered DBDriver which provides a uniform interface to
the database driver. Calling myDBDriver.connect( specifier )
should return a connection object for the specifier.
DBDrivers should return DBSpecifier objects when queried
for the list of "system" specifiers (if they provide that
functionality).
The application should manipulate specifier objects, rather
than connection parameters to allow for, for instance,
changing drivers databases, users or passwords for the
specifier from within the interface (i.e. if an error is
encountered, the error should report the specifier, and
potentially allow for altering the specifier and then
re-connecting).
Note:
Many database systems will not require all of the
data values described. They might require extra
properties as well. Unused properties should be
ignored by the driver. Properties which are
needed should be added to sub-classes, rather than
the base class here.
XXX There should be a registry of sub-classes
from which we can create factories for the specifiers! |
|
- Method resolution order:
- DBSpecifier
- Propertied
- object
Methods defined here:
- __add__(self, other)
- Add the values in other to our values
If there is no change, returns self, otherwise returns
a new instance of our class with the updated values.
- __cmp__(self, other)
- Compare this specifier to the other specifier
If the other isn't a specifier, always returns -1
Otherwise compares:
drivername,dsn,database,user,host
- __str__(self)
- Convert to a string representation
- connect(self, share=1, **arguments)
- Connect to the database specified, return (driver,connection)
See DBDriver.connect for argument semantics.
Will raise ImportError if can't find our driver's
class.
- getDriver(self)
- Get driver instance for this specifier
Data and other attributes defined here:
- database = <StringProperty 'database'>
- The name of the database within the database server
- drivername = <BasicProperty 'drivername'>
- The database driver name to use in connecting to the database
- dsn = <StringProperty 'dsn'>
- Database specifier name, the system-specific name for this database
- host = <StringProperty 'host'>
- The network address of the database
- password = <StringProperty 'password'>
- The password used to connect to the database
- user = <StringProperty 'user'>
- The username used to connect to the database
Methods inherited from Propertied:
- __init__(self, *arguments, **namedarguments)
- Propertied object initialisation, allows passing in initial values for properties by name
- clone(self, **newValues)
- Clone this object, with optional new property values
This method calls the __init__ method of your class with
the current property values of your class. Providing newValues
(a dictionary) overrides property settings with new values.
- getCloneProperties(self)
- Get properties dictionary (key:value) for use in cloning of the instance
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
- toString(self, indentation='', alreadyDone=None, indentString=' ')
- Get a nicely formatted representation of this object
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
XXX Needs a far better API, likely a stand-alone class
without the automatic inheritance problems here :(
Class methods inherited from Propertied:
- getProperties(cls) from type
- Get the BasicProperty properties for a particular object's class
Data and other attributes inherited from Propertied:
- __dict__ = <dictproxy object at 0x01DF3750>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Propertied' objects>
- list of weak references to the object (if defined)
| |