graphalchemy / graphalchemy / mixins /

Full commit
# -*- coding: utf-8 -*-
'''graph writers'''

import nanotime

from graphalchemy.core import octopus, defer, app

__all__ = ('Links', 'Nodes')

# settings
conf = octopus.G

class Writer(octopus.event.Worker):

    '''graph writer base'''

    # graph source
    _db = app(conf.key.backend, conf.userspace)

    def delete(self, this, indices=None):
        delete graph element

        @param this: graph object
        @param indicies: graph indices (default: None)
        self.w.delete_element(this, indices)

    def index(self, index, fts=False):
        create link index

        @param index: node index name
        @param fts: create a full text index (default: False)
        self.w.create_index(index, fts)

    def index_many(self, index, this, indexed):
        index properties on a graph element

        @param index: graph index label
        @param this: graph object
        @param indexed: properties to index
        self.w.index_many(self.r.index(index), this, indexed)

    def index_one(self, index, key, value, this):
        index one property of a graph element

        @param index: graph index label
        @param key: graph element property key
        @param value: graph element property value
        @param this: graph object
        self.w.index_one(self.r.index(index), key, value, this)

    def modify(self, this, data):
        update a graph element's properties

        @param this: graph object
        @param data: data
        self.w.update(this, data)

    def now():
        '''current time in microseconds'''