[gen] Added attributes 'created' and 'modified', now accessible on Appy wrappers; added method AbstractWrapper.countRef that allows to count the number of objects tied to a given object via a Ref field whose name is given as method param.
This commit is contained in:
parent
1b3af98305
commit
0d0d7c1123
|
@ -104,6 +104,8 @@ class AbstractWrapper(object):
|
|||
elif name == 'id': return self.o.id
|
||||
elif name == 'uid': return self.o.UID()
|
||||
elif name == 'klass': return self.__class__.__bases__[-1]
|
||||
elif name == 'created': return self.o.created
|
||||
elif name == 'modified': return self.o.modified
|
||||
elif name == 'url': return self.o.absolute_url()
|
||||
elif name == 'state': return self.o.State()
|
||||
elif name == 'stateLabel':
|
||||
|
@ -344,6 +346,13 @@ class AbstractWrapper(object):
|
|||
if res: return res._len # It is a LazyMap instance
|
||||
else: return 0
|
||||
|
||||
def countRefs(self, fieldName):
|
||||
'''Counts the number of objects linked to this one via Ref field
|
||||
p_fieldName.'''
|
||||
uids = getattr(self.o.aq_base, fieldName, None)
|
||||
if not uids: return 0
|
||||
return len(uids)
|
||||
|
||||
def compute(self, klass, sortBy='', maxResults=None, context=None,
|
||||
expression=None, noSecurity=False, **fields):
|
||||
'''This method, like m_search and m_count above, performs a query on
|
||||
|
|
Loading…
Reference in a new issue