loops/rest
2019-04-26 17:13:59 +02:00
..
__init__.py starting to set up a REST module for all sorts of external communication 2007-01-19 15:22:09 +00:00
common.py starting to set up a REST module for all sorts of external communication 2007-01-19 15:22:09 +00:00
configure.zcml bug fix in rest/configure.zcml because of Zope 3.3 2007-02-18 15:30:09 +00:00
README.txt move QueryConcept stuff to loops.expert (keeping old query module for backward compatibility); work in progress: child-based queries with actions 2008-10-23 13:35:23 +00:00
tests.py fix tests/doctests according to current ZTK and BlueBream versions 2019-04-26 17:13:59 +02:00
traversal.py starting to set up a REST module for all sorts of external communication 2007-01-19 15:22:09 +00:00

===============================================================
loops.xmlrpc
===============================================================

  ($Id$)

Let's do some basic set up

  >>> from zope.app.testing.setup import placefulSetUp, placefulTearDown
  >>> site = placefulSetUp(True)

  >>> from zope import component, interface
  >>> from zope.publisher.browser import TestRequest

and setup a simple loops site with a concept manager and some concepts
(with all the type machinery, what in real life is done via standard
ZCML setup):

  >>> from cybertools.relation.registry import DummyRelationRegistry
  >>> component.provideUtility(DummyRelationRegistry())
  >>> from cybertools.relation.tests import IntIdsStub
  >>> component.provideUtility(IntIdsStub())

  >>> from loops.type import ConceptType, TypeConcept
  >>> component.provideAdapter(ConceptType)
  >>> component.provideAdapter(TypeConcept)

  >>> from loops.base import Loops
  >>> loopsRoot = site['loops'] = Loops()

  >>> from loops.setup import SetupManager
  >>> setup = SetupManager(loopsRoot)
  >>> concepts, resources, views = setup.setup()

Let's look what setup has provided us with:

  >>> sorted(concepts)
  [u'domain', u'file', u'hasType', u'note', u'predicate',
   u'standard', u'textdocument', u'type']


loops Traversal
===============

The loops root object provides a traversal mechanism that goes beyond the
standard container traversal. One can directly access objects by their
unique id or via a symbolic name (like `startObject`); usually the traverser
returns a REST view of the object.

  >>> from loops.rest.traversal import LoopsTraverser
  >>> from zope.publisher.interfaces.browser import IBrowserPublisher
  >>> component.provideAdapter(LoopsTraverser, provides=IBrowserPublisher)

  >>> from loops.rest.common import ConceptView
  >>> component.provideAdapter(ConceptView)

Navigation typically starts at a start object, which by default ist the
domain type concept (or the top-level type concept, if there is no domain type):

  >>> request = TestRequest()
  >>> obj = LoopsTraverser(loopsRoot, request).publishTraverse(request, 'startObject')
  >>> obj
  <loops.rest.common.ConceptView object at ...>
  >>> obj.context.title
  u'Domain'

The traversal adapter returns a view that when called renders the
representation of its context object:

  >>> obj()
  'Hello REST'


Fin de partie
=============

  >>> placefulTearDown()