Package snakelegs :: Module fields :: Class ReferenceField
[hide private]
[frames] | no frames]

Class ReferenceField

object --+    
         |    
 BaseField --+
             |
            ReferenceField

A field holding a reference to another document of type ref_type. The value can be set from a pymongo ObjectId, a hexadecimal string, or an instance of a Document subclass. The document to which the field refers is automatically fetched when the reference field is accessed

Instance Methods [hide private]
 
__init__(self, ref_type, default=None)
x.__init__(...) initializes x; see help(type(x)) for signature
 
setvalue(self, value)
Set the value that this field will hold.
 
dbgetvalue(self)
Return the value to be sent to the database.
 
getvalue(self)
Get the value stored in this field.

Inherited from BaseField: deferred, delvalue

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from BaseField: value

Inherited from object: __class__

Method Details [hide private]

__init__(self, ref_type, default=None)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

setvalue(self, value)

 

Set the value that this field will hold. You should use this method to perform validation as well. Raise a TypeError if value is of the incorrect type. By default, this method stores value in self._value

Overrides: BaseField.setvalue
(inherited documentation)

dbgetvalue(self)

 

Return the value to be sent to the database. You may find it useful to override this if your field should send its data to the user in one format and to the database in another format

Overrides: BaseField.dbgetvalue
(inherited documentation)

getvalue(self)

 

Get the value stored in this field. By default returns self._value

Overrides: BaseField.getvalue
(inherited documentation)