Commits

Lynn Rees  committed 96bf824

- clean up

  • Participants
  • Parent commits 1af2621

Comments (0)

Files changed (13)

File graphalchemy/core.py

 __all__ = ['octopus']
 
 octopus = Spine(graphalchemy, Required, Defaults)
+
+# decorators
+defer = octopus.context.defer
+direct = octopus.context.direct
+factory = octopus.context.factory
+service = octopus.context.service
+subscribe = octopus.context.subscribe
+class_defer = octopus.context.class_defer

File graphalchemy/finders.py

 from appspace import NoAppError
 from appspace.six import string_types
 
-from graphalchemy.core import octopus
+from graphalchemy.core import octopus, direct
 
 __all__ = ('links', 'nodes')
 
 # settings
 conf = octopus.S
-# decorators
-direct = octopus.context.direct
 
 
 class Finder(octopus.context.thing):
         '''
         if element is not None:
             try:
-                return self.M.get(element['_model'], self.S.userspace)
+                return self.Q.app(element['_model'], self.S.userspace)
             except (NoAppError, KeyError):
                 pass
         elif isinstance(model, string_types):
-            return self.M.get(model, self.S.userspace)
+            return self.Q.app(model, self.S.userspace)
         return model if model else self.generic
 
 

File graphalchemy/generics/collectors.py

 # -*- coding: utf-8 -*-
 '''generic collectors'''
 
-from graphalchemy.core import octopus
+from graphalchemy.core import octopus, direct
 from graphalchemy.mixins.collectors import LinksMixin, NodesMixin
 
 __all__ = ('Links', 'Nodes')
 
 # settings
 conf = octopus.S
-# decorators
-direct = octopus.context.direct
 
 
 class Links(LinksMixin):

File graphalchemy/generics/elements.py

 # pylint: disable-msg=w0201
 '''generic element models'''
 
-from graphalchemy.core import octopus
+from graphalchemy.core import octopus, defer, direct
 from graphalchemy.mixins.elements import LinkMixin, NodeMixin, ElementMixin
 
 __all__ = ('Link', 'Node')
 
 # settings
 conf = octopus.S
-# decorators
-direct = octopus.context.direct
-defer = octopus.context.defer
 
 
 class Generic(ElementMixin, octopus.process.thing):

File graphalchemy/graphs.py

 
 from stuf.utils import clsname
 
-from graphalchemy.core import octopus
+from graphalchemy.core import octopus, subscribe
 
 __all__ = ['Graph']
 
 # settings
 conf = octopus.S
-# decorators
-subscribe = octopus.context.subscribe
 
 
 class Session(octopus.workflow.session):
         # database configuration in url format
         self.url = url
         # open database
-        self._db = self.apply(database, required.backends, url)
+        self._db = self.Q.apply(database, required.backends, url)
         # add manager instance to appspace
-        self.set(self, graph_manager, userspace)
+        self.Q.add(self, graph_manager, userspace)
         # add data source to appspace
-        self.set(self._db, self.S.key.backend, userspace)
+        self.Q.add(self._db, self.S.key.backend, userspace)
 
     def __repr__(self):
         return '{name}@{url}'.format(

File graphalchemy/managers.py

 # -*- coding: utf-8 -*-
 '''graph element managers'''
 
-from graphalchemy.core import octopus
+from graphalchemy.core import octopus, direct, subscribe
 
 __all__ = ('Links', 'Nodes')
 
 reader = conf.reader
 wrapper = conf.wrapper
 writer = conf.writer
-# decorators
-direct = octopus.context.direct
-factory = octopus.context.factory
-subscribe = octopus.context.subscribe
 
 
 class Manager(octopus.workflow.flow):

File graphalchemy/mixins/collectors.py

 conf = octopus.S
 appspace = conf.appspace
 finder = conf.model.finder
-# decorators
-direct = octopus.context.direct
 
 
 class CollectorsMixin(octopus.context.thing):

File graphalchemy/mixins/elements.py

 
 from stuf.utils import both, getcls, lazy, clsname, either
 
-from graphalchemy.core import octopus
+from graphalchemy.core import octopus, defer, direct
 
 __all__ = ('LinksMixin', 'NodesMixin')
 
 # settings
 conf = getattr(octopus, 'S')
-# decorators
-defer = octopus.context.defer
-direct = octopus.context.direct
 
 
 class ElementMixin(object):

File graphalchemy/models/collectors.py

 
 from stuf.utils import lazy
 
-from graphalchemy.core import octopus
+from graphalchemy.core import octopus, direct
 from graphalchemy.mixins.collectors import NodesMixin
 
 __all__ = ('In', 'Nodes', 'Out')
 
 # settings
 conf = octopus.S
-# decorators
-direct = octopus.context.direct
 
 
 class Nodes(NodesMixin):

File graphalchemy/models/elements.py

 
 from stuf.utils import lazy_class, selfname
 
-from graphalchemy.core import octopus
 from graphalchemy.errors import ReversionError
+from graphalchemy.core import octopus, direct, defer
 from graphalchemy.mixins.elements import NodeMixin, ElementMixin
 
 __all__ = ['Node']
 
 # settings
 conf = octopus.S
-# decorators
-class_defer = octopus.context.class_defer
-defer = octopus.context.defer
-direct = octopus.context.direct
 
 
 class Node(NodeMixin, ElementMixin, octopus.workflow.thing):
 
     @classmethod
     def _link(cls):
-        return cls.M.get(cls.S.generic.element.link, cls.S.generics)
+        return cls.Q.app(cls.S.generic.element.link, cls.S.generics)
 
     @defer
     def _versioning(self, diff):

File graphalchemy/readers.py

 
 from appspace import AppLookupError
 
-from graphalchemy.core import octopus
+from graphalchemy.core import octopus, direct, service, factory
 
 __all__ = ('Links', 'Nodes')
 
 # settings
 conf = octopus.S
-# decorators
-direct = octopus.context.direct
-factory = octopus.context.factory
-service = octopus.context.service
 
 
 class Reader(octopus.context.publisher):
             anchor_link = C.anchor_link
             S = self.S
             userspace = S.userspace
-            return self.M.get(anchor_link, userspace)
+            return self.Q.app(anchor_link, userspace)
         except AppLookupError:
             label = S.anchor.label
             anchor = self.filter_by(C.index, label, label)
             if anchor:
-                self.M.set(anchor, anchor_link, userspace)
+                self.Q.add(anchor, anchor_link, userspace)
                 return anchor
             
     def close(self):
             if model is None:
                 model = self._finder(model)
             C = model.C
-            return self.M.get(C.reference_link, S.userspace)
+            return self.Q.app(C.reference_link, S.userspace)
         except AppLookupError:
             label = S.reference.label
             ref = self.filter_by(C.index, label, label)
             if ref:
-                self.M.set(ref, C.reference_link, S.userspace)
+                self.Q.add(ref, C.reference_link, S.userspace)
                 return ref
 
     def root(self):
         '''
         try:
             S = self.S
-            return self.M.get(S.root, S.userspace)
+            return self.Q.app(S.root, S.userspace)
         except AppLookupError:
             root = self.r.root
             root = self._finder(element=root)(root)
-            self.M.set(root, S.root, S.userspace)
+            self.Q.add(root, S.root, S.userspace)
             return root
 
     def walk(self, this, direction=None, label=None, keys=None, end='end'):

File graphalchemy/wrappers.py

 # -*- coding: utf-8 -*-
 '''graph model wrappers'''
 
-from graphalchemy.core import octopus
+from graphalchemy.core import octopus, direct, subscribe
 
 __all__ = ('Links', 'Nodes')
 
 finder = conf.model.finder
 reader = conf.reader
 writer = conf.writer
-# decorators
-direct = octopus.context.direct
-subscribe = octopus.context.subscribe
 
 
 class Wrapper(octopus.workflow.flow):
 
     # node model finder
     _finder = direct(finder.node, appspace)
-    # mode reader
+    # node reader
     _reader = subscribe(reader.node, appspace)
     # node writer
     _writer = subscribe(writer.node, appspace)

File graphalchemy/writers.py

 import nanotime
 from markupsafe import escape
 
-from graphalchemy.core import octopus
+from graphalchemy.core import octopus, defer, direct, factory, service
 
 __all__ = ('Links', 'Nodes')
 
 # settings
 conf = octopus.S
-appspace = conf.appspace
 backends = conf.backends
 db = conf.key.db
-# decorators
-defer = octopus.context.defer
-direct = octopus.context.direct
-factory = octopus.context.factory
-service = octopus.context.service
 
 
 class Writer(octopus.context.publisher):
     '''graph link writer'''
 
     # link model finder
-    _finder = direct(conf.model.finder.link, appspace)
+    _finder = direct(conf.model.finder.link, conf.appspace)
     # direct link reader
     r = factory(conf.read.link, backends, db)
     # direct link writer
         '''
         if kw is None:
             kw = {}
-        kw.update(_created=self.now(), _uuid=self.A.uuid())
+        kw.update(_created=self.now(), _uuid=self.Q.uuid())
         return self.w.build(link, start, end, **kw)
 
 
     '''graph node writer'''
 
     # node model finder
-    _finder = direct(conf.model.finder.node, appspace)
+    _finder = direct(conf.model.finder.node, conf.appspace)
     # direct node reader
     r = factory(conf.read.node, backends, db)
     # direct node writer
         slug_from = C.slug_from
         if not slug_from:
             return
-        slug = tmpslug = self.A.slugify(properties[slug_from])
+        slug = tmpslug = self.Q.slugify(properties[slug_from])
         slug_field = C.slug_field
         # loop until unique slug is located
         filter_by = self.r.filter_by
             return node
         data = dict(
             _created=self.now(),
-            _uuid=self.A.uuid(),
+            _uuid=self.Q.uuid(),
             text=S.description.format(name=name),
         )
         data.update(kw)
         if model is None:
             model = self._finder(model)
         C = model.C
-        data.update(_created=self.now(), _model=C.name, _uuid=self.A.uuid())
+        data.update(_created=self.now(), _model=C.name, _uuid=self.Q.uuid())
         # number of versions to maintain
         if C.versioned:
             data['_versions'] = 0
         @param data: data
         @param model: graph model (default: None)
         '''
-        data.update(_created=self.now(), _uuid=self.A.uuid())
+        data.update(_created=self.now(), _uuid=self.Q.uuid())
         return self.w.build(data)
 
     @service('model')
         h = self
         data = dict(
             _created=h.now(),
-            _uuid=self.A.uuid(),
+            _uuid=self.Q.uuid(),
             text=S.description.format(name=name),
         )
         data.update(kw)