eliminate Zope 3.3 deprecation messages from loops test
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1586 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
47319d25e8
commit
0f56075002
24 changed files with 134 additions and 97 deletions
61
README.txt
61
README.txt
|
@ -20,7 +20,6 @@ with lower-level aspects like type or state management.
|
||||||
|
|
||||||
>>> from zope import component
|
>>> from zope import component
|
||||||
>>> from zope.app import zapi
|
>>> from zope.app import zapi
|
||||||
>>> from zope.app.tests import ztapi
|
|
||||||
>>> from zope.interface import Interface
|
>>> from zope.interface import Interface
|
||||||
>>> from zope.publisher.browser import TestRequest
|
>>> 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
|
In order to do this we first have to provide a relation registry. For
|
||||||
testing we use a simple dummy implementation.
|
testing we use a simple dummy implementation.
|
||||||
|
|
||||||
>>> from zope.app.intid.interfaces import IIntIds
|
|
||||||
>>> from cybertools.relation.tests import IntIdsStub
|
>>> from cybertools.relation.tests import IntIdsStub
|
||||||
>>> from zope.app.testing import ztapi
|
>>> component.provideUtility(IntIdsStub())
|
||||||
>>> ztapi.provideUtility(IIntIds, IntIdsStub())
|
|
||||||
>>> from cybertools.relation.interfaces import IRelationRegistry
|
>>> from cybertools.relation.interfaces import IRelationRegistry
|
||||||
>>> from cybertools.relation.registry import DummyRelationRegistry
|
>>> from cybertools.relation.registry import DummyRelationRegistry
|
||||||
>>> ztapi.provideUtility(IRelationRegistry, DummyRelationRegistry())
|
>>> component.provideUtility(DummyRelationRegistry())
|
||||||
>>> from cybertools.relation.registry import RelationRegistry
|
>>> 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
|
As relationships are based on predicates that are themselves concepts we
|
||||||
also need a default predicate concept; the default name for this is
|
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 cybertools.typology.interfaces import ITypeManager
|
||||||
>>> from loops.interfaces import ILoopsObject
|
>>> from loops.interfaces import ILoopsObject
|
||||||
>>> from loops.type import LoopsTypeManager, LoopsType
|
>>> from loops.type import LoopsTypeManager, LoopsType
|
||||||
>>> ztapi.provideAdapter(ILoopsObject, ITypeManager, LoopsTypeManager)
|
>>> component.provideAdapter(LoopsTypeManager, (ILoopsObject,), ITypeManager)
|
||||||
|
|
||||||
>>> from loops.concept import ConceptTypeSourceList
|
>>> from loops.concept import ConceptTypeSourceList
|
||||||
>>> types = ConceptTypeSourceList(cc1)
|
>>> types = ConceptTypeSourceList(cc1)
|
||||||
|
@ -205,8 +200,7 @@ types and predicates.
|
||||||
>>> from loops.browser.common import LoopsTerms
|
>>> from loops.browser.common import LoopsTerms
|
||||||
>>> from zope.app.form.browser.interfaces import ITerms
|
>>> from zope.app.form.browser.interfaces import ITerms
|
||||||
>>> from zope.schema.interfaces import IIterableSource
|
>>> from zope.schema.interfaces import IIterableSource
|
||||||
>>> ztapi.provideAdapter(IIterableSource, ITerms, LoopsTerms,
|
>>> component.provideAdapter(LoopsTerms, (IIterableSource, IBrowserRequest), ITerms)
|
||||||
... with=(IBrowserRequest,))
|
|
||||||
|
|
||||||
>>> sorted((t.title, t.token) for t in view.conceptTypes())
|
>>> sorted((t.title, t.token) for t in view.conceptTypes())
|
||||||
[(u'Topic', '.loops/concepts/topic'), (u'Type', '.loops/concepts/type'),
|
[(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.util import removeTargetRelation
|
||||||
>>> from loops.interfaces import ITargetRelation
|
>>> from loops.interfaces import ITargetRelation
|
||||||
>>> from cybertools.relation.interfaces import IRelationInvalidatedEvent
|
>>> from cybertools.relation.interfaces import IRelationInvalidatedEvent
|
||||||
>>> ztapi.subscribe([ITargetRelation, IRelationInvalidatedEvent], None,
|
>>> component.getSiteManager().registerHandler(removeTargetRelation,
|
||||||
... removeTargetRelation)
|
... (ITargetRelation, IRelationInvalidatedEvent))
|
||||||
|
|
||||||
>>> m111.target = cc1
|
>>> m111.target = cc1
|
||||||
>>> m111.target is 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.node import ConfigureView
|
||||||
>>> from loops.browser.resource import DocumentView, ResourceView
|
>>> from loops.browser.resource import DocumentView, ResourceView
|
||||||
>>> ztapi.provideAdapter(IDocument, Interface, DocumentView,
|
>>> component.provideAdapter(DocumentView, (IDocument, IBrowserRequest), Interface)
|
||||||
... with=(IBrowserRequest,))
|
>>> component.provideAdapter(ResourceView, (IResource, IBrowserRequest), Interface)
|
||||||
>>> ztapi.provideAdapter(IResource, Interface, ResourceView,
|
|
||||||
... with=(IBrowserRequest,))
|
|
||||||
|
|
||||||
>>> form = {'action': 'create', 'create.title': 'New Resource',
|
>>> form = {'action': 'create', 'create.title': 'New Resource',
|
||||||
... 'create.type': 'loops.resource.MediaAsset',}
|
... 'create.type': 'loops.resource.MediaAsset',}
|
||||||
|
@ -538,11 +530,10 @@ view for rendering.)
|
||||||
|
|
||||||
>>> from zope.component.interfaces import IFactory
|
>>> from zope.component.interfaces import IFactory
|
||||||
>>> from zope.app.renderer import rest
|
>>> from zope.app.renderer import rest
|
||||||
>>> ztapi.provideUtility(IFactory, rest.ReStructuredTextSourceFactory,
|
>>> component.provideUtility(rest.ReStructuredTextSourceFactory, IFactory,
|
||||||
... 'zope.source.rest')
|
... 'zope.source.rest')
|
||||||
>>> ztapi.provideAdapter(rest.IReStructuredTextSource, Interface,
|
>>> component.provideAdapter(rest.ReStructuredTextToHTMLRenderer,
|
||||||
... rest.ReStructuredTextToHTMLRenderer,
|
... (rest.IReStructuredTextSource, IBrowserRequest), Interface)
|
||||||
... with=(IBrowserRequest,))
|
|
||||||
|
|
||||||
>>> m112.target = doc1
|
>>> m112.target = doc1
|
||||||
|
|
||||||
|
@ -557,18 +548,6 @@ view for rendering.)
|
||||||
>>> view.renderTarget()
|
>>> view.renderTarget()
|
||||||
u'<p>Test data</p>\n<p>Another paragraph</p>\n'
|
u'<p>Test data</p>\n<p>Another paragraph</p>\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
|
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
|
to it are removed as well. (To make this work we have to handle
|
||||||
the IObjectRemovedEvent; this is usually done via ZCML in the
|
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.app.container.interfaces import IObjectRemovedEvent
|
||||||
>>> from zope.interface import Interface
|
>>> from zope.interface import Interface
|
||||||
>>> from cybertools.relation.registry import invalidateRelations
|
>>> from cybertools.relation.registry import invalidateRelations
|
||||||
>>> ztapi.subscribe([Interface, IObjectRemovedEvent], None,
|
>>> component.getSiteManager().registerHandler(invalidateRelations,
|
||||||
... invalidateRelations)
|
... (Interface, IObjectRemovedEvent))
|
||||||
|
|
||||||
>>> del resources['doc1']
|
>>> del resources['doc1']
|
||||||
>>> m111.target
|
>>> m111.target
|
||||||
>>> IMediaAssetView.providedBy(m111)
|
>>> IMediaAssetView.providedBy(m111)
|
||||||
False
|
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
|
Ordering Nodes
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|
12
base.py
12
base.py
|
@ -23,8 +23,10 @@
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from zope.app.container.btree import BTreeContainer
|
||||||
from zope.app.folder.folder import Folder
|
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 zope.interface import implements
|
||||||
|
|
||||||
from loops.interfaces import ILoops
|
from loops.interfaces import ILoops
|
||||||
|
@ -33,9 +35,17 @@ loopsPrefix = '.loops'
|
||||||
|
|
||||||
|
|
||||||
class Loops(Folder):
|
class Loops(Folder):
|
||||||
|
#class Loops(BTreeContainer):
|
||||||
|
|
||||||
implements(ILoops)
|
implements(ILoops)
|
||||||
|
|
||||||
|
def getSiteManager(self):
|
||||||
|
return self.__parent__.getSiteManager()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _SampleContainer__data(self):
|
||||||
|
return self.data
|
||||||
|
|
||||||
_skinName = ''
|
_skinName = ''
|
||||||
def getSkinName(self): return self._skinName
|
def getSkinName(self): return self._skinName
|
||||||
def setSkinName(self, skinName): self._skinName = skinName
|
def setSkinName(self, skinName): self._skinName = skinName
|
||||||
|
|
|
@ -23,7 +23,7 @@ $Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.app import zapi
|
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.app.form.browser.interfaces import ITerms
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.dottedname.resolve import resolve
|
from zope.dottedname.resolve import resolve
|
||||||
|
@ -31,8 +31,9 @@ from zope.formlib import form
|
||||||
from zope.formlib.form import FormFields
|
from zope.formlib.form import FormFields
|
||||||
from zope.formlib.namedtemplate import NamedTemplate
|
from zope.formlib.namedtemplate import NamedTemplate
|
||||||
from zope.interface import Interface, implements
|
from zope.interface import Interface, implements
|
||||||
from zope.app.publisher.browser import applySkin
|
from zope.publisher.browser import applySkin
|
||||||
from zope.publisher.interfaces.browser import ISkin
|
#from zope.publisher.interfaces.browser import ISkin
|
||||||
|
from zope.publisher.interfaces.browser import IBrowserSkinType
|
||||||
from zope import schema
|
from zope import schema
|
||||||
from zope.schema.vocabulary import SimpleTerm
|
from zope.schema.vocabulary import SimpleTerm
|
||||||
from zope.security import canAccess, canWrite
|
from zope.security import canAccess, canWrite
|
||||||
|
@ -92,7 +93,7 @@ class BaseView(GenericView):
|
||||||
def setSkin(self, skinName):
|
def setSkin(self, skinName):
|
||||||
skin = None
|
skin = None
|
||||||
if skinName and IView.providedBy(self.context):
|
if skinName and IView.providedBy(self.context):
|
||||||
skin = zapi.queryUtility(ISkin, skinName)
|
skin = zapi.queryUtility(IBrowserSkinType, skinName)
|
||||||
if skin:
|
if skin:
|
||||||
applySkin(self.request, skin)
|
applySkin(self.request, skin)
|
||||||
self.skin = skin
|
self.skin = skin
|
||||||
|
|
|
@ -25,7 +25,7 @@ $Id$
|
||||||
from zope import interface, component, schema
|
from zope import interface, component, schema
|
||||||
from zope.app import zapi
|
from zope.app import zapi
|
||||||
from zope.app.catalog.interfaces import ICatalog
|
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.container.contained import ObjectRemovedEvent
|
||||||
from zope.app.form.browser.interfaces import ITerms
|
from zope.app.form.browser.interfaces import ITerms
|
||||||
from zope.app.form.interfaces import IDisplayWidget
|
from zope.app.form.interfaces import IDisplayWidget
|
||||||
|
|
|
@ -494,7 +494,7 @@
|
||||||
menu="zmi_views" title="Configure"
|
menu="zmi_views" title="Configure"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<editform
|
<!--<editform
|
||||||
label="Edit Media Asset"
|
label="Edit Media Asset"
|
||||||
name="edit_target.html"
|
name="edit_target.html"
|
||||||
schema="loops.interfaces.IMediaAsset"
|
schema="loops.interfaces.IMediaAsset"
|
||||||
|
@ -514,7 +514,7 @@
|
||||||
template="edit.pt"
|
template="edit.pt"
|
||||||
permission="zope.ManageContent"
|
permission="zope.ManageContent"
|
||||||
menu="zmi_views" title="Edit Document"
|
menu="zmi_views" title="Edit Document"
|
||||||
/>
|
/>-->
|
||||||
|
|
||||||
<page
|
<page
|
||||||
name="node.html"
|
name="node.html"
|
||||||
|
@ -596,6 +596,14 @@
|
||||||
permission="zope.ManageContent"
|
permission="zope.ManageContent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<zope:view
|
||||||
|
type="zope.publisher.interfaces.browser.IBrowserRequest"
|
||||||
|
for="loops.interfaces.IFile"
|
||||||
|
provides="zope.app.form.interfaces.IInputWidget"
|
||||||
|
factory="loops.browser.form.UploadWidget"
|
||||||
|
permission="zope.Public"
|
||||||
|
/>
|
||||||
|
|
||||||
<zope:adapter factory="loops.browser.form.ResourceNameChooser" />
|
<zope:adapter factory="loops.browser.form.ResourceNameChooser" />
|
||||||
|
|
||||||
<!-- inner HTML views -->
|
<!-- inner HTML views -->
|
||||||
|
|
|
@ -25,10 +25,12 @@ $Id$
|
||||||
from zope import component, interface, schema
|
from zope import component, interface, schema
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
from zope.event import notify
|
from zope.event import notify
|
||||||
from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
|
from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
|
||||||
|
|
||||||
from zope.app.container.interfaces import INameChooser
|
from zope.app.container.interfaces import INameChooser
|
||||||
from zope.app.container.contained import NameChooser
|
from zope.app.container.contained import NameChooser
|
||||||
|
#from zope.app.content_types import guess_content_types
|
||||||
|
from zope.app.form.browser.textwidgets import FileWidget, TextAreaWidget
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.formlib.form import Form, EditForm, FormFields
|
from zope.formlib.form import Form, EditForm, FormFields
|
||||||
|
@ -49,6 +51,21 @@ from loops import util
|
||||||
from loops.util import _
|
from loops.util import _
|
||||||
|
|
||||||
|
|
||||||
|
# special widgets
|
||||||
|
|
||||||
|
class UploadWidget(FileWidget):
|
||||||
|
|
||||||
|
def _toFieldValue(self, input):
|
||||||
|
fn = getattr(input, 'filename', '') # zope.publisher.browser.FileUpload
|
||||||
|
self.request.form['filename'] = fn
|
||||||
|
if input:
|
||||||
|
self.request.form['_tempfilename'] = input.headers.get('_tempfilename')
|
||||||
|
# f = self.context
|
||||||
|
# f.extfiledata = tempfilename # provide for rename
|
||||||
|
# f.contentType = guess_content_types(fn)
|
||||||
|
return super(UploadWidget, self)._toFieldValue(input)
|
||||||
|
|
||||||
|
|
||||||
# forms
|
# forms
|
||||||
|
|
||||||
class ObjectForm(NodeView):
|
class ObjectForm(NodeView):
|
||||||
|
@ -84,6 +101,8 @@ class NoteWidgetController(object):
|
||||||
|
|
||||||
widgetControllers = {INote: NoteWidgetController}
|
widgetControllers = {INote: NoteWidgetController}
|
||||||
|
|
||||||
|
# specialWidgets = {(IFile, 'data'): UploadWidget}
|
||||||
|
|
||||||
|
|
||||||
class EditObjectForm(ObjectForm, EditForm):
|
class EditObjectForm(ObjectForm, EditForm):
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
<!-- macros for rendering edit/create forms
|
||||||
|
$Id$ -->
|
||||||
|
|
||||||
<metal:block define-macro="edit">
|
<metal:block define-macro="edit">
|
||||||
<form method="post" enctype="multipart/form-data">
|
<form method="post" enctype="multipart/form-data">
|
||||||
<input type="hidden" name="form.action" value="edit"
|
<input type="hidden" name="form.action" value="edit"
|
||||||
|
|
|
@ -23,7 +23,7 @@ $Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.app import zapi
|
from zope.app import zapi
|
||||||
from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
|
from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
|
||||||
from zope.event import notify
|
from zope.event import notify
|
||||||
from zope.formlib.form import FormFields
|
from zope.formlib.form import FormFields
|
||||||
from loops import Loops
|
from loops import Loops
|
||||||
|
|
|
@ -25,25 +25,22 @@ $Id$
|
||||||
from zope import component, interface, schema
|
from zope import component, interface, schema
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.app import zapi
|
from zope.app import zapi
|
||||||
from zope.app.annotation.interfaces import IAnnotations
|
from zope.annotation.interfaces import IAnnotations
|
||||||
from zope.app.catalog.interfaces import ICatalog
|
from zope.app.catalog.interfaces import ICatalog
|
||||||
from zope.app.container.browser.contents import JustContents
|
from zope.app.container.browser.contents import JustContents
|
||||||
#from zope.app.container.browser.adding import ContentAdding
|
|
||||||
from zope.app.container.browser.adding import Adding
|
from zope.app.container.browser.adding import Adding
|
||||||
from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
|
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
from zope.app.security.interfaces import IUnauthenticatedPrincipal
|
from zope.app.security.interfaces import IUnauthenticatedPrincipal
|
||||||
from zope.dottedname.resolve import resolve
|
from zope.dottedname.resolve import resolve
|
||||||
from zope.event import notify
|
from zope.event import notify
|
||||||
|
from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
|
||||||
|
from zope.lifecycleevent import Attributes
|
||||||
from zope.formlib.form import Form, FormFields
|
from zope.formlib.form import Form, FormFields
|
||||||
from zope.formlib.namedtemplate import NamedTemplate
|
from zope.formlib.namedtemplate import NamedTemplate
|
||||||
from zope.proxy import removeAllProxies
|
from zope.proxy import removeAllProxies
|
||||||
from zope.security import canAccess, canWrite
|
from zope.security import canAccess, canWrite
|
||||||
from zope.security.proxy import removeSecurityProxy
|
from zope.security.proxy import removeSecurityProxy
|
||||||
|
|
||||||
from zope.app.event.objectevent import ObjectModifiedEvent, Attributes
|
|
||||||
from zope.event import notify
|
|
||||||
|
|
||||||
from cybertools.ajax import innerHtml
|
from cybertools.ajax import innerHtml
|
||||||
from cybertools.browser import configurator
|
from cybertools.browser import configurator
|
||||||
from cybertools.browser.view import GenericView
|
from cybertools.browser.view import GenericView
|
||||||
|
|
|
@ -26,7 +26,7 @@ from zope.cachedescriptors.property import Lazy
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.app import zapi
|
from zope.app import zapi
|
||||||
from zope.app.catalog.interfaces import ICatalog
|
from zope.app.catalog.interfaces import ICatalog
|
||||||
from zope.app.dublincore.interfaces import ICMFDublinCore
|
from zope.dublincore.interfaces import ICMFDublinCore
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
from zope.app.security.interfaces import IUnauthenticatedPrincipal
|
from zope.app.security.interfaces import IUnauthenticatedPrincipal
|
||||||
from zope.formlib.form import FormFields
|
from zope.formlib.form import FormFields
|
||||||
|
|
|
@ -23,9 +23,9 @@ $Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.app import zapi
|
from zope.app import zapi
|
||||||
from zope.app.dublincore.interfaces import IZopeDublinCore
|
from zope.dublincore.interfaces import IZopeDublinCore
|
||||||
from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
|
from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter
|
||||||
from zope.app.dublincore.zopedublincore import ScalarProperty
|
from zope.dublincore.zopedublincore import ScalarProperty
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<interface interface=".interfaces.ILoops"
|
<interface interface=".interfaces.ILoops"
|
||||||
type="zope.app.content.interfaces.IContentType" />
|
type="zope.app.content.interfaces.IContentType" />
|
||||||
|
|
||||||
<content class=".Loops">
|
<class class="loops.Loops">
|
||||||
|
|
||||||
<implements
|
<implements
|
||||||
interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
|
interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
permission="zope.ManageContent"
|
permission="zope.ManageContent"
|
||||||
set_schema=".interfaces.ILoops" />
|
set_schema=".interfaces.ILoops" />
|
||||||
|
|
||||||
</content>
|
</class>
|
||||||
|
|
||||||
<!-- concept manager and concept -->
|
<!-- concept manager and concept -->
|
||||||
|
|
||||||
|
|
14
helpers.txt
14
helpers.txt
|
@ -15,7 +15,6 @@ Let's first do some basic imports
|
||||||
|
|
||||||
>>> from zope import interface, component
|
>>> from zope import interface, component
|
||||||
>>> from zope.app import zapi
|
>>> from zope.app import zapi
|
||||||
>>> from zope.app.tests import ztapi
|
|
||||||
>>> from zope.interface import Interface
|
>>> from zope.interface import Interface
|
||||||
>>> from zope.publisher.browser import TestRequest
|
>>> from zope.publisher.browser import TestRequest
|
||||||
|
|
||||||
|
@ -23,8 +22,7 @@ and provide a relation registry:
|
||||||
|
|
||||||
>>> from cybertools.relation.interfaces import IRelationRegistry
|
>>> from cybertools.relation.interfaces import IRelationRegistry
|
||||||
>>> from cybertools.relation.registry import DummyRelationRegistry
|
>>> from cybertools.relation.registry import DummyRelationRegistry
|
||||||
>>> from zope.app.testing import ztapi
|
>>> component.provideUtility(DummyRelationRegistry())
|
||||||
>>> ztapi.provideUtility(IRelationRegistry, DummyRelationRegistry())
|
|
||||||
|
|
||||||
and care for some type adapter machinery:
|
and care for some type adapter machinery:
|
||||||
|
|
||||||
|
@ -96,7 +94,7 @@ purpose:
|
||||||
|
|
||||||
>>> from cybertools.typology.interfaces import IType
|
>>> from cybertools.typology.interfaces import IType
|
||||||
>>> from loops.type import ConceptType
|
>>> from loops.type import ConceptType
|
||||||
>>> ztapi.provideAdapter(IConcept, IType, ConceptType)
|
>>> component.provideAdapter(ConceptType)
|
||||||
>>> cc1_type = IType(cc1)
|
>>> cc1_type = IType(cc1)
|
||||||
|
|
||||||
As we have not yet associated a type with one of our content objects we get
|
As we have not yet associated a type with one of our content objects we get
|
||||||
|
@ -182,7 +180,7 @@ Now let's have a look at resources.
|
||||||
|
|
||||||
>>> from loops.interfaces import IResource, IDocument
|
>>> from loops.interfaces import IResource, IDocument
|
||||||
>>> from loops.type import ResourceType
|
>>> from loops.type import ResourceType
|
||||||
>>> ztapi.provideAdapter(IDocument, IType, ResourceType)
|
>>> component.provideAdapter(ResourceType, (IDocument,), IType)
|
||||||
|
|
||||||
>>> doc1_type = IType(doc1)
|
>>> doc1_type = IType(doc1)
|
||||||
>>> doc1_type.title
|
>>> doc1_type.title
|
||||||
|
@ -231,7 +229,7 @@ get a type manager from all loops objects, always with the same context:
|
||||||
>>> from cybertools.typology.interfaces import ITypeManager
|
>>> from cybertools.typology.interfaces import ITypeManager
|
||||||
>>> from loops.interfaces import ILoopsObject
|
>>> from loops.interfaces import ILoopsObject
|
||||||
>>> from loops.type import LoopsTypeManager
|
>>> from loops.type import LoopsTypeManager
|
||||||
>>> ztapi.provideAdapter(ILoopsObject, ITypeManager, LoopsTypeManager)
|
>>> component.provideAdapter(LoopsTypeManager)
|
||||||
>>> typeManager = ITypeManager(loopsRoot)
|
>>> typeManager = ITypeManager(loopsRoot)
|
||||||
>>> typeManager.context == ITypeManager(cc1).context == loopsRoot
|
>>> typeManager.context == ITypeManager(cc1).context == loopsRoot
|
||||||
True
|
True
|
||||||
|
@ -366,8 +364,8 @@ view/multi-adapter with this name:
|
||||||
Controlling presentation using view properties
|
Controlling presentation using view properties
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
|
||||||
>>> from zope.app.annotation.interfaces import IAttributeAnnotatable, IAnnotations
|
>>> from zope.annotation.interfaces import IAttributeAnnotatable, IAnnotations
|
||||||
>>> from zope.app.annotation.attribute import AttributeAnnotations
|
>>> from zope.annotation.attribute import AttributeAnnotations
|
||||||
>>> from loops.interfaces import INode
|
>>> from loops.interfaces import INode
|
||||||
|
|
||||||
First we have to make sure we can use attribute annotations with our nodes,
|
First we have to make sure we can use attribute annotations with our nodes,
|
||||||
|
|
|
@ -29,7 +29,7 @@ from zope.app.container.constraints import contains, containers
|
||||||
from zope.app.container.interfaces import IContainer, IOrderedContainer
|
from zope.app.container.interfaces import IContainer, IOrderedContainer
|
||||||
from zope.app.file.interfaces import IImage as IBaseAsset
|
from zope.app.file.interfaces import IImage as IBaseAsset
|
||||||
from zope.app.folder.interfaces import IFolder
|
from zope.app.folder.interfaces import IFolder
|
||||||
from zope.app.size.interfaces import ISized
|
from zope.size.interfaces import ISized
|
||||||
from cybertools.relation.interfaces import IRelation
|
from cybertools.relation.interfaces import IRelation
|
||||||
|
|
||||||
import util
|
import util
|
||||||
|
|
|
@ -21,7 +21,7 @@ ZCML setup):
|
||||||
>>> from cybertools.relation.interfaces import IRelationRegistry
|
>>> from cybertools.relation.interfaces import IRelationRegistry
|
||||||
>>> from cybertools.relation.registry import DummyRelationRegistry
|
>>> from cybertools.relation.registry import DummyRelationRegistry
|
||||||
>>> relations = DummyRelationRegistry()
|
>>> relations = DummyRelationRegistry()
|
||||||
>>> component.provideUtility(relations, IRelationRegistry)
|
>>> component.provideUtility(relations)
|
||||||
|
|
||||||
>>> from cybertools.typology.interfaces import IType
|
>>> from cybertools.typology.interfaces import IType
|
||||||
>>> from loops.interfaces import IConcept, ITypeConcept
|
>>> from loops.interfaces import IConcept, ITypeConcept
|
||||||
|
@ -174,19 +174,14 @@ with a principal folder:
|
||||||
>>> from zope.app.appsetup.bootstrap import ensureUtility
|
>>> from zope.app.appsetup.bootstrap import ensureUtility
|
||||||
>>> from zope.app.authentication.authentication import PluggableAuthentication
|
>>> from zope.app.authentication.authentication import PluggableAuthentication
|
||||||
>>> ensureUtility(site, IAuthentication, '', PluggableAuthentication,
|
>>> ensureUtility(site, IAuthentication, '', PluggableAuthentication,
|
||||||
... copy_to_zlog=False)
|
... copy_to_zlog=False, asObject=True)
|
||||||
''
|
<...PluggableAuthentication...>
|
||||||
>>> pau = component.getUtility(IAuthentication, context=site)
|
>>> pau = component.getUtility(IAuthentication, context=site)
|
||||||
|
|
||||||
>>> from zope.app.component.site import UtilityRegistration
|
|
||||||
>>> from zope.app.authentication.principalfolder import PrincipalFolder
|
>>> from zope.app.authentication.principalfolder import PrincipalFolder
|
||||||
>>> from zope.app.authentication.interfaces import IAuthenticatorPlugin
|
>>> from zope.app.authentication.interfaces import IAuthenticatorPlugin
|
||||||
>>> pFolder = PrincipalFolder('loops.')
|
>>> pFolder = PrincipalFolder('loops.')
|
||||||
>>> pau['loops'] = pFolder
|
>>> pau['loops'] = pFolder
|
||||||
>>> reg = UtilityRegistration('loops', IAuthenticatorPlugin, pFolder)
|
|
||||||
>>> pau.registrationManager.addRegistration(reg)
|
|
||||||
'UtilityRegistration'
|
|
||||||
>>> reg.status = u'Active'
|
|
||||||
>>> pau.authenticatorPlugins = ('loops',)
|
>>> pau.authenticatorPlugins = ('loops',)
|
||||||
|
|
||||||
In addition, we have to create at least one node in the view space
|
In addition, we have to create at least one node in the view space
|
||||||
|
|
|
@ -29,7 +29,7 @@ from zope.interface import implements
|
||||||
from zope.app.authentication.interfaces import IPluggableAuthentication
|
from zope.app.authentication.interfaces import IPluggableAuthentication
|
||||||
from zope.app.authentication.interfaces import IAuthenticatorPlugin
|
from zope.app.authentication.interfaces import IAuthenticatorPlugin
|
||||||
from zope.app.authentication.principalfolder import InternalPrincipal
|
from zope.app.authentication.principalfolder import InternalPrincipal
|
||||||
from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
|
from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
|
||||||
from zope.app.security.interfaces import IAuthentication
|
from zope.app.security.interfaces import IAuthentication
|
||||||
from zope.event import notify
|
from zope.event import notify
|
||||||
from zope.i18nmessageid import MessageFactory
|
from zope.i18nmessageid import MessageFactory
|
||||||
|
|
|
@ -9,7 +9,7 @@ from loops.organize.party import Person
|
||||||
class Test(unittest.TestCase):
|
class Test(unittest.TestCase):
|
||||||
"Basic tests for the organize sub-package."
|
"Basic tests for the organize sub-package."
|
||||||
|
|
||||||
def testSomethin(self):
|
def testSomething(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,9 @@ def getPrincipalFolder(context=None):
|
||||||
if not authPluginId in pau.authenticatorPlugins:
|
if not authPluginId in pau.authenticatorPlugins:
|
||||||
raise ValueError(u'There is no loops authenticator '
|
raise ValueError(u'There is no loops authenticator '
|
||||||
'plugin available.')
|
'plugin available.')
|
||||||
return component.queryUtility(IAuthenticatorPlugin, authPluginId,
|
#return component.queryUtility(IAuthenticatorPlugin, authPluginId,
|
||||||
context=pau)
|
# context=pau)
|
||||||
|
for name, plugin in pau.getAuthenticatorPlugins():
|
||||||
|
if name == authPluginId:
|
||||||
|
return plugin
|
||||||
|
|
||||||
|
|
2
query.py
2
query.py
|
@ -24,7 +24,7 @@ $Id$
|
||||||
|
|
||||||
from zope import schema, component
|
from zope import schema, component
|
||||||
from zope.interface import Interface, Attribute, implements
|
from zope.interface import Interface, Attribute, implements
|
||||||
from zope.app import traversing
|
from zope import traversing
|
||||||
from zope.app.catalog.interfaces import ICatalog
|
from zope.app.catalog.interfaces import ICatalog
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ from zope.app.container.btree import BTreeContainer
|
||||||
from zope.app.container.contained import Contained
|
from zope.app.container.contained import Contained
|
||||||
from zope.app.file.image import Image
|
from zope.app.file.image import Image
|
||||||
from zope.app.file.interfaces import IFile
|
from zope.app.file.interfaces import IFile
|
||||||
from zope.app.filerepresentation.interfaces import IReadFile, IWriteFile
|
from zope.filerepresentation.interfaces import IReadFile, IWriteFile
|
||||||
from zope.app.size.interfaces import ISized
|
from zope.size.interfaces import ISized
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
from zope.i18nmessageid import MessageFactory
|
from zope.i18nmessageid import MessageFactory
|
||||||
|
@ -38,7 +38,7 @@ from zope import schema
|
||||||
from persistent import Persistent
|
from persistent import Persistent
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
|
|
||||||
from zope.app.event.objectevent import ObjectModifiedEvent, Attributes
|
from zope.lifecycleevent import ObjectModifiedEvent, Attributes
|
||||||
from zope.event import notify
|
from zope.event import notify
|
||||||
|
|
||||||
from cybertools.relation.registry import getRelations
|
from cybertools.relation.registry import getRelations
|
||||||
|
@ -285,6 +285,7 @@ class DocumentWriteFileAdapter(object):
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
|
# TODO: use typeInterface...
|
||||||
ITextDocument(self.context).data = unicode(data.replace('\r', ''), 'UTF-8')
|
ITextDocument(self.context).data = unicode(data.replace('\r', ''), 'UTF-8')
|
||||||
notify(ObjectModifiedEvent(self.context, Attributes(IDocument, 'data')))
|
notify(ObjectModifiedEvent(self.context, Attributes(IDocument, 'data')))
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ $Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope import interface, component
|
from zope import interface, component
|
||||||
from zope.app import traversing
|
from zope import traversing
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.formlib.namedtemplate import NamedTemplate, NamedTemplateImplementation
|
from zope.formlib.namedtemplate import NamedTemplate, NamedTemplateImplementation
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -22,7 +22,7 @@ Automatic setup of a loops site.
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
|
from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
|
||||||
from zope.event import notify
|
from zope.event import notify
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.component import adapts
|
from zope.component import adapts
|
||||||
|
|
13
view.py
13
view.py
|
@ -22,6 +22,7 @@ Definition of the View and related classses.
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from zope import component
|
||||||
from zope.app import zapi
|
from zope.app import zapi
|
||||||
from zope.app.container.btree import BTreeContainer
|
from zope.app.container.btree import BTreeContainer
|
||||||
from zope.app.container.contained import Contained
|
from zope.app.container.contained import Contained
|
||||||
|
@ -185,9 +186,19 @@ class NodeTraverser(ItemTraverser):
|
||||||
if name == '.loops':
|
if name == '.loops':
|
||||||
return self.context.getLoopsRoot()
|
return self.context.getLoopsRoot()
|
||||||
if name.startswith('.target'):
|
if name.startswith('.target'):
|
||||||
|
traversalStack = request._traversal_stack
|
||||||
|
while traversalStack and traversalStack[0].startswith('.target'):
|
||||||
|
# skip obsolete target references in the url
|
||||||
|
name = traversalStack.pop(0)
|
||||||
|
traversedNames = request._traversed_names
|
||||||
|
if traversedNames:
|
||||||
|
lastTraversed = traversedNames[-1]
|
||||||
|
if lastTraversed.startswith('.target') and lastTraversed != name:
|
||||||
|
# let <base .../> tag show the current object
|
||||||
|
traversedNames[-1] = name
|
||||||
if len(name) > len('.target'):
|
if len(name) > len('.target'):
|
||||||
uid = int(name[len('.target'):])
|
uid = int(name[len('.target'):])
|
||||||
target = zapi.getUtility(IIntIds).getObject(uid)
|
target = component.getUtility(IIntIds).getObject(uid)
|
||||||
else:
|
else:
|
||||||
target = self.context.target
|
target = self.context.target
|
||||||
if target is not None:
|
if target is not None:
|
||||||
|
|
|
@ -24,10 +24,10 @@ $Id$
|
||||||
|
|
||||||
from zope.interface import implements
|
from zope.interface import implements
|
||||||
from zope.event import notify
|
from zope.event import notify
|
||||||
from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
|
from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
|
||||||
from zope.app.publisher.xmlrpc import XMLRPCView
|
from zope.app.publisher.xmlrpc import XMLRPCView
|
||||||
from zope.app.publisher.xmlrpc import MethodPublisher
|
from zope.app.publisher.xmlrpc import MethodPublisher
|
||||||
from zope.app.traversing.api import getName
|
from zope.traversing.api import getName
|
||||||
from zope.security.proxy import removeSecurityProxy
|
from zope.security.proxy import removeSecurityProxy
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue