everest.resources.base

Resources.

class everest.resources.base.Collection(aggregate, name=None)[source]

Bases: everest.resources.base.Resource

This is an abstract base class for all resource collections. A collection is a set of member resources which can be filtered, sorted, and sliced.

__getitem__(key)[source]

Gets a member (by name).

Parameters:key (string or unicode) – the name of the member
Raises :everest.exceptions.DuplicateException if more than one member is found for the given key value.
Returns:object implementing everest.resources.interfaces.IMemberResource
__init__(aggregate, name=None)[source]

Constructor:

Parameters:
  • name (string) – the name of the collection
  • aggregate (everest.entities.aggregates.Aggregate - an object implementing an interface derived from everest.entities.interfaces.IAggregate) – the associated aggregate
__iter__()[source]

Returns an iterator over the (possibly filtered and ordered) collection.

__len__()[source]

Returns the size (count) of the collection.

add(member)[source]

Adds the given member to this collection.

Parameters:member (object implementing everest.resources.interfaces.IMemberResource) – member to add.
Raises ValueError:
 if a member with the same name exists
clone()[source]

Returns a clone of this collection.

classmethod create_from_aggregate(aggregate)[source]

Creates a new collection from the given aggregate.

Parameters:aggregate (everest.entities.aggregates.Aggregate instance) – aggregate containing the entities exposed by this collection resource
create_member(entity)[source]

Creates a new member resource from the given entity and adds it to this collection.

default_order = <everest.querying.specifications.AscendingOrderSpecification object at 0x3097e50>

The default order of the collection’s members.

description = ''

A description of the collection.

get(key, default=None)[source]

Returns a member for the given key or the given default value if no match was found in the collection.

get_aggregate()[source]

Returns the aggregate underlying this collection.

Returns:an object implementing everest.entities.interfaces.IAggregate.
max_limit = 1000

The maximum number of member that can be shown on one page (superclass default: 1000).

remove(member)[source]

Removes the given member from this collection.

Parameters:member (object implementing everest.resources.interfaces.IMemberResource) – member to add.
Raises ValueError:
 if the member can not be found in this collection
root_name = None

The name for the root collection (used as URL path to the root collection inside the service).

set_relationship(relationship)[source]

Sets the relation parent for this collection.

The relation parent affects the expressions built for filter and order operations.

Parameters:relationship – relation with another resource, encapsulated in a everest.relationship.Relationship instance.
title = None

The title of the collection.

update_from_data(data_element)[source]

Updates this collection from the given data element.

This iterates over the members of this collection and checks if a member with the same ID exists in the given update data. If yes, the existing member is updated with the update member; if no, the member is removed. All data elements in the update data that have no ID are added as new members. Data elements with an ID that can not be found in this collection trigger an error.

Parameters:data_element (object implementing :class:everest.resources.interfaces.IExplicitDataElement) – data element (hierarchical) to create a resource from
Raises ValueError:
 when a data element with an ID that is not present in this collection is encountered.
class everest.resources.base.Member(entity, name=None)[source]

Bases: everest.resources.attributes.ResourceAttributeControllerMixin, everest.resources.base.Resource

This is an abstract class for all member resources.

__eq__(other)[source]

Equality operator.

Equality is based on a resource’s name only.

__init__(entity, name=None)[source]

Constructor:

Parameters:
  • name (string) – unique name of the member within the collection
  • entity (an object implementing an interface derived from everest.entities.interfaces.IEntity) – the associated entity (domain object)
__ne__(other)[source]

Inequality operator.

classmethod create_from_entity(entity)[source]

Class factory method creating a new resource from the given entity.

delete()[source]

Deletes this member.

Deleting a member resource means removing it from its parent resource.

get_entity()[source]

Returns the entity this resource manages.

Returns:an object implementing everest.entities.interfaces.IEntity.
update_from_data(data_element)[source]

Updates this member from the given data element.

Parameters:data_element (object implementing :class:everest.resources.representers.interfaces.IExplicitDataElement) – data element (hierarchical) to create a resource from
class everest.resources.base.Resource[source]

Bases: object

This is the abstract base class for all resources.

__init__()[source]

Constructor:

__weakref__

list of weak references to the object (if defined)

Adds a link to another resource.

Parameters:link (everest.resources.base.Link) – a resource link
classmethod create_from_data(data_element)[source]

Creates a resource instance from the given data element (tree).

Parameters:data_element (object implementing everest.resources.representers.interfaces.IExplicitDataElement) – data element (hierarchical) to create a resource from
description = ''

Detailed description of this resource.

A set of links to other resources.

path[source]

Returns the path to this resource in the tree of resources.

relation = None

The relation identifier to show in links to this resource. Needs to be specified in derived classes.

title = ''

Descriptive title for this resource.

urn[source]

Returns the URN for this resource (globally unique identifier).

Project Versions

Previous topic

everest.resources.attributes

Next topic

everest.resources.descriptors

This Page