diff --git a/README.txt b/README.txt index 3041d14..3ed2701 100755 --- a/README.txt +++ b/README.txt @@ -20,7 +20,6 @@ with lower-level aspects like type or state management. >>> from zope import component >>> from zope.app import zapi - >>> from zope.app.tests import ztapi >>> from zope.interface import Interface >>> from zope.publisher.browser import TestRequest @@ -54,16 +53,12 @@ Now we want to relate the second concept to the first one. In order to do this we first have to provide a relation registry. For testing we use a simple dummy implementation. - >>> from zope.app.intid.interfaces import IIntIds >>> from cybertools.relation.tests import IntIdsStub - >>> from zope.app.testing import ztapi - >>> ztapi.provideUtility(IIntIds, IntIdsStub()) + >>> component.provideUtility(IntIdsStub()) >>> from cybertools.relation.interfaces import IRelationRegistry >>> from cybertools.relation.registry import DummyRelationRegistry - >>> ztapi.provideUtility(IRelationRegistry, DummyRelationRegistry()) + >>> component.provideUtility(DummyRelationRegistry()) >>> from cybertools.relation.registry import RelationRegistry - >>> #ztapi.provideUtility(IRelationRegistry, RelationRegistry()) - >>> #zapi.getUtility(IRelationRegistry).setupIndexes() As relationships are based on predicates that are themselves concepts we also need a default predicate concept; the default name for this is @@ -124,7 +119,7 @@ type manager. >>> from cybertools.typology.interfaces import ITypeManager >>> from loops.interfaces import ILoopsObject >>> from loops.type import LoopsTypeManager, LoopsType - >>> ztapi.provideAdapter(ILoopsObject, ITypeManager, LoopsTypeManager) + >>> component.provideAdapter(LoopsTypeManager, (ILoopsObject,), ITypeManager) >>> from loops.concept import ConceptTypeSourceList >>> types = ConceptTypeSourceList(cc1) @@ -205,8 +200,7 @@ types and predicates. >>> from loops.browser.common import LoopsTerms >>> from zope.app.form.browser.interfaces import ITerms >>> from zope.schema.interfaces import IIterableSource - >>> ztapi.provideAdapter(IIterableSource, ITerms, LoopsTerms, - ... with=(IBrowserRequest,)) + >>> component.provideAdapter(LoopsTerms, (IIterableSource, IBrowserRequest), ITerms) >>> sorted((t.title, t.token) for t in view.conceptTypes()) [(u'Topic', '.loops/concepts/topic'), (u'Type', '.loops/concepts/type'), @@ -421,8 +415,8 @@ out - this is usually done through ZCML.) >>> from loops.util import removeTargetRelation >>> from loops.interfaces import ITargetRelation >>> from cybertools.relation.interfaces import IRelationInvalidatedEvent - >>> ztapi.subscribe([ITargetRelation, IRelationInvalidatedEvent], None, - ... removeTargetRelation) + >>> component.getSiteManager().registerHandler(removeTargetRelation, + ... (ITargetRelation, IRelationInvalidatedEvent)) >>> m111.target = cc1 >>> m111.target is cc1 @@ -493,10 +487,8 @@ view; these views we have to provide as multi-adapters: >>> from loops.browser.node import ConfigureView >>> from loops.browser.resource import DocumentView, ResourceView - >>> ztapi.provideAdapter(IDocument, Interface, DocumentView, - ... with=(IBrowserRequest,)) - >>> ztapi.provideAdapter(IResource, Interface, ResourceView, - ... with=(IBrowserRequest,)) + >>> component.provideAdapter(DocumentView, (IDocument, IBrowserRequest), Interface) + >>> component.provideAdapter(ResourceView, (IResource, IBrowserRequest), Interface) >>> form = {'action': 'create', 'create.title': 'New Resource', ... 'create.type': 'loops.resource.MediaAsset',} @@ -538,11 +530,10 @@ view for rendering.) >>> from zope.component.interfaces import IFactory >>> from zope.app.renderer import rest - >>> ztapi.provideUtility(IFactory, rest.ReStructuredTextSourceFactory, - ... 'zope.source.rest') - >>> ztapi.provideAdapter(rest.IReStructuredTextSource, Interface, - ... rest.ReStructuredTextToHTMLRenderer, - ... with=(IBrowserRequest,)) + >>> component.provideUtility(rest.ReStructuredTextSourceFactory, IFactory, + ... 'zope.source.rest') + >>> component.provideAdapter(rest.ReStructuredTextToHTMLRenderer, + ... (rest.IReStructuredTextSource, IBrowserRequest), Interface) >>> m112.target = doc1 @@ -557,18 +548,6 @@ view for rendering.) >>> view.renderTarget() u'
Test data
\nAnother paragraph
\n' -It is possible to edit a target's attributes directly in an -edit form provided by the node: - - >>> from loops.target import DocumentProxy, MediaAssetProxy - >>> ztapi.provideAdapter(INode, IDocumentView, DocumentProxy) - >>> ztapi.provideAdapter(INode, IMediaAssetView, MediaAssetProxy) - - >>> proxy = zapi.getAdapter(m111, IDocumentView) - >>> proxy.title = u'Set via proxy' - >>> resources['doc1'].title - u'Set via proxy' - If the target object is removed from its container all references to it are removed as well. (To make this work we have to handle the IObjectRemovedEvent; this is usually done via ZCML in the @@ -577,14 +556,26 @@ cybertools.relation package.) >>> from zope.app.container.interfaces import IObjectRemovedEvent >>> from zope.interface import Interface >>> from cybertools.relation.registry import invalidateRelations - >>> ztapi.subscribe([Interface, IObjectRemovedEvent], None, - ... invalidateRelations) + >>> component.getSiteManager().registerHandler(invalidateRelations, + ... (Interface, IObjectRemovedEvent)) >>> del resources['doc1'] >>> m111.target >>> IMediaAssetView.providedBy(m111) False +Views Related to Virtual Targets +-------------------------------- + +From a node usually any object in the concept or resource space can +be accessed as a `virtual target`. This is done by putting ".targetNNN" +at the end of the URL, with NNN being the unique id of the concept +or resource. + + >>> from loops.view import NodeTraverser + >>> from zope.publisher.interfaces.browser import IBrowserPublisher + >>> component.provideAdapter(NodeTraverser, provides=IBrowserPublisher) + Ordering Nodes -------------- diff --git a/base.py b/base.py index babc7fc..b261276 100644 --- a/base.py +++ b/base.py @@ -23,8 +23,10 @@ $Id$ """ +from zope.app.container.btree import BTreeContainer from zope.app.folder.folder import Folder -from zope.app.traversing.api import getPath, traverse +from zope.app.folder.interfaces import IFolder +from zope.traversing.api import getPath, traverse from zope.interface import implements from loops.interfaces import ILoops @@ -33,9 +35,17 @@ loopsPrefix = '.loops' class Loops(Folder): +#class Loops(BTreeContainer): implements(ILoops) + def getSiteManager(self): + return self.__parent__.getSiteManager() + + @property + def _SampleContainer__data(self): + return self.data + _skinName = '' def getSkinName(self): return self._skinName def setSkinName(self, skinName): self._skinName = skinName diff --git a/browser/common.py b/browser/common.py index 2a1198d..eae5999 100644 --- a/browser/common.py +++ b/browser/common.py @@ -23,7 +23,7 @@ $Id$ """ from zope.app import zapi -from zope.app.dublincore.interfaces import IZopeDublinCore +from zope.dublincore.interfaces import IZopeDublinCore from zope.app.form.browser.interfaces import ITerms from zope.cachedescriptors.property import Lazy from zope.dottedname.resolve import resolve @@ -31,8 +31,9 @@ from zope.formlib import form from zope.formlib.form import FormFields from zope.formlib.namedtemplate import NamedTemplate from zope.interface import Interface, implements -from zope.app.publisher.browser import applySkin -from zope.publisher.interfaces.browser import ISkin +from zope.publisher.browser import applySkin +#from zope.publisher.interfaces.browser import ISkin +from zope.publisher.interfaces.browser import IBrowserSkinType from zope import schema from zope.schema.vocabulary import SimpleTerm from zope.security import canAccess, canWrite @@ -92,7 +93,7 @@ class BaseView(GenericView): def setSkin(self, skinName): skin = None if skinName and IView.providedBy(self.context): - skin = zapi.queryUtility(ISkin, skinName) + skin = zapi.queryUtility(IBrowserSkinType, skinName) if skin: applySkin(self.request, skin) self.skin = skin diff --git a/browser/concept.py b/browser/concept.py index 2a7c809..ee0be16 100644 --- a/browser/concept.py +++ b/browser/concept.py @@ -25,7 +25,7 @@ $Id$ from zope import interface, component, schema from zope.app import zapi from zope.app.catalog.interfaces import ICatalog -from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent +from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent from zope.app.container.contained import ObjectRemovedEvent from zope.app.form.browser.interfaces import ITerms from zope.app.form.interfaces import IDisplayWidget diff --git a/browser/configure.zcml b/browser/configure.zcml index c61e6bb..b7c477d 100644 --- a/browser/configure.zcml +++ b/browser/configure.zcml @@ -494,7 +494,7 @@ menu="zmi_views" title="Configure" /> -