예제 #1
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 = ''

        content = self.adapted

        if Update in self.request:
            changed = False
            try:
                changed = applyWidgetsChanges(self, self.schema,
                    target=content, names=self.fieldNames)
                # We should not generate events when an adapter is used.
                # That's the adapter's job.
                if changed and self.context is self.adapted:
                    description = Attributes(self.schema, *self.fieldNames)
                    notify(ObjectModifiedEvent(content, description))
            except WidgetsError, errors:
                self.errors = errors
                status = _("An error occurred.")
                transaction.abort()
            else:
                setUpEditWidgets(self, self.schema, source=self.adapted,
                                 ignoreStickyValues=True, 
                                 names=self.fieldNames)
                if changed:
                    self.changed()
                    formatter = self.request.locale.dates.getFormatter(
                        'dateTime', 'medium')
                    status = _("Updated on ${date_time}",
                               mapping={'date_time':
                                        formatter.format(datetime.utcnow())})
예제 #2
0
 def _setUpWidgets(self):
     adapted = self.schema(self.context)
     if adapted is not self.context:
         if not ILocation.providedBy(adapted):
             adapted = LocationProxy(adapted)
         adapted.__parent__ = self.context
     self.adapted = adapted
     setUpEditWidgets(self, self.schema, source=self.adapted,
                      names=self.fieldNames)
예제 #3
0
파일: __init__.py 프로젝트: goschtl/zope
 def _setUpWidgets(self):
     adapted = self.schema(self.context)
     if adapted is not self.context:
         if not ILocation.providedBy(adapted):
             adapted = LocationProxy(adapted)
         adapted.__parent__ = self.context
     self.adapted = adapted
     setUpEditWidgets(self, self.schema, source=self.adapted,
                      names=self.fieldNames)
    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 = ''

        content = self.adapted

        if Update in self.request.form.keys():
            changed = False
            try:
                changed = applyWidgetsChanges(self,
                                              self.schema,
                                              target=content,
                                              names=self.fieldNames)
                # We should not generate events when an adapter is used.
                # That's the adapter's job.  We need to unwrap the objects to
                # compare them, as they are wrapped differently.
                # Additionally, we can't use Acquisition.aq_base() because
                # it strangely returns different objects for these two even
                # when they are identical.  In particular
                # aq_base(self.adapted) != self.adapted.aq_base :-(
                if changed and getattr(self.context, 'aq_base', self.context)\
                        is getattr(self.adapted, 'aq_base', self.adapted):
                    description = Attributes(self.schema, *self.fieldNames)
                    notify(ObjectModifiedEvent(content, description))
            except WidgetsError as errors:
                self.errors = errors
                status = _("An error occurred.")
                transaction.abort()
            else:
                setUpEditWidgets(self,
                                 self.schema,
                                 source=self.adapted,
                                 ignoreStickyValues=True,
                                 names=self.fieldNames)
                if changed:
                    self.changed()
                    formatter = self.request.locale.dates.getFormatter(
                        'dateTime', 'medium')
                    status = _("Updated on ${date_time}",
                               mapping={
                                   'date_time':
                                   formatter.format(datetime.utcnow())
                               })

        self.update_status = status
        return status
예제 #5
0
 def __init__(self, field, request):
     self.context = field
     self.request = request
     data = WidgetData()
     if interfaces.IRequirement.providedBy(field.context):
         ss = field.context.scoresystem
         if scoresystem.ICustomScoreSystem.providedBy(ss):
             data.custom = True
             data.min = ss.min
             data.max = ss.max
         else:
             data.existing = ss
     self.name = self._prefix + field.__name__
     utility.setUpEditWidgets(self,
                              IWidgetData,
                              source=data,
                              prefix=self.name + '.')
예제 #6
0
파일: __init__.py 프로젝트: a25kk/stv2
    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 = ''

        content = self.adapted

        if Update in self.request.form.keys():
            changed = False
            try:
                changed = applyWidgetsChanges(self, self.schema,
                    target=content, names=self.fieldNames)
                # We should not generate events when an adapter is used.
                # That's the adapter's job.  We need to unwrap the objects to
                # compare them, as they are wrapped differently.
                # Additionally, we can't use Acquisition.aq_base() because
                # it strangely returns different objects for these two even
                # when they are identical.  In particular
                # aq_base(self.adapted) != self.adapted.aq_base :-(
                if changed and getattr(self.context, 'aq_base', self.context)\
                            is getattr(self.adapted, 'aq_base', self.adapted):
                    description = Attributes(self.schema, *self.fieldNames)
                    notify(ObjectModifiedEvent(content, description))
            except WidgetsError, errors:
                self.errors = errors
                status = _("An error occurred.")
                transaction.abort()
            else:
                setUpEditWidgets(self, self.schema, source=self.adapted,
                                 ignoreStickyValues=True,
                                 names=self.fieldNames)
                if changed:
                    self.changed()
                    # XXX: Needs locale support:
                    #formatter = self.request.locale.dates.getFormatter(
                    #    'dateTime', 'medium')
                    #status = _("Updated on ${date_time}",
                    #           mapping={'date_time':
                    #                    formatter.format(datetime.utcnow())})
                    status = _("Updated on ${date_time}",
                               mapping={'date_time': str(datetime.utcnow())})
예제 #7
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 = ''

        content = self.adapted

        if Update in self.request:
            changed = False
            try:
                changed = applyWidgetsChanges(self,
                                              self.schema,
                                              target=content,
                                              names=self.fieldNames)
                # We should not generate events when an adapter is used.
                # That's the adapter's job.
                if changed and self.context is self.adapted:
                    description = Attributes(self.schema, *self.fieldNames)
                    notify(ObjectModifiedEvent(content, description))
            except WidgetsError, errors:
                self.errors = errors
                status = _("An error occurred.")
                transaction.doom()
            else:
                setUpEditWidgets(self,
                                 self.schema,
                                 source=self.adapted,
                                 ignoreStickyValues=True,
                                 names=self.fieldNames)
                if changed:
                    self.changed()
                    formatter = self.request.locale.dates.getFormatter(
                        'dateTime', 'medium')
                    status = _("Updated on ${date_time}",
                               mapping={
                                   'date_time':
                                   formatter.format(datetime.utcnow())
                               })
예제 #8
0
파일: browser.py 프로젝트: bendavis78/zope
    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 = ''

        content = self.adapted

        if Update in self.request.form.keys():
            changed = False
            try:
                changed = applyWidgetsChanges(self,
                                              self.schema,
                                              target=content,
                                              names=self.fieldNames)
                # We should not generate events when an adapter is used.
                # That's the adapter's job.
                if changed and self.context is self.adapted:
                    notify(ObjectModifiedEvent(content))
            except WidgetsError, errors:
                self.errors = errors
                status = "An error occured."
                get_transaction().abort()
            else:
                setUpEditWidgets(self,
                                 self.schema,
                                 source=self.adapted,
                                 ignoreStickyValues=True,
                                 names=self.fieldNames)
                if changed:
                    self.changed()
                    # XXX: Needs i18n support:
                    # formatter = self.request.locale.dates.getFormatter(
                    #     'dateTime', 'medium')
                    # status = _("Updated on ${date_time}")
                    # status.mapping = {'date_time': formatter.format(
                    #     datetime.utcnow())}
                    status = "Updated on %s" % str(datetime.utcnow())
예제 #9
0
 def _setUpWidgets(self):
     self.adapted = self.schema(self.context)
     setUpEditWidgets(self,
                      self.schema,
                      source=self.adapted,
                      names=self.fieldNames)
예제 #10
0
 def _setUpWidgets(self):
     self.adapted = self.schema(self.context)
     setUpEditWidgets(self, self.schema, source=self.adapted,
                      names=self.fieldNames)
예제 #11
0
 def __init__(self, *args):
     super(CacheableView, self).__init__(*args)
     self.cacheable = ICacheable(self.context)
     setUpEditWidgets(self, ICacheable, self.cacheable)
예제 #12
0
 def _setUpWidgets(self):
     adapted = self.schema(self.context)
     if adapted is not self.context:
         adapted.__parent__ = self.context
     setUpEditWidgets(self, self.schema, source=self.adapted,
                      names=self.fieldNames)