Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes
Archetypes.Schema.Facade.FacadeMetadataSchema Class Reference
Inheritance diagram for Archetypes.Schema.Facade.FacadeMetadataSchema:
Inheritance graph
[legend]
Collaboration diagram for Archetypes.Schema.Facade.FacadeMetadataSchema:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def bind
def validate

Public Attributes

 set_id
 schemata
 storage
 isMetadata
 context

Static Public Attributes

tuple security = ClassSecurityInfo()

Static Private Attributes

 __implements__ = IBindableSchema
tuple _names = CMFMetadataFieldNamesDescriptor()
tuple _fields = CMFMetadataFieldsDescriptor()

Detailed Description

A Facade Schema, which adapts CMFMetadata 'Sets'
to groups of Archetypes fields

Definition at line 95 of file Facade.py.


Constructor & Destructor Documentation

def Archetypes.Schema.Facade.FacadeMetadataSchema.__init__ (   self,
  args,
  kwargs 
)

Definition at line 108 of file Facade.py.

00108 
00109     def __init__(self, *args, **kwargs):
00110         # Everything else is ignored.
00111         self.set_id = kwargs['set_id']
00112         self.schemata = kwargs['schemata']
00113         if not kwargs.get('storage'):
00114             kwargs['storage'] = FacadeMetadataStorage(self.set_id)
00115         self.storage = kwargs['storage']
00116         self.isMetadata = kwargs.get('isMetadata', True)

Here is the caller graph for this function:


Member Function Documentation

Definition at line 117 of file Facade.py.

00117 
00118     def bind(self, context):
00119         self.context = context

def Archetypes.Schema.Facade.FacadeMetadataSchema.validate (   self,
  instance = None,
  REQUEST = None,
  errors = None,
  data = None,
  metadata = None 
)
Validate the state of the entire object.

The passed dictionary ``errors`` will be filled with human readable
error messages as values and the corresponding fields' names as
keys.

If a REQUEST object is present, validate the field values in the
REQUEST.  Otherwise, validate the values currently in the object.

Definition at line 122 of file Facade.py.

00122 
00123                  errors=None, data=None, metadata=None):
00124         """Validate the state of the entire object.
00125 
00126         The passed dictionary ``errors`` will be filled with human readable
00127         error messages as values and the corresponding fields' names as
00128         keys.
00129 
00130         If a REQUEST object is present, validate the field values in the
00131         REQUEST.  Otherwise, validate the values currently in the object.
00132         """
00133         if REQUEST:
00134             fieldset = REQUEST.form.get('fieldset', None)
00135         else:
00136             fieldset = None
00137         fields = []
00138 
00139         if fieldset is not None:
00140             schemata = instance.Schemata()
00141             fields = [(field.getName(), field)
00142                       for field in schemata[fieldset].fields()]
00143         else:
00144             if data:
00145                 fields.extend([(field.getName(), field)
00146                                for field in self.filterFields(isMetadata=0)])
00147             if metadata:
00148                 fields.extend([(field.getName(), field)
00149                                for field in self.filterFields(isMetadata=1)])
00150 
00151         if REQUEST:
00152             form = REQUEST.form
00153         else:
00154             form = None
00155         _marker = []
00156         field_data = {}
00157         for name, field in fields:
00158             value = None
00159             widget = field.widget
00160             if form:
00161                 result = widget.process_form(instance, field, form,
00162                                              empty_marker=_marker)
00163             else:
00164                 result = None
00165             if result is None or result is _marker:
00166                 accessor = field.getAccessor(instance)
00167                 if accessor is not None:
00168                     value = accessor()
00169                 else:
00170                     # can't get value to validate -- bail
00171                     continue
00172             else:
00173                 value = result[0]
00174             field_data[name] = value
00175 
00176         pm = getToolByName(self.context, 'portal_metadata', None)
00177         set = pm.getMetadataSet(self.set_id)
00178         set.validate(self.set_id, field_data, errors)
00179         return errors

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 100 of file Facade.py.

Definition at line 106 of file Facade.py.

Definition at line 105 of file Facade.py.

Definition at line 118 of file Facade.py.

Definition at line 115 of file Facade.py.

Definition at line 111 of file Facade.py.

tuple Archetypes.Schema.Facade.FacadeMetadataSchema.security = ClassSecurityInfo() [static]

Definition at line 102 of file Facade.py.

Definition at line 110 of file Facade.py.

Definition at line 114 of file Facade.py.


The documentation for this class was generated from the following file: