Package couchdbkit :: Package schema :: Module properties :: Class SetProperty
[hide private]
[frames] | no frames]

Class SetProperty

source code

object --+    
         |    
  Property --+
             |
            SetProperty

A property that stores a Python set as a list of unique elements.

Note that Python set operations like union that return a set object do not alter list that will be stored with the next save, while operations like update that change a set object in-place do keep the list in sync.

Nested Classes [hide private]
  data_type
set() -> new empty set object set(iterable) -> new set object
Instance Methods [hide private]
 
__init__(self, verbose_name=None, default=None, required=None, item_type=None, **kwds)
Construct SetProperty.
source code
 
validate(self, value, required=True)
validate value
source code
 
validate_set_contents(self, value) source code
 
default_value(self)
Return default value for set.
source code
 
to_python(self, value)
convert to python type
source code
 
to_json(self, value)
convert to json, Converted value is saved in couchdb.
source code

Inherited from Property: __delete__, __get__, __property_config__, __property_init__, __set__, empty

Inherited from Property (private): _to_json, _to_python

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

Class Variables [hide private]

Inherited from Property: creation_counter

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, verbose_name=None, default=None, required=None, item_type=None, **kwds)
(Constructor)

source code 
Construct SetProperty.

:args verbose_name: Optional verbose name.

:args default: Optional default value; if omitted, an empty
               set is used.

:args required: True if field is required, default is False.

:args item_type: Optional data type of items that set
                 contains.  Used to assist with JSON
                 serialization/deserialization when data is
                 stored/retireved.

:args **kwds: Optional additional keyword arguments, passed to
              base class.

Overrides: object.__init__

validate(self, value, required=True)

source code 

validate value

Overrides: Property.validate
(inherited documentation)

default_value(self)

source code 
Return default value for set.

Because the property supplied to 'default' is a static value,
that value must be shallow copied to prevent all fields with
default values from sharing the same instance.

Returns:
  Copy of the default value.

Overrides: Property.default_value

to_python(self, value)

source code 

convert to python type

Overrides: Property.to_python
(inherited documentation)

to_json(self, value)

source code 

convert to json, Converted value is saved in couchdb.

Overrides: Property.to_json
(inherited documentation)