[Subversion] / PEAK / src / peak / util / Struct.py |
No default branch
Bookmark a link to HEAD:
(view)
(download)
(as text)
Normalized whitespace.
Added LDAP field type converter support, with unit tests. This uses the 'peak.ldap.field_converters.*' property namespace, looking up the field names to find a converter (or import string thereof) that takes two arguments (name and value) and returns a replacement value. The value passed in may be 'None' if no value was present in the retrieved data. Otherwise, it's a list of values returned from the LDAP directory (except for the 'dn' field, which is always just a string.) Converters are imported from within the peak.storage package, so we can add some "standard" converters and then reference them with import strings like '"LDAP.someConverter"'.
Standardized call signature for metaclass.__new__ methods as __new__(meta, name, bases, ...) to make it easier to find metaclass __new__ methods (as opposed to class __new__ methods). Eliminated a metaclass __new__ that wasn't needed (replaced with an __init__). There are now only two PEAK metaclasses that use __new__: structType and Singleton. Neither is particularly likely to need mixing with Persistent.__class__, so we should be able to steer clear of any danger that might come about from Persistent.__class__ being somewhere other than at the end of the __bases__ list. Whew! I think that finally concludes the integration of Persistent into the model.Element base class; so now it should be possible to create Element subclasses and store the instances in Racks.
Re-org/refactoring of many items from the TODO list for 0.5, including: * moved peak.binding.imports -> peak.util.imports, added importSuite() * Decided not to do binding.Acquire, it should just be a documented idiom * Moved LDAP and lockfile URLs to peak.storage.LDAP and peak.running.lockfiles, respectively * Moved factories.getObjectInstance -> spi, updated peak.ini to load naming.spi as the provider. * Consolidated naming.references into naming.names * Made ParsedURLs compile their pattern strings, and automatically make their 'fromX()' methods classmethods (and the same is true for other 'struct' types. * Refactored cursors and connections out into distinct SQLCursor/LDAPCursor types, based on a common AbstractCursor. * Added TooManyResults/TooFewResults errors to peak.exceptions
Misc. docstring fixes for better summaries in generated API docs.
Added DBCursor and LDAPCursor to peak.storage, along with their corresponding interfaces. ManagedConnections now support registerCursor() and closeCursors() methods, as well as __call__() to create a new cursor and optionally execute a query on it. Cursor objects can be iterated over to return rows, inverted to return a single row, or processed for multi-sets as in:: row = aConn('SQL that returns exactly one row').justOne() # shortcut for the above row = ~ aConn('SQL that returns exactly one row') # multiple result sets rs1, rs2 = aConn('SQL that returns 2 result sets').allSets() # iteration for row in aConn('SQL that returns 0-n rows, in 1 set'): # do something Rows returned are 'struct' objects (a cross between a tuple, dict, and object w/attributes), unless the underlying DB returns non-standard rows. The LDAPCursor class also iterates over asynchronously retrieved results, but isn't very well tested at this point. None of this has been tested with actual databases, just a few mockup test harnesses. To support all this, I also needed to add a 'hasBinding()' method to binding.Base and an 'addField' method to the 'structType' metaclass.
Fixed up struct's constructor calling patterns to be a bit more sensible, and adjusted naming classes accordingly.
Fixed some class/type problems with NamingExceptions; refactored URL classes to use the new 'struct' class as a base type.
Refactored struct metaclass for cleaner construction. Misc. doc additions.
Added new 'struct' type to serve as a basis for compact, immutable object classes. Structs are tuples on the inside, dictionaries on the outside, plus whatever properties and methods you care to add. They also offer a wide variety of constructor options, including the string parsing of your choice, and the ability to define new constructors of your own devising. This class will end up being the base class for many PEAK objects, including naming.ParsedURL, storage.SQLRecord, storage.LDAPRecord, and so on.
cvs-admin@eby-sarna.com Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |