schema.py
branchtls-sprint
changeset 1045 5040a5835e4d
parent 1034 0356bbfb2f26
child 1090 a99dc223c583
equal deleted inserted replaced
1044:3672a7c86784 1045:5040a5835e4d
   966                        _('text/html'),
   966                        _('text/html'),
   967                        _('text/plain'),
   967                        _('text/plain'),
   968                        )
   968                        )
   969     def __init__(self):
   969     def __init__(self):
   970         pass
   970         pass
       
   971     
   971     def serialize(self):
   972     def serialize(self):
   972         """called to make persistent valuable data of a constraint"""
   973         """called to make persistent valuable data of a constraint"""
   973         return None
   974         return None
   974 
   975 
   975     @classmethod
   976     @classmethod
   977         """called to restore serialized data of a constraint. Should return
   978         """called to restore serialized data of a constraint. Should return
   978         a `cls` instance
   979         a `cls` instance
   979         """
   980         """
   980         return cls()
   981         return cls()
   981     
   982     
   982     def vocabulary(self, entity=None):
   983     def vocabulary(self, entity=None, req=None):
   983         if entity and entity.req.user.has_permission(PERM_USE_TEMPLATE_FORMAT):
   984         if req is None and entity is not None:
       
   985             req = entity.req
       
   986         if req is not None and req.user.has_permission(PERM_USE_TEMPLATE_FORMAT):
   984             return self.regular_formats + tuple(self.need_perm_formats)
   987             return self.regular_formats + tuple(self.need_perm_formats)
   985         return self.regular_formats
   988         return self.regular_formats
   986     
   989     
   987     def __str__(self):
   990     def __str__(self):
   988         return 'value in (%s)' % u', '.join(repr(unicode(word)) for word in self.vocabulary())
   991         return 'value in (%s)' % u', '.join(repr(unicode(word)) for word in self.vocabulary())