ripozo.viewsets package¶
Subpackages¶
Submodules¶
ripozo.viewsets.constructor module¶
-
class
ripozo.viewsets.constructor.
ResourceMetaClass
[source]¶ Bases:
type
A metaclass that is used for registering ResourceBase and its subclasses
- Parameters
registered_resource_classes (dict) – A dictionary mapping the classes instantiated by this meta class to their base_urls
registered_names_map (dict) – A dictionary mapping the names of the classes to the actual instances of this meta class
-
registered_names_map
= {}¶
-
registered_resource_classes
= {}¶
ripozo.viewsets.resource_base module¶
-
class
ripozo.viewsets.resource_base.
ResourceBase
(properties=None, errors=None, meta=None, status_code=200, query_args=None, include_relationships=True)[source]¶ Bases:
object
The core of ripozo.
- Parameters
__abstract__ (bool) – abstract classes are not registered by the ResourceMetaClass
_relationships (dict) – The relationships that will be constructed by instances
_pks (list) – The pks for this resource. These, along with the
namespace
andresource_name
are combined to generate the url_manager (type) – The BaseManager subclass that is responsible for persistence within the applictation. I.E. the AlchemyManager from ripozo-sqlalchemy
_namespace (unicode) – The namespace of this resource. This is prepended to the resource_name and pks to create the url
_resource_name (unicode) – The name of the resource.
_preprocessors (list) – A list of functions that will be run before any apimethod is called.
_postprocessors (list) – A list of functions that will be run after any apimethod from this class is called.
_links (dict) – Works similarly to relationships. The primary difference between this and links is that links will assume the resource is the same as this class if a relation is not specified. Additionally, links are supposed to be meta information effectively. They are not necessarily about this specific resource. For example, next and previous links for a list resource or created links when creating a new resource on a list resource.
-
base_url
= '/resource_base'¶
-
base_url_sans_pks
= '/resource_base'¶
-
classmethod
endpoint_dictionary
()[source]¶ A dictionary of the endpoints with the method as the key and the route options as the value
- Returns
dictionary of endpoints
- Return type
dict
-
property
has_all_pks
¶ - Returns
Indicates whether an instance of this class has all of the items in the pks list as a key in the
self.properties
attribute.- Return type
bool
-
property
has_error
¶
-
property
item_pks
¶ Gets a dictionary of an individual resource’s primary keys. The key of the dictionary is the name of the primary key and the value is the actual value of the primary key specified
- Return type
dict
-
links
= ()¶
-
manager
= None¶
-
namespace
= '/'¶
-
pks
= []¶
-
postprocessors
= []¶
-
preprocessors
= []¶
-
relationships
= ()¶
-
resource_name
= 'resource_base'¶
-
property
url
¶ Lazily constructs the url for this specific resource using the specific pks as specified in the pks tuple.
- Returns
The url for this resource
- Return type
unicode
-
ripozo.viewsets.resource_base.
create_url
(base_url, **kwargs)[source]¶ Generates a fully qualified url. It iterates over the keyword arguments and for each key it replaces any instances of “<key>” with “value” The keys of the dictionary must be strings.
- Parameters
base_url (unicode) – The url template that will be used to generate an acutal url
kwargs (dict) – The dictionary of template variables and their associated values
- Returns
A complete url.
- Return type
unicode
ripozo.viewsets.restmixins module¶
-
class
ripozo.viewsets.restmixins.
Create
(properties=None, errors=None, meta=None, status_code=200, query_args=None, include_relationships=True)[source]¶ Bases:
ripozo.viewsets.resource_base.ResourceBase
-
links
= (<ripozo.viewsets.relationships.relationship.Relationship object>,)¶
-
-
class
ripozo.viewsets.restmixins.
CreateRetrieve
(properties=None, errors=None, meta=None, status_code=200, query_args=None, include_relationships=True)[source]¶ Bases:
ripozo.viewsets.restmixins.Create
,ripozo.viewsets.restmixins.Retrieve
-
class
ripozo.viewsets.restmixins.
CreateRetrieveUpdate
(properties=None, errors=None, meta=None, status_code=200, query_args=None, include_relationships=True)[source]¶ Bases:
ripozo.viewsets.restmixins.Create
,ripozo.viewsets.restmixins.Retrieve
,ripozo.viewsets.restmixins.Update
-
class
ripozo.viewsets.restmixins.
CreateRetrieveUpdateDelete
(properties=None, errors=None, meta=None, status_code=200, query_args=None, include_relationships=True)[source]¶ Bases:
ripozo.viewsets.restmixins.Create
,ripozo.viewsets.restmixins.Retrieve
,ripozo.viewsets.restmixins.Update
,ripozo.viewsets.restmixins.Delete
-
class
ripozo.viewsets.restmixins.
Delete
(properties=None, errors=None, meta=None, status_code=200, query_args=None, include_relationships=True)[source]¶
-
class
ripozo.viewsets.restmixins.
Retrieve
(properties=None, errors=None, meta=None, status_code=200, query_args=None, include_relationships=True)[source]¶
-
class
ripozo.viewsets.restmixins.
RetrieveList
(properties=None, errors=None, meta=None, status_code=200, query_args=None, include_relationships=True)[source]¶ Bases:
ripozo.viewsets.resource_base.ResourceBase
-
links
= (<ripozo.viewsets.relationships.relationship.Relationship object>, <ripozo.viewsets.relationships.relationship.Relationship object>)¶
-
-
class
ripozo.viewsets.restmixins.
RetrieveUpdate
(properties=None, errors=None, meta=None, status_code=200, query_args=None, include_relationships=True)[source]¶ Bases:
ripozo.viewsets.restmixins.Retrieve
,ripozo.viewsets.restmixins.Update
-
class
ripozo.viewsets.restmixins.
RetrieveUpdateDelete
(properties=None, errors=None, meta=None, status_code=200, query_args=None, include_relationships=True)[source]¶ Bases:
ripozo.viewsets.restmixins.Retrieve
,ripozo.viewsets.restmixins.Update
,ripozo.viewsets.restmixins.Delete