Beispiel #1
0
 def recordify(self, obj):
     """ Turns an obj into a record tuple """
     record = []
     # the unique id is always the first element
     for name in self.names:
         if name.startswith("PlominoViewColumn_"):
             marker, viewname, columnname = name.split('_')
             if not obj.isSelectedInView(viewname):
                 v = None
             else:
                 v = asUnicode(
                         obj.computeColumnValue(viewname, columnname))
             record.append(v)
         else:
             attr = getattr(obj, name, MV)
             if attr is not MV and safe_callable(attr):
                 attr = attr()
             if isinstance(attr, str):
                 attr = attr.decode('utf-8')
             elif isinstance(attr, (list, tuple)):
                 new_value = []
                 for v in attr:
                     if isinstance(v, str):
                         v = v.decode('utf-8')
                     new_value.append(v)
                 attr = new_value
             record.append(attr)
     return tuple(record)
Beispiel #2
0
 def recordify(self, obj):
     """ Turns an obj into a record tuple """
     record = []
     # the unique id is always the first element
     for name in self.names:
         if name.startswith("PlominoViewColumn_"):
             marker, viewname, columnname = name.split('_')
             if not obj.isSelectedInView(viewname):
                 v = None
             else:
                 v = asUnicode(obj.computeColumnValue(viewname, columnname))
             record.append(v)
         else:
             attr = getattr(obj, name, MV)
             if attr is not MV and safe_callable(attr):
                 attr = attr()
             if isinstance(attr, str):
                 attr = attr.decode('utf-8')
             elif isinstance(attr, (list, tuple)):
                 new_value = []
                 for v in attr:
                     if isinstance(v, str):
                         v = v.decode('utf-8')
                     new_value.append(v)
                 attr = new_value
             record.append(attr)
     return tuple(record)
Beispiel #3
0
 def recordify(self, object):
     """ turns an object into a record tuple """
     record = []
     # the unique id is always the first element
     for x in self.names:
         if x.startswith("PlominoViewColumn_"):
             param = x.split('_')
             viewname = param[1]
             columnname = param[2]
             if not object.isSelectedInView(viewname):
                 v = None
             else:
                 v = asUnicode(
                     object.computeColumnValue(viewname, columnname))
             record.append(v)
         else:
             attr = getattr(object, x, MV)
             if attr is not MV and safe_callable(attr):
                 attr = attr()
             if type(attr) == type(''):
                 attr = attr.decode('utf-8')
             elif type(attr) == type([]) or type(attr) == type(()):
                 new_value = []
                 for v in attr:
                     if type(v) == type(''):
                         v = v.decode('utf-8')
                     new_value.append(v)
                 attr = new_value
             record.append(attr)
     return tuple(record)
Beispiel #4
0
 def recordify(self, object):
     """ turns an object into a record tuple """
     record = []
     # the unique id is allways the first element
     for x in self.names:
         attr=getattr(object, x, MV)
         if(attr is not MV and safe_callable(attr)): attr=attr()
         record.append(attr)
     return tuple(record)
Beispiel #5
0
 def recordify(self, object):
     """ turns an object into a record tuple """
     record = []
     # the unique id is allways the first element
     for x in self.names:
         attr = getattr(object, x, MV)
         if (attr is not MV and safe_callable(attr)): attr = attr()
         record.append(attr)
     return tuple(record)
Beispiel #6
0
def render(self, v):
    "Render an object in the way done by the 'name' attribute"
    if hasattr(v, '__render_with_namespace__'):
        v = v.__render_with_namespace__(self)
    else:
        vbase = getattr(v, 'aq_base', v)
        if safe_callable(vbase):
            if getattr(vbase, 'isDocTemp', 0):
                v = v(None, self)
            else:
                v = v()
    return v
    def Value(self, **kw):
        catalog = getToolByName(self, 'portal_catalog')
        context = ICriteriaContext(self)
        wrapper = component.queryMultiAdapter(
            (context, catalog), IIndexableObject)
        if wrapper is None:
            wrapper = context

        value = getattr(wrapper, self.Field())
        if safe_callable(value):
            value = value()
        return value
Beispiel #8
0
def render(self, v):
    "Render an object in the way done by the 'name' attribute"
    if hasattr(v, '__render_with_namespace__'):
        v = v.__render_with_namespace__(self)
    else:
        vbase = getattr(v, 'aq_base', v)
        if safe_callable(vbase):
            if getattr(vbase, 'isDocTemp', 0):
                v = v(None, self)
            else:
                v = v()
    return v