Beispiel #1
0
 def get(self, instance, **kwargs):
     value = ObjectField.get(self, instance, **kwargs)
     if type(value) in types.StringTypes:
         # migration from TextField
         zpt = ZopePageTemplate(self.getName())
         ObjectField.set(self, instance, zpt, **kwargs)
         value = ObjectField.get(self, instance, **kwargs)
     return value.pt_render(extra_context={'options': kwargs})
Beispiel #2
0
 def get(self, instance, **kwargs):
     value = ObjectField.get(self, instance, **kwargs)
     if type(value) in types.StringTypes:
         # migration from TextField
         zpt = ZopePageTemplate(self.getName())
         ObjectField.set(self, instance, zpt, **kwargs)
         value = ObjectField.get(self, instance, **kwargs)
     if config.CATCH_RENDER_ERRORS:
         try:
             return value.pt_render(extra_context={'options': kwargs})
         except Exception, e:
             return _(u"zpt_field_render_error",
                      default=u'<div class="error">An error occured while rendering this field</div>')
Beispiel #3
0
 def getRaw(self, instance, **kwargs):
     body = ObjectField.get(self, instance, **kwargs).body()
     p1 = body.find(self._seperator)
     if p1 == -1:
         # no seperator: we return the whole body
         return body
     else:
         p1 = p1 + len(self._seperator)
         p2 = body.find(self._seperator, p1)
         return body[p1:p2]
    def getRaw(self, instance, aslist=False, **kwargs):
        """Return the list of UIDs referenced under this fields
        relationship
        """
        objects = []
        uids = ObjectField.get(self, instance, **kwargs)

        if uids is None:
            uids = []

        if not self.multiValued and not aslist:
            if uids:
                uids = uids[0]
            else:
                uids = None
        return uids
    def getRaw(self, instance, aslist=False, **kwargs):
        """Return the list of UIDs referenced under this fields
        relationship
        """
        objects = []
        uids = ObjectField.get(self, instance, **kwargs)

        if uids is None:
            uids = []

        if not self.multiValued and not aslist:
            if uids:
                uids = uids[0]
            else:
                uids = None
        return uids
Beispiel #6
0
    def get(self, instance, aslist=False, **kwargs):
        """
        """
        res = ObjectField.get(self, instance, **kwargs)
        if res is None:
            return res

        if self.multiValued:
            resolved = []
            for rel in res:
                resolved.append(rel.to_object)
        else:
            resolved = res.to_object
            if aslist:
                resolved = [resolved]

        return resolved
    def get(self, instance, aslist=False, **kwargs):
        """
        """
        res = ObjectField.get(self, instance, **kwargs)
        if res is None:
            return res

        if self.multiValued:
            resolved = []
            for rel in res:
                resolved.append(rel.to_object)
        else:
            resolved = res.to_object
            if aslist:
                resolved = [resolved]

        return resolved
    def get(self, instance, aslist=False, **kwargs):
        objects = []
        rc = getToolByName(instance, REFERENCE_CATALOG)
        uids = ObjectField.get(self, instance, **kwargs)

        if uids is None:
            uids = []

        for uid in uids:
            if uid:
                objects.append(rc.lookupObject(uid))

        if objects:
            if not self.multiValued:
                return objects[0]
            else:
                return objects

        return []
    def get(self, instance, aslist=False, **kwargs):
        objects = []
        rc = getToolByName(instance, REFERENCE_CATALOG)
        uids = ObjectField.get(self, instance, **kwargs)

        if uids is None:
            uids = []

        for uid in uids:
            if uid:
                objects.append(rc.lookupObject(uid))

        if objects:
            if not self.multiValued:
                return objects[0]
            else:
                return objects

        return []
Beispiel #10
0
 def getRaw(self, instance, **kwargs):
     dtml = ObjectField.get(self, instance, **kwargs)
     if getattr(dtml, 'read', _marker) is not _marker:
         return dtml.read()
     else:
         return dtml
Beispiel #11
0
 def get(self, instance, **kwargs):
     dtml = ObjectField.get(self, instance, **kwargs)
     if not kwargs.has_key('client'):
         kwargs['client'] = instance
     value = dtml(**kwargs)
     return value
Beispiel #12
0
 def getRaw(self, instance, **kwargs):
     zpt = ObjectField.get(self, instance, **kwargs)
     if getattr(zpt, 'read', _marker) is not _marker:
         return zpt.read()
     else:
         return zpt
Beispiel #13
0
 def get(self, instance, **kwargs):
     script = ObjectField.get(self, instance, **kwargs)
     return script(**kwargs)
Beispiel #14
0
 def get(self, instance, **kwargs):
     zpt = ObjectField.get(self, instance, **kwargs)
     return zpt.pt_render(extra_context={'options': kwargs})
Beispiel #15
0
 def getRaw(self, instance, **kwargs):
     dtml = ObjectField.get(self, instance, **kwargs)
     return dtml.read()
Beispiel #16
0
 def getRaw(self, instance, **kwargs):
     zpt = ObjectField.get(self, instance, **kwargs)
     return zpt.read()