Logo Search packages:      
Sourcecode: zope-archetypes version File versions

def Archetypes::ArchetypeTool::ArchetypeTool::getSearchWidgets (   self,
  package = None,
  type = None,
  context = None 
)

empty widgets for searching

Definition at line 560 of file ArchetypeTool.py.

00560                                                                      :
        """empty widgets for searching"""

        # possible problem: assumes fields with same name can be
        # searched with the same widget
        widgets = {}
        context = context is not None and context or self
        for t in self.listTypes(package, type):
            instance = t('fake')
            instance = instance.__of__(context)
            if isinstance(instance, DefaultDublinCoreImpl):
                DefaultDublinCoreImpl.__init__(instance)
            instance._is_fake_instance = 1
            schema = instance.schema = instance.Schema().copy()
            fields = [f for f in schema.fields()
                      if (not widgets.has_key(f.getName())
                          and f.index and f.accessor)]
            for field in fields:
                field.required = 0
                field.addable = 0 # for ReferenceField
                if not isinstance(field.vocabulary, DisplayList):
                    field.vocabulary = field.Vocabulary(instance)
                if '' not in field.vocabulary.keys():
                    field.vocabulary = DisplayList([('', '<any>')]) + \
                                       field.vocabulary
                widget = field.widget
                widget.populate = 0
                widgets[field.getName()] = WidgetWrapper(
                    field_name=field.accessor,
                    mode='search',
                    widget=field.widget,
                    instance=instance,
                    field=field,
                    accessor=field.getDefault)
        widgets = widgets.items()
        widgets.sort()
        return [widget for name, widget in widgets]

    ## Reference Engine Support


Generated by  Doxygen 1.6.0   Back to index