diff -r fbfab570a276 -r 1cba3393ba01 schemas/base.py --- a/schemas/base.py Mon Jun 22 14:20:46 2009 +0200 +++ b/schemas/base.py Tue Jun 23 13:31:16 2009 +0200 @@ -6,11 +6,15 @@ :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses """ __docformat__ = "restructuredtext en" +_ = unicode +from yams.buildobjs import (EntityType, RelationType, SubjectRelation, + String, Boolean, Datetime) +from cubicweb.schema import RQLConstraint +from cubicweb.schemas import META_ETYPE_PERMS, META_RTYPE_PERMS class CWUser(WorkflowableEntityType): """define a CubicWeb user""" - meta = True # XXX backported from old times, shouldn't be there anymore permissions = { 'read': ('managers', 'users', ERQLExpression('X identity U')), 'add': ('managers',), @@ -35,7 +39,7 @@ description=_('groups grant permissions to the user')) -class EmailAddress(MetaEntityType): +class EmailAddress(EntityType): """an electronic mail address associated to a short alias""" permissions = { 'read': ('managers', 'users', 'guests',), # XXX if P use_email X, U has_read_permission P @@ -81,11 +85,11 @@ 'delete': ('managers', RRQLExpression('U has_update_permission S'),), } -class in_group(MetaRelationType): +class in_group(RelationType): """core relation indicating a user's groups""" - meta = False + permissions = META_RTYPE_PERMS -class owned_by(MetaRelationType): +class owned_by(RelationType): """core relation indicating owners of an entity. This relation implicitly put the owner into the owners group for the entity """ @@ -100,7 +104,7 @@ subject = '**' object = 'CWUser' -class created_by(MetaRelationType): +class created_by(RelationType): """core relation indicating the original creator of an entity""" permissions = { 'read': ('managers', 'users', 'guests'), @@ -114,13 +118,13 @@ object = 'CWUser' -class creation_date(MetaAttributeRelationType): +class creation_date(RelationType): """creation time of an entity""" cardinality = '11' subject = '**' object = 'Datetime' -class modification_date(MetaAttributeRelationType): +class modification_date(RelationType): """latest modification time of an entity""" cardinality = '11' subject = '**' @@ -137,7 +141,6 @@ 'update': ('managers', 'owners',), 'delete': ('managers', 'owners',), } - meta = True # key is a reserved word for mysql pkey = String(required=True, internationalizable=True, maxsize=256, description=_('defines what\'s the property is applied for. ' @@ -152,7 +155,7 @@ ' a global property')) -class for_user(MetaRelationType): +class for_user(RelationType): """link a property to the user which want this property customization. Unless you're a site manager, this relation will be handled automatically. """ @@ -164,9 +167,11 @@ inlined = True -class CWPermission(MetaEntityType): +class CWPermission(EntityType): """entity type that may be used to construct some advanced security configuration """ + permissions = META_ETYPE_PERMS + name = String(required=True, indexed=True, internationalizable=True, maxsize=100, description=_('name or identifier of the permission')) label = String(required=True, internationalizable=True, maxsize=100, @@ -186,7 +191,7 @@ 'delete': ('managers',), } -class require_group(MetaRelationType): +class require_group(RelationType): """used to grant a permission to a group""" permissions = { 'read': ('managers', 'users', 'guests'), @@ -200,7 +205,7 @@ symetric = True -class CWCache(MetaEntityType): +class CWCache(EntityType): """a simple cache entity characterized by a name and a validity date. @@ -212,7 +217,7 @@ permissions = { 'read': ('managers', 'users', 'guests'), 'add': ('managers',), - 'update': ('managers', 'users',), + 'update': ('managers', 'users',), # XXX 'delete': ('managers',), }