Back to index

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

List of all members.

Public Member Functions

def __add__
def copy
def copy
def copy
def wrapped
def moveField
def edit
def setDefaults
def updateAll
def allow
def validate
def toString
def signature
def changeSchemataForField
def getSchemataNames
def getSchemataFields
def replaceField
def getName
def fields
def editableFields
def viewableFields
def widgets
def filterFields
def __setitem__
def addField
def __delitem__
def __getitem__
def get
def has_key
def keys
def searchable
def hasPrimary
def initializeLayers
def cleanupLayers

Static Public Attributes

tuple security = ClassSecurityInfo()
 values = fields
 delField = __delitem__
 updateField = addField

Detailed Description

Wrapped Schema

Definition at line 887 of file __init__.py.


Member Function Documentation

def Archetypes.Schema.Schema.__add__ (   self,
  other 
) [inherited]

Reimplemented from Archetypes.Schema.SchemaLayerContainer.

Definition at line 682 of file __init__.py.

00682 
00683     def __add__(self, other):
00684         c = Schema()
00685         # We can't use update and keep the order so we do it manually
00686         for field in self.fields():
00687             c.addField(field)
00688         for field in other.fields():
00689             c.addField(field)
00690         # Need to be smarter when joining layers
00691         # and internal props
00692         c._props.update(self._props)
00693         layers = {}
00694         for k, v in self.registeredLayers():
00695             layers[k] = v
00696         for k, v in other.registeredLayers():
00697             layers[k] = v
00698         for k, v in layers.items():
00699             c.registerLayer(k, v)
00700         return c

Here is the call graph for this function:

def Archetypes.Schema.Schemata.__delitem__ (   self,
  name 
) [inherited]

Definition at line 226 of file __init__.py.

00226 
00227     def __delitem__(self, name):
00228         if not self._fields.has_key(name):
00229             raise KeyError("Schemata has no field '%s'" % name)
00230         del self._fields[name]
00231         self._names.remove(name)

def Archetypes.Schema.Schemata.__getitem__ (   self,
  name 
) [inherited]

Definition at line 232 of file __init__.py.

00232 
00233     def __getitem__(self, name):
00234         return self._fields[name]

Here is the caller graph for this function:

def Archetypes.Schema.Schemata.__setitem__ (   self,
  name,
  field 
) [inherited]

Definition at line 174 of file __init__.py.

00174 
00175     def __setitem__(self, name, field):
00176         assert name == field.getName()
00177         self.addField(field)

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.Schemata.addField (   self,
  field 
) [inherited]
Adds a given field to my dictionary of fields.

Reimplemented in Archetypes.Schema.MetadataSchema.

Definition at line 180 of file __init__.py.

00180 
00181     def addField(self, field):
00182         """Adds a given field to my dictionary of fields."""
00183         field = aq_base(field)
00184         self._validateOnAdd(field)
00185         name = field.getName()
00186         if name not in self._names:
00187             self._names.append(name)
00188         self._fields[name] = field

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.BasicSchema.allow (   self,
  name 
) [inherited]

Definition at line 530 of file __init__.py.

00530 
00531     def allow(self, name):
00532         return self.has_key(name)

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.BasicSchema.changeSchemataForField (   self,
  fieldname,
  schemataname 
) [inherited]
change the schemata for a field 

Definition at line 630 of file __init__.py.

00630 
00631     def changeSchemataForField(self, fieldname, schemataname):
00632         """ change the schemata for a field """
00633         field = self[fieldname]
00634         self.delField(fieldname)
00635         field.schemata = schemataname
00636         self.addField(field)

Here is the call graph for this function:

def Archetypes.Schema.SchemaLayerContainer.cleanupLayers (   self,
  instance,
  item = None,
  container = None 
) [inherited]

Definition at line 347 of file __init__.py.

00347 
00348     def cleanupLayers(self, instance, item=None, container=None):
00349         # scan each field looking for registered layers optionally
00350         # call its cleanupInstance method and then the cleanupField
00351         # method
00352         queuedLayers = []
00353         queued = lambda x: x in queuedLayers
00354 
00355         for field in self.fields():
00356             if ILayerContainer.isImplementedBy(field):
00357                 layers = field.registeredLayers()
00358                 for layer, obj in layers:
00359                     if not queued((layer, obj)):
00360                         queuedLayers.append((layer, obj))
00361                     if ILayer.isImplementedBy(obj):
00362                         obj.cleanupField(instance, field)
00363 
00364         for layer, obj in queuedLayers:
00365             if ILayer.isImplementedBy(obj):
00366                 obj.cleanupInstance(instance, item, container)
00367 
00368         # Now do the same for objects registered at this level
00369 
00370         if ILayerContainer.isImplementedBy(self):
00371             for layer, obj in self.registeredLayers():
00372                 if (not queued((layer, obj)) and
00373                     ILayer.isImplementedBy(obj)):
00374                     obj.cleanupInstance(instance, item, container)
00375                     queuedLayers.append((layer, obj))

Here is the call graph for this function:

def Archetypes.Schema.SchemaLayerContainer.copy (   self) [inherited]

Definition at line 388 of file __init__.py.

00388 
00389     def copy(self):
00390         c = SchemaLayerContainer()
00391         layers = {}
00392         for k, v in self.registeredLayers():
00393             c.registerLayer(k, v)
00394         return c
00395 
00396 InitializeClass(SchemaLayerContainer)
00397 

Here is the call graph for this function:

def Archetypes.Schema.BasicSchema.copy (   self) [inherited]
Returns a deep copy of this Schema.

Reimplemented from Archetypes.Schema.Schemata.

Definition at line 452 of file __init__.py.

00452 
00453     def copy(self):
00454         """Returns a deep copy of this Schema.
00455         """
00456         c = BasicSchema()
00457         for field in self.fields():
00458             c.addField(field.copy())
00459         # Need to be smarter when joining layers
00460         # and internal props
00461         c._props.update(self._props)
00462         return c

Here is the call graph for this function:

def Archetypes.Schema.Schema.copy (   self,
  factory = None 
) [inherited]
Returns a deep copy of this Schema.

Definition at line 702 of file __init__.py.

00702 
00703     def copy(self, factory=None):
00704         """Returns a deep copy of this Schema.
00705         """
00706         if factory is None:
00707             factory = self.__class__
00708         c = factory()
00709         for field in self.fields():
00710             c.addField(field.copy())
00711         # Need to be smarter when joining layers
00712         # and internal props
00713         c._props.update(self._props)
00714         layers = {}
00715         for k, v in self.registeredLayers():
00716             c.registerLayer(k, v)
00717         return c

Here is the call graph for this function:

def Archetypes.Schema.BasicSchema.edit (   self,
  instance,
  name,
  value 
) [inherited]

Definition at line 464 of file __init__.py.

00464 
00465     def edit(self, instance, name, value):
00466         if self.allow(name):
00467             instance[name] = value

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.Schemata.editableFields (   self,
  instance,
  visible_only = False 
) [inherited]
Returns a list of editable fields for the given instance

Definition at line 107 of file __init__.py.

00107 
00108     def editableFields(self, instance, visible_only=False):
00109         """Returns a list of editable fields for the given instance
00110         """
00111         ret = []
00112         for field in self.fields():
00113             if field.writeable(instance, debug=False) and    \
00114                    (not visible_only or
00115                     field.widget.isVisible(instance, 'edit') != 'invisible'):
00116                 ret.append(field)
00117         return ret

Here is the call graph for this function:

def Archetypes.Schema.Schemata.fields (   self) [inherited]
Returns a list of my fields in order of their indices.

Definition at line 98 of file __init__.py.

00098 
00099     def fields(self):
00100         """Returns a list of my fields in order of their indices."""
00101         return [self._fields[name] for name in self._names]
00102 

Here is the caller graph for this function:

def Archetypes.Schema.Schemata.filterFields (   self,
  predicates,
  values 
) [inherited]
Returns a subset of self.fields(), containing only fields that
satisfy the given conditions.

You can either specify predicates or values or both. If you provide
both, all conditions must be satisfied.

For each ``predicate`` (positional argument), ``predicate(field)`` must
return 1 for a Field ``field`` to be returned as part of the result.

Each ``attr=val`` function argument defines an additional predicate:
A field must have the attribute ``attr`` and field.attr must be equal
to value ``val`` for it to be in the returned list.

Definition at line 137 of file __init__.py.

00137 
00138     def filterFields(self, *predicates, **values):
00139         """Returns a subset of self.fields(), containing only fields that
00140         satisfy the given conditions.
00141 
00142         You can either specify predicates or values or both. If you provide
00143         both, all conditions must be satisfied.
00144 
00145         For each ``predicate`` (positional argument), ``predicate(field)`` must
00146         return 1 for a Field ``field`` to be returned as part of the result.
00147 
00148         Each ``attr=val`` function argument defines an additional predicate:
00149         A field must have the attribute ``attr`` and field.attr must be equal
00150         to value ``val`` for it to be in the returned list.
00151         """
00152 
00153         results = []
00154 
00155         for field in self.fields(): # step through each of my fields
00156 
00157             # predicate failed:
00158             failed = [pred for pred in predicates if not pred(field)]
00159             if failed: continue
00160 
00161             # attribute missing:
00162             missing_attrs = [attr for attr in values.keys() \
00163                              if not shasattr(field, attr)]
00164             if missing_attrs: continue
00165 
00166             # attribute value unequal:
00167             diff_values = [attr for attr in values.keys() \
00168                            if getattr(field, attr) != values[attr]]
00169             if diff_values: continue
00170 
00171             results.append(field)
00172 
00173         return results

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.Schemata.get (   self,
  name,
  default = None 
) [inherited]

Definition at line 236 of file __init__.py.

00236 
00237     def get(self, name, default=None):
00238         return self._fields.get(name, default)

Here is the caller graph for this function:

def Archetypes.Schema.Schemata.getName (   self) [inherited]
Returns the Schemata's name.

Definition at line 68 of file __init__.py.

00068 
00069     def getName(self):
00070         """Returns the Schemata's name."""
00071         return self.__name__
00072 

Here is the caller graph for this function:

def Archetypes.Schema.BasicSchema.getSchemataFields (   self,
  name 
) [inherited]
Return list of fields belong to schema 'name'
in order of appearing

Definition at line 647 of file __init__.py.

00647 
00648     def getSchemataFields(self, name):
00649         """Return list of fields belong to schema 'name'
00650         in order of appearing
00651         """
00652         return [f for f in self.fields() if f.schemata == name]

Here is the call graph for this function:

Here is the caller graph for this function:

Return list of schemata names in order of appearing

Definition at line 638 of file __init__.py.

00638 
00639     def getSchemataNames(self):
00640         """Return list of schemata names in order of appearing"""
00641         lst = []
00642         for f in self.fields():
00643             if not f.schemata in lst:
00644                 lst.append(f.schemata)
00645         return lst

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.Schemata.has_key (   self,
  name 
) [inherited]

Definition at line 240 of file __init__.py.

00240 
00241     def has_key(self, name):
00242         return self._fields.has_key(name)

Here is the caller graph for this function:

def Archetypes.Schema.Schemata.hasPrimary (   self) [inherited]
Returns the first primary field or False

Definition at line 263 of file __init__.py.

00263 
00264     def hasPrimary(self):
00265         """Returns the first primary field or False"""
00266         for f in self.fields():
00267             if getattr(f, 'primary', False):
00268                 return f
00269         return False

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.SchemaLayerContainer.initializeLayers (   self,
  instance,
  item = None,
  container = None 
) [inherited]

Definition at line 316 of file __init__.py.

00316 
00317     def initializeLayers(self, instance, item=None, container=None):
00318         # scan each field looking for registered layers optionally
00319         # call its initializeInstance method and then the
00320         # initializeField method
00321         initializedLayers = []
00322         called = lambda x: x in initializedLayers
00323 
00324         for field in self.fields():
00325             if ILayerContainer.isImplementedBy(field):
00326                 layers = field.registeredLayers()
00327                 for layer, obj in layers:
00328                     if ILayer.isImplementedBy(obj):
00329                         if not called((layer, obj)):
00330                             obj.initializeInstance(instance, item, container)
00331                             # Some layers may have the same name, but
00332                             # different classes, so, they may still
00333                             # need to be initialized
00334                             initializedLayers.append((layer, obj))
00335                         obj.initializeField(instance, field)
00336 
00337         # Now do the same for objects registered at this level
00338         if ILayerContainer.isImplementedBy(self):
00339             for layer, obj in self.registeredLayers():
00340                 if (not called((layer, obj)) and
00341                     ILayer.isImplementedBy(obj)):
00342                     obj.initializeInstance(instance, item, container)
00343                     initializedLayers.append((layer, obj))
00344 

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.Schemata.keys (   self) [inherited]

Definition at line 246 of file __init__.py.

00246 
00247     def keys(self):
00248         return self._names

Here is the caller graph for this function:

def Archetypes.Schema.Schema.moveField (   self,
  name,
  direction = None,
  pos = None,
  after = None,
  before = None 
) [inherited]
Move a field

>>> from Products.Archetypes.atapi import StringField as SF
>>> schema = Schema((SF('a'), SF('b'), SF('c'),))

>>> schema.keys()
['a', 'b', 'c']

>>> sbefore = schema.copy()
>>> sbefore.moveField('c', before='a')
>>> sbefore.keys()
['c', 'a', 'b']

>>> safter = schema.copy()
>>> safter.moveField('a', after='b')
>>> safter.keys()
['b', 'a', 'c']

>>> spos = schema.copy()
>>> spos.moveField('b', pos='top')
>>> spos.keys()
['b', 'a', 'c']

>>> spos = schema.copy()
>>> spos.moveField('b', pos='bottom')
>>> spos.keys()
['a', 'c', 'b']

>>> spos = schema.copy()
>>> spos.moveField('c', pos=0)
>>> spos.keys()
['c', 'a', 'b']

maxint can be used to move the field to the last position possible
>>> from sys import maxint
>>> spos = schema.copy()
>>> spos.moveField('a', pos=maxint)
>>> spos.keys()
['b', 'c', 'a']

Errors
======

>>> schema.moveField('d', pos=0)
Traceback (most recent call last):
...
KeyError: 'd'

>>> schema.moveField('a', pos=0, before='b')
Traceback (most recent call last):
...
ValueError: You must apply exactly one argument.

>>> schema.moveField('a')
Traceback (most recent call last):
...
ValueError: You must apply exactly one argument.

>>> schema.moveField('a', before='a')
Traceback (most recent call last):
...
ValueError: name and before can't be the same

>>> schema.moveField('a', after='a')
Traceback (most recent call last):
...
ValueError: name and after can't be the same

>>> schema.moveField('a', pos='foo')
Traceback (most recent call last):
...
ValueError: pos must be a number or top/bottom

Definition at line 725 of file __init__.py.

00725 
00726     def moveField(self, name, direction=None, pos=None, after=None, before=None):
00727         """Move a field
00728 
00729         >>> from Products.Archetypes.atapi import StringField as SF
00730         >>> schema = Schema((SF('a'), SF('b'), SF('c'),))
00731 
00732         >>> schema.keys()
00733         ['a', 'b', 'c']
00734 
00735         >>> sbefore = schema.copy()
00736         >>> sbefore.moveField('c', before='a')
00737         >>> sbefore.keys()
00738         ['c', 'a', 'b']
00739 
00740         >>> safter = schema.copy()
00741         >>> safter.moveField('a', after='b')
00742         >>> safter.keys()
00743         ['b', 'a', 'c']
00744 
00745         >>> spos = schema.copy()
00746         >>> spos.moveField('b', pos='top')
00747         >>> spos.keys()
00748         ['b', 'a', 'c']
00749 
00750         >>> spos = schema.copy()
00751         >>> spos.moveField('b', pos='bottom')
00752         >>> spos.keys()
00753         ['a', 'c', 'b']
00754 
00755         >>> spos = schema.copy()
00756         >>> spos.moveField('c', pos=0)
00757         >>> spos.keys()
00758         ['c', 'a', 'b']
00759 
00760         maxint can be used to move the field to the last position possible
00761         >>> from sys import maxint
00762         >>> spos = schema.copy()
00763         >>> spos.moveField('a', pos=maxint)
00764         >>> spos.keys()
00765         ['b', 'c', 'a']
00766 
00767         Errors
00768         ======
00769 
00770         >>> schema.moveField('d', pos=0)
00771         Traceback (most recent call last):
00772         ...
00773         KeyError: 'd'
00774 
00775         >>> schema.moveField('a', pos=0, before='b')
00776         Traceback (most recent call last):
00777         ...
00778         ValueError: You must apply exactly one argument.
00779 
00780         >>> schema.moveField('a')
00781         Traceback (most recent call last):
00782         ...
00783         ValueError: You must apply exactly one argument.
00784 
00785         >>> schema.moveField('a', before='a')
00786         Traceback (most recent call last):
00787         ...
00788         ValueError: name and before can't be the same
00789 
00790         >>> schema.moveField('a', after='a')
00791         Traceback (most recent call last):
00792         ...
00793         ValueError: name and after can't be the same
00794 
00795         >>> schema.moveField('a', pos='foo')
00796         Traceback (most recent call last):
00797         ...
00798         ValueError: pos must be a number or top/bottom
00799 
00800         """
00801         if bool(direction) + bool(after) + bool(before) + bool(pos is not None) != 1:
00802             raise ValueError, "You must apply exactly one argument."
00803         keys = self.keys()
00804 
00805         if name not in keys:
00806             raise KeyError, name
00807 
00808         if direction is not None:
00809             return self._moveFieldInSchemata(name, direction)
00810 
00811         if pos is not None:
00812             if not (isinstance(pos, int) or pos in ('top', 'bottom',)):
00813                 raise ValueError, "pos must be a number or top/bottom"
00814             if pos == 'top':
00815                 return self._moveFieldToPosition(name, 0)
00816             elif pos == 'bottom':
00817                 return self._moveFieldToPosition(name, len(keys))
00818             else:
00819                 return self._moveFieldToPosition(name, pos)
00820 
00821         if after is not None:
00822             if after == name:
00823                 raise ValueError, "name and after can't be the same"
00824             idx = keys.index(after)
00825             return self._moveFieldToPosition(name, idx+1)
00826 
00827         if before is not None:
00828             if before == name:
00829                 raise ValueError, "name and before can't be the same"
00830             idx = keys.index(before)
00831             return self._moveFieldToPosition(name, idx)

Here is the call graph for this function:

def Archetypes.Schema.BasicSchema.replaceField (   self,
  name,
  field 
) [inherited]

Definition at line 655 of file __init__.py.

00655 
00656     def replaceField(self, name, field):
00657         if IField.isImplementedBy(field):
00658             oidx = self._names.index(name)
00659             new_name = field.getName()
00660             self._names[oidx] = new_name
00661             del self._fields[name]
00662             self._fields[new_name] = field
00663         else:
00664             raise ValueError, "Object doesn't implement IField: %r" % field
00665 
00666 InitializeClass(BasicSchema)
00667 

def Archetypes.Schema.Schemata.searchable (   self) [inherited]
Returns a list containing names of all searchable fields.

Definition at line 258 of file __init__.py.

00258 
00259     def searchable(self):
00260         """Returns a list containing names of all searchable fields."""
00261 
00262         return [f.getName() for f in self.fields() if f.searchable]

Here is the call graph for this function:

def Archetypes.Schema.BasicSchema.setDefaults (   self,
  instance 
) [inherited]
Only call during object initialization. Sets fields to
schema defaults

Definition at line 470 of file __init__.py.

00470 
00471     def setDefaults(self, instance):
00472         """Only call during object initialization. Sets fields to
00473         schema defaults
00474         """
00475         ## TODO think about layout/vs dyn defaults
00476         for field in self.values():
00477             if field.getName().lower() == 'id': continue
00478             if field.type == "reference": continue
00479 
00480             # always set defaults on writable fields
00481             mutator = field.getMutator(instance)
00482             if mutator is None:
00483                 continue
00484             default = field.getDefault(instance)
00485 
00486             args = (default,)
00487             kw = {'field': field.__name__,
00488                   '_initializing_': True}
00489             if shasattr(field, 'default_content_type'):
00490                 # specify a mimetype if the mutator takes a
00491                 # mimetype argument
00492                 # if the schema supplies a default, we honour that, 
00493                 # otherwise we use the site property
00494                 default_content_type = field.default_content_type
00495                 if default_content_type is None:
00496                     default_content_type = getDefaultContentType(instance)
00497                 kw['mimetype'] = default_content_type
00498             mapply(mutator, *args, **kw)

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.BasicSchema.signature (   self) [inherited]

Definition at line 624 of file __init__.py.

00624 
00625     def signature(self):
00626         from md5 import md5
00627         return md5(self.toString()).digest()

Here is the call graph for this function:

def Archetypes.Schema.BasicSchema.toString (   self) [inherited]

Definition at line 615 of file __init__.py.

00615 
00616     def toString(self):
00617         s = '%s: {' % self.__class__.__name__
00618         for f in self.fields():
00619             s = s + '%s,' % (f.toString())
00620         s = s + '}'
00621         return s

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.BasicSchema.updateAll (   self,
  instance,
  kwargs 
) [inherited]
This method mutates fields in the given instance.

For each keyword argument k, the key indicates the name of the
field to mutate while the value is used to call the mutator.

E.g. updateAll(instance, id='123', amount=500) will, depending on the
actual mutators set, result in two calls: ``instance.setId('123')`` and
``instance.setAmount(500)``.

Definition at line 501 of file __init__.py.

00501 
00502     def updateAll(self, instance, **kwargs):
00503         """This method mutates fields in the given instance.
00504 
00505         For each keyword argument k, the key indicates the name of the
00506         field to mutate while the value is used to call the mutator.
00507 
00508         E.g. updateAll(instance, id='123', amount=500) will, depending on the
00509         actual mutators set, result in two calls: ``instance.setId('123')`` and
00510         ``instance.setAmount(500)``.
00511         """
00512 
00513         keys = kwargs.keys()
00514 
00515         for name in keys:
00516 
00517             field = self.get(name, None)
00518 
00519             if field is None:
00520                 continue
00521 
00522             if not field.writeable(instance):
00523                 continue
00524 
00525             # If passed the test above, mutator is guaranteed to
00526             # exist.
00527             method = field.getMutator(instance)
00528             method(kwargs[name])

Here is the call graph for this function:

def Archetypes.Schema.BasicSchema.validate (   self,
  instance = None,
  REQUEST = None,
  errors = None,
  data = None,
  metadata = None 
) [inherited]
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 535 of file __init__.py.

00535 
00536                  errors=None, data=None, metadata=None):
00537         """Validate the state of the entire object.
00538 
00539         The passed dictionary ``errors`` will be filled with human readable
00540         error messages as values and the corresponding fields' names as
00541         keys.
00542 
00543         If a REQUEST object is present, validate the field values in the
00544         REQUEST.  Otherwise, validate the values currently in the object.
00545         """
00546         if REQUEST:
00547             fieldset = REQUEST.form.get('fieldset', None)
00548             fieldsets = REQUEST.form.get('fieldsets', None)
00549         else:
00550             fieldset = fieldsets = None
00551         fields = []
00552 
00553         if fieldsets is not None:
00554             schemata = instance.Schemata()
00555             for fieldset in fieldsets:
00556                 fields += [(field.getName(), field)
00557                            for field in schemata[fieldset].fields()]            
00558         elif fieldset is not None:
00559             schemata = instance.Schemata()
00560             fields = [(field.getName(), field)
00561                       for field in schemata[fieldset].fields()]            
00562         else:
00563             if data:
00564                 fields.extend([(field.getName(), field)
00565                                for field in self.filterFields(isMetadata=0)])
00566             if metadata:
00567                 fields.extend([(field.getName(), field)
00568                                for field in self.filterFields(isMetadata=1)])
00569 
00570         if REQUEST:
00571             form = REQUEST.form
00572         else:
00573             form = None
00574             
00575         for name, field in fields:
00576             
00577             # Should not validate something we can't write to anyway
00578             if not field.writeable(instance):
00579                 continue
00580             
00581             error = 0
00582             value = None
00583             widget = field.widget
00584             
00585             if form:
00586                 result = widget.process_form(instance, field, form,
00587                                              empty_marker=_marker)
00588             else:
00589                 result = None
00590             if result is None or result is _marker:
00591                 accessor = field.getEditAccessor(instance) or field.getAccessor(instance)
00592                 if accessor is not None:
00593                     value = accessor()
00594                 else:
00595                     # can't get value to validate -- bail
00596                     continue
00597             else:
00598                 value = result[0]
00599 
00600             res = field.validate(instance=instance,
00601                                  value=value,
00602                                  errors=errors,
00603                                  REQUEST=REQUEST)
00604             if res:
00605                 errors[field.getName()] = res
00606         return errors
00607 

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.Schemata.viewableFields (   self,
  instance 
) [inherited]
Returns a list of viewable fields for the given instance

Definition at line 119 of file __init__.py.

00119 
00120     def viewableFields(self, instance):
00121         """Returns a list of viewable fields for the given instance
00122         """
00123         return [field for field in self.fields()
00124                 if field.checkPermission('view', instance)]

Here is the call graph for this function:

def Archetypes.Schema.Schemata.widgets (   self) [inherited]
Returns a dictionary that contains a widget for
each field, using the field name as key.

Definition at line 126 of file __init__.py.

00126 
00127     def widgets(self):
00128         """Returns a dictionary that contains a widget for
00129         each field, using the field name as key."""
00130 
00131         widgets = {}
00132         for f in self.fields():
00133             widgets[f.getName()] = f.widget
00134         return widgets

Here is the call graph for this function:

Here is the caller graph for this function:

def Archetypes.Schema.Schema.wrapped (   self,
  parent 
) [inherited]

Definition at line 719 of file __init__.py.

00719 
00720     def wrapped(self, parent):
00721         schema = self.copy(factory=WrappedSchema)
00722         return schema.__of__(parent)

Here is the call graph for this function:


Member Data Documentation

Definition at line 251 of file __init__.py.

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

Reimplemented from Archetypes.Schema.Schema.

Definition at line 892 of file __init__.py.

Definition at line 255 of file __init__.py.

Definition at line 104 of file __init__.py.


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