Exemplo n.º 1
0
 def _create_sheet(self, meta: SheetMetadata,
                   context: object,
                   request: Request,
                   creating: ResourceMetadata=None) -> IResourceSheet:
     sheet = meta.sheet_class(meta, context, self.registry,
                              request=request,
                              creating=creating,
                              )
     return sheet
Exemplo n.º 2
0
 def __init__(self, meta: SheetMetadata,
              context: IResourceSheet,
              registry: Registry,
              request: IRequest=None,
              creating: ResourceMetadata=None):
     self.meta = meta
     self.context = context
     self.registry = registry
     self.request = request
     self.creating = creating
     self.schema = meta.schema_class()
     self.extra_js_url = ''  # used for html forms :mod:`adhocracy_core.sdi`
Exemplo n.º 3
0
 def __init__(self, meta: SheetMetadata,
              context: IResourceSheet,
              registry: Registry,
              request: IRequest=None,
              creating: ResourceMetadata=None):
     self.meta = meta
     self.context = context
     self.registry = registry
     self.request = request
     self.creating = creating
     self.schema = meta.schema_class()
     self.extra_js_url = ''  # used for html forms :mod:`adhocracy_core.sdi`
Exemplo n.º 4
0
 def _create_sheet(self,
                   meta: SheetMetadata,
                   context: object,
                   request: Request,
                   creating: ResourceMetadata = None) -> IResourceSheet:
     sheet = meta.sheet_class(
         meta,
         context,
         self.registry,
         request=request,
         creating=creating,
     )
     return sheet
Exemplo n.º 5
0
def add_sheet_to_registry(metadata: SheetMetadata, registry: Registry):
    """Register sheet adapter and metadata to registry.

    There registry should have an `content` attribute with
    :class:`adhocracy_core.registry.ResourceRegistry` to store the metadata.
    """
    assert metadata.isheet.isOrExtends(ISheet)
    isheet = metadata.isheet
    if metadata.create_mandatory:
        assert metadata.creatable and metadata.create_mandatory
    schema = metadata.schema_class()
    for child in schema.children:
        assert child.default != colander.null
        assert child.default != colander.drop
    assert issubclass(schema.__class__, colander.MappingSchema)
    _assert_schema_preserves_super_type_data_structure(schema)
    registry.content.sheets_meta[isheet] = metadata
Exemplo n.º 6
0
def add_sheet_to_registry(metadata: SheetMetadata, registry: Registry):
    """Register sheet adapter and metadata to registry.

    There registry should have an `content` attribute with
    :class:`adhocracy_core.registry.ResourceRegistry` to store the metadata.
    """
    assert metadata.isheet.isOrExtends(ISheet)
    isheet = metadata.isheet
    if metadata.create_mandatory:
        assert metadata.creatable and metadata.create_mandatory
    schema = metadata.schema_class()
    for child in schema.children:
        assert child.default != colander.null
        assert child.default != colander.drop
    assert issubclass(schema.__class__, colander.MappingSchema)
    _assert_schema_preserves_super_type_data_structure(schema)
    registry.content.sheets_meta[isheet] = metadata
Exemplo n.º 7
0
            if key in appstruct:
                setattr(self.context, key, appstruct[key])

    def delete_field_values(self, fields: [str]):
        """Delete value for every field name in `fields`."""
        for key in fields:
            if hasattr(self.context, key):
                delattr(self.context, key)


sheet_meta = SheetMetadata(
    isheet=ISheet,
    sheet_class=AnnotationRessourceSheet,
    schema_class=colander.MappingSchema,
    permission_view='view',
    permission_edit='edit',
    permission_create='create',
    readable=True,
    editable=True,
    creatable=True,
    create_mandatory=False,
)


def add_sheet_to_registry(metadata: SheetMetadata, registry: Registry):
    """Register sheet adapter and metadata to registry.

    There registry should have an `content` attribute with
    :class:`adhocracy_core.registry.ResourceRegistry` to store the metadata.
    """
    assert metadata.isheet.isOrExtends(ISheet)
    isheet = metadata.isheet