ploneintranet.network package

Submodules

ploneintranet.network.graph module

class ploneintranet.network.graph.NetworkGraph(context=None)

Bases: persistent.Persistent, ExplicitAcquirer

Stores a social network graph of users:

  • bookmarking/unbookmarking
  • following/unfollowing
  • liking/unliking
  • tagging/untagging

other users, content objects, status updates, tags.

All parameters with item_id or user_id references are resolvable, permanently stable, string ids. - StatusUpdates: a str() cast of status.id. - content: a uuid on the content. - users: a stable userid (not a changeable email) - tags: merging or renaming tags requires migrating the tag storage

Be aware that if item_type==”user”, both item_id and user_id are user ids. In that case user_id is the actor (subject) and item_id is the target (object). For example if Alex endorses Bernard with tag ‘leadership’, then: item_type=’user’, item_id=’bernard’, user_id=’alex’.

Return values are normally BTrees.OOBTree.OOTreeSet iterables, except in some special cases documented on the tags accessors below, where a flattened structure is returned using the unpack() utility method.

_bookmark_type_validator(item_type)

Return validated input

Raises value error if input is invalid

_bookmark_user_validator(user_id)

Return validated input

_set_insert(storage, key, value)

Given a btreeish storage be sure storage[key] is a OOTreeSet we can insert value in to

_set_remove(storage, key)

Remove from OOTreeSet key if found

bookmark(item_type, item_id, user_id=None)
bookmarked_on(item_id, user_id=None)
clear(context=None)

Set up storage for personalized data structures.

_bookmarks[“content”][userid] = (uuid, uuid, …) _bookmarked[“content”][uuid] = (userid, userid, …)

_bookmarked_on[userid][item_id] = datetime # UTC

_following[“user”][userid] = (userid, userid, …) _followers[“user”][userid] = (userid, userid, …)

Other follow types can be switched on here but are not used anywhere yet.

_likes[“content”][userid] = (uuid, uuid, …) _liked[“content”][uuid] = (userid, userid, …)

_likes[“update”][userid] = (statusid, statusid, …) _liked[“update”][statusid] = (userid, userid, …)

More complex than following or liking since tagging is a 3-way relation (subject, tags, object)

Endorsements can be implemented as users tagging item_id users.

supported_tag_types = (“user”, “content”, “update”)

Objects tagged by a user: _tagged[userid] = {tag: {type: ids}} _tagged[userid][tag] = {type: ids} _tagged[userid][tag][“user”] = (userid, userid, …) _tagged[userid][tag][“content”] = (uuid, uuid, …)

Users that tagged an object: _tagger[item_type][id] = {tag: userids} _tagger[“user”][userid][tag] = (userid, userid, …) _tagger[“content”][uuid][tag] = (userid, userid, …)

Tags applied by a user: _tags[user_id] = {item_type: item_id: (tag, tag,…)} _tags[user_id][“user”][userid] = (tag, tag, …) _tags[user_id][“content”][uuid] = (tag, tag, …)

Find objects by tag: (and the users who applied that tag) _bytag[tag] = {item_type: {item_id: (userid, userid)} _bytag[tag][“user”][user_id] = (userid, userid, …) _bytag[tag][“content”][uuid] = (userid, userid, …)

follow(item_type, item_id, user_id=None)
get_bookmarkers(item_type, item_id)
get_bookmarks(item_type, user_id=None)
get_bookmarks_by_date(item_type, user_id=None)
get_followers(item_type, item_id)
get_following(item_type, user_id=None)
get_likers(item_type, item_id)
get_likes(item_type, user_id=None)
get_tagged(item_type=None, user_id=None, tag=None)
get_taggers(item_type, item_id, tag=None)
get_tags(item_type, item_id, user_id=None)
is_bookmarked(item_type, item_id, user_id=None)
is_bookmarking(item_type, item_id, user_id=None)
is_followed(item_type, item_id, user_id=None)
is_following(item_type, item_id, user_id=None)
is_liked(item_type, item_id, user_id=None)
is_liking(item_type, item_id, user_id=None)
is_tagged(item_type, item_id, user_id, tag)
like(item_type, item_id, user_id=None)
supported_bookmark_types = (u'content',)
supported_follow_types = (u'user', u'content', u'tag')
supported_like_types = (u'content', u'update')
supported_tag_types = (u'user', u'content')
tag(item_type, item_id, user_id, *tags)
unbookmark(item_type, item_id, user_id=None)
unfollow(item_type, item_id, user_id=None)
unlike(item_type, item_id, user_id=None)
unpack(btreeish)
untag(item_type, item_id, user_id, *tags)
ploneintranet.network.graph.decode(value, permissive=False)

Force all strings into unicode

ploneintranet.network.interfaces module

interface ploneintranet.network.interfaces.INetworkGraph

Bases: zope.interface.Interface

Stores a social network graph of users following/unfollowing or liking/unliking other users, content objects, status updates, tags.

All references are string ids.

Every method that has a user_id=None fallback, will fall back to the id of the currently logged in user if no user_id is given.

Return values are BTrees.OOBTree.OOTreeSet iterables.

is_followed(item_type, item_id, user_id=None)

Does <user_id> follow <item_type> <item_id>?

get_likers(item_type, item_id)

List all userids liking <item_type> <item_id>

is_liking(item_type, item_id, user_id=None)

Does <user_id> like <item_type> <item_id>?

get_taggers(item_type, item_id, tag=None)

List user_ids that tagged <item_type> <item_id> with <tag>. If tag==None: returns {tag: (itemids..)} mapping

get_tagged(item_type=None, userid=None, tag=None)

List <item_type> item_ids tagged as <tag> by <user_id>.

See implementation docstring and test suite for specifications of return values when one or more parameters are set to None.

unfollow(item_type, item_id, user_id=None)

User <user_id> unsubscribes from <item_type> <item_id>

tag(item_type, item_id, user_id, *tags)

User <user_id> adds tags <*tags> on <item_type> <item_id>

is_following(item_type, item_id, user_id=None)

Does <user_id> follow <item_type> <item_id>?

is_tagged(item_type, item_id, user_id, tag)

Did <user_id> apply tag <tag> on <item_type> <item_id>?

follow(item_type, item_id, user_id=None)

User <user_id> subscribes to <item_type> <item_id>

untag(item_type, item_id, user_id, *tags)

User <user_id> removes tags <*tags> from <item_type> <item_id>

get_likes(item_type, user_id=None)

List all <item_type> liked by <user_id>

get_tags(item_type, item_id, user_id=None)

List tags set on <item_type> <item_id> by <user_id>. If user_id==None: return {tag: (userids..)} mapping

like(item_type, item_id, user_id=None)

User <user_id> likes <item_type> <item_id>

unlike(item_type, item_id, user_id=None)

User <user_id> unlikes <item_type> <item_id>

get_followers(item_type, item_id)

List all users that subscribe to <item_type> <item_id>

get_following(item_type, user_id=None)

List all <item_type> that <user_id> subscribes to

is_liked(item_type, item_id, user_id=None)

Does <user_id> like <item_type> <item_id>?

interface ploneintranet.network.interfaces.INetworkTool

Bases: ploneintranet.network.interfaces.INetworkGraph

Provide INetworkContainer as a site utility.

is_followed(item_type, item_id, user_id=None)

Does <user_id> follow <item_type> <item_id>?

get_likers(item_type, item_id)

List all userids liking <item_type> <item_id>

is_liking(item_type, item_id, user_id=None)

Does <user_id> like <item_type> <item_id>?

get_taggers(item_type, item_id, tag=None)

List user_ids that tagged <item_type> <item_id> with <tag>. If tag==None: returns {tag: (itemids..)} mapping

get_tagged(item_type=None, userid=None, tag=None)

List <item_type> item_ids tagged as <tag> by <user_id>.

See implementation docstring and test suite for specifications of return values when one or more parameters are set to None.

unfollow(item_type, item_id, user_id=None)

User <user_id> unsubscribes from <item_type> <item_id>

tag(item_type, item_id, user_id, *tags)

User <user_id> adds tags <*tags> on <item_type> <item_id>

is_following(item_type, item_id, user_id=None)

Does <user_id> follow <item_type> <item_id>?

is_tagged(item_type, item_id, user_id, tag)

Did <user_id> apply tag <tag> on <item_type> <item_id>?

follow(item_type, item_id, user_id=None)

User <user_id> subscribes to <item_type> <item_id>

untag(item_type, item_id, user_id, *tags)

User <user_id> removes tags <*tags> from <item_type> <item_id>

get_likes(item_type, user_id=None)

List all <item_type> liked by <user_id>

get_tags(item_type, item_id, user_id=None)

List tags set on <item_type> <item_id> by <user_id>. If user_id==None: return {tag: (userids..)} mapping

like(item_type, item_id, user_id=None)

User <user_id> likes <item_type> <item_id>

unlike(item_type, item_id, user_id=None)

User <user_id> unlikes <item_type> <item_id>

get_followers(item_type, item_id)

List all users that subscribe to <item_type> <item_id>

get_following(item_type, user_id=None)

List all <item_type> that <user_id> subscribes to

is_liked(item_type, item_id, user_id=None)

Does <user_id> like <item_type> <item_id>?

ploneintranet.network.testing module

ploneintranet.network.tool module

class ploneintranet.network.tool.NetworkTool(context=None)

Bases: Products.CMFCore.utils.UniqueObject, OFS.SimpleItem.SimpleItem, ploneintranet.network.graph.NetworkGraph

Provide INetworkContainer as a site utility.

id = 'ploneintranet_network'
meta_type = 'ploneintranet.network tool'

ploneintranet.network.upgrades module

ploneintranet.network.upgrades.upgrade_to_0006(context)

Module contents