示例#1
0
 def _setUpEditWidgets(self):
     setUpWidgets(self,
                  self.context.schema,
                  IDisplayWidget,
                  prefix=self.name,
                  names=self.names,
                  context=self.context)
示例#2
0
 def results(self, name):
     if not (name + '.search' in self.request):
         return None
     schema = self.context.schema
     setUpWidgets(self, schema, IInputWidget, prefix=name + '.field')
     data = getWidgetsData(self, schema)
     return self.context.search(data)
示例#3
0
    def update(self):
        if self.update_status is not None:
            # We've been called before. Just return the status we previously
            # computed.
            return self.update_status

        status = ''

        if Update in self.request:
            try:
                changed = applyWidgetsChanges(self,
                                              self.schema,
                                              target=self.data,
                                              names=self.fieldNames)
            except WidgetsError as errors:  # pragma: no cover
                self.errors = errors
                status = _("An error occurred.")
                transaction.doom()
            else:
                if changed:
                    status = self.setData(self.data)
                setUpWidgets(self,
                             self.schema,
                             IInputWidget,
                             initial=self.data,
                             ignoreStickyValues=True,
                             names=self.fieldNames)

        self.update_status = status
        return status
示例#4
0
 def results(self, name):
     if not (name+'.search' in self.request):
         return None
     schema = self.context.schema
     setUpWidgets(self, schema, IInputWidget, prefix=name+'.field')
     data = getWidgetsData(self, schema)
     return self.context.search(data)
示例#5
0
 def _setUpWidgets(self):
     self.data = Data(self.getData())
     setUpWidgets(self,
                  self.schema,
                  IInputWidget,
                  initial=self.data,
                  names=self.fieldNames)
示例#6
0
    def update(self):
        if self.update_status is not None:
            # We've been called before. Just return the status we previously
            # computed.
            return self.update_status

        status = ''

        if Update in self.request:
            try:
                changed = applyWidgetsChanges(
                    self, self.schema, target=self.data, names=self.fieldNames)
            except WidgetsError, errors:
                self.errors = errors
                status = _("An error occurred.")
                transaction.doom()
            else:
                if changed:
                    status = self.setData(self.data)
                setUpWidgets(
                    self, self.schema, IInputWidget, initial=self.data,
                    ignoreStickyValues=True, names=self.fieldNames)
示例#7
0
    def update(self):
        if 'REMOVE' in self.request:
            keys = utility.getWidgetsData(self,
                                          ICategoriesForm,
                                          names=['categories'])['categories']
            if not keys:
                return
            for key in keys:
                del self.categories[key]
            self.message = _('Categories successfully deleted.')

        elif 'ADD' in self.request:
            value = utility.getWidgetsData(self,
                                           ICategoriesForm,
                                           names=['newCategory'
                                                  ])['newCategory']
            if not value:
                return
            name = unicode(value).encode('punycode')
            self.categories[name] = value
            self.message = _('Category successfully added.')

        elif 'CHANGE' in self.request:
            key = utility.getWidgetsData(self,
                                         ICategoriesForm,
                                         names=['defaultCategory'
                                                ])['defaultCategory']
            self.categories.default_key = key
            self.message = _('Default category successfully changed.')

        utility.setUpWidgets(self,
                             self.schema,
                             IInputWidget,
                             initial=self.getData(),
                             ignoreStickyValues=True,
                             names=self.fieldNames)
示例#8
0
 def _setUpWidgets(self):
     setUpWidgets(self, self.schema, IInputWidget, names=self.fieldNames)
示例#9
0
    def __init__(self, context, request):
        BrowserView.__init__(self, context, request)

        setUpWidgets(self, ISimpleContact, IInputWidget)
示例#10
0
文件: add.py 项目: CGTIC/Plone_SP
 def _setUpWidgets(self):
     setUpWidgets(self, self.schema, IInputWidget, names=self.fieldNames)
示例#11
0
 def _setUpWidgets(self):
     self.data = Data(self.getData())
     setUpWidgets(
         self, self.schema, IInputWidget, initial=self.data, 
         names=self.fieldNames)
示例#12
0
 def _setUpEditWidgets(self):
     setUpWidgets(
         self, self.context.schema, IDisplayWidget, prefix=self.name, names=self.names, context=self.context
     )
示例#13
0
    def render(self, name):
        schema = self.context.schema
        sourcename = getName(self.context)
        sourcepath = getPath(self.context)
        setUpWidgets(self, schema, IInputWidget, prefix=name + '.field')
        html = []

        # add sub title for source search field
        html.append('<h4>%s</h4>' % sourcename)

        # start row for path display field
        html.append('<div class="row">')

        # for each source add path of source
        html.append('  <div class="label">')
        label = translate(source_label, context=self.request)
        title = translate(source_title, context=self.request)
        html.append('    <label for="%s" title="%s">' % (sourcename, title))
        html.append('      %s' % label)
        html.append('    </label>')
        html.append('  </div>')
        html.append('  <div class="field">')
        html.append('      %s' % sourcepath)
        html.append('  </div>')
        html.append('</div>')

        # start row for search fields
        html.append('<div class="row">')

        for field_name, field in getFieldsInOrder(schema):
            widget = getattr(self, field_name + '_widget')

            # for each field add label...
            html.append('  <div class="label">')
            html.append('    <label for="%s" title="%s">' %
                        (widget.name, widget.hint))
            html.append('      %s' % widget.label)
            html.append('    </label>')
            html.append('  </div>')

            # ...and field widget
            html.append('  <div class="field">')
            html.append('    %s' % widget())

            if widget.error():
                html.append('    <div class="error">')
                html.append('      %s' % widget.error())
                html.append('    </div>')
            html.append('  </div>')
        # end row
        html.append('</div>')

        # add search button for search fields
        html.append('<div class="row">')
        html.append('  <div class="field">')
        html.append(
            '    <input type="submit" name="%s" value="%s" />' %
            (name + '.search', translate(search_label, context=self.request)))
        html.append('  </div>')
        html.append('</div>')

        return '\n'.join(html)
示例#14
0
文件: browser.py 项目: goschtl/zope
    def __init__(self, context, request):
        BrowserView.__init__(self, context, request)

        setUpWidgets(self, ISimpleContact, IInputWidget)
示例#15
0
 def __init__(self, context, request):
     BrowserView.__init__(self, context, request)
     setUpWidgets(self, self.schema, IInputWidget)
示例#16
0
 def __init__(self, context, request):
     BrowserView.__init__(self, context, request)
     setUpWidgets(self, self.schema, IInputWidget)
示例#17
0
 def _setUpEditWidgets(self):
     # subwidgets need a new name
     setUpWidgets(self, self.context.schema, IInputWidget,
                      prefix=self.name, names=self.names,
                      context=self.context)
示例#18
0
    def render(self, name):
        schema = self.context.schema
        sourcename = getName(self.context)
        sourcepath = getPath(self.context)
        setUpWidgets(self, schema, IInputWidget, prefix=name+'.field')
        html = []

        # add sub title for source search field
        html.append('<h4>%s</h4>' % sourcename)

        # start row for path display field
        html.append('<div class="row">')

        # for each source add path of source
        html.append('  <div class="label">')
        label = translate(source_label, context=self.request)
        title = translate(source_title, context=self.request)
        html.append('    <label for="%s" title="%s">' % (sourcename, title))
        html.append('      %s' % label)
        html.append('    </label>')
        html.append('  </div>')
        html.append('  <div class="field">')
        html.append('      %s' % sourcepath)
        html.append('  </div>')
        html.append('</div>')

        # start row for search fields
        html.append('<div class="row">')

        for field_name, field in getFieldsInOrder(schema):
            widget = getattr(self, field_name+'_widget')

            # for each field add label...
            html.append('  <div class="label">')
            html.append('    <label for="%s" title="%s">'
                        % (widget.name, widget.hint))
            html.append('      %s' % widget.label)
            html.append('    </label>')
            html.append('  </div>')

            # ...and field widget
            html.append('  <div class="field">')
            html.append('    %s' % widget())

            if widget.error():
                html.append('    <div class="error">')
                html.append('      %s' % widget.error())
                html.append('    </div>')
            html.append('  </div>')
        # end row
        html.append('</div>')

        # add search button for search fields
        html.append('<div class="row">')
        html.append('  <div class="field">')
        html.append('    <input type="submit" name="%s" value="%s" />'
                     % (name+'.search',
                        translate(search_label, context=self.request)))
        html.append('  </div>')
        html.append('</div>')

        return '\n'.join(html)