adhocracy_core.interfaces module¶
Interfaces for plugable dependencies, basic metadata structures.
-
namedtuple(typename, field_names, verbose=False, rename=False)[source]¶ Like collections.namedtuple but with more functionalities.
Provide an _add method which concatenate elements to the value identified by the key.
-
class
Dimensions(width, height)¶ Bases:
tupleDimensions of a two-dimensional object (e.g. image).
-
height¶ Alias for field number 1
-
width¶ Alias for field number 0
-
-
class
SheetMetadata[source]¶ Bases:
adhocracy_core.interfaces.SheetMetadataMetadata to register a sheet type to set/get resource data.
- isheet:
- Marker interface for this sheet type, a subtype of
ISheet. Subtype has to override. - sheet_class:
IResourceSheetimplementation for this sheet- schema_class:
colander.MappingSchemato define the sheet data structure, default values and validators. Subtype must preserve the super type data structure. SeeIResourceSheet.schemafor more documentation.- permission_view:
- Permission to view or search for this data.
- permission_edit:
- Permission to edit this data.
- permission_create:
- Permission to create a new resource with this sheet data.
- readable:
- The sheet data is readable
- editable:
- The sheet data is editable
- creatable:
- The sheet data can be set if you create (post) a new resource
- create_mandatory:
- This Sheet must be set if you create (post) a new resource
-
interface
ISheetReferenceAutoUpdateMarker[source]¶ Extends:
adhocracy_core.interfaces.ISheetSheet Interface to autoupdate sheets with references.
If one referenced resource has a new version this sheet changes the reference to the new version.
-
interface
IPostPoolSheet[source]¶ Extends:
adhocracy_core.interfaces.ISheetMarker interfaces for sheets with post_pool Attributes.
This implies the sheet schema is a subtype of
adhocracy_core.schema.PostPoolSchemaor has at least a field node withadhocracy_core.Schema.PostPool.
-
interface
IPredicateSheet[source]¶ Extends:
adhocracy_core.interfaces.ISheetMarker interface for predicate sheets.
A predicate sheet has outgoing references named subject and object. It represents a subject-predicate-object data structure like RDF triples.
-
interface
IResourceSheet[source]¶ Extends:
substanced.interfaces.IPropertySheetSheet object to get/set resource data defined by a term:schema.
Variables: - meta (SheetMetadata) – The sheet configuration
- context (IResource) –
Resource to set/get data, find services, traverse object hierarchy.
If creating this should be the parent of the to be created resource.
- registry – Pyramid registry to get Adapters, sheets, metadata, settings, ...
- request (pyramid.interfaces.IRequest) –
The current request or None.
Use for permission checks, serialize/deserialize Resource-URLs, get user (
IResourceSheet.deserialze()andIResourceSheet.serialize()depend request). - creating (ResourceMetadata) –
The configuration of the to be created resource.
If not None the context attribute should be the parent of the new resource and set/get methods should not be used.
Used by deferred validators to allow different behavior when creating.
- schema (colander.MappingSchema) –
schema to define the data structure (without bindings).
Deferred schema validators and defaults values are not executed yet. To the the schema with bindings use:
IResourceSheet.get_schema_with_bindings().Deferred default values can rely on the following bindings:
context, registry, creatingDeferred validators can rely on the following bindings:
context, registry, request, creating
-
meta¶
-
context¶
-
registry¶
-
request¶
-
creating¶
-
schema¶
-
get_schema_with_bindings()¶ Return schema for serialization/deserialization.
Deferred validators/defaults are executed with the following bindings:
context, registry, request, creating
-
set(appstruct, omit=(), send_event=True, send_reference_event=True, omit_readonly=True)¶ Store
appstructdictionary data.Parameters: - send_event – raise resource sheet edited event.
- omit_readonly – do not store readonly
appstructdata. - send_reference_event – raise backreference added/removed events.
-
get(params={}, add_back_references=True, omit_defaults=False)¶ Get appstruct data.
Parameters: - params – optional parameters that can modify the appearance
of the returned dictionary. Valid keys/values are defined in
adhocracy_core.interfaces.SearchQuery. - add_back_references – allow to omit back references
- omit_defaults – omit fields with default values only
Deferred defaults are executed with the following bindings:
context, registry- params – optional parameters that can modify the appearance
of the returned dictionary. Valid keys/values are defined in
-
serialize(params={})¶ Get sheet appstruct data and serialize with schema.
Parameters: params – parameters passed to
IResourceSheet.get().If empty the following parameters set: only_visible=True and allows with the view permission.
Raises: ValueError – If the request attribute is None.
-
deserialize(cstruct)¶ Deserialize cstruct with schema from get_schema_with_bindings.
Raises: colander.Invalid – If schema validation fails.
-
delete_field_values(fields)¶ Delete values for every field name in fields.
-
interface
ISheetRequirePassword[source]¶ Extends:
adhocracy_core.interfaces.ISheetSheet Interface indicating that a password is required for editing.
To edit such a Sheet the password needs to be send in an additional request header.
-
class
ResourceMetadata[source]¶ Bases:
adhocracy_core.interfaces.ResourceMetadataMetadata to register Resource Types.
- content_name:
- Human readable name, subtypes have to override
- iresource:
- Resource type interface, subtypes have to override
- content_class:
- Class to create content objects
- permission_create:
- Permission to create and add this resource to the object hierarchy.
- is_implicit_addable:
- Make this type addable if supertype is addable.
- basic_sheets:
- Basic property interfaces to define data
- extended_sheets:
- Extended property interfaces to define data, subtypes should override
- after_creation:
- Callables to run after creation. They are passed the instance being created and the registry.
- use_autonaming:
- Automatically generate the name if the new content object is added to the parent.
- autonaming_prefix:
- uses this prefix for autonaming.
- use_autonaming_random:
- Use random the name if the new content object is added to the parent. You can enable only one, autonaming or random autonaming.
- is_sdi_addable:
- Make this resource type automatically addable with the substanced admin interface (sdi).
- sdi_column_mapper:
- Mapping function to add columns with addition information to an sdi folder view.
- element_types:
- Set addable content types, class heritage is honored.
- default_workflow:
- Name of workflow to be assigned to instances. Possible workflows can be
found in
adhocracy_core.workflows. - alternative_workflows:
- Other workflow names that may be set.
- item_type:
- Set addable content types, class heritage is honored
-
interface
IPool[source]¶ Extends:
adhocracy_core.interfaces.IResourceResource with children - a folder in the object hierarchy.
-
keys()¶ Return subobject names present in this pool.
-
__iter__()¶ An alias for
keys.
-
values()¶ Return subobjects present in this pool.
-
items()¶ Return (name, value) pairs of subobjects in the folder.
-
get(name, default=None)¶ Get subobject by name.
Raises: substanced.folder.FolderKeyError – if name is not in this pool
-
__contains__(name)¶ Check if this pool contains an subobject named by name.
-
add(name, other)¶ Add subobject other.
Returns: The name used to place the subobject in the folder (a derivation of name, usually the result ofself.check_name(name)).
-
check_name(name)¶ Check that the passed name is valid.
Returns: The name.
Raises: - substanced.folder.FolderKeyError – if ‘name’ already exists in this pool.
- ValueError – if ‘name’ contains ‘@@’, slashes or is empty.
-
next_name(subobject, prefix='')¶ Return Name for subobject.
-
add_next(subobject, prefix='')¶ Add new subobject and auto generate name.
-
add_service(service_name, other)¶ Add a term:service to this folder named service_name.
-
find_service(service_name, *sub_service_names)¶ Return a service named by service_name.
Parameters: - service_name – Search in this pool and his lineage for a service named service_name
- sub_service_names – If provided traverse the service to find the give sub service name. If the sub service is found, use it to travers to the next sub service name.
Returns: Return the service for the given context. If nothing is found return None.
This is a shortcut for
substanced.service.find_service().
-
-
interface
IServicePool[source]¶ Extends:
adhocracy_core.interfaces.IPool,substanced.interfaces.IServicePool serving as a service.
-
interface
IItem[source]¶ Extends:
adhocracy_core.interfaces.IPoolPool for any versionable objects (DAG), tags and related Pools.
-
interface
ISimple[source]¶ Extends:
adhocracy_core.interfaces.IResourceSimple resource without versions and children.
-
interface
ITag[source]¶ Extends:
adhocracy_core.interfaces.ISimpleTag to link specific versions.
-
interface
IItemVersion[source]¶ Extends:
adhocracy_core.interfaces.IResourceVersionable resource, created during a Participation Process.
-
class
SheetReferenceClass(*arg, **kw)[source]¶ Bases:
substanced.interfaces.ReferenceClassReference a source and target with a specific ISheet interface.
Uses class attributes “target_*” and “source_*” to set tagged values.
-
interface
SheetReference¶
-
interface
SheetToSheet[source]¶ Extends:
adhocracy_core.interfaces.SheetReferenceBase type to reference resource ISheets.
-
interface
NewVersionToOldVersion[source]¶ Extends:
adhocracy_core.interfaces.SheetReferenceBase type to reference an old ItemVersion.
-
interface
IResourceSheetModified[source]¶ Extends:
zope.interface.interfaces.IObjectEventAn event type sent when a resource sheet is modified.
-
object¶ The modified resource
-
isheet¶ The modified sheet interface of the resource
-
registry¶ The pyramid registry
-
request¶ The current request for additional permission checksor None (for testing/scripting).
-
-
interface
IResourceCreatedAndAdded[source]¶ Extends:
zope.interface.interfaces.IObjectEventAn event type sent when a new IResource is created and added.
-
object¶ The new resource
-
parent¶ The parent of the new resource
-
registry¶ The pyramid registry
-
creator¶ User resource object of the authenticated User
-
autoupdated¶ Creation was caused automatically by application
-
-
interface
IResourceWillBeDeleted[source]¶ Extends:
zope.interface.interfaces.IObjectEventAn event type sent when a IResource will be deleted.
-
object¶ The going to be deleted resource
-
parent¶ The parent of the deleted resource
-
registry¶ The pyramid registry
-
-
interface
IItemVersionNewVersionAdded[source]¶ Extends:
zope.interface.interfaces.IObjectEventAn event type sent when a new ItemVersion is added.
-
object¶ The old ItemVersion followed by the new one
-
new_version¶ The new ItemVersion
-
registry¶ The pyramid registry
-
creator¶ User resource object of the authenticated User
-
-
interface
ISheetReferenceNewVersion[source]¶ Extends:
zope.interface.interfaces.IObjectEventAn event type sent when a referenced ItemVersion has a new follower.
-
object¶ The resource referencing the outdated ItemVersion.
-
isheet¶ The sheet referencing the outdated ItemVersion
-
isheet_field¶ The sheet field referencing the outdated ItemVersion
-
old_version¶ The referenced but outdated ItemVersion
-
new_version¶ The follower of the outdated ItemVersion
-
root_versions¶ Non-empty list of roots of the ItemVersion (only resources that can be reached from one of the roots should be updated)
-
registry¶ The pyramid registry
-
creator¶ User resource object of the authenticated User
-
is_batchmode¶ Flag to do sheet autoupdates in batch request mode.
-
-
interface
ISheetBackReferenceModified[source]¶ Extends:
zope.interface.interfaces.IObjectEventAn event type sent when a sheet back reference was added/removed.
See Subtypes for more detailed semantic.
-
object¶ The referenced resource
-
isheet¶ The referenced sheet.
-
reference¶ The Reference with object as target.
-
registry¶ The pyramid registry
-
-
interface
ISheetBackReferenceAdded[source]¶ Extends:
adhocracy_core.interfaces.ISheetBackReferenceModifiedAn event type sent when a sheet back reference was added.
-
interface
ISheetBackReferenceRemoved[source]¶ Extends:
adhocracy_core.interfaces.ISheetBackReferenceModifiedAn event type sent when a sheet back reference was removed.
-
interface
ILocalRolesModfied[source]¶ Extends:
zope.interface.interfaces.IObjectEventAn event type send when an resource`s local role is modified.
-
object¶ The resource being modified
-
new_local_roles¶ The new resource`s local roles
-
old_local_roles¶ The old resource`s local roles
-
registry¶ The pyramid registry
-
-
interface
IActivitiesGenerated[source]¶ Extends:
zope.interface.interfaces.IObjectEventAn event type send when activity s are created.
-
object¶ Not used
-
activities¶ The added activities
-
request¶ The current pyramid request
-
-
interface
ITokenManger[source]¶ ITokenManger interface.
-
get_user_id(token)¶ Get userid for authentication token.
Returns: user id for this token Raises: KeyError – if there is no corresponding userid
-
delete_token(token)¶ Delete authentication token.
-
delete_expired_tokens(timeout)¶ Delete expired authentication tokens.
-
-
class
VisibilityChange[source]¶ Bases:
enum.EnumTrack changes in the visibility of a resource.
-
visible= <VisibilityChange.visible: 1>¶ Was and is visible
-
invisible= <VisibilityChange.invisible: 2>¶ Was and is NOT visible
-
concealed= <VisibilityChange.concealed: 3>¶ Was visible but is now invisible
-
revealed= <VisibilityChange.revealed: 4>¶ Was invisible but is now visible
-
-
class
AuditlogEntry[source]¶ Bases:
adhocracy_core.interfaces.AuditlogEntryMetadata to log which user modifies resources.
-
class
AuditlogAction[source]¶ Bases:
enum.EnumName of the Resource modification action.
-
created= <AuditlogAction.created: 'created'>¶
-
modified= <AuditlogAction.modified: 'modified'>¶
-
invisible= <AuditlogAction.invisible: 'invisible'>¶
-
concealed= <AuditlogAction.concealed: 'concealed'>¶
-
revealed= <AuditlogAction.revealed: 'revealed'>¶
-
-
class
Activity[source]¶ Bases:
adhocracy_core.interfaces.ActivityMetadata to log user activities.
Based on W3C Activity stream v2 Ontology (https://www.w3.org/TR/activitystreams-vocabulary/).
- subject: (IResource):
- user/group that is causing the activity, required None means the application is the subject
- type (ActivityType):
- name of activity executed by user, required
- object: (IResource):
- resource path (location) of activity object, required
- target (IResource):
- resource path of indirect activity object
- name (pyramid.i18n.TranslationString):
- simple, humane readable description of the activity.
- sheet_data (list):
- List of sheet appstruct data when changing or deleting resources, not part of the activity stream ontology
- published (datetime.DateTime):
- the date/time the activity was published, required
-
class
ActivityType[source]¶ Bases:
enum.EnumType of user activity.
Based on https://www.w3.org/TR/activitystreams-vocabulary.
-
add= <ActivityType.add: 'Add'>¶
-
update= <ActivityType.update: 'Update'>¶
-
remove= <ActivityType.remove: 'Remove'>¶
-
transition= <ActivityType.transition: 'Transition'>¶ Transition to new workflow state.
-
-
class
SerializedActivity[source]¶ Bases:
adhocracy_core.interfaces.SerializedActivityUsed to store
adhocracy_core.interfaces.Activity.
-
class
SearchResult(elements, count, frequency_of, group_by)¶ Bases:
tuple-
count¶ Alias for field number 1
-
elements¶ Alias for field number 0
-
frequency_of¶ Alias for field number 2
-
group_by¶ Alias for field number 3
-
-
class
FieldComparator[source]¶ Bases:
adhocracy_core.interfaces.ComparatorComparators for
hypatia.field.FieldIndexsearch index.-
eq= <FieldComparator.eq: 'eq'>¶
-
noteq= <FieldComparator.noteq: 'noteq'>¶
-
gt= <FieldComparator.gt: 'gt'>¶
-
ge= <FieldComparator.ge: 'ge'>¶
-
lt= <FieldComparator.lt: 'lt'>¶
-
le= <FieldComparator.le: 'le'>¶
-
-
class
FieldSequenceComparator[source]¶ Bases:
adhocracy_core.interfaces.ComparatorComparators for
hypatia.field.FieldIndexsearch index.These comparators need to be combined with a sequence of index values.
-
any= <FieldSequenceComparator.any: 'any'>¶
-
notany= <FieldSequenceComparator.notany: 'notany'>¶
-
-
class
KeywordComparator[source]¶ Bases:
adhocracy_core.interfaces.ComparatorComparators for
hypatia.keyword.KeywordIndexsearch index.-
eq= <KeywordComparator.eq: 'eq'>¶
-
noteq= <KeywordComparator.noteq: 'noteq'>¶
-
-
class
KeywordSequenceComparator[source]¶ Bases:
adhocracy_core.interfaces.ComparatorComparators for
hypatia.keyword.KeywordIndexsearch index.These comparators need to be combined with a sequence of index values.
-
any= <KeywordSequenceComparator.any: 'any'>¶
-
notany= <KeywordSequenceComparator.notany: 'notany'>¶
-
-
class
ReferenceComparator[source]¶ Bases:
adhocracy_core.interfaces.ComparatorComparators for
adhocracy_core.catalog.index.Referenceindex.These comparators need to be combined with a
adhocracy_core.interfaces.Reference. value-
traverse= <ReferenceComparator.traverse: 'traverse'>¶
-
-
class
SearchQuery[source]¶ Bases:
adhocracy_core.interfaces.QueryQuery parameters to search resources.
- interfaces (IInterface or (IInterface)
or (KeywordSearchComparator, IInterface) or (KeywordSearchComparator, (IInterface)):
Resource type (iresource) or sheet (isheet) interfaces
indexes ({str:object} or {str:(SearchComparator, object)} or {str:(SearchComparator, (object))}
Mapping index name to wanted index value. Available indexes are defined inadhocracy_core.catalog.adhocracyAvailable :class:`SearchComparator`s depend on the index type.- references (Reference or (ReferenceComparator.traverse, Reference)):
References with (source, isheet, isheet_field, target).
- If source is None search for resources referencing target (back references).
- If target is None search for resources referenced by source (Reference).
- If the tuple (ReferenceComparator.traverse, Reference) is given, the resource graph is traversed following all references with the same type as the given reference.
- root (IResource):
- root resource to start searching in descendants
- depth (int):
- path depth to search descendants
- only_visible (bool):
- filter hidden resources
- allows ([str], str):
- filter resources that don’t allow the principals the given permission ([principal], permission).
- resolve (bool):
- return elements list of resources or lazy iterator set
- sort_by (str):
- index name to sort result. Available indexes are defined in
adhocracy_core.catalog.adhocracyandsubstanced.catalog.system - reverse (bool):
- reverse sort
- limit (int):
- max number of resources in search result
- offset (int):
- starting position of resources in search result (only works together with limit)
- frequency_of (str):
- index name to count frequency of indexed values.
- group_by (str):
- index name to group result resources by indexed value.
-
interface
IRolesUserLocator[source]¶ Extends:
substanced.interfaces.IUserLocatorAdapter responsible for returning a user or get info about it.
-
get_roleids(userid)¶ Return the roles for userid or None.
We return ‘None’ if the the user does not exists to provide a similar behavior as
substanced.interfaces.IUserLocator.get_groupids().
-
get_user_by_activation_path(activation_path)¶ Find user per activation path or return None.
-
get_user_by_service_konto_userid(userid)¶ Find user per service konto userid or return None.
-
-
interface
IRoleACLAuthorizationPolicy[source]¶ Extends:
pyramid.interfaces.IAuthorizationPolicyA authorization policy supporting creator term:local role.
-
permits(context, principals, permission)¶ Check that one principal has the permission for context.
This method extends the behavior of
ACLAuthorizationPolicy(). If a principal is the creator of context the creator local_role is addded.
-
-
interface
IRateValidator[source]¶ Adapter responsible for validating rates about rateables.
-
validate(self, rate)¶ Return True if rate is valid, False otherwise.
-
helpful_error_message(self)¶ Return a error message that explains which values are allowed.
-
-
class
Reference[source]¶ Bases:
adhocracy_core.interfaces.ReferenceReference between two resources.
- source (IResource):
- Referencing resource
- isheet (IInterface):
- Resource sheet of source with referencing field
- field (str):
- Referencing field
- target (IResource):
- Referenced resource
-
class
HTTPCacheMode[source]¶ Bases:
enum.EnumCaching Mode for
IHTTPCacheStrategy.You can change the mode in you pyramid ini file with the adhocracy.caching_mode setting.
-
no_cache= <HTTPCacheMode.no_cache: 1>¶ Make all cache strategies set do not cache header only.
-
without_proxy_cache= <HTTPCacheMode.without_proxy_cache: 2>¶ Make all cache strategies set headers that work without a proxy cache
-
with_proxy_cache= <HTTPCacheMode.with_proxy_cache: 3>¶ Make all cache strategies set headers that only work with a proxy cache between webserver and backend. The proxy cache has to accepts purge requests form the backend. To make this work you have to set the adhocracy_core.caching_proxy setting in you pyramid ini file.
-
-
interface
IHTTPCacheStrategy[source]¶ Strategy to set http cache headers.
-
set_cache_headers_for_mode(mode)¶ Set response cache headers according to
HTTPCacheMode.
-
check_conditional_request()¶ Check if conditional_request and raise 304 Error if needed.
-
-
interface
IAdhocracyWorkflow[source]¶ Extends:
substanced.interfaces.IWorkflowIAdhocracyWorkflow interface.
-
get_next_states(context, request)¶ Get states you can trigger a transition to.
-
-
error_entry¶ alias of
ErrorEntry