t.utils : module documentation

Part of twistar

General catchall for functions that don't make sense as methods.
Line # Kind Name Docs
8 Function createInstances Create an instance of list of instances of a given class using the given properties.
31 Function dictToWhere Convert a dictionary of attribute: value to a where statement.
47 Function joinWheres Take two wheres (of the same format as the where parameter in the function DBObject.find) and join them.
65 Function joinMultipleWheres Take a list of wheres (of the same format as the where parameter in the function DBObject.find) and join them.
84 Function deferredDict Just like a defer.DeferredList but instead accepts and returns a dict.
def createInstances(props, klass):
Create an instance of list of instances of a given class using the given properties.
ParameterspropsOne of:
  1. A dict, in which case return an instance of klass
  2. A list of dicts, in which case return a list of klass instances
ReturnsA Deferred that will pass the result to a callback
def dictToWhere(attrs, joiner='AND'):
Convert a dictionary of attribute: value to a where statement.

For instance, dictToWhere({'one': 'two', 'three': 'four'}) returns: ['(one = ?) AND (three = ?)', 'two', 'four']

ReturnsExpression above if len(attrs) > 0, None otherwise
def joinWheres(wone, wtwo, joiner='AND'):
Take two wheres (of the same format as the where parameter in the function DBObject.find) and join them.
ParameterswoneFirst where list
woneSecond where list
joinerOptional text for joining the two wheres.
ReturnsA joined version of the two given wheres.
def joinMultipleWheres(wheres, joiner='AND'):
Take a list of wheres (of the same format as the where parameter in the function DBObject.find) and join them.
ParameterswheresList of where clauses to join list
joinerOptional text for joining the two wheres.
ReturnsA joined version of the list of the given wheres.
def deferredDict(d):
Just like a defer.DeferredList but instead accepts and returns a dict.
ParametersdA dict whose values are all Deferred objects.
ReturnsA DeferredList whose callback will be given a dictionary whose keys are the same as the parameter d's and whose values are the results of each individual deferred call.
API Documentation for twistar, generated by pydoctor at 2012-06-12 10:00:49.