Docs for DAL.validators_method.im_class

[ Python Tutorial ] [ Python Libraries ] [ web2py epydoc ]

Description


<class 'pydal.base.MetaDAL'> extends (<class 'pydal.helpers.classes.Serializable'>, <class 'pydal.helpers.classes.BasicStorage'>)











































































An instance of this class represents a database connection

Args:
uri(str): contains information for connecting to a database.
Defaults to `'sqlite://dummy.db'`

Note:
experimental: you can specify a dictionary as uri
parameter i.e. with::

db = DAL({"uri": "sqlite://storage.sqlite",
"tables": {...}, ...})

for an example of dict input you can check the output
of the scaffolding db model with

db.as_dict()

Note that for compatibility with Python older than
version 2.6.5 you should cast your dict input keys
to str due to a syntax limitation on kwarg names.
for proper DAL dictionary input you can use one of::

obj = serializers.cast_keys(dict, [encoding="utf-8"])
#or else (for parsing json input)
obj = serializers.loads_json(data, unicode_keys=False)

pool_size: How many open connections to make to the database object.
folder: where .table files will be created. Automatically set within
web2py. Use an explicit path when using DAL outside web2py
db_codec: string encoding of the database (default: 'UTF-8')
table_hash: database identifier with .tables. If your connection hash
change you can still using old .tables if they have db_hash
as prefix
check_reserved: list of adapters to check tablenames and column names
against sql/nosql reserved keywords. Defaults to `None`

- 'common' List of sql keywords that are common to all database
types such as "SELECT, INSERT". (recommended)
-
'all' Checks against all known SQL keywords
- '<adaptername>'' Checks against the specific adapters list of
keywords
- '<adaptername>_nonreserved' Checks against the specific adapters
list of nonreserved keywords. (if available)

migrate: sets default migrate behavior for all tables
fake_migrate: sets default fake_migrate behavior for all tables
migrate_enabled: If set to False disables ALL migrations
fake_migrate_all: If set to True fake migrates ALL tables
attempts: Number of times to attempt connecting
auto_import: If set to True, tries import automatically table
definitions from the databases folder (works only for simple models)
bigint_id: If set, turn on bigint instead of int for id and reference
fields
lazy_tables: delays table definition until table access
after_connection: can a callable that will be executed after the
connection

Example:
Use as::

db = DAL('sqlite://test.db')

or::

db = DAL(**{"uri": ..., "tables": [...]...}) # experimental

db.define_table('tablename', Field('fieldname1'),
Field('fieldname2'))




Attributes


DAL.validators_method.im_class.Field <type 'type'> extends (<class 'pydal.objects.Expression'>, <class 'pydal.helpers.classes.Serializable'>) belongs to class <type 'type'>

DAL.validators_method.im_class.Row <type 'type'> extends (<class 'pydal.helpers.classes.BasicStorage'>,) belongs to class <type 'type'>
A dictionary that lets you do d['a'] as well as d.a this is only used to store a `Row`

DAL.validators_method.im_class.Table <type 'type'> extends (<class 'pydal.helpers.classes.Serializable'>, <class 'pydal.helpers.classes.BasicStorage'>) belongs to class <type 'type'>
Represents a database table Example:: You can create a table as:: db = DAL(...) db.define_table('users', Field('name')) And then:: db.users.insert(name='me') # print db.users._insert(...) to see SQL db.users.drop()

DAL.validators_method.im_class.__call__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.__class__ <type 'type'> extends (<type 'type'>,) belongs to class <type 'type'>

DAL.validators_method.im_class.__contains__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.__delattr__ <type 'wrapper_descriptor'> belongs to class <type 'wrapper_descriptor'>
x.__delattr__('name') <==> del x.name

DAL.validators_method.im_class.__delitem__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.__dict__ <type 'dictproxy'> belongs to class <type 'dictproxy'>

DAL.validators_method.im_class.__doc__ <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

DAL.validators_method.im_class.__format__ <type 'method_descriptor'> belongs to class <type 'method_descriptor'>
default object formatter

DAL.validators_method.im_class.__getattr__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.__getattribute__ <type 'wrapper_descriptor'> belongs to class <type 'wrapper_descriptor'>
x.__getattribute__('name') <==> x.name

DAL.validators_method.im_class.__getitem__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.__hash__ <type 'wrapper_descriptor'> belongs to class <type 'wrapper_descriptor'>
x.__hash__() <==> hash(x)

DAL.validators_method.im_class.__init__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.__iter__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.__module__ <type 'str'> belongs to class <type 'str'>
str(object='') -> string Return a nice string representation of the object. If the argument is a string, the return value is the same object.

DAL.validators_method.im_class.__new__ <type 'function'> belongs to class <type 'function'>

DAL.validators_method.im_class.__nonzero__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.__reduce__ <type 'method_descriptor'> belongs to class <type 'method_descriptor'>
helper for pickle

DAL.validators_method.im_class.__reduce_ex__ <type 'method_descriptor'> belongs to class <type 'method_descriptor'>
helper for pickle

DAL.validators_method.im_class.__repr__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.__setattr__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.__setitem__ <type 'wrapper_descriptor'> belongs to class <type 'wrapper_descriptor'>
x.__setattr__('name', value) <==> x.name = value

DAL.validators_method.im_class.__sizeof__ <type 'method_descriptor'> belongs to class <type 'method_descriptor'>
__sizeof__() -> int size of object in memory, in bytes

DAL.validators_method.im_class.__str__ <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.__subclasshook__ <type 'builtin_function_or_method'> belongs to class <type 'builtin_function_or_method'>
Abstract classes can override this to customize issubclass(). This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

DAL.validators_method.im_class.__weakref__ <type 'getset_descriptor'> belongs to class <type 'getset_descriptor'>
list of weak references to the object (if defined)

DAL.validators_method.im_class._remove_references_to <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.as_dict <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.as_json <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.as_xml <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.as_yaml <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.can_join <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.check_reserved_keyword <type 'instancemethod'> belongs to class <type 'instancemethod'>
Validates `name` against SQL keywords Uses self.check_reserve which is a list of operators to use.

DAL.validators_method.im_class.clear <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.close <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.commit <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.copy <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.define_table <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.distributed_transaction_begin <type 'function'> belongs to class <type 'function'>

DAL.validators_method.im_class.distributed_transaction_commit <type 'function'> belongs to class <type 'function'>

DAL.validators_method.im_class.executesql <type 'instancemethod'> belongs to class <type 'instancemethod'>
Executes an arbitrary query Args: query (str): the query to submit to the backend placeholders: is optional and will always be None. If using raw SQL with placeholders, placeholders may be a sequence of values to be substituted in or, (if supported by the DB driver), a dictionary with keys matching named placeholders in your SQL. as_dict: will always be None when using DAL. If using raw SQL can be set to True and the results cursor returned by the DB driver will be converted to a sequence of dictionaries keyed with the db field names. Results returned with as_dict=True are the same as those returned when applying .to_list() to a DAL query. If "as_ordered_dict"=True the behaviour is the same as when "as_dict"=True with the keys (field names) guaranteed to be in the same order as returned by the select name executed on the database. fields: list of DAL Fields that match the fields returned from the DB. The Field objects should be part of one or more Table objects defined on the DAL object. The "fields" list can include one or more DAL Table objects in addition to or instead of including Field objects, or it can be just a single table (not in a list). In that case, the Field objects will be extracted from the table(s). Note: if either `fields` or `colnames` is provided, the results will be converted to a DAL `Rows` object using the `db._adapter.parse()` method colnames: list of field names in tablename.fieldname format Note: It is also possible to specify both "fields" and the associated "colnames". In that case, "fields" can also include DAL Expression objects in addition to Field objects. For Field objects in "fields", the associated "colnames" must still be in tablename.fieldname format. For Expression objects in "fields", the associated "colnames" can be any arbitrary labels. DAL Table objects referred to by "fields" or "colnames" can be dummy tables and do not have to represent any real tables in the database. Also, note that the "fields" and "colnames" must be in the same order as the fields in the results cursor returned from the DB.

DAL.validators_method.im_class.export_to_csv_file <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.get <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.get_instances <type 'function'> belongs to class <type 'function'>
Returns a dictionary with uri as key with timings and defined tables:: {'sqlite://storage.sqlite': { 'dbstats': [(select auth_user.email from auth_user, 0.02009)], 'dbtables': { 'defined': ['auth_cas', 'auth_event', 'auth_group', 'auth_membership', 'auth_permission', 'auth_user'], 'lazy': '[]' } } }

DAL.validators_method.im_class.has_key <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.has_representer <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.import_from_csv_file <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.import_table_definitions <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.items <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.iteritems <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.iterkeys <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.itervalues <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.keys <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.lazy_define_table <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.logger <class 'logging.Logger'> belongs to class <class 'logging.Logger'>
Instances of the Logger class represent a single logging channel. A "logging channel" indicates an area of an application. Exactly how an "area" is defined is up to the application developer. Since an application can have any number of areas, logging channels are identified by a unique string. Application areas can be nested (e.g. an area of "input processing" might include sub-areas "read CSV files", "read XLS files" and "read Gnumeric files"). To cater for this natural nesting, channel names are organized into a namespace hierarchy where levels are separated by periods, much like the Java or Python package namespace. So in the instance given above, channel names might be "input" for the upper level, and "input.csv", "input.xls" and "input.gnu" for the sub-levels. There is no arbitrary limit to the depth of nesting.

DAL.validators_method.im_class.parse_as_rest <type 'instancemethod'> belongs to class <type 'instancemethod'>
Example: Use as:: db.define_table('person',Field('name'),Field('info')) db.define_table('pet', Field('ownedby',db.person), Field('name'),Field('info') ) @request.restful() def index(): def GET(*args,**vars): patterns = [ "/friends[person]", "/{person.name}/:field", "/{person.name}/pets[pet.ownedby]", "/{person.name}/pets[pet.ownedby]/{pet.name}", "/{person.name}/pets[pet.ownedby]/{pet.name}/:field", ("/dogs[pet]", db.pet.info=='dog'), ("/dogs[pet]/{pet.name.startswith}", db.pet.info=='dog'), ] parser = db.parse_as_rest(patterns,args,vars) if parser.status == 200: return dict(content=parser.response) else: raise HTTP(parser.status,parser.error) def POST(table_name,**vars): if table_name == 'person': return db.person.validate_and_insert(**vars) elif table_name == 'pet': return db.pet.validate_and_insert(**vars) else: raise HTTP(400) return locals()

DAL.validators_method.im_class.pop <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.represent <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.representers <type 'dict'> belongs to class <type 'dict'>
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

DAL.validators_method.im_class.rollback <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.serializers <type 'dict'> belongs to class <type 'dict'>
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

DAL.validators_method.im_class.set_folder <type 'function'> belongs to class <type 'function'>

DAL.validators_method.im_class.smart_query <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.tables <type 'property'> belongs to class <type 'property'>

DAL.validators_method.im_class.update <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.uuid <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.validators <type 'NoneType'> belongs to class <type 'NoneType'>

DAL.validators_method.im_class.validators_method <type 'instancemethod'> belongs to class <type 'instancemethod'>
Field type validation, using web2py's validators mechanism. makes sure the content of a field is in line with the declared fieldtype

DAL.validators_method.im_class.values <type 'instancemethod'> belongs to class <type 'instancemethod'>

DAL.validators_method.im_class.where <type 'instancemethod'> belongs to class <type 'instancemethod'>