def __init__(self, field, size=5, *a, **kw):
     self.args = a
     self.kwargs = kw
     self.field = field
     CompoundField.__init__(self, self.field.getName(),
                            *self.args, **self.kwargs)
     self.resize(size)
 def get(self, instance, **kwargs):
     value = CompoundField.get(self, instance, **kwargs)
     if not value.get("identifier"):
         default = self._defaultBibliography(instance, value)
         if default:
             value["identifier"] = default
     return value
    def set(self, instance, value, **kwargs):
        """sets value and distribute to subfields"""
        # keep evil eval for BBB, but: its a security hole
        # disabled by default
        if config.EVIL_EVAL and type(value) in (type(''),type(u'')):
            #if the value comes as string eval it to a dict
            value = eval(value)

        if type(value) == DictType:
            return CompoundField.set(self, instance, value, **kwargs)

        if not value:
            return
        
        fields = self.Schema().fields()[1:self.getSize(instance)+1]
        if self.autoresize and len(fields) != len(value):
            self.resize(len(value), instance=instance)
            fields = self.Schema().fields()[1:self.getSize(instance)+1]
        for i, f in enumerate(fields):
            if i >= len(value):
                break
            f.set(instance, value[i], **kwargs)
 def set(self, instance, value, **kwargs):
     return CompoundField.set(self,instance,value,**kwargs)
 def getRaw(self, instance, **kwargs):
     return CompoundField.getRaw(self,instance,**kwargs)
from Products.CompoundField.CompoundField import CompoundField
from Products.CompoundField.testClasses.XBoxField import XBoxField
from Products.CompoundField.testClasses.XPointField import XPointField
from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.CompoundField.config import *

##code-section module-header #fill in your manual code here
##/code-section module-header

schema = Schema((
    CompoundField(
        name='point',
        widget=CompoundField._properties['widget'](
            label='Point',
            label_msgid='CompoundField_label_point',
            i18n_domain='CompoundField',
        ),
        schema=Schema((IntegerField('x'), IntegerField('y'))),
    ),
    XBoxField(
        name='box',
        widget=XBoxField._properties['widget'](
            label='Box',
            label_msgid='CompoundField_label_box',
            i18n_domain='CompoundField',
        ),
    ),
    XPointField(
        name='point2',
        widget=XPointField._properties['widget'](
Exemple #7
0
        widget=EEAReferenceBrowserWidget(
            label='External data references',
            description=("References to external data sets, available on "
                         "other websites or via other organisations' "
                         "communication channels."),
            label_msgid='indicators_label_specRelatedItems',
            description_msgid='indicators_help_specRelatedItems',
            macro="indicatorsrelationwidget",
        )),
    CompoundField(
        name='frequency_of_updates',
        schema=frequency_of_updates_schema,
        schemata='default',
        required_for_published=True,
        validators=('validate_frequency_years', ),
        #required=True,
        widget=CompoundWidget(
            label="Frequency of updates",
            description="How often is this indicators assessments updates?",
            label_msgid='indicators_label_frequency_of_updates',
            description_msgid='indicators_help_frequency_of_updates',
        ),
    ),
))

Specification_schema = ATFolderSchema.copy() + \
        getattr(ATFolder, 'schema', Schema(())).copy() + \
        schema.copy()

# Batch reorder of the fields

#this is created like this because we want explicit control over how the
 def get(self, instance, **kwargs):
     return CompoundField.get(self, instance, **kwargs)
 def set(self, instance, value, **kwargs):
     return CompoundField.set(self, instance, value, **kwargs)