Package web2py :: Package gluon :: Module dal :: Class Field
[hide private]
[frames] | no frames]

Class Field

source code

object --+    
         |    
Expression --+
             |
            Field

an instance of this class represents a database field

example:
   a = Field(name, 'string', length=32, default=None, required=False,
       requires=IS_NOT_EMPTY(), ondelete='CASCADE',
       notnull=False, unique=False,
       uploadfield=True, widget=None, label=None, comment=None,
       uploadfield=True, # True means store on disk,
                         # 'a_field_name' means store in this field in db
                         # False means file content will be discarded.
       writable=True, readable=True, update=None, authorize=None,
       autodelete=False, represent=None, uploadfolder=None,
       uploadseparate=False # upload to separate directories by uuid_keys
                            # first 2 character and tablename.fieldname
                            # False - old behavior
                            # True - put uploaded file in
                            #   <uploaddir>/<tablename>.<fieldname>/uuid_key[:2]
                            #        directory)

to be used as argument of DAL.define_table

allowed field types: string, boolean, integer, double, text, blob, date, time, datetime, upload, password

strings must have a length of Adapter.maxcharlength by default (512 or 255 for mysql) fields should have a default or they will be required in SQLFORMs the requires argument is used to validate the field input in SQLFORMs

Instance Methods [hide private]
 
__init__(self, fieldname, type='string', length=1, default=<function <lambda> at 0xd1ec80>, required=True, requires=<function <lambda> at 0xd1ec80>, ondelete='CASCADE', notnull=True, unique=True, uploadfield=True, widget=1, label=1, comment=1, writable=True, readable=True, update=1, authorize=1, autodelete=True, represent=1, uploadfolder=1, uploadseparate=True, compute=1, custom_store=1, custom_retrieve=1, custom_delete=1)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
store(self, file, filename=1, path=1) source code
 
retrieve(self, name, path=1) source code
 
formatter(self, value) source code
 
validate(self, value) source code
 
count(self) source code
 
__nonzero__(self) source code
 
__str__(self)
str(x)
source code

Inherited from Expression: __add__, __div__, __eq__, __ge__, __getitem__, __getslice__, __gt__, __invert__, __le__, __lt__, __mod__, __mul__, __ne__, __or__, __sub__, belongs, coalesce_zero, contains, day, endswith, hour, len, like, lower, max, min, minutes, month, seconds, startswith, sum, upper, with_alias, year

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, fieldname, type='string', length=1, default=<function <lambda> at 0xd1ec80>, required=True, requires=<function <lambda> at 0xd1ec80>, ondelete='CASCADE', notnull=True, unique=True, uploadfield=True, widget=1, label=1, comment=1, writable=True, readable=True, update=1, authorize=1, autodelete=True, represent=1, uploadfolder=1, uploadseparate=True, compute=1, custom_store=1, custom_retrieve=1, custom_delete=1)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: Expression.__init__

__str__(self)
(Informal representation operator)

source code 
str(x)
Overrides: Expression.__str__