Home | Trees | Index | Help |
|
---|
Package Modeling :: Module utils |
|
Some useful functions to be used within the Modeling package, or by tools using this framework.
The module also defines two classes:
base_object
is equivalent to object (types.ObjectType) when it is available (python2.2 or higher), or is an empty class in python2.1base_persistent_object
equals to ZODB.Persistent if ZODB is installed, or else equals tobase_object
. This is for use byModel
,Entity
,Attribute
andRelationship
--the ZModeler in particular requires that they inherit from ZODB.Persistent so that they can be stored in the zodb.
$Id: utils.py 980 2006-02-26 18:04:47Z sbigaret $
Function Summary | |
---|---|
Takes an instance object and caches the result for all simple methods, i.e. | |
Return the same string with the first letter capitalized | |
deprecated(methodName,
replacement,
removed_in_version)
| |
Eliminates multiple occurences of items in 'sequence' and returns the corresponding list. | |
Takes a class object and tries to update its docstring, as well as its methods' docstrings, using the supplied dictionary. | |
Finds and load the module 'name'. | |
Checks | |
Returns true if 'anObject' is a sequence-like object, false otherwise | |
Return the same string w/ all letter lower | |
Searches and returns within 'aClass' the methods that accepts no arguments except 'self'. | |
This method is responsible for warning the user when we detect that he/she is relying on a feature (e.g. | |
Transforms a string to a valid python identifier, i.e. | |
If param is a string (or unicode) and equals to 0, returns 0 ; otherwise returns 'not not param'. |
Function Details |
---|
cache_simple_methods(anInstance, exclude=None)Takes an instance object and caches the result for all simple methods, i.e. methods that takes no arguments except 'self'. The caching is made by substituting the method with a lambda returning the value the original method returned. This method does nothing under python v2.1 if ZODB is found in the path, because it is incompatible with the extension class, used by classes Entity, Relationship, etc. Parameters:
See also: methods_to_cache() |
capitalizeFirstLetter(aName)Return the same string with the first letter capitalized |
eliminate_multiple_occurences(sequence, func=<function <lambda> at 0xb791a10c>)Eliminates multiple occurences of items in 'sequence' and returns the corresponding list. The returned list is a subset of the supplied sequence, and the original order of items is preserved (if an item is present more than once in 'sequence', only the first occurence is present in the returned list). Parameters:
|
finalize_docstrings(klass, aDict)Takes a class object and tries to update its docstring, as well as its methods' docstrings, using the supplied dictionary. This is used, for example, in Entity, where some docstrings contains '%(key)s' statements, to be filled with the same thing ; this makes it possible to update groups of methods / 'see also' paragraphs without having to copy/paste things everywhere. Parameters:
|
getModule(name, path=None)Finds and load the module 'name'. This is used by method 'classForEntity()'. Raises in case it cannot be found See also: module 'imp', functions 'find_module()' and 'load_module()' |
isaValidName(aName)Checks |
isListOrTuple(anObject)Returns true if 'anObject' is a sequence-like object, false otherwise In this context, a sequence-like object is a tuple, a list, or an instance of Modeling.FaultHandler.AccessArrayFaultHandler |
lower(aString)Return the same string w/ all letter lower |
methods_to_cache(aClass, exclude=None)Searches and returns within 'aClass' the methods that accepts no arguments except 'self'. Parameters:
|
migration_warnings()This method is responsible for warning the user when we detect that he/she is relying on a feature (e.g. an environment variable) that has been deprecated/removed and as no effect anymore (or will have no effect anymore in a near future). |
stringToPythonIdentifier(aString)Transforms a string to a valid python identifier, i.e. replaces all spaces with underscores and drops all chars not in (strings.)letters+digits+'_' |
toBoolean(param)If param is a string (or unicode) and equals to 0, returns 0 ; otherwise returns 'not not param'. |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Sat Mar 4 13:36:24 2006 | http://epydoc.sf.net |