Exemplo n.º 1
0
 def __init__(self, category, context):
     self.category = category
     self.context = context
     self.storage = self._lookup_or_create_storage()
     # We dynamically provide all the rating methods
     # of our underlying storage
     rating_type = queryType(self.storage, IRatingType)
     alsoProvides(self, rating_type)
Exemplo n.º 2
0
 def __init__(self, category, context):
     self.category = category
     self.context = context
     self.storage = self._lookup_or_create_storage()
     # We dynamically provide all the rating methods
     # of our underlying storage
     rating_type = queryType(self.storage, IRatingType)
     alsoProvides(self, rating_type)
Exemplo n.º 3
0
 def __getattr__(self, name):
     """If name is part of our storage interface, return the
     attribute from the storage, checking the read_expr first.
     """
     rating_type = queryType(self, IRatingType)
     # make sure it works even if the rating type isn't set yet
     if rating_type and name in rating_type.names(True):
         assert self.can_read
         return getattr(self.storage, name)
     else:
         raise AttributeError(name)
Exemplo n.º 4
0
 def __getattr__(self, name):
     """If name is part of our storage interface, return the
     attribute from the storage, checking the read_expr first.
     """
     rating_type = queryType(self, IRatingType)
     # make sure it works even if the rating type isn't set yet
     if rating_type and name in rating_type.names(True):
         assert self.can_read
         return getattr(self.storage, name)
     else:
         raise AttributeError(name)
Exemplo n.º 5
0
 def __setattr__(self, name, value):
     """If name is part of our storage interface, set the
     attribute from the storage, checking the write_expr first.
     """
     rating_type = queryType(self, IRatingType)
     # make sure it works even if the rating type isn't set yet
     if rating_type and name in rating_type.names(True):
         assert self.can_write
         # special handling for the "rating" atribute from
         # EditorialRatingStorage
         if name =='rating':
             self._rating_set(value)
         else:
             setattr(self.storage, name, value)
     else:
         super(RatingCategoryAdapter, self).__setattr__(name, value)
Exemplo n.º 6
0
 def __setattr__(self, name, value):
     """If name is part of our storage interface, set the
     attribute from the storage, checking the write_expr first.
     """
     rating_type = queryType(self, IRatingType)
     # make sure it works even if the rating type isn't set yet
     if rating_type and name in rating_type.names(True):
         assert self.can_write
         # special handling for the "rating" atribute from
         # EditorialRatingStorage
         if name == 'rating':
             self._rating_set(value)
         else:
             setattr(self.storage, name, value)
     else:
         super(RatingCategoryAdapter, self).__setattr__(name, value)
Exemplo n.º 7
0
 def __getattr__(self, name):
     """If name is part of our storage interface, return the
     attribute from the storage, checking the read_expr first.
     """
     # But be sure not to interfere with the standard attributes that
     # interfaces themselves want; our next `queryType` call depends
     # on them.
     if name == '__provides__':
         # This is only an issue in the Python implementation of zope.interface;
         # without this check, we'd get infinite recursion. We *probably*
         # actually get infinite recursion in the C implementation,
         # it just ignores the problem.
         return super(RatingCategoryAdapter, self).__getattr__(name)
     rating_type = queryType(self, IRatingType)
     # make sure it works even if the rating type isn't set yet
     if rating_type and name in rating_type.names(True):
         assert self.can_read
         return getattr(self.storage, name)
     else:
         raise AttributeError(name)
Exemplo n.º 8
0
Arquivo: layout.py Projeto: bcgsc/gum
 def get_type_info(self):
     type_interface = queryType(self.context, IContentType)
     if not type_interface:
         return None
     return {'typename' : type_interface.getTaggedValue('typename'),
             'actions' : type_interface.getTaggedValue('actions') }