320 self.schema.del_relation_def(self.type, 'has_text', 'String') |
320 self.schema.del_relation_def(self.type, 'has_text', 'String') |
321 |
321 |
322 def schema_entity(self): |
322 def schema_entity(self): |
323 """return True if this entity type is used to build the schema""" |
323 """return True if this entity type is used to build the schema""" |
324 return self.type in self.schema.schema_entity_types() |
324 return self.type in self.schema.schema_entity_types() |
325 |
325 |
326 def has_format(self, attr): |
|
327 """return true if this entity's schema has a format field for the given |
|
328 attribute |
|
329 """ |
|
330 return self.has_subject_relation('%s_format' % attr) |
|
331 |
|
332 def has_format(self, attr): |
|
333 """return true if this entity's schema has an encoding field for the given |
|
334 attribute |
|
335 """ |
|
336 return self.has_subject_relation('%s_format' % attr) |
|
337 |
|
338 def rich_text_fields(self): |
|
339 """return an iterator on (attribute, format attribute) of rich text field |
|
340 |
|
341 (the first tuple element containing the text and the second the text format) |
|
342 """ |
|
343 for rschema, _ in self.attribute_definitions(): |
|
344 if rschema.type.endswith('_format') and self.has_subject_relation(rschema.type[:-7]): |
|
345 yield self.subject_relation(rschema.type[:-7]), rschema |
|
346 |
|
347 def check_perm(self, session, action, eid=None): |
326 def check_perm(self, session, action, eid=None): |
348 # NB: session may be a server session or a request object |
327 # NB: session may be a server session or a request object |
349 user = session.user |
328 user = session.user |
350 # check user is in an allowed group, if so that's enough |
329 # check user is in an allowed group, if so that's enough |
351 # internal sessions should always stop there |
330 # internal sessions should always stop there |