コード例 #1
0
ファイル: page.py プロジェクト: tonibagur/appy
    def isShowable(self, obj, layoutType, elem='page'):
        '''Is this page showable for p_obj on p_layoutType ("view" or "edit")?

           If p_elem is not "page", this method returns the fact that a
           sub-element is viewable or not (buttons "save", "cancel", etc).'''
        # Define what attribute to test for "showability".
        attr = (elem == 'page') and 'show' or ('show%s' % elem.capitalize())
        # Get the value of the "show" attribute as identified above
        res = getattr(self, attr)
        if callable(res):
            res = gutils.callMethod(obj.appy(), res)
        if isinstance(res, str): return res == layoutType
        return res
コード例 #2
0
 def callMethod(self, obj, method, cache=True):
     '''This method is used to call a p_method on p_obj. p_method is part of
        this type definition (ie a default method, the method of a Computed
        field, a method used for showing or not a field...). Normally, those
        methods are called without any arg. But one may need, within the
        method, to access the related field. This method tries to call
        p_method with no arg *or* with the field arg.'''
     obj = obj.appy()
     try:
         return gutils.callMethod(obj, method, cache=cache)
     except TypeError, te:
         # Try a version of the method that would accept self as an
         # additional parameter. In this case, we do not try to cache the
         # value (we do not call gutils.callMethod), because the value may
         # be different depending on the parameter.
         tb = sutils.Traceback.get()
         try:
             return method(obj, self)
         except (Exception, e):
             obj.log(tb, type='error')
             # Raise the initial error.
             raise te
コード例 #3
0
ファイル: __init__.py プロジェクト: Alejoss/django-sis
 def callMethod(self, obj, method, cache=True):
     '''This method is used to call a p_method on p_obj. p_method is part of
        this type definition (ie a default method, the method of a Computed
        field, a method used for showing or not a field...). Normally, those
        methods are called without any arg. But one may need, within the
        method, to access the related field. This method tries to call
        p_method with no arg *or* with the field arg.'''
     obj = obj.appy()
     try:
         return gutils.callMethod(obj, method, cache=cache)
     except TypeError, te:
         # Try a version of the method that would accept self as an
         # additional parameter. In this case, we do not try to cache the
         # value (we do not call gutils.callMethod), because the value may
         # be different depending on the parameter.
         tb = sutils.Traceback.get()
         try:
             return method(obj, self)
         except Exception, e:
             obj.log(tb, type='error')
             # Raise the initial error.
             raise te
コード例 #4
0
ファイル: search.py プロジェクト: santosh02/school
 def isShowable(self, klass, tool):
     '''Is this Search instance (defined in p_klass) showable?'''
     if self.show.__class__.__name__ == 'staticmethod':
         return gutils.callMethod(tool, self.show, klass=klass)
     return self.show