def __init__(self, Mapped, QEntity=None, **mapping): ''' Construct the entity support for the provided model class and query class. @param Mapped: class The mapped entity model class. @param QEntity: class|None The query mapped class if there is one. @param mapping: key arguments of columns The column mappings provided for criteria name in case they are needed, this is only used if a QEntity is provided. ''' assert isclass(Mapped), 'Invalid class %s' % Mapped assert isinstance(Mapped, MappedSupport), 'Invalid mapped class %s' % Mapped model = typeFor(Mapped) assert isinstance(model, TypeModel), 'Invalid model class %s' % Mapped assert isinstance(model.propertyId, TypeProperty), 'Invalid model property id %s' % model.propertyId self.Entity = model.clazz self.Mapped = Mapped self.MappedId = modelId(Mapped) if QEntity is not None: assert isclass(QEntity), 'Invalid class %s' % QEntity assert isinstance(typeFor(QEntity), TypeQuery), 'Invalid query entity class %s' % QEntity if __debug__: for name in mapping: assert name in typeFor(QEntity).properties, 'Invalid criteria name \'%s\' for %s' % (name, QEntity) self._mapping = mapping else: assert not mapping, 'Illegal mappings %s with no QEntity provided' % mapping self.QEntity = QEntity
def __init__(self, Acl, AclAccess, Compensate, signatures=None): ''' Construct the compensate service alchemy. @param AclAccess: class of WithAclAccess The ACL access relation mapped class. @param Compensate: class of WithCompensate The compensate relation mapped class. @param signatures: dictionary{string: string|callable(identifier) -> string} A dictionary containing as keys the signatures that will be injected and as a value either the marker to be injected or a callable that takes the identifier as a parameter and provides the marker string value. ''' assert isinstance(Acl, MappedSupport), 'Invalid mapped class %s' % Acl assert issubclass(AclAccess, WithAclAccess), 'Invalid acl access class %s' % AclAccess assert issubclass(Compensate, WithCompensate), 'Invalid compensate class %s' % Compensate if __debug__: if signatures is not None: assert isinstance(signatures, dict), 'Invalid fill in signatures %s' % signatures for signature, marker in signatures.items(): assert isinstance(signature, str), 'Invalid signature %s' % signature assert isinstance(marker, str) or callable(marker), 'Invalid marker %s' % marker self.Acl = Acl self.AclIdentifier = modelId(Acl) self.AclAccess = AclAccess self.AliasAclAccess = aliased(AclAccess) self.Compensate = Compensate self.signatures = signatures
def __init__(self, Rbac): ''' Construct the RBAC service alchemy. @param Rbac: Base class The Rbac mapped class that organizes the RBAC structure. ''' assert isinstance(Rbac, MappedSupport), 'Invalid mapped class %s' % Rbac assert issubclass(Rbac, WithRbac), 'Invalid Rbac class %s' % Rbac self.Rbac = Rbac self.RbacIdentifier = modelId(Rbac)
def __init__(self, Rbac): ''' Construct the RBAC service alchemy. @param Rbac: Base class The Rbac mapped class that organizes the RBAC structure. ''' assert isinstance(Rbac, MappedSupport), 'Invalid mapped class %s' % Rbac assert issubclass(Rbac, WithRbac), 'Invalid Rbac class %s' % Rbac self.Rbac = Rbac self.RbacIdentifier = modelId(Rbac)
def __init__(self, Category, CategoryAction): ''' Construct the action category service alchemy. @param Category: Base class The category mapped class that organizes the actions based on. @param CategoryAction: class of WithCategoryAction The action category relation mapped class. ''' assert isinstance(Category, MappedSupport), 'Invalid mapped class %s' % Category assert issubclass(CategoryAction, WithCategoryAction), 'Invalid category action class %s' % CategoryAction pks = [pk for pk in mappingFor(Category).columns if pk.primary_key] assert pks, 'Cannot detect any primary key for %s' % Category assert not len(pks) > 1, 'To many primary keys %s for %s' % (pks, Category) self.Category = Category self.CategoryId = pks[0] self.CategoryIdentifier = modelId(Category) self.CategoryAction = CategoryAction
def __init__(self, Acl, AclAccess): ''' Construct the ACL service alchemy. @param Acl: Base class The ACL mapped class that organizes the ACL structure. @param AclAccess: class of WithAclAccess The ACL access relation mapped class. ''' assert isinstance(Acl, MappedSupport), 'Invalid mapped class %s' % Acl assert issubclass(AclAccess, WithAclAccess), 'Invalid acl access class %s' % AclAccess pks = [pk for pk in mappingFor(Acl).columns if pk.primary_key] assert pks, 'Cannot detect any primary key for %s' % Acl assert not len(pks) > 1, 'To many primary keys %s for %s' % (pks, Acl) self.Acl = Acl self.AclId = pks[0] self.AclIdentifier = modelId(Acl) self.AclAccess = AclAccess self.EntryFilter = AclAccess.EntryFilter self.PropertyFilter = AclAccess.PropertyFilter
def __init__(self, Mapped, QEntity=None, **mapping): ''' Construct the entity support for the provided model class and query class. @param Mapped: class The mapped entity model class. @param QEntity: class|None The query mapped class if there is one. @param mapping: key arguments of columns The column mappings provided for criteria name in case they are needed, this is only used if a QEntity is provided. ''' assert isclass(Mapped), 'Invalid class %s' % Mapped assert isinstance(Mapped, MappedSupport), 'Invalid mapped class %s' % Mapped model = typeFor(Mapped) assert isinstance(model, TypeModel), 'Invalid model class %s' % Mapped assert isinstance( model.propertyId, TypeProperty), 'Invalid model property id %s' % model.propertyId self.Entity = model.clazz self.Mapped = Mapped self.MappedId = modelId(Mapped) if QEntity is not None: assert isclass(QEntity), 'Invalid class %s' % QEntity assert isinstance( typeFor(QEntity), TypeQuery), 'Invalid query entity class %s' % QEntity if __debug__: for name in mapping: assert name in typeFor( QEntity ).properties, 'Invalid criteria name \'%s\' for %s' % ( name, QEntity) self._mapping = mapping else: assert not mapping, 'Illegal mappings %s with no QEntity provided' % mapping self.QEntity = QEntity
def __init__(self, Acl, AclAccess, Compensate, signatures=None): ''' Construct the compensate service alchemy. @param AclAccess: class of WithAclAccess The ACL access relation mapped class. @param Compensate: class of WithCompensate The compensate relation mapped class. @param signatures: dictionary{string: string|callable(identifier) -> string} A dictionary containing as keys the signatures that will be injected and as a value either the marker to be injected or a callable that takes the identifier as a parameter and provides the marker string value. ''' assert isinstance(Acl, MappedSupport), 'Invalid mapped class %s' % Acl assert issubclass( AclAccess, WithAclAccess), 'Invalid acl access class %s' % AclAccess assert issubclass( Compensate, WithCompensate), 'Invalid compensate class %s' % Compensate if __debug__: if signatures is not None: assert isinstance( signatures, dict), 'Invalid fill in signatures %s' % signatures for signature, marker in signatures.items(): assert isinstance(signature, str), 'Invalid signature %s' % signature assert isinstance( marker, str) or callable(marker), 'Invalid marker %s' % marker self.Acl = Acl self.AclIdentifier = modelId(Acl) self.AclAccess = AclAccess self.AliasAclAccess = aliased(AclAccess) self.Compensate = Compensate self.signatures = signatures
def __init__(self, Acl, AclAccess): ''' Construct the ACL service alchemy. @param Acl: Base class The ACL mapped class that organizes the ACL structure. @param AclAccess: class of WithAclAccess The ACL access relation mapped class. ''' assert isinstance(Acl, MappedSupport), 'Invalid mapped class %s' % Acl assert issubclass( AclAccess, WithAclAccess), 'Invalid acl access class %s' % AclAccess pks = [pk for pk in mappingFor(Acl).columns if pk.primary_key] assert pks, 'Cannot detect any primary key for %s' % Acl assert not len(pks) > 1, 'To many primary keys %s for %s' % (pks, Acl) self.Acl = Acl self.AclId = pks[0] self.AclIdentifier = modelId(Acl) self.AclAccess = AclAccess self.EntryFilter = AclAccess.EntryFilter self.PropertyFilter = AclAccess.PropertyFilter
def remRole(self, identifier:lambda p:modelId(p.RBAC), roleName:Role.Name) -> bool: '''
def insert(self, entity): ''' @see: IEntityCRUDPrototype.insert ''' return modelId(insertModel(self.Mapped, entity))
def addRight(self, identifier:lambda p:modelId(p.RBAC), rightId:Right.Id): '''
def insert(self, entity:lambda p:p.Entity) -> lambda p:modelId(p.Entity): '''
def getAll(self, q:lambda p:p.QEntity=None, **options:SliceAndTotal) -> lambda p:Iter(modelId(p.Entity)): '''
def getAcls(self, accessId:Access, **options:SliceAndTotal) -> lambda p: Iter(modelId(p.ACL)): '''
def addPropertyFilter(self, identifier:lambda p: modelId(p.ACL), accessId:Access.Id, propertyName:Property, filterName:Filter.Name): '''
def addAcl(self, identifier:lambda p: modelId(p.ACL), accessId:Access.Id): '''
def addAcl(self, identifier: lambda p: modelId(p.ACL), accessId: Access.Id): '''
def remRight(self, identifier:lambda p:modelId(p.RBAC), rightId:Right.Id) -> bool: '''
def remCompensate(self, identifier:lambda p: modelId(p.ACL), accessId:Access.Id, compensatedId:Access.Id) -> bool: '''
def addCompensate(self, identifier:lambda p: modelId(p.ACL), accessId:Access.Id, compensatedId:Access.Id): '''
def addRole(self, identifier:lambda p:modelId(p.RBAC), roleName:Role.Name): '''
def addEntryFilter(self, identifier: lambda p: modelId(p.ACL), accessId: Access.Id, entryPosition: Entry.Position, filterName: Filter.Name): '''
def insert(self, entity): ''' @see: IEntityCRUDPrototype.insert ''' return modelId(insertModel(self.Mapped, entity))
def addEntryFilter(self, identifier:lambda p: modelId(p.ACL), accessId:Access.Id, entryPosition:Entry.Position, filterName:Filter.Name): '''
def addPropertyFilter(self, identifier: lambda p: modelId(p.ACL), accessId: Access.Id, propertyName: Property, filterName: Filter.Name): '''
def registerFilter(self, identifier:lambda p: modelId(p.ACL), accessId:Access.Id, filterName:Filter.Name, place:str=None) -> bool: '''
def registerFilter(self, identifier: lambda p: modelId(p.ACL), accessId: Access.Id, filterName: Filter.Name, place: str = None) -> bool: '''
def addAction(self, identifier:lambda p: modelId(p.CATEGORY), actionPath:Action.Path): '''
def getAcls(self, accessId: Access, **options: SliceAndTotal) -> lambda p: Iter(modelId(p.ACL)): '''