Added method Wrapper.isEmpty(name) that checks if the content of some field is empty or not on a given object.

This commit is contained in:
Gaetan Delannay 2012-06-13 09:31:09 +02:00
parent 5b255ce55d
commit e13575c506
4 changed files with 10 additions and 1 deletions

View file

@ -178,7 +178,8 @@ class Group(ModelClass):
roles = gen.String(validator=gen.Selection('getGrantableRoles'), roles = gen.String(validator=gen.Selection('getGrantableRoles'),
multiplicity=(0,None), **m) multiplicity=(0,None), **m)
users = gen.Ref(User, multiplicity=(0,None), add=False, link=True, users = gen.Ref(User, multiplicity=(0,None), add=False, link=True,
back=gen.Ref(attribute='groups', show=User.showRoles), back=gen.Ref(attribute='groups', show=User.showRoles,
multiplicity=(0,None)),
showHeaders=True, shownInfo=('title', 'login')) showHeaders=True, shownInfo=('title', 'login'))
# The Translation class -------------------------------------------------------- # The Translation class --------------------------------------------------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 818 B

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 754 B

After

Width:  |  Height:  |  Size: 784 B

View file

@ -125,6 +125,14 @@ class AbstractWrapper(object):
return customUser.__dict__[methodName](self, *args, **kwargs) return customUser.__dict__[methodName](self, *args, **kwargs)
def getField(self, name): return self.o.getAppyType(name) def getField(self, name): return self.o.getAppyType(name)
def isEmpty(self, name):
'''Returns True if value of field p_name is considered as being
empty.'''
obj = self.o
if hasattr(obj.aq_base, name):
field = obj.getAppyType(name)
return field.isEmptyValue(getattr(obj, name))
return True
def link(self, fieldName, obj): def link(self, fieldName, obj):
'''This method links p_obj (which can be a list of objects) to this one '''This method links p_obj (which can be a list of objects) to this one