# coding=utf-8 # # Copyright (C) 2010-2012 Platform Computing # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # Python module holding routines for handling resources and collections.
Created on Jun 30, 2011
@author: tmetsch '''
#============================================================================== # Handling of Resources & Links #==============================================================================
''' Handles all the model magic during creation of an entity.
If it's an resource it will verify that all links are created.
If it's a link it will ensure that source and target are properly set.
key -- The key for the entity. entity -- The entity itself - either Link or Resource instance. registry -- The registry used for this process. extras -- Any extra arguments which are defined by the user. '''
# if it is an resource we create make sure we create the links properly # if it's a resource - set/create links properly. # FUTURE_IMPROVEMENT: string links
# call all the backends who are associated with this entity.kind...
''' Handles all the model magic during deletion if an entity.
If it's a link it will remove the link from the entity source links list.
entity -- The entity itself - either Link or Resource instance. registry -- The registry used for this process. extras -- Any extra arguments which are defined by the user. ''' # it's an resource - so delete all it's links # FUTURE_IMPROVEMENT: string links
# call all the backends who are associated with this entity.kind...
''' Replace an entity - backends decide what is done.
If it's a link the entities must be replaced.
old -- The old entity. new -- The new entity. registry -- The registry used for this process. extras -- Any extra arguments which are defined by the user. ''' ' update request')
' entity.')
# call all the backends who are associated with this entity.kind...
''' Update an entity - backends decide what is done.
If it's a link the entities must be updated.
old -- The old entity. new -- The new entity. registry -- The registry used for this process. extras -- Any extra arguments which are defined by the user. ''' ' update request')
# call all the backends who are associated with this entity.kind... # for added mixins called create!
''' Retrieves/refreshed an entity.
If it's a link the entities must be retrieved/refreshed.
entity -- The entity which is to be retrieved. registry -- The registry used for this process. extras -- Any extra arguments which are defined by the user. ''' # if it's a resource - retrieve all links... # FUTURE_IMPROVEMENT: string links
# call all the backends who are associated with this entity.kind...
''' Performs an action on the entity.
entity -- The entity on which to perform the operation. action -- The action definition. registry -- The registry used for this process. attributes -- The attributes fro the operation. extras -- Any extra arguments which are defined by the user. '''
#============================================================================== # Collections #==============================================================================
''' Updates a Collection of Mixin. If not present in the current collections entities will be added to the collection (aka. assigned the Mixin).
mixin -- The mixin which defines the collection. old_entities -- The entities which are in the collection to date. new_entities -- The entities which should be added to the collection. registry -- The registry used for this process. extras -- Any extra arguments which are defined by the user. ''' + ' of Mixins.')
''' Replaces a Collection of Mixin. If not present in the current collections entities will be added to the collection (aka. assigned the Mixin). If old entities are not present in the new collection the mixin will be removed from them.
mixin -- The mixin which defines the collection. old_entities -- The entities which are in the collection to date. new_entities -- The new collection of entities. registry -- The registry used for this process. extras -- Any extra arguments which are defined by the user. ''' + ' of Mixins.')
''' Removes entities from a collection by removing the mixin from their list.
mixin -- The mixin which defines the collection. entities -- The entities which are to be removed. registry -- The registry used for this process. extras -- Any extra arguments which are defined by the user. ''' + ' of Mixins.')
''' Return all entities which fall under a path.
If the path is in locations return all entities of the kind which defines the location.
If the path is just a path return all children.
path -- The path under which to look... registry -- The registry used for this process. extras -- Any extra arguments which are defined by the user. ''' else:
''' Filters a set of entities and return those who match the given categories and attributes.
entities -- The entities which are to be filtered. categories -- Categories which must be present in the entity. attributes -- Attributes which must match with the entity's attrs. '''
#============================================================================== # Query Interface #==============================================================================
''' Filter the categories. Only those requested should be added to the resulting list.
categories -- The list of categories to filter against. registry -- The registry used for this process. extras -- Passed on extra object. '''
''' Add a mixin to the service.
mixins -- The mixins which are to be added. registry -- The registry used for this process. extras -- Passed on extra object. '''
else: ' exists.')
''' Remove a mixin from the service.
mixins -- The mixin which are to be removed. registry -- The registry used for this process. extras -- Any extra arguments which are defined by the user. '''
#============================================================================== # Convenient stuff #==============================================================================
''' Create a key with the hierarchy of the entity encapsulated.
kind -- The kind which this id should be created for. '''
''' Returns the intersection of two lists.
list_a -- The first list. list_b -- Another list. ''' else:
''' Returns a list of elements which are only in list_a.
list_a -- The list to look into for unique elements. list_b -- Ths list the verify against. ''' |