[gen] More methods on AbstractWrapper.
This commit is contained in:
parent
1d0ee7a614
commit
b83f6d512d
|
@ -1022,12 +1022,18 @@ class Ref(Field):
|
|||
res = refObject.tool.o.truncateValue(res, maxWidth)
|
||||
return res
|
||||
|
||||
def getIndexOf(self, obj, tiedUid):
|
||||
def getIndexOf(self, obj, tiedUid, raiseError=True):
|
||||
'''Gets the position of tied object identified by p_tiedUid within this
|
||||
field on p_obj.'''
|
||||
uids = getattr(obj.aq_base, self.name, None)
|
||||
if not uids: raise IndexError()
|
||||
return uids.index(tiedUid)
|
||||
if not uids:
|
||||
if raiseError: raise IndexError()
|
||||
else: return
|
||||
if tiedUid in uids:
|
||||
return uids.index(tiedUid)
|
||||
else:
|
||||
if raiseError: raise IndexError()
|
||||
else: return
|
||||
|
||||
def sort(self, obj):
|
||||
'''Called when the user wants to sort the content of this field.'''
|
||||
|
|
|
@ -1083,4 +1083,14 @@ class AbstractWrapper(object):
|
|||
p_name.'''
|
||||
v = getattr(self, name)
|
||||
if v: return v.getFilePath(self)
|
||||
|
||||
def getIndexOf(self, name, obj):
|
||||
'''Returns, as an integer starting at 0, the position of p_obj within
|
||||
objects linked to p_self via field p_name.'''
|
||||
o = self.o
|
||||
return o.getAppyType(name).getIndexOf(o, obj.uid)
|
||||
|
||||
def allows(self, permission, raiseError=False):
|
||||
'''Check doc @Mixin.allows.'''
|
||||
return self.o.allows(permission, raiseError=raiseError)
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue