assembl.models.user_key_values module

Models for arbitrary key-values storage, bound to a namespace, a user, and some other object (currently only the discussion).

class assembl.models.user_key_values.AbstractNamespacedKeyValue[source]

Bases: object

Mixin class for namespace-key-value triples in a namespaced dictionaries (dict of dict)

class assembl.models.user_key_values.AbstractPerUserNamespacedKeyValue[source]

Bases: assembl.models.user_key_values.AbstractNamespacedKeyValue

Mixin class for user-namespace-key-value quads in a user-local namespaced dictionaries (dict of dict)

class assembl.models.user_key_values.DiscussionPerUserNamespacedKeyValue(**kwargs)[source]

Bases: assembl.models.DiscussionBoundBase, assembl.models.user_key_values.AbstractPerUserNamespacedKeyValue

User-local namespaced dictionaries for a given discussion

container_url()[source]

What is the URL where we expect to find this resource

classmethod get_discussion_conditions(discussion_id, alias_maker=None)[source]

Returns a list of SQLA expressions that constrain a query on this class to a given discussion.

get_discussion_id()[source]

Get the ID of an associated discussion object, if any.

key

The key of the key-value tuple

namespace

The namespace of the key-value tuple

target_class

alias of assembl.models.discussion.Discussion

unique_query()[source]

returns a couple (query, usable), with a sqla query for conflicting similar objects. usable is true if the query has to be enforced; sometimes it makes sense to return un-usable query that will be used to construct queries of subclasses. Note that when a duplicate is found, you’ll often want to expunge the original.

user_id

The user of the key-value tuple

value

The value of the key-value tuple

class assembl.models.user_key_values.IdeaNamespacedKeyValue(**kwargs)[source]

Bases: assembl.models.DiscussionBoundBase, assembl.models.user_key_values.AbstractNamespacedKeyValue

Namespaced dictionaries for a given idea (not user-bound)

container_url()[source]

What is the URL where we expect to find this resource

classmethod get_discussion_conditions(discussion_id, alias_maker=None)[source]

Returns a list of SQLA expressions that constrain a query on this class to a given discussion.

get_discussion_id()[source]

Get the ID of an associated discussion object, if any.

key

The key of the key-value tuple

namespace

The namespace of the key-value tuple

target_class

alias of assembl.models.idea.Idea

unique_query()[source]

returns a couple (query, usable), with a sqla query for conflicting similar objects. usable is true if the query has to be enforced; sometimes it makes sense to return un-usable query that will be used to construct queries of subclasses. Note that when a duplicate is found, you’ll often want to expunge the original.

value

The value of the key-value tuple

class assembl.models.user_key_values.NamespacedKVCollection(target, namespace)[source]

Bases: collections.abc.MutableMapping

View of the AbstractNamespacedKeyValue for a given namespace as a python dict

class assembl.models.user_key_values.NamespacedUserKVCollection(target, user_id, namespace)[source]

Bases: collections.abc.MutableMapping

View of the AbstractPerUserNamespacedKeyValue for a given namespace as a python dict

class assembl.models.user_key_values.NsDict(target)[source]

Bases: collections.abc.MutableMapping

The dictonary of :py:class:NamespacedKVCollection, indexed by namespace, as a python dict

class assembl.models.user_key_values.UserNsDict(target, user_id)[source]

Bases: collections.abc.MutableMapping

The dictonary of :py:class:NamespacedUserKVCollection, indexed by namespace, as a python dict

class assembl.models.user_key_values.UserPreferenceCollection(user_id, discussion=None)[source]

Bases: assembl.models.user_key_values.NamespacedUserKVCollection

The ‘preferences’ namespace has some specific behaviour.

These are user preferences. See :py:mod:.preferences.

items()a set-like object providing a view on D’s items[source]