[Zope3-checkins] SVN: Zope3/trunk/ Merge of jim-adapter branch:
Jim Fulton
jim at zope.com
Wed Apr 26 20:54:24 EDT 2006
Log message for revision 67630:
Merge of jim-adapter branch:
This branch has three major refactorings on it:
- A redesign of the adapter registration machinery
- A major simplification of local component management
See zope.component.interfaces.IComponentRegistry.
- A flexible system for combining component registries.
- A beginning of the migration of packages out of zope.app.
- A new package for doing deferred imports. This allows you
to make names available at the package level without creating
circular imports. See zope.deferredimport and see
zope.component.__init__ for examples of it's use. This package
also provides a way to deprecate names in a module.
- Deprecation of zope. i18nmessageid.MessageID
I should have created checkin messages for individual sets of related
changes, but there were just too many for the time allowed.
Changed:
U Zope3/trunk/releases/Zope/DEPENDENCIES.cfg
U Zope3/trunk/src/buddydemo/browser.py
U Zope3/trunk/src/buddydemo/configure.zcml
U Zope3/trunk/src/buddydemo/tests.py
U Zope3/trunk/src/bugtracker/__init__.py
U Zope3/trunk/src/bugtracker/browser/bug.py
U Zope3/trunk/src/bugtracker/browser/comment.py
U Zope3/trunk/src/bugtracker/browser/tracker.py
U Zope3/trunk/src/bugtracker/bug.py
U Zope3/trunk/src/bugtracker/configure.zcml
U Zope3/trunk/src/bugtracker/exportimport.py
U Zope3/trunk/src/bugtracker/mail.py
U Zope3/trunk/src/bugtracker/tests/placelesssetup.py
U Zope3/trunk/src/bugtracker/tests/test_dependencies.py
U Zope3/trunk/src/bugtracker/tests/test_mail.py
U Zope3/trunk/src/bugtracker/tests/test_tracker.py
U Zope3/trunk/src/bugtracker/tests/test_vocabularies.py
U Zope3/trunk/src/bugtracker/tests/test_xmlexportimport.py
U Zope3/trunk/src/bugtracker/tracker.py
U Zope3/trunk/src/bugtracker/vocabulary.py
U Zope3/trunk/src/bugtracker/xmlrpc.py
U Zope3/trunk/src/z3checkins/browser.py
U Zope3/trunk/src/z3checkins/configure.zcml
U Zope3/trunk/src/z3checkins/folder.py
U Zope3/trunk/src/z3checkins/message.py
U Zope3/trunk/src/z3checkins/tests/test_message.py
_U Zope3/trunk/src/zope/
A Zope3/trunk/src/zope/annotation/
U Zope3/trunk/src/zope/app/DEPENDENCIES.cfg
U Zope3/trunk/src/zope/app/PACKAGE.cfg
UU Zope3/trunk/src/zope/app/__init__.py
D Zope3/trunk/src/zope/app/annotation/README.txt
UU Zope3/trunk/src/zope/app/annotation/__init__.py
D Zope3/trunk/src/zope/app/annotation/_factory.py
UU Zope3/trunk/src/zope/app/annotation/attribute.py
D Zope3/trunk/src/zope/app/annotation/configure.zcml
UU Zope3/trunk/src/zope/app/annotation/interfaces.py
D Zope3/trunk/src/zope/app/annotation/tests/
D Zope3/trunk/src/zope/app/apidoc/apidoc-ftesting.zcml
U Zope3/trunk/src/zope/app/apidoc/apidoc.py
U Zope3/trunk/src/zope/app/apidoc/bookmodule/book.zcml
U Zope3/trunk/src/zope/app/apidoc/browser/preference.py
U Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt
U Zope3/trunk/src/zope/app/apidoc/codemodule/browser/class_.py
U Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.py
U Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.zcml
U Zope3/trunk/src/zope/app/apidoc/codemodule/browser/module.py
U Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py
U Zope3/trunk/src/zope/app/apidoc/codemodule/class_.py
U Zope3/trunk/src/zope/app/apidoc/codemodule/codemodule.py
U Zope3/trunk/src/zope/app/apidoc/codemodule/function.py
U Zope3/trunk/src/zope/app/apidoc/codemodule/metaconfigure.py
U Zope3/trunk/src/zope/app/apidoc/codemodule/module.py
U Zope3/trunk/src/zope/app/apidoc/codemodule/text.py
U Zope3/trunk/src/zope/app/apidoc/component.py
U Zope3/trunk/src/zope/app/apidoc/component.txt
U Zope3/trunk/src/zope/app/apidoc/configure.zcml
D Zope3/trunk/src/zope/app/apidoc/ftesting.zcml
U Zope3/trunk/src/zope/app/apidoc/ifacemodule/README.txt
U Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py
U Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt
U Zope3/trunk/src/zope/app/apidoc/ifacemodule/ftests.py
U Zope3/trunk/src/zope/app/apidoc/ifacemodule/ifacemodule.py
U Zope3/trunk/src/zope/app/apidoc/presentation.py
U Zope3/trunk/src/zope/app/apidoc/presentation.txt
U Zope3/trunk/src/zope/app/apidoc/tests.py
U Zope3/trunk/src/zope/app/apidoc/typemodule/type.py
U Zope3/trunk/src/zope/app/apidoc/utilitymodule/browser.py
U Zope3/trunk/src/zope/app/apidoc/utilitymodule/browser.txt
U Zope3/trunk/src/zope/app/apidoc/utilitymodule/tests.py
U Zope3/trunk/src/zope/app/apidoc/utilitymodule/utilitymodule.py
U Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py
U Zope3/trunk/src/zope/app/apidoc/zcmlmodule/browser.py
U Zope3/trunk/src/zope/app/apidoc/zcmlmodule/tests.py
U Zope3/trunk/src/zope/app/applicationcontrol/applicationcontrol.py
U Zope3/trunk/src/zope/app/applicationcontrol/browser/configure.zcml
U Zope3/trunk/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py
U Zope3/trunk/src/zope/app/applicationcontrol/browser/zodbcontrol.py
U Zope3/trunk/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py
U Zope3/trunk/src/zope/app/appsetup/appsetup.py
U Zope3/trunk/src/zope/app/appsetup/bootstrap.py
U Zope3/trunk/src/zope/app/appsetup/bootstrap.txt
U Zope3/trunk/src/zope/app/appsetup/tests.py
U Zope3/trunk/src/zope/app/authentication/README.txt
U Zope3/trunk/src/zope/app/authentication/authentication.py
A Zope3/trunk/src/zope/app/authentication/browser/adding.py
U Zope3/trunk/src/zope/app/authentication/browser/configure.zcml
U Zope3/trunk/src/zope/app/authentication/browser/ftests.py
U Zope3/trunk/src/zope/app/authentication/browser/group_searching_with_empty_string.txt
U Zope3/trunk/src/zope/app/authentication/browser/groupfolder.txt
U Zope3/trunk/src/zope/app/authentication/browser/groupfolder.zcml
U Zope3/trunk/src/zope/app/authentication/browser/pau_prefix_and_searching.txt
U Zope3/trunk/src/zope/app/authentication/browser/principalfolder.txt
U Zope3/trunk/src/zope/app/authentication/browser/register.py
U Zope3/trunk/src/zope/app/authentication/browser/special-groups.txt
U Zope3/trunk/src/zope/app/authentication/groupfolder.txt
U Zope3/trunk/src/zope/app/authentication/groupfolder.zcml
U Zope3/trunk/src/zope/app/authentication/idpicker.py
U Zope3/trunk/src/zope/app/authentication/password.py
U Zope3/trunk/src/zope/app/authentication/principalfolder.py
U Zope3/trunk/src/zope/app/authentication/session.py
U Zope3/trunk/src/zope/app/authentication/tests.py
U Zope3/trunk/src/zope/app/authentication/vocabulary.py
U Zope3/trunk/src/zope/app/authentication/vocabulary.txt
U Zope3/trunk/src/zope/app/basicskin/standardmacros.py
U Zope3/trunk/src/zope/app/basicskin/tests/sampleinterfaces.py
U Zope3/trunk/src/zope/app/basicskin/tests/test_standardmacros.py
U Zope3/trunk/src/zope/app/broken/broken.py
U Zope3/trunk/src/zope/app/broken/configure.zcml
U Zope3/trunk/src/zope/app/browser.zcml
U Zope3/trunk/src/zope/app/cache/annotationcacheable.py
U Zope3/trunk/src/zope/app/cache/browser/cacheable.py
U Zope3/trunk/src/zope/app/cache/browser/configure.zcml
U Zope3/trunk/src/zope/app/cache/browser/ram.py
U Zope3/trunk/src/zope/app/cache/caching.py
U Zope3/trunk/src/zope/app/cache/configure.zcml
U Zope3/trunk/src/zope/app/cache/interfaces/ram.py
U Zope3/trunk/src/zope/app/cache/tests/test_annotationcacheable.py
U Zope3/trunk/src/zope/app/cache/tests/test_caching.py
U Zope3/trunk/src/zope/app/cache/tests/test_ramcache.py
U Zope3/trunk/src/zope/app/catalog/browser/README.txt
U Zope3/trunk/src/zope/app/catalog/browser/configure.zcml
U Zope3/trunk/src/zope/app/catalog/catalog.py
U Zope3/trunk/src/zope/app/catalog/configure.zcml
U Zope3/trunk/src/zope/app/catalog/tests.py
U Zope3/trunk/src/zope/app/component/README.txt
U Zope3/trunk/src/zope/app/component/__init__.py
U Zope3/trunk/src/zope/app/component/adapter.py
D Zope3/trunk/src/zope/app/component/adapterregistry.txt
A Zope3/trunk/src/zope/app/component/back35.py
D Zope3/trunk/src/zope/app/component/bbb/
U Zope3/trunk/src/zope/app/component/browser/__init__.py
U Zope3/trunk/src/zope/app/component/browser/configure.zcml
D Zope3/trunk/src/zope/app/component/browser/editregistration.pt
D Zope3/trunk/src/zope/app/component/browser/ftests.py
U Zope3/trunk/src/zope/app/component/browser/metaconfigure.py
D Zope3/trunk/src/zope/app/component/browser/registered.pt
U Zope3/trunk/src/zope/app/component/browser/registration.pt
U Zope3/trunk/src/zope/app/component/browser/registration.py
A Zope3/trunk/src/zope/app/component/browser/registration.txt
D Zope3/trunk/src/zope/app/component/browser/site.py
D Zope3/trunk/src/zope/app/component/browser/site_management.pt
A Zope3/trunk/src/zope/app/component/browser/siteregistration.pt
D Zope3/trunk/src/zope/app/component/browser/tests/
A Zope3/trunk/src/zope/app/component/browser/tests.py
D Zope3/trunk/src/zope/app/component/browser/tools.py
D Zope3/trunk/src/zope/app/component/browser/tools.txt
D Zope3/trunk/src/zope/app/component/browser/utility.py
D Zope3/trunk/src/zope/app/component/browser/utilreg_details.pt
U Zope3/trunk/src/zope/app/component/configure.zcml
U Zope3/trunk/src/zope/app/component/contentdirective.py
U Zope3/trunk/src/zope/app/component/fields.py
U Zope3/trunk/src/zope/app/component/hooks.py
UU Zope3/trunk/src/zope/app/component/interface.py
U Zope3/trunk/src/zope/app/component/interfaces/__init__.py
U Zope3/trunk/src/zope/app/component/interfaces/registration.py
U Zope3/trunk/src/zope/app/component/meta.zcml
U Zope3/trunk/src/zope/app/component/metaconfigure.py
U Zope3/trunk/src/zope/app/component/metadirectives.py
U Zope3/trunk/src/zope/app/component/registration.py
D Zope3/trunk/src/zope/app/component/registration.txt
U Zope3/trunk/src/zope/app/component/site.py
U Zope3/trunk/src/zope/app/component/site.txt
D Zope3/trunk/src/zope/app/component/statusproperty.txt
U Zope3/trunk/src/zope/app/component/testing.py
A Zope3/trunk/src/zope/app/component/tests/deprecated35_registration.txt
A Zope3/trunk/src/zope/app/component/tests/deprecated35_statusproperty.txt
A Zope3/trunk/src/zope/app/component/tests/gen3.fs
D Zope3/trunk/src/zope/app/component/tests/test_adapter.py
U Zope3/trunk/src/zope/app/component/tests/test_contentdirective.py
U Zope3/trunk/src/zope/app/component/tests/test_directives.py
U Zope3/trunk/src/zope/app/component/tests/test_fields.py
D Zope3/trunk/src/zope/app/component/tests/test_interface.py
U Zope3/trunk/src/zope/app/component/tests/test_registration.py
U Zope3/trunk/src/zope/app/component/tests/test_site.py
U Zope3/trunk/src/zope/app/component/tests/views.py
U Zope3/trunk/src/zope/app/component/vocabulary.py
U Zope3/trunk/src/zope/app/configure.zcml
U Zope3/trunk/src/zope/app/container/browser/adding.py
U Zope3/trunk/src/zope/app/container/browser/contents.py
U Zope3/trunk/src/zope/app/container/browser/find.py
U Zope3/trunk/src/zope/app/container/browser/ftests/test_contents.py
U Zope3/trunk/src/zope/app/container/browser/metaconfigure.py
U Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py
U Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py
U Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py
U Zope3/trunk/src/zope/app/container/configure.zcml
U Zope3/trunk/src/zope/app/container/contained.py
U Zope3/trunk/src/zope/app/container/directory.py
U Zope3/trunk/src/zope/app/container/ftests/test_view_permissions.py
U Zope3/trunk/src/zope/app/container/interfaces.py
U Zope3/trunk/src/zope/app/container/size.py
U Zope3/trunk/src/zope/app/container/tests/test_containertraversable.py
U Zope3/trunk/src/zope/app/container/tests/test_objectcopier.py
U Zope3/trunk/src/zope/app/container/tests/test_objectmover.py
U Zope3/trunk/src/zope/app/container/tests/test_ordered.py
U Zope3/trunk/src/zope/app/container/tests/test_size.py
U Zope3/trunk/src/zope/app/container/traversal.py
U Zope3/trunk/src/zope/app/content/__init__.py
UU Zope3/trunk/src/zope/app/content_types.py
D Zope3/trunk/src/zope/app/contenttypes/
UU Zope3/trunk/src/zope/app/copypastemove/__init__.py
D Zope3/trunk/src/zope/app/copypastemove/configure.zcml
UU Zope3/trunk/src/zope/app/copypastemove/interfaces.py
D Zope3/trunk/src/zope/app/copypastemove/tests/
UU Zope3/trunk/src/zope/app/datetimeutils.py
U Zope3/trunk/src/zope/app/dav/adapter.py
U Zope3/trunk/src/zope/app/dav/configure.zcml
U Zope3/trunk/src/zope/app/dav/ftests/dav.py
U Zope3/trunk/src/zope/app/dav/ftests/test_propfind.py
U Zope3/trunk/src/zope/app/dav/ftests/test_proppatch.py
U Zope3/trunk/src/zope/app/dav/metaconfigure.py
U Zope3/trunk/src/zope/app/dav/mkcol.py
U Zope3/trunk/src/zope/app/dav/opaquenamespaces.py
U Zope3/trunk/src/zope/app/dav/tests/test_adapter.py
U Zope3/trunk/src/zope/app/dav/tests/test_mkcol.py
U Zope3/trunk/src/zope/app/dav/tests/test_propfind.py
U Zope3/trunk/src/zope/app/dav/tests/test_proppatch.py
U Zope3/trunk/src/zope/app/dav/tests/unitfixtures.py
U Zope3/trunk/src/zope/app/debug/debug.py
UU Zope3/trunk/src/zope/app/decorator.py
U Zope3/trunk/src/zope/app/demo/hellopackage/configure.zcml
U Zope3/trunk/src/zope/app/demo/jobboard/browser.py
U Zope3/trunk/src/zope/app/demo/jobboard/configure.zcml
U Zope3/trunk/src/zope/app/demo/menu/menu.py
U Zope3/trunk/src/zope/app/demo/passwdauth/__init__.py
U Zope3/trunk/src/zope/app/demo/skinpref/skin.py
U Zope3/trunk/src/zope/app/demo/widget/configure.zcml
U Zope3/trunk/src/zope/app/dependable/__init__.py
U Zope3/trunk/src/zope/app/dependable/configure.zcml
U Zope3/trunk/src/zope/app/dependable/interfaces.py
U Zope3/trunk/src/zope/app/dependable/tests.py
U Zope3/trunk/src/zope/app/dtmlpage/configure.zcml
U Zope3/trunk/src/zope/app/dtmlpage/dtmlpage.py
U Zope3/trunk/src/zope/app/dtmlpage/ftests.py
U Zope3/trunk/src/zope/app/dtmlpage/tests/test_dtmlpage.py
D Zope3/trunk/src/zope/app/dublincore/PACKAGE.cfg
UU Zope3/trunk/src/zope/app/dublincore/__init__.py
UU Zope3/trunk/src/zope/app/dublincore/annotatableadapter.py
D Zope3/trunk/src/zope/app/dublincore/browser/
D Zope3/trunk/src/zope/app/dublincore/configure.zcml
UU Zope3/trunk/src/zope/app/dublincore/creatorannotator.py
UU Zope3/trunk/src/zope/app/dublincore/dcsv.py
UU Zope3/trunk/src/zope/app/dublincore/dcterms.py
D Zope3/trunk/src/zope/app/dublincore/fssync/
UU Zope3/trunk/src/zope/app/dublincore/interfaces.py
D Zope3/trunk/src/zope/app/dublincore/tests/
UU Zope3/trunk/src/zope/app/dublincore/timeannotators.py
UU Zope3/trunk/src/zope/app/dublincore/xmlmetadata.py
UU Zope3/trunk/src/zope/app/dublincore/zopedublincore.py
U Zope3/trunk/src/zope/app/error/__init__.py
U Zope3/trunk/src/zope/app/error/browser/__init__.py
U Zope3/trunk/src/zope/app/error/browser/configure.zcml
A Zope3/trunk/src/zope/app/event/README.txt
U Zope3/trunk/src/zope/app/event/__init__.py
U Zope3/trunk/src/zope/app/event/configure.zcml
A Zope3/trunk/src/zope/app/event/dispatch.py
D Zope3/trunk/src/zope/app/event/dispatching.py
UU Zope3/trunk/src/zope/app/event/interfaces.py
UU Zope3/trunk/src/zope/app/event/objectevent.py
U Zope3/trunk/src/zope/app/event/tests/__init__.py
UU Zope3/trunk/src/zope/app/event/tests/placelesssetup.py
D Zope3/trunk/src/zope/app/event/tests/test_dispatching.py
U Zope3/trunk/src/zope/app/event/tests/test_objectevent.py
U Zope3/trunk/src/zope/app/exception/browser/configure.zcml
U Zope3/trunk/src/zope/app/exception/browser/ftests.py
U Zope3/trunk/src/zope/app/exception/browser/systemerror.txt
U Zope3/trunk/src/zope/app/exception/browser/unauthorized.py
U Zope3/trunk/src/zope/app/exception/interfaces.py
U Zope3/trunk/src/zope/app/externaleditor/browser/__init__.py
U Zope3/trunk/src/zope/app/externaleditor/interfaces.py
U Zope3/trunk/src/zope/app/externaleditor/tests/test_external_edit.py
U Zope3/trunk/src/zope/app/file/DEPENDENCIES.cfg
U Zope3/trunk/src/zope/app/file/browser/file.py
U Zope3/trunk/src/zope/app/file/browser/ftests.py
U Zope3/trunk/src/zope/app/file/browser/image.py
U Zope3/trunk/src/zope/app/file/browser/tests/test_imagedata.py
U Zope3/trunk/src/zope/app/file/configure.zcml
U Zope3/trunk/src/zope/app/file/image.py
U Zope3/trunk/src/zope/app/file/tests/test_image.py
UU Zope3/trunk/src/zope/app/filerepresentation/__init__.py
UU Zope3/trunk/src/zope/app/filerepresentation/interfaces.py
U Zope3/trunk/src/zope/app/folder/configure.zcml
U Zope3/trunk/src/zope/app/folder/folder.py
U Zope3/trunk/src/zope/app/folder/interfaces.py
U Zope3/trunk/src/zope/app/folder/tests.py
U Zope3/trunk/src/zope/app/form/__init__.py
U Zope3/trunk/src/zope/app/form/browser/add.py
U Zope3/trunk/src/zope/app/form/browser/editview.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_booleanradiowidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_checkboxwidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_datetimewidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_filewidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_floatwidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_intwidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_textareawidget.py
U Zope3/trunk/src/zope/app/form/browser/ftests/test_textwidget.py
U Zope3/trunk/src/zope/app/form/browser/metadirectives.py
U Zope3/trunk/src/zope/app/form/browser/schemadisplay.py
U Zope3/trunk/src/zope/app/form/browser/tests/test_add.py
U Zope3/trunk/src/zope/app/form/browser/tests/test_datetimewidget.py
U Zope3/trunk/src/zope/app/form/browser/tests/test_datewidget.py
U Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py
U Zope3/trunk/src/zope/app/form/browser/tests/test_editview.py
U Zope3/trunk/src/zope/app/form/browser/textwidgets.py
U Zope3/trunk/src/zope/app/form/browser/widget.py
U Zope3/trunk/src/zope/app/form/browser/widgets.txt
U Zope3/trunk/src/zope/app/form/interfaces.py
U Zope3/trunk/src/zope/app/form/tests/test_utility.py
U Zope3/trunk/src/zope/app/form/tests/test_widget.py
U Zope3/trunk/src/zope/app/fssync/browser/__init__.py
U Zope3/trunk/src/zope/app/fssync/committer.py
U Zope3/trunk/src/zope/app/fssync/fspickle.py
U Zope3/trunk/src/zope/app/fssync/fsregistry.py
U Zope3/trunk/src/zope/app/fssync/syncer.py
U Zope3/trunk/src/zope/app/fssync/tests/test_committer.py
U Zope3/trunk/src/zope/app/fssync/tests/test_fspickle.py
U Zope3/trunk/src/zope/app/ftp/README.txt
U Zope3/trunk/src/zope/app/ftp/__init__.py
U Zope3/trunk/src/zope/app/ftp/tests/test_ftpview.py
U Zope3/trunk/src/zope/app/homefolder/README.txt
U Zope3/trunk/src/zope/app/homefolder/browser.py
U Zope3/trunk/src/zope/app/homefolder/configure.zcml
U Zope3/trunk/src/zope/app/homefolder/tests.py
U Zope3/trunk/src/zope/app/http/delete.py
U Zope3/trunk/src/zope/app/http/exception/configure.zcml
U Zope3/trunk/src/zope/app/http/put.py
U Zope3/trunk/src/zope/app/http/tests/test_delete.py
U Zope3/trunk/src/zope/app/http/tests/test_put.py
U Zope3/trunk/src/zope/app/i18n/__init__.py
U Zope3/trunk/src/zope/app/i18n/browser/configure.zcml
U Zope3/trunk/src/zope/app/i18n/configure.zcml
D Zope3/trunk/src/zope/app/i18n/locales.zcml
D Zope3/trunk/src/zope/app/i18n/meta.zcml
D Zope3/trunk/src/zope/app/i18n/metaconfigure.py
U Zope3/trunk/src/zope/app/i18n/tests/__init__.py
UU Zope3/trunk/src/zope/app/i18n/tests/placelesssetup.py
U Zope3/trunk/src/zope/app/i18n/tests/test_translationdomain.py
D Zope3/trunk/src/zope/app/i18n/tests/testi18ndirectives.py
U Zope3/trunk/src/zope/app/i18n/translationdomain.py
U Zope3/trunk/src/zope/app/i18nfile/browser/i18nimage.py
U Zope3/trunk/src/zope/app/i18nfile/configure.zcml
U Zope3/trunk/src/zope/app/interface/vocabulary.py
U Zope3/trunk/src/zope/app/intid/__init__.py
U Zope3/trunk/src/zope/app/intid/browser/configure.zcml
U Zope3/trunk/src/zope/app/intid/browser/tracking.txt
U Zope3/trunk/src/zope/app/intid/configure.zcml
U Zope3/trunk/src/zope/app/intid/tests.py
U Zope3/trunk/src/zope/app/introspector/__init__.py
U Zope3/trunk/src/zope/app/introspector/browser.py
U Zope3/trunk/src/zope/app/introspector/tests/test_introspector.py
U Zope3/trunk/src/zope/app/introspector/tests/test_introspectorview.py
U Zope3/trunk/src/zope/app/keyreference/interfaces.py
U Zope3/trunk/src/zope/app/locales/extract.py
UU Zope3/trunk/src/zope/app/location/__init__.py
D Zope3/trunk/src/zope/app/location/configure.zcml
UU Zope3/trunk/src/zope/app/location/interfaces.py
UU Zope3/trunk/src/zope/app/location/location.py
UU Zope3/trunk/src/zope/app/location/pickling.py
D Zope3/trunk/src/zope/app/location/tests.py
UU Zope3/trunk/src/zope/app/location/traversing.py
U Zope3/trunk/src/zope/app/locking/README.txt
U Zope3/trunk/src/zope/app/locking/adapter.py
U Zope3/trunk/src/zope/app/locking/configure.zcml
U Zope3/trunk/src/zope/app/locking/interfaces.py
U Zope3/trunk/src/zope/app/locking/storage.py
U Zope3/trunk/src/zope/app/locking/tests.py
D Zope3/trunk/src/zope/app/mail/DEPENDENCIES.cfg
D Zope3/trunk/src/zope/app/mail/SETUP.cfg
UU Zope3/trunk/src/zope/app/mail/__init__.py
D Zope3/trunk/src/zope/app/mail/configure.zcml
UU Zope3/trunk/src/zope/app/mail/delivery.py
UU Zope3/trunk/src/zope/app/mail/event.py
UU Zope3/trunk/src/zope/app/mail/interfaces.py
D Zope3/trunk/src/zope/app/mail/mail-configure.zcml
D Zope3/trunk/src/zope/app/mail/mail-meta.zcml
UU Zope3/trunk/src/zope/app/mail/maildir.py
UU Zope3/trunk/src/zope/app/mail/mailer.py
D Zope3/trunk/src/zope/app/mail/meta.zcml
D Zope3/trunk/src/zope/app/mail/metaconfigure.py
D Zope3/trunk/src/zope/app/mail/metadirectives.py
D Zope3/trunk/src/zope/app/mail/tests/
U Zope3/trunk/src/zope/app/mail/vocabulary.py
U Zope3/trunk/src/zope/app/meta.zcml
U Zope3/trunk/src/zope/app/module/README.txt
U Zope3/trunk/src/zope/app/module/configure.zcml
U Zope3/trunk/src/zope/app/module/manager.py
U Zope3/trunk/src/zope/app/module/tests.py
D Zope3/trunk/src/zope/app/observable/
U Zope3/trunk/src/zope/app/onlinehelp/DEPENDENCIES.cfg
U Zope3/trunk/src/zope/app/onlinehelp/__init__.py
U Zope3/trunk/src/zope/app/onlinehelp/browser/__init__.py
U Zope3/trunk/src/zope/app/onlinehelp/browser/tree.py
U Zope3/trunk/src/zope/app/onlinehelp/configure.zcml
U Zope3/trunk/src/zope/app/onlinehelp/onlinehelp.py
U Zope3/trunk/src/zope/app/onlinehelp/onlinehelptopic.py
U Zope3/trunk/src/zope/app/onlinehelp/tests/test_helpdirectives.py
U Zope3/trunk/src/zope/app/onlinehelp/tests/test_onlinehelp.py
U Zope3/trunk/src/zope/app/onlinehelp/tests/test_treeview.py
U Zope3/trunk/src/zope/app/pagetemplate/configure.zcml
U Zope3/trunk/src/zope/app/pagetemplate/engine.py
U Zope3/trunk/src/zope/app/pagetemplate/simpleviewclass.py
U Zope3/trunk/src/zope/app/pagetemplate/talesapi.py
U Zope3/trunk/src/zope/app/pagetemplate/tests/test_directives.py
U Zope3/trunk/src/zope/app/pagetemplate/tests/test_talesapi.py
U Zope3/trunk/src/zope/app/pagetemplate/urlquote.py
U Zope3/trunk/src/zope/app/pluggableauth/__init__.py
U Zope3/trunk/src/zope/app/pluggableauth/configure.zcml
U Zope3/trunk/src/zope/app/pluggableauth/tests/test_pluggableauth.py
U Zope3/trunk/src/zope/app/preference/README.txt
U Zope3/trunk/src/zope/app/preference/configure.zcml
U Zope3/trunk/src/zope/app/preference/default.py
U Zope3/trunk/src/zope/app/preference/interfaces.py
U Zope3/trunk/src/zope/app/preference/metaconfigure.py
U Zope3/trunk/src/zope/app/preference/preference.py
D Zope3/trunk/src/zope/app/presentation/
U Zope3/trunk/src/zope/app/principalannotation/__init__.py
U Zope3/trunk/src/zope/app/principalannotation/configure.zcml
U Zope3/trunk/src/zope/app/principalannotation/tests.py
U Zope3/trunk/src/zope/app/publication/browser.py
U Zope3/trunk/src/zope/app/publication/configure.zcml
U Zope3/trunk/src/zope/app/publication/httpfactory.py
U Zope3/trunk/src/zope/app/publication/interfaces.py
U Zope3/trunk/src/zope/app/publication/publicationtraverse.py
U Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py
U Zope3/trunk/src/zope/app/publication/tests/test_httpfactory.py
U Zope3/trunk/src/zope/app/publication/tests/test_requestpublicationfactories.py
U Zope3/trunk/src/zope/app/publication/tests/test_requestpublicationregistry.py
U Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py
U Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py
U Zope3/trunk/src/zope/app/publication/traversers.py
U Zope3/trunk/src/zope/app/publication/zopepublication.py
U Zope3/trunk/src/zope/app/publisher/DEPENDENCIES.cfg
U Zope3/trunk/src/zope/app/publisher/browser/__init__.py
U Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py
U Zope3/trunk/src/zope/app/publisher/browser/fields.py
U Zope3/trunk/src/zope/app/publisher/browser/fileresource.py
U Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py
U Zope3/trunk/src/zope/app/publisher/browser/icon.py
U Zope3/trunk/src/zope/app/publisher/browser/managementviewselector.py
U Zope3/trunk/src/zope/app/publisher/browser/menu.py
U Zope3/trunk/src/zope/app/publisher/browser/menu.txt
U Zope3/trunk/src/zope/app/publisher/browser/menumeta.py
U Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
U Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py
U Zope3/trunk/src/zope/app/publisher/browser/pagetemplateresource.py
U Zope3/trunk/src/zope/app/publisher/browser/resource.py
U Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py
U Zope3/trunk/src/zope/app/publisher/browser/resources.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/support.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_addMenuItem.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_browserlanguages.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_icondirective.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_pagetemplateresource.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_resources.py
U Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py
U Zope3/trunk/src/zope/app/publisher/browser/vocabulary.py
U Zope3/trunk/src/zope/app/publisher/fieldconverters.py
U Zope3/trunk/src/zope/app/publisher/fileresource.py
U Zope3/trunk/src/zope/app/publisher/interfaces/browser.py
U Zope3/trunk/src/zope/app/publisher/xmlrpc/README.txt
U Zope3/trunk/src/zope/app/publisher/xmlrpc/__init__.py
U Zope3/trunk/src/zope/app/publisher/xmlrpc/metaconfigure.py
U Zope3/trunk/src/zope/app/publisher/xmlrpc/metadirectives.py
U Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/test_directives.py
U Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/xmlrpc_error.zcml
U Zope3/trunk/src/zope/app/pythonpage/configure.zcml
U Zope3/trunk/src/zope/app/pythonpage/tests.py
D Zope3/trunk/src/zope/app/rdb/SETUP.cfg
UU Zope3/trunk/src/zope/app/rdb/__init__.py
D Zope3/trunk/src/zope/app/rdb/browser/
A Zope3/trunk/src/zope/app/rdb/browser.py
D Zope3/trunk/src/zope/app/rdb/configure.zcml
D Zope3/trunk/src/zope/app/rdb/gadfly/
D Zope3/trunk/src/zope/app/rdb/gadfly-meta.zcml
A Zope3/trunk/src/zope/app/rdb/gadfly.py
D Zope3/trunk/src/zope/app/rdb/gadflyda.py
D Zope3/trunk/src/zope/app/rdb/gadflyda.zcml
D Zope3/trunk/src/zope/app/rdb/gadflymeta.py
UU Zope3/trunk/src/zope/app/rdb/interfaces.py
D Zope3/trunk/src/zope/app/rdb/meta.zcml
D Zope3/trunk/src/zope/app/rdb/metaconfigure.py
D Zope3/trunk/src/zope/app/rdb/metadirectives.py
D Zope3/trunk/src/zope/app/rdb/rdb-configure.zcml
D Zope3/trunk/src/zope/app/rdb/rdb-meta.zcml
D Zope3/trunk/src/zope/app/rdb/tests/
U Zope3/trunk/src/zope/app/recorder/browser.py
U Zope3/trunk/src/zope/app/recorder/tests.py
D Zope3/trunk/src/zope/app/registration/
U Zope3/trunk/src/zope/app/renderer/__init__.py
U Zope3/trunk/src/zope/app/renderer/configure.zcml
U Zope3/trunk/src/zope/app/renderer/metaconfigure.py
U Zope3/trunk/src/zope/app/renderer/plaintext.py
U Zope3/trunk/src/zope/app/renderer/rest.py
U Zope3/trunk/src/zope/app/renderer/stx.py
U Zope3/trunk/src/zope/app/renderer/vocabulary.py
U Zope3/trunk/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py
U Zope3/trunk/src/zope/app/rotterdam/xmlobject.py
U Zope3/trunk/src/zope/app/schema/browser/__init__.py
U Zope3/trunk/src/zope/app/schema/browser/configure.zcml
U Zope3/trunk/src/zope/app/schema/browser/traversal.py
U Zope3/trunk/src/zope/app/schema/configure.zcml
U Zope3/trunk/src/zope/app/schema/interfaces.py
U Zope3/trunk/src/zope/app/schema/metaconfigure.py
U Zope3/trunk/src/zope/app/schema/schema.py
U Zope3/trunk/src/zope/app/schema/tests/test_fieldfactory.py
U Zope3/trunk/src/zope/app/schema/tests/test_interfaceutility.py
U Zope3/trunk/src/zope/app/schema/vocabulary.py
U Zope3/trunk/src/zope/app/schemacontent/browser/__init__.py
U Zope3/trunk/src/zope/app/schemacontent/browser/configure.zcml
U Zope3/trunk/src/zope/app/schemacontent/configure.zcml
U Zope3/trunk/src/zope/app/schemacontent/content.py
U Zope3/trunk/src/zope/app/schemacontent/tests/test_content.py
U Zope3/trunk/src/zope/app/security/_protections.py
U Zope3/trunk/src/zope/app/security/adapter.py
U Zope3/trunk/src/zope/app/security/browser/configure.zcml
U Zope3/trunk/src/zope/app/security/configure.zcml
UU Zope3/trunk/src/zope/app/security/fields.py
U Zope3/trunk/src/zope/app/security/interfaces.py
U Zope3/trunk/src/zope/app/security/meta.zcml
U Zope3/trunk/src/zope/app/security/metaconfigure.py
U Zope3/trunk/src/zope/app/security/metadirectives.py
U Zope3/trunk/src/zope/app/security/permission.py
U Zope3/trunk/src/zope/app/security/principal.py
U Zope3/trunk/src/zope/app/security/tests/__init__.py
D Zope3/trunk/src/zope/app/security/tests/test_adapter.py
U Zope3/trunk/src/zope/app/security/tests/test_directives.py
D Zope3/trunk/src/zope/app/security/tests/test_fields.py
U Zope3/trunk/src/zope/app/security/tests/test_protectclass.py
U Zope3/trunk/src/zope/app/security/tests/test_protectsubclass.py
U Zope3/trunk/src/zope/app/security/tests/test_securitydirectives.py
U Zope3/trunk/src/zope/app/security/vocabulary.py
U Zope3/trunk/src/zope/app/securitypolicy/browser/configure.zcml
U Zope3/trunk/src/zope/app/securitypolicy/browser/ftests.py
U Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt
U Zope3/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py
U Zope3/trunk/src/zope/app/securitypolicy/browser/tests/test_rolepermissionview.py
U Zope3/trunk/src/zope/app/securitypolicy/configure.zcml
U Zope3/trunk/src/zope/app/securitypolicy/grantinfo.py
U Zope3/trunk/src/zope/app/securitypolicy/metaconfigure.py
U Zope3/trunk/src/zope/app/securitypolicy/metadirectives.py
U Zope3/trunk/src/zope/app/securitypolicy/principalpermission.py
U Zope3/trunk/src/zope/app/securitypolicy/role.py
U Zope3/trunk/src/zope/app/securitypolicy/rolepermission.py
U Zope3/trunk/src/zope/app/securitypolicy/securitymap.py
U Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalpermissionmanager.py
U Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalrolemanager.py
U Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationrolepermissionmanager.py
U Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py
U Zope3/trunk/src/zope/app/securitypolicy/tests/test_rolepermissionmanager.py
U Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py
U Zope3/trunk/src/zope/app/securitypolicy/tests/test_zopepolicy.py
U Zope3/trunk/src/zope/app/securitypolicy/vocabulary.py
U Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.txt
U Zope3/trunk/src/zope/app/servicenames.py
U Zope3/trunk/src/zope/app/session/configure.zcml
U Zope3/trunk/src/zope/app/session/http.py
U Zope3/trunk/src/zope/app/session/session.py
D Zope3/trunk/src/zope/app/site/folder.py
D Zope3/trunk/src/zope/app/site/interfaces.py
D Zope3/trunk/src/zope/app/site/service.py
D Zope3/trunk/src/zope/app/site/servicecontainer.py
U Zope3/trunk/src/zope/app/site/tests/__init__.py
D Zope3/trunk/src/zope/app/site/tests/placefulsetup.py
UU Zope3/trunk/src/zope/app/size/__init__.py
D Zope3/trunk/src/zope/app/size/configure.zcml
UU Zope3/trunk/src/zope/app/size/interfaces.py
D Zope3/trunk/src/zope/app/size/tests.py
U Zope3/trunk/src/zope/app/sqlexpr/sqlexpr.py
U Zope3/trunk/src/zope/app/sqlexpr/tests.py
U Zope3/trunk/src/zope/app/sqlscript/DEPENDENCIES.cfg
U Zope3/trunk/src/zope/app/sqlscript/browser/sqlscript.py
U Zope3/trunk/src/zope/app/sqlscript/configure.zcml
U Zope3/trunk/src/zope/app/sqlscript/interfaces.py
U Zope3/trunk/src/zope/app/sqlscript/sqlscript.py
U Zope3/trunk/src/zope/app/sqlscript/tests/test_sqlscript.py
U Zope3/trunk/src/zope/app/testing/DEPENDENCIES.cfg
A Zope3/trunk/src/zope/app/testing/back35.py
U Zope3/trunk/src/zope/app/testing/functional.py
U Zope3/trunk/src/zope/app/testing/placelesssetup.py
U Zope3/trunk/src/zope/app/testing/setup.py
U Zope3/trunk/src/zope/app/testing/ztapi.py
UU Zope3/trunk/src/zope/app/tests/__init__.py
A Zope3/trunk/src/zope/app/tests/dochttp.py
A Zope3/trunk/src/zope/app/tests/functional.py
A Zope3/trunk/src/zope/app/tests/placelesssetup.py
A Zope3/trunk/src/zope/app/tests/setup.py
D Zope3/trunk/src/zope/app/tests/test_datetimeparse.py
D Zope3/trunk/src/zope/app/tests/test_decorator.py
D Zope3/trunk/src/zope/app/tests/test_standard_dates.py
D Zope3/trunk/src/zope/app/tests/test_tzinfo.py
A Zope3/trunk/src/zope/app/tests/ztapi.py
UU Zope3/trunk/src/zope/app/timezones.py
U Zope3/trunk/src/zope/app/traversing/__init__.py
UU Zope3/trunk/src/zope/app/traversing/adapters.py
UU Zope3/trunk/src/zope/app/traversing/api.py
UU Zope3/trunk/src/zope/app/traversing/browser/__init__.py
UU Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py
D Zope3/trunk/src/zope/app/traversing/browser/configure.zcml
UU Zope3/trunk/src/zope/app/traversing/browser/interfaces.py
D Zope3/trunk/src/zope/app/traversing/browser/tests.py
D Zope3/trunk/src/zope/app/traversing/configure.zcml
D Zope3/trunk/src/zope/app/traversing/ftests/
UU Zope3/trunk/src/zope/app/traversing/interfaces.py
D Zope3/trunk/src/zope/app/traversing/namespace.py
D Zope3/trunk/src/zope/app/traversing/tests/
U Zope3/trunk/src/zope/app/tree/adapters.py
U Zope3/trunk/src/zope/app/tree/browser/__init__.py
U Zope3/trunk/src/zope/app/tree/browser/cookie.py
U Zope3/trunk/src/zope/app/tree/configure.zcml
U Zope3/trunk/src/zope/app/tree/tests/test_adapters.py
U Zope3/trunk/src/zope/app/twisted/ftp/ftp.py
U Zope3/trunk/src/zope/app/twisted/ftp/tests/demofs.py
U Zope3/trunk/src/zope/app/twisted/tests/test_inputbuffering.py
U Zope3/trunk/src/zope/app/twisted/tests/test_zeo.py
U Zope3/trunk/src/zope/app/undo/__init__.py
U Zope3/trunk/src/zope/app/undo/browser.py
U Zope3/trunk/src/zope/app/undo/tests/test_zodbundomanager.py
UU Zope3/trunk/src/zope/app/utility/__init__.py
UU Zope3/trunk/src/zope/app/utility/interfaces.py
UU Zope3/trunk/src/zope/app/utility/utility.py
UU Zope3/trunk/src/zope/app/utility/vocabulary.py
U Zope3/trunk/src/zope/app/versioncontrol/README.txt
U Zope3/trunk/src/zope/app/versioncontrol/event.py
U Zope3/trunk/src/zope/app/versioncontrol/history.py
U Zope3/trunk/src/zope/app/versioncontrol/interfaces.py
U Zope3/trunk/src/zope/app/versioncontrol/repository.py
U Zope3/trunk/src/zope/app/versioncontrol/tests.py
U Zope3/trunk/src/zope/app/versioncontrol/utility.py
U Zope3/trunk/src/zope/app/versioncontrol/version.py
U Zope3/trunk/src/zope/app/wfmc/metaconfigure.py
U Zope3/trunk/src/zope/app/wfmc/tests.py
U Zope3/trunk/src/zope/app/workflow/browser/configure.zcml
U Zope3/trunk/src/zope/app/workflow/browser/definition.py
U Zope3/trunk/src/zope/app/workflow/configure.zcml
U Zope3/trunk/src/zope/app/workflow/definition.py
U Zope3/trunk/src/zope/app/workflow/instance.py
U Zope3/trunk/src/zope/app/workflow/stateful/browser/configure.zcml
U Zope3/trunk/src/zope/app/workflow/stateful/browser/contentworkflow.py
U Zope3/trunk/src/zope/app/workflow/stateful/browser/definition.py
U Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_contentworkflowsmanager.py
U Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_processdefinition.py
U Zope3/trunk/src/zope/app/workflow/stateful/browser/instance.py
U Zope3/trunk/src/zope/app/workflow/stateful/configure.zcml
U Zope3/trunk/src/zope/app/workflow/stateful/contentworkflow.py
U Zope3/trunk/src/zope/app/workflow/stateful/definition.py
U Zope3/trunk/src/zope/app/workflow/stateful/instance.py
U Zope3/trunk/src/zope/app/workflow/stateful/tests/test_contentworkflow.py
U Zope3/trunk/src/zope/app/workflow/stateful/tests/test_instance.py
U Zope3/trunk/src/zope/app/workflow/stateful/tests/test_xmlimportexport.py
U Zope3/trunk/src/zope/app/workflow/stateful/xmlimportexport.py
U Zope3/trunk/src/zope/app/workflow/tests/test_instance.py
U Zope3/trunk/src/zope/app/workflow/tests/workflowsetup.py
U Zope3/trunk/src/zope/app/xmlrpcintrospection/xmlrpcintrospection.py
U Zope3/trunk/src/zope/app/zapi/__init__.py
U Zope3/trunk/src/zope/app/zapi/interfaces.py
U Zope3/trunk/src/zope/app/zopeappgenerations/__init__.py
D Zope3/trunk/src/zope/app/zopeappgenerations/evolve1.py
U Zope3/trunk/src/zope/app/zopeappgenerations/evolve3.py
A Zope3/trunk/src/zope/app/zopeappgenerations/evolve4.py
U Zope3/trunk/src/zope/app/zptpage/configure.zcml
U Zope3/trunk/src/zope/app/zptpage/tests/test_zptpage.py
U Zope3/trunk/src/zope/app/zptpage/zptpage.py
U Zope3/trunk/src/zope/component/DEPENDENCIES.cfg
U Zope3/trunk/src/zope/component/__init__.py
A Zope3/trunk/src/zope/component/_api.py
A Zope3/trunk/src/zope/component/_declaration.py
A Zope3/trunk/src/zope/component/adapter.py
A Zope3/trunk/src/zope/component/back35.py
U Zope3/trunk/src/zope/component/bbb/__init__.py
D Zope3/trunk/src/zope/component/bbb/adapter.py
D Zope3/trunk/src/zope/component/bbb/contextdependent.py
D Zope3/trunk/src/zope/component/bbb/exceptions.py
D Zope3/trunk/src/zope/component/bbb/service.py
D Zope3/trunk/src/zope/component/bbb/servicenames.py
D Zope3/trunk/src/zope/component/bbb/tests/
D Zope3/trunk/src/zope/component/bbb/utility.py
A Zope3/trunk/src/zope/component/contextdependent.py
A Zope3/trunk/src/zope/component/event.py
A Zope3/trunk/src/zope/component/event.txt
A Zope3/trunk/src/zope/component/eventtesting.py
A Zope3/trunk/src/zope/component/exceptions.py
U Zope3/trunk/src/zope/component/factory.txt
A Zope3/trunk/src/zope/component/globalregistry.py
A Zope3/trunk/src/zope/component/interface.py
U Zope3/trunk/src/zope/component/interfaces.py
A Zope3/trunk/src/zope/component/meta.zcml
A Zope3/trunk/src/zope/component/persistentregistry.py
A Zope3/trunk/src/zope/component/persistentregistry.txt
A Zope3/trunk/src/zope/component/registry.py
A Zope3/trunk/src/zope/component/registry.txt
A Zope3/trunk/src/zope/component/service.py
A Zope3/trunk/src/zope/component/servicenames.py
UU Zope3/trunk/src/zope/component/site.py
U Zope3/trunk/src/zope/component/socketexample.txt
U Zope3/trunk/src/zope/component/testing.py
U Zope3/trunk/src/zope/component/tests.py
A Zope3/trunk/src/zope/component/utility.py
A Zope3/trunk/src/zope/component/zcml.py
A Zope3/trunk/src/zope/component/zcml.txt
U Zope3/trunk/src/zope/contentprovider/README.txt
U Zope3/trunk/src/zope/contentprovider/interfaces.py
A Zope3/trunk/src/zope/contenttype/
A Zope3/trunk/src/zope/copypastemove/
A Zope3/trunk/src/zope/datetime/
A Zope3/trunk/src/zope/decorator/
A Zope3/trunk/src/zope/deferredimport/
U Zope3/trunk/src/zope/deprecation/README.txt
U Zope3/trunk/src/zope/deprecation/__init__.py
U Zope3/trunk/src/zope/deprecation/deprecation.py
U Zope3/trunk/src/zope/deprecation/tests.py
A Zope3/trunk/src/zope/dublincore/
U Zope3/trunk/src/zope/exceptions/DEPENDENCIES.cfg
U Zope3/trunk/src/zope/exceptions/__init__.py
D Zope3/trunk/src/zope/exceptions/_duplicate.py
D Zope3/trunk/src/zope/exceptions/_notfounderror.py
U Zope3/trunk/src/zope/exceptions/interfaces.py
A Zope3/trunk/src/zope/filerepresentation/
U Zope3/trunk/src/zope/formlib/__init__.py
U Zope3/trunk/src/zope/formlib/form.py
U Zope3/trunk/src/zope/formlib/interfaces.py
U Zope3/trunk/src/zope/formlib/namedtemplate.py
U Zope3/trunk/src/zope/formlib/page.py
D Zope3/trunk/src/zope/formlib/page.txt
U Zope3/trunk/src/zope/formlib/tests.py
U Zope3/trunk/src/zope/i18n/__init__.py
A Zope3/trunk/src/zope/i18n/locales/configure.zcml
D Zope3/trunk/src/zope/i18n/messageid.py
A Zope3/trunk/src/zope/i18n/meta.zcml
A Zope3/trunk/src/zope/i18n/testing.py
U Zope3/trunk/src/zope/i18n/tests/test_itranslationdomain.py
U Zope3/trunk/src/zope/i18n/tests/test_negotiator.py
U Zope3/trunk/src/zope/i18n/tests/test_translationdomain.py
A Zope3/trunk/src/zope/i18n/tests/test_zcml.py
U Zope3/trunk/src/zope/i18n/translationdomain.py
A Zope3/trunk/src/zope/i18n/zcml.py
U Zope3/trunk/src/zope/i18nmessageid/DEPENDENCIES.cfg
U Zope3/trunk/src/zope/i18nmessageid/__init__.py
D Zope3/trunk/src/zope/i18nmessageid/messageid.py
U Zope3/trunk/src/zope/i18nmessageid/tests.py
U Zope3/trunk/src/zope/interface/__init__.py
U Zope3/trunk/src/zope/interface/adapter.py
U Zope3/trunk/src/zope/interface/adapter.txt
U Zope3/trunk/src/zope/interface/declarations.py
U Zope3/trunk/src/zope/interface/interface.py
U Zope3/trunk/src/zope/interface/interfaces.py
U Zope3/trunk/src/zope/interface/tests/test_declarations.py
A Zope3/trunk/src/zope/lifecycleevent/
A Zope3/trunk/src/zope/location/
U Zope3/trunk/src/zope/proxy/__init__.py
U Zope3/trunk/src/zope/proxy/_zope_proxy_proxy.c
U Zope3/trunk/src/zope/proxy/tests/test_proxy.py
U Zope3/trunk/src/zope/publisher/DEPENDENCIES.cfg
U Zope3/trunk/src/zope/publisher/browser.py
U Zope3/trunk/src/zope/publisher/http.py
U Zope3/trunk/src/zope/publisher/interfaces/__init__.py
A Zope3/trunk/src/zope/publisher/interfaces/back35.py
U Zope3/trunk/src/zope/publisher/interfaces/browser.py
A Zope3/trunk/src/zope/publisher/tests/test_browser.py
A Zope3/trunk/src/zope/rdb/
U Zope3/trunk/src/zope/schema/interfaces.py
A Zope3/trunk/src/zope/security/adapter.py
U Zope3/trunk/src/zope/security/checker.py
A Zope3/trunk/src/zope/security/meta.zcml
A Zope3/trunk/src/zope/security/permission.py
A Zope3/trunk/src/zope/security/tests/test_adapter.py
U Zope3/trunk/src/zope/security/tests/test_checker.py
A Zope3/trunk/src/zope/security/tests/test_permission.py
A Zope3/trunk/src/zope/security/zcml.py
A Zope3/trunk/src/zope/sendmail/
A Zope3/trunk/src/zope/size/
U Zope3/trunk/src/zope/tal/dummyengine.py
U Zope3/trunk/src/zope/tal/talinterpreter.py
U Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py
A Zope3/trunk/src/zope/traversing/
U Zope3/trunk/src/zope/viewlet/DEPENDENCIES.cfg
U Zope3/trunk/src/zope/viewlet/README.txt
U Zope3/trunk/src/zope/viewlet/directives.txt
U Zope3/trunk/src/zope/viewlet/interfaces.py
U Zope3/trunk/src/zope/viewlet/metaconfigure.py
U Zope3/trunk/src/zope/viewlet/metadirectives.py
U Zope3/trunk/src/zope/viewlet/tests.py
U Zope3/trunk/src/zope/viewlet/viewlet.py
U Zope3/trunk/src/zope/wfmc/README.txt
U Zope3/trunk/src/zwiki/browser/wiki.py
U Zope3/trunk/src/zwiki/browser/wikipage.py
U Zope3/trunk/src/zwiki/comment.py
U Zope3/trunk/src/zwiki/configure.zcml
U Zope3/trunk/src/zwiki/interfaces.py
U Zope3/trunk/src/zwiki/tests/test_docstrings.py
U Zope3/trunk/src/zwiki/tests/test_traversable.py
U Zope3/trunk/src/zwiki/tests/test_traverser.py
U Zope3/trunk/src/zwiki/tests/test_wikimail.py
U Zope3/trunk/src/zwiki/tests/test_wikipagehierarchy.py
U Zope3/trunk/src/zwiki/traversal.py
U Zope3/trunk/src/zwiki/wikipage.py
A Zope3/trunk/to-do.txt
U Zope3/trunk/utilities/runurl.py
-=-
Modified: Zope3/trunk/releases/Zope/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/releases/Zope/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/releases/Zope/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -6,6 +6,8 @@
zope.contentprovider
zope.formlib
+zope.rdb
+zope.sendmail
zope.testing
zope.viewlet
zope.app
@@ -19,10 +21,8 @@
zope.app.generations
zope.app.i18nfile
zope.app.introspector
-zope.app.mail
zope.app.onlinehelp
zope.app.pluggableauth
-zope.app.rdb
zope.app.securitypolicy
zope.app.server
zope.app.session
Modified: Zope3/trunk/src/buddydemo/browser.py
===================================================================
--- Zope3/trunk/src/buddydemo/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/buddydemo/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,7 +1,7 @@
import zope.interface
from buddydemo.interfaces import IBuddy, IPostalInfo
from zope.event import notify
-from zope.app.event.objectevent import ObjectModifiedEvent
+from zope.lifecycleevent import ObjectModifiedEvent
class BuddyInfo:
"""Provide an interface for viewing a Buddy
Modified: Zope3/trunk/src/buddydemo/configure.zcml
===================================================================
--- Zope3/trunk/src/buddydemo/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/buddydemo/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -9,7 +9,7 @@
<class class=".buddy.Buddy">
<implements
- interface="zope.app.annotation.IAttributeAnnotatable" />
+ interface="zope.annotation.IAttributeAnnotatable" />
<require permission="zope.View"
interface=".interfaces.IBuddy" />
<require permission="zope.ManageContent"
Modified: Zope3/trunk/src/buddydemo/tests.py
===================================================================
--- Zope3/trunk/src/buddydemo/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/buddydemo/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -79,9 +79,8 @@
There should be an ObjectModifiedEvent event logged:
- >>> from zope.app.event.tests.placelesssetup \
- ... import getEvents
- >>> from zope.app.event.interfaces \
+ >>> from zope.component.eventtesting import getEvents
+ >>> from zope.lifecycleevent.interfaces \
... import IObjectModifiedEvent
>>> [event] = getEvents(IObjectModifiedEvent)
>>> event.object is fake
Modified: Zope3/trunk/src/bugtracker/__init__.py
===================================================================
--- Zope3/trunk/src/bugtracker/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,5 +15,5 @@
$Id$
"""
-from zope.i18n import MessageIDFactory
-TrackerMessageID = MessageIDFactory('bugtracker')
+from zope.i18nmessageid import MessageFactory
+TrackerMessageID = MessageFactory('bugtracker')
Modified: Zope3/trunk/src/bugtracker/browser/bug.py
===================================================================
--- Zope3/trunk/src/bugtracker/browser/bug.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/browser/bug.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,12 +25,12 @@
from zope.schema.vocabulary import getVocabularyRegistry
from zope.security.checker import getChecker
from zope.structuredtext.html import HTML
+from zope.size.interfaces import ISized
+from zope.dublincore.interfaces import IZopeDublinCore
from zope.app import zapi
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.form import CustomWidgetFactory
from zope.app.form.browser import TextWidget, TextAreaWidget, DropdownWidget
-from zope.app.size.interfaces import ISized
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from bugtracker.interfaces import IComment
Modified: Zope3/trunk/src/bugtracker/browser/comment.py
===================================================================
--- Zope3/trunk/src/bugtracker/browser/comment.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/browser/comment.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,15 +17,13 @@
"""
import re
+import zope.component
from zope.proxy import removeAllProxies
from zope.schema.vocabulary import getVocabularyRegistry
from zope.structuredtext.document import Document
from zope.structuredtext.html import HTML
+from zope.dublincore.interfaces import IZopeDublinCore
-from zope.app import zapi
-from zope.app.dublincore.interfaces import IZopeDublinCore
-
-
class CommentViewBase(object):
def __init__(self, context, request):
@@ -53,9 +51,9 @@
def body(self):
ttype = getattr(self.context.body, 'ttype', None)
if ttype is not None:
- source = zapi.createObject(self.context.body.ttype,
- self.context.body)
- view = zapi.getMultiAdapter(
+ source = zope.component.createObject(self.context.body.ttype,
+ self.context.body)
+ view = zope.component.getMultiAdapter(
(removeAllProxies(source), self.request))
html = view.render()
else:
Modified: Zope3/trunk/src/bugtracker/browser/tracker.py
===================================================================
--- Zope3/trunk/src/bugtracker/browser/tracker.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/browser/tracker.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,11 +15,11 @@
$Id$
"""
-from zope.app import zapi
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.schema.vocabulary import getVocabularyRegistry
+from zope.traversing.api import getName
from zope.app.container.browser.adding import Adding
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.schema.vocabulary import getVocabularyRegistry
from bugtracker import TrackerMessageID as _
from bugtracker.batching import Batch
@@ -35,7 +35,7 @@
def add(self, content):
self.context['dummy'] = content
- self.contentName = zapi.name(content)
+ self.contentName = getName(content)
return self.context[name]
@@ -161,7 +161,7 @@
return len(filter(IComment.isImplementedBy, self.context.values()))
def name(self):
- return zapi.name(self.context)
+ return getName(self.context)
def descriptionPreview(self):
if len(self.context.description) < 200:
Modified: Zope3/trunk/src/bugtracker/bug.py
===================================================================
--- Zope3/trunk/src/bugtracker/bug.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/bug.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,12 +17,12 @@
"""
from zope.interface import implements
from zope.proxy import removeAllProxies
+from zope.annotation.interfaces import IAnnotations
+from zope.dublincore.interfaces import IZopeDublinCore
from zope.app import zapi
-from zope.app.annotation.interfaces import IAnnotations
from zope.app.container.btree import BTreeContainer
from zope.app.container.contained import contained
-from zope.app.dublincore.interfaces import IZopeDublinCore
from bugtracker.interfaces import IBug, IComment
from bugtracker.interfaces import IAttachmentContainer
Modified: Zope3/trunk/src/bugtracker/configure.zcml
===================================================================
--- Zope3/trunk/src/bugtracker/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -172,7 +172,7 @@
<class class=".tracker.BugTracker">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
+ interface="zope.annotation.interfaces.IAttributeAnnotatable" />
<factory
id="bugtracker.BugTracker"
@@ -242,7 +242,7 @@
<class class=".bug.Bug">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"/>
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"/>
<factory
id="bugtracker.Bug"
@@ -322,7 +322,7 @@
<class class=".comment.Comment">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"/>
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"/>
<factory
id="bugtracker.BugComment"
@@ -376,8 +376,8 @@
<!-- Register event listener for change mails -->
<subscriber
handler=".mail.Mailer"
- for="zope.app.event.interfaces.IObjectCreatedEvent
- zope.app.event.interfaces.IObjectModifiedEvent" />
+ for="zope.lifecycleevent.interfaces.IObjectCreatedEvent
+ zope.lifecycleevent.interfaces.IObjectModifiedEvent" />
<!-- Register various browser related components, including all views -->
Modified: Zope3/trunk/src/bugtracker/exportimport.py
===================================================================
--- Zope3/trunk/src/bugtracker/exportimport.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/exportimport.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,9 +25,8 @@
from zope.publisher.browser import TestRequest
from zope.schema.vocabulary import getVocabularyRegistry
from zope.security.proxy import removeSecurityProxy
+from zope.dublincore.interfaces import IZopeDublinCore
-from zope.app import zapi
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.file import File, Image
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
Modified: Zope3/trunk/src/bugtracker/mail.py
===================================================================
--- Zope3/trunk/src/bugtracker/mail.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/mail.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,15 +15,14 @@
$Id$
"""
+import zope.component
from zope.interface import implements
+from zope.annotation.interfaces import IAnnotations
+from zope.lifecycleevent.interfaces import IObjectCreatedEvent, IObjectModifiedEvent
+from zope.sendmail.interfaces import IMailDelivery
+from zope.traversing.api import getName, getParent
+from bugtracker.interfaces import IBug, IBugTracker, IMailSubscriptions
-from zope.app import zapi
-from zope.app.annotation.interfaces import IAnnotations
-from zope.app.event.interfaces import IObjectCreatedEvent, IObjectModifiedEvent
-from zope.app.mail.interfaces import IMailDelivery
-
-from interfaces import IBug, IBugTracker, IMailSubscriptions
-
SubscriberKey = 'bugtracker.MailSubsriptions.emails'
class MailSubscriptions:
@@ -70,19 +69,19 @@
self.handleModified(event.object)
def handleAdded(self, object):
- subject = 'Added: %s (%s)' %(object.title, zapi.name(object))
+ subject = 'Added: %s (%s)' %(object.title, getName(object))
emails = self.getAllSubscribers(object)
body = object.description
self.mail(emails, subject, body)
def handleModified(self, object):
- subject = 'Modified: %s (%s)' %(object.title, zapi.name(object))
+ subject = 'Modified: %s (%s)' %(object.title, getName(object))
emails = self.getAllSubscribers(object)
body = object.description
self.mail(emails, subject, body)
def handleRemoved(self, object):
- subject = 'Removed: %s (%s)' %(object.title, zapi.name(object))
+ subject = 'Removed: %s (%s)' %(object.title, getName(object))
emails = self.getAllSubscribers(object)
body = object.description
self.mail(emails, subject, body)
@@ -93,7 +92,7 @@
obj = object
while IBug.providedBy(obj) or IBugTracker.providedBy(obj):
emails += tuple(IMailSubscriptions(obj).getSubscriptions())
- obj = zapi.getParent(obj)
+ obj = getParent(obj)
return emails
def mail(self, toaddrs, subject, body):
@@ -101,5 +100,5 @@
if not toaddrs:
return
msg = 'Subject: %s\n\n\n%s' %(subject, body)
- mail_utility = zapi.getUtility(IMailDelivery, 'bug-mailer')
+ mail_utility = zope.component.getUtility(IMailDelivery, 'bug-mailer')
mail_utility.send('bugtracker at zope3.org' , toaddrs, msg)
Modified: Zope3/trunk/src/bugtracker/tests/placelesssetup.py
===================================================================
--- Zope3/trunk/src/bugtracker/tests/placelesssetup.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/tests/placelesssetup.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -24,30 +24,29 @@
from zope.component.interfaces import IFactory
from zope.interface import classImplements, implements
from zope.schema.vocabulary import getVocabularyRegistry
+from zope.size.interfaces import ISized
+from zope.size import DefaultSized
+from zope.traversing.interfaces import IContainmentRoot, ITraverser
+from zope.traversing.interfaces import ITraversable, IPhysicallyLocatable
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.traversing.adapters import DefaultTraversable, Traverser
+from zope.location.interfaces import ILocation
+from zope.location.traversing import LocationPhysicallyLocatable
+from zope.annotation.attribute import AttributeAnnotations
+from zope.annotation.interfaces import IAnnotations, IAttributeAnnotatable
+from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter
+from zope.dublincore.interfaces import IWriteZopeDublinCore
+from zope.dublincore.interfaces import IZopeDublinCore
-from zope.app import zapi
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup as SetupBase
-from zope.app.annotation.attribute import AttributeAnnotations
from zope.app.file import File
from zope.app.container.interfaces import INameChooser
-from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
-from zope.app.annotation.interfaces import IAnnotations, IAttributeAnnotatable
-from zope.app.dublincore.interfaces import IWriteZopeDublinCore
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.location.interfaces import ILocation
-from zope.app.location.traversing import LocationPhysicallyLocatable
from zope.app.renderer.plaintext import IPlainTextSource
from zope.app.renderer.plaintext import PlainTextToHTMLRenderer
from zope.app.renderer.plaintext import PlainTextSourceFactory
from zope.app.security.interfaces import IAuthentication
-from zope.app.size.interfaces import ISized
-from zope.app.traversing.interfaces import IContainmentRoot, ITraverser
-from zope.app.traversing.interfaces import ITraversable, IPhysicallyLocatable
from zope.app.security.principalregistry import principalRegistry
-from zope.app.size import DefaultSized
-from zope.app.traversing.adapters import DefaultTraversable, Traverser
-from zope.app.traversing.interfaces import IPhysicallyLocatable
from bugtracker.bug import Bug, BugDependencyAdapter
from bugtracker.comment import Comment
Modified: Zope3/trunk/src/bugtracker/tests/test_dependencies.py
===================================================================
--- Zope3/trunk/src/bugtracker/tests/test_dependencies.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/tests/test_dependencies.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,32 +17,26 @@
"""
import unittest
+import zope.component
+from zope.component.testing import PlacelessSetup
from zope.interface import classImplements
-from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.location.traversing import LocationPhysicallyLocatable
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.annotation.attribute import AttributeAnnotations
-from zope.app.testing import ztapi
-from zope.app.annotation.interfaces import IAnnotations, IAttributeAnnotatable
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.location.interfaces import ILocation
-from zope.app.location.traversing import LocationPhysicallyLocatable
-from zope.app.traversing.interfaces import IPhysicallyLocatable
-
from bugtracker.interfaces import IBug, IBugDependencies
from bugtracker.bug import Bug, BugDependencyAdapter
from bugtracker.tracker import BugTracker
-
class DependencyTest(PlacelessSetup, unittest.TestCase):
def setUp(self):
super(DependencyTest, self).setUp()
classImplements(Bug, IAttributeAnnotatable);
- ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,
- AttributeAnnotations)
- ztapi.provideAdapter(IBug, IBugDependencies,
- BugDependencyAdapter)
- ztapi.provideAdapter(ILocation, IPhysicallyLocatable,
- LocationPhysicallyLocatable)
+ zope.component.provideAdapter(AttributeAnnotations)
+ zope.component.provideAdapter(BugDependencyAdapter, (IBug,),
+ IBugDependencies)
+ zope.component.provideAdapter(LocationPhysicallyLocatable)
self.bug = Bug()
Modified: Zope3/trunk/src/bugtracker/tests/test_mail.py
===================================================================
--- Zope3/trunk/src/bugtracker/tests/test_mail.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/tests/test_mail.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,21 +17,20 @@
"""
import unittest
-from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.component.testing import PlacelessSetup
from zope.interface import classImplements, implements
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.location.interfaces import ILocation
+from zope.location.traversing import LocationPhysicallyLocatable
+from zope.annotation.interfaces import IAnnotations, IAttributeAnnotatable
+from zope.annotation.attribute import AttributeAnnotations
+from zope.lifecycleevent import ObjectModifiedEvent
+from zope.dublincore.interfaces import IWriteZopeDublinCore
+from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter
+from zope.sendmail.interfaces import IMailDelivery
from zope.app.testing import ztapi
-from zope.app.annotation.interfaces import IAnnotations, IAttributeAnnotatable
-from zope.app.dublincore.interfaces import IWriteZopeDublinCore
-from zope.app.traversing.interfaces import IPhysicallyLocatable
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
-from zope.app.event.objectevent import ObjectModifiedEvent
-from zope.app.location.interfaces import ILocation
-from zope.app.location.traversing import LocationPhysicallyLocatable
-from zope.app.mail.interfaces import IMailDelivery
-
from bugtracker.bug import Bug
from bugtracker.interfaces import IBug, IBugTracker, IMailSubscriptions
from bugtracker.mail import MailSubscriptions, SubscriberKey, Mailer
Modified: Zope3/trunk/src/bugtracker/tests/test_tracker.py
===================================================================
--- Zope3/trunk/src/bugtracker/tests/test_tracker.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/tests/test_tracker.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,8 +17,8 @@
"""
import unittest
-from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
-from zope.app.dublincore.interfaces import IWriteZopeDublinCore
+from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter
+from zope.dublincore.interfaces import IWriteZopeDublinCore
from zope.app.container.tests.test_btree import TestBTreeContainer
from bugtracker.tests.placelesssetup import PlacelessSetup
Modified: Zope3/trunk/src/bugtracker/tests/test_vocabularies.py
===================================================================
--- Zope3/trunk/src/bugtracker/tests/test_vocabularies.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/tests/test_vocabularies.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,14 +20,13 @@
from zope.interface import classImplements, implements
from zope.schema.interfaces import ITokenizedTerm
from zope.schema.vocabulary import getVocabularyRegistry
+from zope.annotation.attribute import AttributeAnnotations
+from zope.annotation.interfaces import IAnnotations, IAttributeAnnotatable
-from zope.app import zapi
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.annotation.interfaces import IAnnotations, IAttributeAnnotatable
from zope.app.container.contained import contained, Contained
-from zope.app.security.interfaces import IAuthentication
+from zope.app.security.interfaces import IAuthentication, PrincipalLookupError
from zope.app.security.principalregistry import principalRegistry, Principal
from bugtracker.interfaces import IManagableVocabulary
@@ -226,13 +225,13 @@
def test_getTerm(self):
self.assertEqual(self.vocab.getTerm('1').value, '1')
self.assertEqual(self.vocab.getTerm('1').principal['login'], 'one')
- self.assertRaises(KeyError, self.vocab.getTerm, ('3',))
+ self.assertRaises(PrincipalLookupError, self.vocab.getTerm, ('3',))
def test_getTermByToken(self):
vocab = self.vocab
self.assertEqual(vocab.getTermByToken('1').value, '1')
self.assertEqual(vocab.getTermByToken('1').principal['login'], 'one')
- self.assertRaises(KeyError, vocab.getTermByToken, ('3',))
+ self.assertRaises(PrincipalLookupError, vocab.getTermByToken, ('3',))
class SampleVocabulary(ManagableVocabulary):
Modified: Zope3/trunk/src/bugtracker/tests/test_xmlexportimport.py
===================================================================
--- Zope3/trunk/src/bugtracker/tests/test_xmlexportimport.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/tests/test_xmlexportimport.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,9 +18,9 @@
import unittest, os
from datetime import datetime
+from zope.datetime import parseDatetimetz
+from zope.dublincore.interfaces import IZopeDublinCore
from zope.app.file import File
-from zope.app.datetimeutils import parseDatetimetz
-from zope.app.dublincore.interfaces import IZopeDublinCore
from bugtracker import tests
from bugtracker.bug import Bug, BugDependencyAdapter
Modified: Zope3/trunk/src/bugtracker/tracker.py
===================================================================
--- Zope3/trunk/src/bugtracker/tracker.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/tracker.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,8 +19,8 @@
from persistent import Persistent
from zope.interface import implements
+from zope.dublincore.interfaces import IZopeDublinCore
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.container.btree import BTreeContainer
from zope.app.container.interfaces import INameChooser
Modified: Zope3/trunk/src/bugtracker/vocabulary.py
===================================================================
--- Zope3/trunk/src/bugtracker/vocabulary.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/vocabulary.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,12 +21,12 @@
from zope.interface import implements, classProvides
from zope.schema.interfaces import ITokenizedTerm, ITitledTokenizedTerm
from zope.schema.interfaces import IVocabulary, IVocabularyTokenized
+from zope.schema.interfaces import IVocabularyFactory
from zope.schema.vocabulary import getVocabularyRegistry
from zope.security.proxy import removeSecurityProxy
+from zope.annotation.interfaces import IAnnotatable, IAnnotations
from zope.app import zapi
-from zope.app.schema.interfaces import IVocabularyFactory
-from zope.app.annotation.interfaces import IAnnotatable, IAnnotations
from bugtracker.interfaces import IManagableVocabulary, IBugTracker
from bugtracker.interfaces import IStatusVocabulary
@@ -99,8 +99,8 @@
def delete(self, value):
if value == self.default.value:
- error_msg = _("Cannot delete default value '${value}'.")
- error_msg.mapping = {'value': value}
+ error_msg = _("Cannot delete default value '${value}'.",
+ mapping = {'value': value})
raise ValueError(error_msg)
del self.annotations[self.key][value]
@@ -123,8 +123,7 @@
value = value.value
if value not in self:
error_msg = _("The value '${value}' was not found in the "
- "vocabulary")
- error_msg.mapping = {'value': value}
+ "vocabulary", mapping={'value': value})
raise ValueError(error_msg)
self.annotations[self.key+'/default'] = value
Modified: Zope3/trunk/src/bugtracker/xmlrpc.py
===================================================================
--- Zope3/trunk/src/bugtracker/xmlrpc.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/bugtracker/xmlrpc.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,11 +22,11 @@
from zope.event import notify
from zope.app.publisher.xmlrpc import MethodPublisher
from zope.schema.vocabulary import getVocabularyRegistry
+from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
from zope.app import zapi
from zope.app.container.contained import contained
from zope.app.container.interfaces import INameChooser
-from zope.app.event.objectevent import ObjectCreatedEvent, ObjectModifiedEvent
from zope.app.file import File, Image
from bugtracker.bug import Bug
Modified: Zope3/trunk/src/z3checkins/browser.py
===================================================================
--- Zope3/trunk/src/z3checkins/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/z3checkins/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -7,16 +7,16 @@
import mailbox
from StringIO import StringIO
+import zope.component
from zope.interface import implements
from zope.exceptions import DuplicationError
from zope.proxy import removeAllProxies
+from zope.datetime import parseDatetimetz, DateTimeError
+from zope.publisher.browser import BrowserView
+from zope.dublincore.interfaces import IZopeDublinCore
-from zope.app import zapi
-from zope.app.datetimeutils import parseDatetimetz, DateTimeError
-from zope.app.publisher.browser import BrowserView
from zope.app.form import CustomWidgetFactory
from zope.app.form.browser import FileWidget
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.pagetemplate import ViewPageTemplateFile
from z3checkins.message import Bookmark
@@ -35,7 +35,7 @@
def createAndAdd(self, data):
if data.has_key('data'): # TODO should we bark if no data is given?
msg_raw = data['data']
- parser = zapi.getUtility(IMessageParser)
+ parser = zope.component.getUtility(IMessageParser)
if msg_raw.startswith("From "):
# detected an mbox file
mbox = StringIO(msg_raw)
@@ -165,7 +165,8 @@
previous_message = item.log_message
else:
same_as_previous = None
- view = zapi.getMultiAdapter((item, self.request), name='html')
+ view = zope.component.getMultiAdapter((item, self.request),
+ name='html')
output = view(same_as_previous=same_as_previous)
html.append(output)
return "".join(html)
Modified: Zope3/trunk/src/z3checkins/configure.zcml
===================================================================
--- Zope3/trunk/src/z3checkins/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/z3checkins/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -11,7 +11,7 @@
interface=".interfaces.IMessage" />
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
+ interface="zope.annotation.interfaces.IAttributeAnnotatable" />
</class>
@@ -21,7 +21,7 @@
interface=".interfaces.ICheckinMessage" />
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
+ interface="zope.annotation.interfaces.IAttributeAnnotatable" />
</class>
@@ -47,7 +47,7 @@
description="A checkin folder" />
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
+ interface="zope.annotation.interfaces.IAttributeAnnotatable" />
</class>
@@ -61,7 +61,7 @@
<adapter for=".interfaces.IMessage"
factory=".folder.MessageSized"
permission="zope.View"
- provides="zope.app.size.interfaces.ISized" />
+ provides="zope.size.interfaces.ISized" />
<utility factory=".message.CheckinMessageParser"
Modified: Zope3/trunk/src/z3checkins/folder.py
===================================================================
--- Zope3/trunk/src/z3checkins/folder.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/z3checkins/folder.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -8,10 +8,10 @@
from persistent.list import PersistentList
from zope.interface import implements
+from zope.size.interfaces import ISized
from zope.app.container.btree import BTreeContainer
from zope.app.container.interfaces import INameChooser
from zope.app.container.interfaces import IContainerNamesContainer
-from zope.app.size.interfaces import ISized
from z3checkins.interfaces import ICheckinFolder, IMessage
Modified: Zope3/trunk/src/z3checkins/message.py
===================================================================
--- Zope3/trunk/src/z3checkins/message.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/z3checkins/message.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -27,16 +27,15 @@
from zope.exceptions import DuplicationError
from zope.interface import implements
from zope.proxy import removeAllProxies
+from zope.datetime import parseDatetimetz, DateTimeError
+from zope.publisher.browser import BrowserView
+from zope.dublincore.interfaces import IZopeDublinCore
-from zope.app import zapi
from zope.app.container.contained import Contained
from zope.app.container.interfaces import IReadContainer
-from zope.app.datetimeutils import parseDatetimetz, DateTimeError
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.form import CustomWidgetFactory
from zope.app.form.browser import FileWidget
from zope.app.pagetemplate import ViewPageTemplateFile
-from zope.app.publisher.browser import BrowserView
from z3checkins.interfaces import IMessage, ICheckinMessage, IMessageContained
from z3checkins.interfaces import IBookmark, IMessageParser, FormatError
Modified: Zope3/trunk/src/z3checkins/tests/test_message.py
===================================================================
--- Zope3/trunk/src/z3checkins/tests/test_message.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/z3checkins/tests/test_message.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -268,7 +268,7 @@
def test_interface(self):
from z3checkins.folder import MessageSized
- from zope.app.size.interfaces import ISized
+ from zope.size.interfaces import ISized
self.assert_(ISized.providedBy(MessageSized(MessageStub())))
def test_sizeForSorting(self):
Property changes on: Zope3/trunk/src/zope
___________________________________________________________________
Name: svn:externals
- testing -r41141 svn://svn.zope.org/repos/main/zope.testing/trunk/src/zope/testing
+ testing -r41141 svn://svn.zope.org/repos/main/zope.testing/trunk/src/zope/testing
browsertestrecorder -r67598 svn://svn.zope.org/repos/main/zope.testrecorder/trunk
Copied: Zope3/trunk/src/zope/annotation (from rev 67629, Zope3/branches/jim-adapter/src/zope/annotation)
Modified: Zope3/trunk/src/zope/app/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/app/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -4,13 +4,20 @@
transaction
zdaemon
zodbcode
+zope.annotation
zope.cachedescriptors
zope.component
zope.configuration
+zope.copypastemove
+zope.datetime
+zope.decorator
+zope.deferredimport
zope.deprecation
zope.dottedname
+zope.dublincore
zope.event
zope.exceptions
+zope.filerepresentation
zope.formlib
# zope.hookable isn't imported here, but we need it to be available
# when zope.component is first imported
@@ -18,6 +25,8 @@
zope.i18n
zope.index
zope.interface
+zope.lifecycleevent
+zope.location
zope.modulealias
zope.pagetemplate
zope.proxy
@@ -25,8 +34,10 @@
zope.schema
zope.security
zope.server
+zope.size
zope.tal
zope.tales
zope.testbrowser
zope.testing
zope.thread
+zope.traversing
\ No newline at end of file
Modified: Zope3/trunk/src/zope/app/PACKAGE.cfg
===================================================================
--- Zope3/trunk/src/zope/app/PACKAGE.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/PACKAGE.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -27,7 +27,6 @@
# Code:
-annotation
applicationcontrol
appsetup
authentication
@@ -41,18 +40,11 @@
# We should include contenttypes via the dependency mechanism.
contenttypes
content_types.py
-copypastemove
-# Maybe convert to a package as well.
-datetimeutils.py
debug
-# move to zope.app.location
-decorator.py
dependable
-dublincore
error
-event
+event #BBB
exception
-filerepresentation
folder
form
ftests
@@ -64,27 +56,20 @@
# maybe we can refactor this away
interface
layers.py
-location
pagetemplate
preview
principalannotation
publication
publisher
-registration
rotterdam
schema
security
servicenames.py
site
-size
skins.py
tests
testing
-# This should go into the (new) datetimeutils package
-timezones.py
locales
-traversing
-utility
wsgi
zopeappgenerations
zapi
Modified: Zope3/trunk/src/zope/app/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,3 +15,4 @@
$Id$
"""
+
Property changes on: Zope3/trunk/src/zope/app/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: Zope3/trunk/src/zope/app/annotation/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/annotation/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/annotation/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,94 +0,0 @@
-Annotations
-===========
-
-There is more to document about annotations, but we'll just sketch out
-a scenario on how to use the annotation factory for now. This is one
-of the easiest ways to use annotations -- basically you can see them
-as persistent, writeable adapters.
-
-First, let's make a persistent object we can create annotations for:
-
- >>> from zope import interface
- >>> class IFoo(interface.Interface):
- ... pass
- >>> from zope.app.annotation.interfaces import IAttributeAnnotatable
- >>> from persistent import Persistent
- >>> class Foo(Persistent):
- ... interface.implements(IFoo, IAttributeAnnotatable)
-
-We directly say that Foo implements IAttributeAnnotatable here. In
-practice this is often done in ZCML, using the `implements`
-subdirective of the `content` or `class` directive.
-
-Now let's create an annotation for this:
-
- >>> class IBar(interface.Interface):
- ... a = interface.Attribute('A')
- ... b = interface.Attribute('B')
- >>> from zope import component
- >>> class Bar(Persistent):
- ... interface.implements(IBar)
- ... component.adapts(IFoo)
- ... def __init__(self):
- ... self.a = 1
- ... self.b = 2
-
-Note that the annotation implementation does not expect any arguments
-to its `__init__`. Otherwise it's basically an adapter.
-
-Now, we'll register the annotation as an adapter. Do do this we use
-the `factory` function provided by `zope.app.annotation`:
-
- >>> from zope.app.annotation import factory
- >>> component.provideAdapter(factory(Bar))
-
-Note that we do not need to specify what the adapter provides or what
-it adapts - we already do this on the annotation class itself.
-
-Now we let's make an instance of `Foo`, and make an annotation for it.
-
- >>> foo = Foo()
- >>> bar = IBar(foo)
- >>> bar.a
- 1
- >>> bar.b
- 2
-
-We'll change `a` and get the annotation again. Our change is still
-there:
-
- >>> bar.a = 3
- >>> IBar(foo).a
- 3
-
-Of course it's still different for another instance of `Foo`:
-
- >>> foo2 = Foo()
- >>> IBar(foo2).a
- 1
-
-What if our annotation does not provide what it adapts with
-`component.adapts`? It will complain:
-
- >>> class IQux(interface.Interface):
- ... pass
- >>> class Qux(Persistent):
- ... interface.implements(IQux)
- >>> component.provideAdapter(factory(Qux)) # doctest: +ELLIPSIS
- Traceback (most recent call last):
- ...
- TypeError: Missing 'zope.component.adapts' on annotation
-
-It's possible to provide an annotation with an explicit key. (If the
-key is not supplied, the key is deduced from the anotation's dotted
-name, provided it is a class.)
-
- >>> class IHoi(interface.Interface):
- ... pass
- >>> class Hoi(Persistent):
- ... interface.implements(IHoi)
- ... component.adapts(IFoo)
- >>> component.provideAdapter(factory(Hoi, 'my.unique.key'))
- >>> isinstance(IHoi(foo), Hoi)
- True
-
Modified: Zope3/trunk/src/zope/app/annotation/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/annotation/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/annotation/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,21 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Annotation (meta data) support
-
-$Id$
-"""
-
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.annotation.interfaces import IAnnotations
-from zope.app.annotation._factory import factory
+# This module has moved to zope.annotation
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.annotation',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/annotation/__init__.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.2
Deleted: Zope3/trunk/src/zope/app/annotation/_factory.py
===================================================================
--- Zope3/trunk/src/zope/app/annotation/_factory.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/annotation/_factory.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,53 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2006 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Adapter factory.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import zope.component
-import zope.interface
-from zope.app.annotation.interfaces import IAnnotations
-import zope.app.container.contained
-
-
-def factory(factory, key=None):
- """Adapter factory to help create annotations easily.
- """
- # if no key is provided,
- # we'll determine the unique key based on the factory's dotted name
- if key is None:
- key = factory.__module__ + '.' + factory.__name__
-
- adapts = zope.component.adaptedBy(factory)
- if adapts is None:
- raise TypeError("Missing 'zope.component.adapts' on annotation")
-
- @zope.component.adapter(list(adapts)[0])
- @zope.interface.implementer(list(zope.component.implementedBy(factory))[0])
- def getAnnotation(context):
- annotations = IAnnotations(context)
- try:
- return annotations[key]
- except KeyError:
- result = factory()
- annotations[key] = result
- zope.app.container.contained.contained(
- result, context, key)
- return result
-
- # Convention to make adapter introspectable, used by apidoc
- getAnnotation.factory = factory
- return getAnnotation
Modified: Zope3/trunk/src/zope/app/annotation/attribute.py
===================================================================
--- Zope3/trunk/src/zope/app/annotation/attribute.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/annotation/attribute.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,80 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Attribute Annotations implementation
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from UserDict import DictMixin
-from BTrees.OOBTree import OOBTree
-
-from zope import component, interface
-
-from zope.app.annotation import interfaces
-
-class AttributeAnnotations(DictMixin):
- """Store annotations on an object
-
- Store annotations in the `__annotations__` attribute on a
- `IAttributeAnnotatable` object.
- """
- interface.implements(interfaces.IAnnotations)
- component.adapts(interfaces.IAttributeAnnotatable)
-
- def __init__(self, obj):
- self.obj = obj
-
- def __nonzero__(self):
- return bool(getattr(self.obj, '__annotations__', 0))
-
- def get(self, key, default=None):
- """See zope.app.annotation.interfaces.IAnnotations"""
- annotations = getattr(self.obj, '__annotations__', None)
- if not annotations:
- return default
-
- return annotations.get(key, default)
-
- def __getitem__(self, key):
- annotations = getattr(self.obj, '__annotations__', None)
- if annotations is None:
- raise KeyError(key)
-
- return annotations[key]
-
- def keys(self):
- annotations = getattr(self.obj, '__annotations__', None)
- if annotations is None:
- return []
-
- return annotations.keys()
-
- def __setitem__(self, key, value):
- """See zope.app.annotation.interfaces.IAnnotations"""
- try:
- annotations = self.obj.__annotations__
- except AttributeError:
- annotations = self.obj.__annotations__ = OOBTree()
-
- annotations[key] = value
-
- def __delitem__(self, key):
- """See zope.app.interfaces.annotation.IAnnotations"""
- try:
- annotation = self.obj.__annotations__
- except AttributeError:
- raise KeyError(key)
-
- del annotation[key]
+# This module has moved to zope.annotation.attribute
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.annotation.attribute',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/annotation/attribute.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.1
Deleted: Zope3/trunk/src/zope/app/annotation/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/annotation/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/annotation/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,11 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope">
-
-
- <adapter
- for=".interfaces.IAttributeAnnotatable"
- provides=".interfaces.IAnnotations"
- factory=".attribute.AttributeAnnotations"
- />
-
-</configure>
Modified: Zope3/trunk/src/zope/app/annotation/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/annotation/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/annotation/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,83 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Annotations store arbitrary application data under package-unique keys.
-
-$Id$
-"""
-
-__docformat__ = 'restructuredtext'
-
-from zope.interface import Interface
-
-class IAnnotatable(Interface):
- """Marker interface for objects that support storing annotations.
-
- This interface says "There exists an adapter to an IAnnotations
- for an object that implements `IAnnotatable`".
-
- Classes should not directly declare that they implement this interface.
- Instead they should implement an interface derived from this one, which
- details how the annotations are to be stored, such as
- `IAttributeAnnotatable`.
- """
-
-class IAnnotations(IAnnotatable):
- """Stores arbitrary application data under package-unique keys.
-
- By "package-unique keys", we mean keys that are are unique by
- virtue of including the dotted name of a package as a prefex. A
- package name is used to limit the authority for picking names for
- a package to the people using that package.
-
- For example, when implementing annotations for storing Zope
- Dublin-Core meta-data, we use the key::
-
- "zope.app.dublincore.ZopeDublinCore"
-
- """
-
- def __nonzero__():
- """Test whether there are any annotations
- """
-
- def __getitem__(key):
- """Return the annotation stored under key.
-
- Raises KeyError if key not found.
- """
-
- def get(key, default=None):
- """Return the annotation stored under key, or default if not found.
- """
-
- def __setitem__(key, value):
- """Store annotation under key.
-
- In order to avoid key collisions, users of this interface must
- use their dotted package name as part of the key name.
- """
-
- def __delitem__(key):
- """Removes the annotation stored under key.
-
- Raises a KeyError if the key is not found.
- """
-
-class IAttributeAnnotatable(IAnnotatable):
- """Marker indicating that annotations can be stored on an attribute.
-
- This is a marker interface giving permission for an `IAnnotations`
- adapter to store data in an attribute named `__annotations__`.
-
- """
+# This module has moved to zope.annotation.interfaces
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.annotation.interfaces',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/annotation/interfaces.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.1
Deleted: Zope3/trunk/src/zope/app/apidoc/apidoc-ftesting.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/apidoc-ftesting.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/apidoc-ftesting.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1 +0,0 @@
-<include package="zope.app.apidoc" file="ftesting.zcml" />
Modified: Zope3/trunk/src/zope/app/apidoc/apidoc.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/apidoc.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/apidoc.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,16 +17,15 @@
"""
__docformat__ = 'restructuredtext'
+import zope.component
from zope.interface import implements
+from zope.publisher.browser import applySkin
+from zope.location import locate
+from zope.location.interfaces import ILocation
-from zope.app import zapi
-from zope.app.location import locate
-from zope.app.location.interfaces import ILocation
-from zope.app.publisher.browser import applySkin
+from zope.app.apidoc.interfaces import IDocumentationModule
+from zope.app.apidoc.utilities import ReadContainerBase
-from interfaces import IDocumentationModule
-from utilities import ReadContainerBase
-
class APIDocumentation(ReadContainerBase):
"""Represent the complete API Documentation.
@@ -42,14 +41,14 @@
def get(self, key, default=None):
"""See zope.app.container.interfaces.IReadContainer"""
- utility = zapi.queryUtility(IDocumentationModule, key, default)
+ utility = zope.component.queryUtility(IDocumentationModule, key, default)
if utility != default:
locate(utility, self, key)
return utility
def items(self):
"""See zope.app.container.interfaces.IReadContainer"""
- items = list(zapi.getUtilitiesFor(IDocumentationModule))
+ items = list(zope.component.getUtilitiesFor(IDocumentationModule))
items.sort()
utils = []
for key, value in items:
Modified: Zope3/trunk/src/zope/app/apidoc/bookmodule/book.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/bookmodule/book.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/bookmodule/book.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -83,18 +83,6 @@
doc_path="README.txt"
/>
<bookchapter
- id="registration"
- title="Registration Framework"
- parent="ca/local"
- doc_path="registration.txt"
- />
- <bookchapter
- id="adapterregistry"
- title="Local Adapter Registry"
- parent="ca/local"
- doc_path="adapterregistry.txt"
- />
- <bookchapter
id="site"
title="Local Sites & Site Managers"
parent="ca/local"
Modified: Zope3/trunk/src/zope/app/apidoc/browser/preference.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/browser/preference.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/browser/preference.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,12 +17,13 @@
"""
__docformat__ = "reStructuredText"
+from zope.publisher.browser import applySkin
+
from zope.app import zapi
from zope.app.apidoc.browser.skin import APIDOC
from zope.app.tree.browser.cookie import CookieTreeView
from zope.app.preference.browser import PreferenceGroupFilter
from zope.app.preference.browser import EditPreferenceGroup
-from zope.app.publisher.browser import applySkin
class APIDocPreferencesTree(CookieTreeView):
"""Preferences Tree using the stateful cookie tree."""
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -142,8 +142,8 @@
>>> pprint(details.getInterfaces())
[{'path': 'zope.app.apidoc.interfaces.IDocumentationModule',
'url': 'zope.app.apidoc.interfaces.IDocumentationModule'},
- {'path': 'zope.app.location.interfaces.ILocation',
- 'url': 'zope.app.location.interfaces.ILocation'},
+ {'path': 'zope.location.interfaces.ILocation',
+ 'url': 'zope.location.interfaces.ILocation'},
{'path': 'zope.app.apidoc.codemodule.interfaces.IModuleDocumentation',
'url': 'zope.app.apidoc.codemodule.interfaces.IModuleDocumentation'},
{'path': 'zope.app.container.interfaces.IReadContainer',
@@ -408,7 +408,7 @@
This namespace is used to traverse into the annotations of an object.
>>> import zope.interface
- >>> from zope.app.annotation.interfaces import IAttributeAnnotatable
+ >>> from zope.annotation.interfaces import IAttributeAnnotatable
>>> class Sample(object):
... zope.interface.implements(IAttributeAnnotatable)
@@ -604,4 +604,4 @@
'value_type': 'PersistentList',
'value_type_link': 'persistent/list/PersistentList'}]
-And that's it. Fur some browser-based demonstration see ``introspector.txt``.
\ No newline at end of file
+And that's it. Fur some browser-based demonstration see ``introspector.txt``.
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/class_.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/class_.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/class_.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,13 +21,13 @@
import types
from zope.proxy import removeAllProxies
from zope.security.proxy import removeSecurityProxy
+from zope.traversing.interfaces import TraversalError
from zope.app import zapi
from zope.app.apidoc.interfaces import IDocumentationModule
from zope.app.apidoc.utilities import getPythonPath, getPermissionIds
from zope.app.apidoc.utilities import renderText, getFunctionSignature
from zope.app.apidoc.utilities import isReferencable
-from zope.app.traversing.interfaces import TraversalError
def getTypeLink(type):
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,13 +22,13 @@
import zope.interface
import zope.security.proxy
+from zope import annotation
from zope.interface import directlyProvidedBy, directlyProvides
-from zope.app import zapi, apidoc, annotation
-from zope.app.location import location
-from zope.app.publisher.browser import BrowserView
-from zope.app.traversing.interfaces import IPhysicallyLocatable
-from zope.app.traversing.interfaces import IContainmentRoot
+from zope.traversing.interfaces import IPhysicallyLocatable, IContainmentRoot
+from zope.location import location
+from zope.publisher.browser import BrowserView
+from zope.app import zapi, apidoc
def getTypeLink(type):
if type is types.NoneType:
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/introspector.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -6,25 +6,25 @@
<!-- ++annotations++ Namespace -->
<zope:view
name="annotations" type="*"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
+ provides="zope.traversing.interfaces.ITraversable" for="*"
factory=".introspector.annotationsNamespace"
/>
<zope:adapter
name="annotations"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
+ provides="zope.traversing.interfaces.ITraversable" for="*"
factory=".introspector.annotationsNamespace"
/>
<!-- ISequence ++items++ Namespace -->
<zope:view
name="items" type="*"
- provides="zope.app.traversing.interfaces.ITraversable"
+ provides="zope.traversing.interfaces.ITraversable"
for="zope.interface.common.sequence.IMinimalSequence"
factory=".introspector.sequenceItemsNamespace"
/>
<zope:adapter
name="items"
- provides="zope.app.traversing.interfaces.ITraversable"
+ provides="zope.traversing.interfaces.ITraversable"
for="zope.interface.common.sequence.IMinimalSequence"
factory=".introspector.sequenceItemsNamespace"
/>
@@ -32,13 +32,13 @@
<!-- IMapping ++items++ Namespace -->
<zope:view
name="items" type="*"
- provides="zope.app.traversing.interfaces.ITraversable"
+ provides="zope.traversing.interfaces.ITraversable"
for="zope.interface.common.mapping.IItemMapping"
factory=".introspector.mappingItemsNamespace"
/>
<zope:adapter
name="items"
- provides="zope.app.traversing.interfaces.ITraversable"
+ provides="zope.traversing.interfaces.ITraversable"
for="zope.interface.common.mapping.IItemMapping"
factory=".introspector.mappingItemsNamespace"
/>
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/module.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/module.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/module.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,10 +19,10 @@
from zope.interface.interface import InterfaceClass
from zope.security.proxy import removeSecurityProxy
from zope.proxy import removeAllProxies
+from zope.publisher.browser import BrowserView
from zope.app import zapi
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.publisher.browser import BrowserView
from zope.app.apidoc.apidoc import APIDocumentation
from zope.app.apidoc.utilities import getPythonPath, renderText, columnize
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/browser/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,6 +21,7 @@
from zope.configuration import xmlconfig
from zope.interface import directlyProvides, implements
from zope.testing import doctest, doctestunit
+from zope.traversing.interfaces import IContainmentRoot
import zope.app
import zope.app.appsetup.appsetup
@@ -28,7 +29,6 @@
from zope.app.renderer.rest import IReStructuredTextSource
from zope.app.renderer.rest import ReStructuredTextToHTMLRenderer
from zope.app.testing import placelesssetup, setup, ztapi
-from zope.app.traversing.interfaces import IContainmentRoot
from zope.app.apidoc.interfaces import IDocumentationModule
from zope.app.apidoc.codemodule.interfaces import IAPIDocRootModule
@@ -85,13 +85,13 @@
# Register ++apidoc++ namespace
from zope.app.apidoc.apidoc import apidocNamespace
- from zope.app.traversing.interfaces import ITraversable
+ from zope.traversing.interfaces import ITraversable
ztapi.provideAdapter(None, ITraversable, apidocNamespace, name="apidoc")
ztapi.provideView(None, None, ITraversable, "apidoc", apidocNamespace)
# Register ++apidoc++ namespace
- from zope.app.traversing.namespace import view
- from zope.app.traversing.interfaces import ITraversable
+ from zope.traversing.namespace import view
+ from zope.traversing.interfaces import ITraversable
ztapi.provideAdapter(None, ITraversable, view, name="view")
ztapi.provideView(None, None, ITraversable, "view", view)
@@ -109,9 +109,9 @@
os.path.dirname(zope.app.__file__), 'meta.zcml')
# Register the index.html view for codemodule.class_.Class
+ from zope.publisher.browser import BrowserView
from zope.app.apidoc.codemodule.class_ import Class
from zope.app.apidoc.codemodule.browser.class_ import ClassDetails
- from zope.app.publisher.browser import BrowserView
class Details(ClassDetails, BrowserView):
pass
ztapi.browserView(Class, 'index.html', Details)
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/class_.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/class_.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/class_.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,7 +22,7 @@
from zope.interface import implements, implementedBy
from zope.security.checker import getCheckerForInstancesOf
-from zope.app.location.interfaces import ILocation
+from zope.location.interfaces import ILocation
from zope.app.apidoc.classregistry import classRegistry
from zope.app.apidoc.utilities import getInterfaceForAttribute
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/codemodule.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/codemodule.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/codemodule.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,11 +19,12 @@
$Id: __init__.py 29269 2005-02-23 22:22:48Z srichter $
"""
__docformat__ = 'restructuredtext'
+
+import zope.component
from zope.interface import Interface, implements
-from zope.app import zapi
+from zope.location.interfaces import ILocation
+
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.location.interfaces import ILocation
-
from zope.app.apidoc.interfaces import IDocumentationModule
from zope.app.apidoc.classregistry import safe_import
from zope.app.apidoc.codemodule.interfaces import IAPIDocRootModule
@@ -68,7 +69,7 @@
"""Setup module and class tree."""
if self.__isSetup:
return
- for name, mod in zapi.getUtilitiesFor(IAPIDocRootModule):
+ for name, mod in zope.component.getUtilitiesFor(IAPIDocRootModule):
module = safe_import(mod)
if module is not None:
self._children[name] = Module(self, name, module)
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/function.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/function.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/function.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,8 +16,9 @@
$Id: __init__.py 29143 2005-02-14 22:43:16Z srichter $
"""
__docformat__ = 'restructuredtext'
+
from zope.interface import implements
-from zope.app.location.interfaces import ILocation
+from zope.location.interfaces import ILocation
from zope.app.apidoc.utilities import getFunctionSignature
from interfaces import IFunctionDocumentation
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,7 +17,7 @@
"""
__docformat__ = 'restructuredtext'
from zope.interface import implements
-from zope.app.component.metaconfigure import utility
+from zope.component.zcml import utility
from zope.app.apidoc import classregistry
from zope.app.apidoc.codemodule.interfaces import IAPIDocRootModule
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/module.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/module.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/module.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,8 +22,8 @@
import zope
from zope.interface import implements
from zope.interface.interface import InterfaceClass
-from zope.app.location.interfaces import ILocation
-from zope.app.location import LocationProxy
+from zope.location.interfaces import ILocation
+from zope.location import LocationProxy
from zope.app.apidoc.classregistry import safe_import
from zope.app.apidoc.utilities import ReadContainerBase
Modified: Zope3/trunk/src/zope/app/apidoc/codemodule/text.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/codemodule/text.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/codemodule/text.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,7 +17,7 @@
"""
__docformat__ = 'restructuredtext'
from zope.interface import implements
-from zope.app.location.interfaces import ILocation
+from zope.location.interfaces import ILocation
class TextFile(object):
"""This class represents a function declared in the module."""
Modified: Zope3/trunk/src/zope/app/apidoc/component.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/component.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/component.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,8 +19,13 @@
import types
from zope.component.interfaces import IFactory
-from zope.component.site import AdapterRegistration, SubscriptionRegistration
-from zope.component.site import UtilityRegistration
+from zope.component.registry import (
+ AdapterRegistration,
+ SubscriptionRegistration,
+ HandlerRegistration,
+ )
+
+from zope.component.registry import UtilityRegistration
from zope.interface import Interface
from zope.interface.interface import InterfaceClass
import zope.interface.declarations
@@ -40,30 +45,35 @@
def getRequiredAdapters(iface, withViews=False):
"""Get adapter registrations where the specified interface is required."""
gsm = zapi.getGlobalSiteManager()
- for reg in gsm.registrations():
- # Only get adapters
- if not isinstance(reg, (AdapterRegistration, SubscriptionRegistration)):
- continue
- # Ignore adapters that have no required interfaces
- if len(reg.required) == 0:
- continue
- # Ignore views
- if not withViews and reg.required[-1] and \
- reg.required[-1].isOrExtends(IRequest):
- continue
- # Only get the adapters for which this interface is required
- for required_iface in reg.required:
- if iface.isOrExtends(required_iface):
- yield reg
+ for meth in ('registeredAdapters',
+ 'registeredSubscriptionAdapters',
+ 'registeredHandlers'):
+ for reg in getattr(gsm, meth)():
+ # Ignore adapters that have no required interfaces
+ if len(reg.required) == 0:
+ continue
+ # Ignore views
+ if not withViews and reg.required[-1].isOrExtends(IRequest):
+ continue
+ # Only get the adapters for which this interface is required
+ for required_iface in reg.required:
+ if iface.isOrExtends(required_iface):
+ yield reg
+def _adapterishRegistrations(registry):
+ for r in registry.registeredAdapters():
+ yield r
+ for r in registry.registeredSubscriptionAdapters():
+ yield r
+ for r in registry.registeredHandlers():
+ yield r
+
def getProvidedAdapters(iface, withViews=False):
"""Get adapter registrations where this interface is provided."""
gsm = zapi.getGlobalSiteManager()
- for reg in gsm.registrations():
+ for reg in _adapterishRegistrations(gsm):
# Only get adapters
- if not isinstance(reg, (AdapterRegistration, SubscriptionRegistration)):
- continue
# Ignore adapters that have no required interfaces
if len(reg.required) == 0:
continue
@@ -109,9 +119,7 @@
"""Return the factory registrations, who will return objects providing this
interface."""
gsm = zapi.getGlobalSiteManager()
- for reg in gsm.registrations():
- if not isinstance(reg, UtilityRegistration):
- continue
+ for reg in gsm.registeredUtilities():
if reg.provided is not IFactory:
continue
interfaces = reg.component.getInterfaces()
@@ -128,9 +136,7 @@
def getUtilities(iface):
"""Return all utility registrations that provide the interface."""
gsm = zapi.getGlobalSiteManager()
- for reg in gsm.registrations():
- if not isinstance(reg, UtilityRegistration):
- continue
+ for reg in gsm.registeredUtilities():
if reg.provided.isOrExtends(iface):
yield reg
@@ -174,26 +180,26 @@
def getAdapterInfoDictionary(reg):
"""Return a PT-friendly info dictionary for an adapter registration."""
- factory = getRealFactory(reg.value)
+ factory = getRealFactory(reg.factory)
path = getPythonPath(factory)
url = None
if isReferencable(path):
url = path.replace('.', '/')
- if isinstance(reg.doc, (str, unicode)):
- doc = reg.doc
+ if isinstance(reg.info, (str, unicode)):
+ doc = reg.info
zcml = None
else:
doc = None
- zcml = getParserInfoInfoDictionary(reg.doc)
+ zcml = getParserInfoInfoDictionary(reg.info)
return {
'provided': getInterfaceInfoDictionary(reg.provided),
'required': [getInterfaceInfoDictionary(iface)
for iface in reg.required
if iface is not None],
- 'name': getattr(reg, 'name', _('<subscription>')),
+ 'name': getattr(reg, 'name', ''),
'factory': path,
'factory_url': url,
'doc': doc,
Modified: Zope3/trunk/src/zope/app/apidoc/component.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/component.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/component.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -44,9 +44,12 @@
>>> regs = list(component.getRequiredAdapters(IFoo))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo',), 'IResult', '', None, ''),
- SubscriptionRegistration(('IFoo',), None, 'stubFactory', '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo], IResult, '', None, u''),
+ HandlerRegistration(<BaseGlobalComponents base>,
+ [IFoo], u'', 'stubFactory', u'')]
Note how the adapter requiring an `IRequest` at the end of the required
interfaces is neglected. This is because it is recognized as a view and views
@@ -55,10 +58,14 @@
>>> regs = list(component.getRequiredAdapters(IFoo, withViews=True))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo', 'IRequest'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo',), 'IResult', '', None, ''),
- SubscriptionRegistration(('IFoo',), None, 'stubFactory', '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IRequest], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo], IResult, '', None, u''),
+ HandlerRegistration(<BaseGlobalComponents base>,
+ [IFoo], u'', 'stubFactory', u'')]
The function will also pick up registrations that have required interfaces the
specified interface extends:
@@ -66,16 +73,20 @@
>>> regs = list(component.getRequiredAdapters(IFoo))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo',), 'IResult', '', None, ''),
- SubscriptionRegistration(('IFoo',), None, 'stubFactory', '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo], IResult, '', None, u''),
+ HandlerRegistration(<BaseGlobalComponents base>,
+ [IFoo], u'', 'stubFactory', u'')]
And all of the required interfaces are considered, of course:
>>> regs = list(component.getRequiredAdapters(IBar))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u'')]
`getProvidedAdapters(iface, withViews=False)`
@@ -88,24 +99,30 @@
>>> regs = list(component.getProvidedAdapters(ISpecialResult))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u'')]
And by specifying the `withView` flag, we get views as well:
>>> regs = list(component.getProvidedAdapters(ISpecialResult, withViews=True))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo', 'IRequest'), 'ISpecialResult', '', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IRequest], ISpecialResult, '', None, u'')]
We can of course also ask for adapters specifying `IResult`:
>>> regs = list(component.getProvidedAdapters(IResult, withViews=True))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo', 'IRequest'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo',), 'IResult', '', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IRequest], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo], IResult, '', None, u'')]
`getClasses(iface)`
@@ -167,16 +184,17 @@
>>> regs = list(component.getFactories(IFooBar))
>>> regs.sort()
>>> regs
- [UtilityRegistration('IFactory', 'MyFooBar',
- <Factory for <class 'zope.app.apidoc.doctest.MyFooBar'>>, '')]
+ [UtilityRegistration(<BaseGlobalComponents base>,
+ IFactory, 'MyFooBar',
+ <Factory for <class 'zope.app.apidoc.doctest.MyFooBar'>>, u'')]
>>> regs = list(component.getFactories(IFoo))
>>> regs.sort()
>>> regs
- [UtilityRegistration('IFactory', 'MyFoo',
- <Factory for <class 'zope.app.apidoc.doctest.MyFoo'>>, ''),
- UtilityRegistration('IFactory', 'MyFooBar',
- <Factory for <class 'zope.app.apidoc.doctest.MyFooBar'>>, '')]
+ [UtilityRegistration(<BaseGlobalComponents base>, IFactory, 'MyFoo',
+ <Factory for <class 'zope.app.apidoc.doctest.MyFoo'>>, u''),
+ UtilityRegistration(<BaseGlobalComponents base>, IFactory, 'MyFooBar',
+ <Factory for <class 'zope.app.apidoc.doctest.MyFooBar'>>, u'')]
`getUtilities(iface)`
@@ -196,16 +214,16 @@
>>> regs = list(component.getUtilities(IFooBar))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
- [UtilityRegistration('IFooBar', '',
- <zope.app.apidoc.doctest.MyFooBar object at ...>, '')]
+ [UtilityRegistration(<BaseGlobalComponents base>, IFooBar, '',
+ <zope.app.apidoc.doctest.MyFooBar object at ...>, u'')]
>>> regs = list(component.getUtilities(IFoo))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
- [UtilityRegistration('IFoo', '',
- <zope.app.apidoc.doctest.MyFoo object at ...>, ''),
- UtilityRegistration('IFooBar', '',
- <zope.app.apidoc.doctest.MyFooBar object at ...>, '')]
+ [UtilityRegistration(<BaseGlobalComponents base>, IFoo, '',
+ <zope.app.apidoc.doctest.MyFoo object at ...>, u''),
+ UtilityRegistration(<BaseGlobalComponents base>, IFooBar, '',
+ <zope.app.apidoc.doctest.MyFooBar object at ...>, u'')]
`getRealFactory(factory)`
@@ -304,8 +322,8 @@
>>> class MyResult(object):
... implements(IResult)
- >>> from zope.component.site import AdapterRegistration
- >>> reg = AdapterRegistration((IFoo, IBar), IResult, 'FooToResult',
+ >>> from zope.component.registry import AdapterRegistration
+ >>> reg = AdapterRegistration(None, (IFoo, IBar), IResult, 'FooToResult',
... MyResult, 'doc info')
And now get the info dictionary:
@@ -328,7 +346,7 @@
>>> from zope.interface import classImplements
>>> classImplements(MyResultType, IResult)
- >>> reg = AdapterRegistration((IFoo, IBar), IResult, 'FooToResult',
+ >>> reg = AdapterRegistration(None, (IFoo, IBar), IResult, 'FooToResult',
... MyResultType, 'doc info')
>>> pprint(component.getAdapterInfoDictionary(reg))
{'doc': 'doc info',
@@ -344,14 +362,14 @@
much like adapter registrations, except that they do not have a name. So let's
see how the function handles subscriptions:
- >>> from zope.component.site import SubscriptionRegistration
- >>> reg = SubscriptionRegistration((IFoo, IBar), None, MyResult, 'doc info')
+ >>> from zope.component.registry import HandlerRegistration
+ >>> reg = HandlerRegistration(None, (IFoo, IBar), '', MyResult, 'doc info')
>>> pprint(component.getAdapterInfoDictionary(reg))
{'doc': 'doc info',
'factory': 'zope.app.apidoc.doctest.MyResult',
'factory_url': 'zope/app/apidoc/doctest/MyResult',
- 'name': u'<subscription>',
+ 'name': '',
'provided': None,
'required': [{'module': 'zope.app.apidoc.doctest', 'name': 'IFoo'},
{'module': 'zope.app.apidoc.doctest', 'name': 'IBar'}],
Modified: Zope3/trunk/src/zope/app/apidoc/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,12 +19,12 @@
<view
name="apidoc" type="*"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
+ provides="zope.traversing.interfaces.ITraversable" for="*"
factory=".apidoc.apidocNamespace"
/>
<adapter
name="apidoc"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
+ provides="zope.traversing.interfaces.ITraversable" for="*"
factory=".apidoc.apidocNamespace"
/>
Deleted: Zope3/trunk/src/zope/app/apidoc/ftesting.zcml
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ftesting.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/ftesting.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,3 +0,0 @@
-<configure xmlns:apidoc="http://namespaces.zope.org/apidoc">
- <apidoc:moduleImport allow="true" />
-</configure>
\ No newline at end of file
Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,7 +15,7 @@
>>> class IFoo(Interface):
... pass
- >>> from zope.app.component.interface import provideInterface
+ >>> from zope.component.interface import provideInterface
>>> provideInterface(None, IFoo)
>>> provideInterface('IFoo', IFoo)
Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -26,12 +26,12 @@
from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
from zope.publisher.interfaces.http import IHTTPRequest
from zope.publisher.interfaces.ftp import IFTPRequest
+from zope.publisher.browser import BrowserView
from zope.security.proxy import removeSecurityProxy
from zope.proxy import removeAllProxies
from zope.app import zapi
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.publisher.browser import BrowserView
from zope.app.apidoc.utilities import getPythonPath, renderText
from zope.app.apidoc.apidoc import APIDocumentation
Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/browser.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -160,7 +160,7 @@
>>> ifacemodule.__parent__ = Root()
>>> ifacemodule.__name__ = 'Interfaces'
- >>> from zope.app.location import LocationProxy
+ >>> from zope.location import LocationProxy
>>> iface = LocationProxy(IFoo, ifacemodule, 'IFoo')
and finally the details view:
@@ -284,7 +284,6 @@
>>> pprint(details.getSpecificRequiredAdapters())
[]
-
`getExtendedRequiredAdapters()`
-------------------------------
@@ -293,14 +292,104 @@
>>> pprint(details.getExtendedRequiredAdapters())
[]
+Note that this includes all interfaces registered for
+interface.Interface.
+
`getGenericRequiredAdapters()`
------------------------------
Get adapters where this interface is required.
- >>> pprint(details.getGenericRequiredAdapters())
- []
+ >>> pprint(sorted(details.getGenericRequiredAdapters()))
+ [{'doc': u'',
+ 'factory': 'None.append',
+ 'factory_url': None,
+ 'name': u'',
+ 'provided': None,
+ 'required': [{'module': 'zope.interface',
+ 'name': 'Interface'}],
+ 'zcml': None},
+ {'doc': u'',
+ 'factory': 'zope.location.traversing.LocationPhysicallyLocatable',
+ 'factory_url': 'zope/location/traversing/LocationPhysicallyLocatable',
+ 'name': '',
+ 'provided': {'module': 'zope.traversing.interfaces',
+ 'name': 'IPhysicallyLocatable'},
+ 'required': [{'module': 'zope.interface',
+ 'name': 'Interface'}],
+ 'zcml': None},
+ {'doc': u'',
+ 'factory': 'zope.traversing.adapters.DefaultTraversable',
+ 'factory_url': 'zope/traversing/adapters/DefaultTraversable',
+ 'name': '',
+ 'provided': {'module': 'zope.traversing.interfaces',
+ 'name': 'ITraversable'},
+ 'required': [{'module': 'zope.interface',
+ 'name': 'Interface'}],
+ 'zcml': None},
+ {'doc': u'',
+ 'factory': 'zope.traversing.adapters.Traverser',
+ 'factory_url': 'zope/traversing/adapters/Traverser',
+ 'name': '',
+ 'provided': {'module': 'zope.traversing.interfaces',
+ 'name': 'ITraverser'},
+ 'required': [{'module': 'zope.interface',
+ 'name': 'Interface'}],
+ 'zcml': None},
+ {'doc': u'',
+ 'factory': 'zope.traversing.namespace.etc',
+ 'factory_url': 'zope/traversing/namespace/etc',
+ 'name': 'etc',
+ 'provided': {'module': 'zope.traversing.interfaces',
+ 'name': 'ITraversable'},
+ 'required': [{'module': 'zope.interface',
+ 'name': 'Interface'}],
+ 'zcml': None},
+ {'doc': u'',
+ 'factory': 'zope.traversing.namespace.etc',
+ 'factory_url': 'zope/traversing/namespace/etc',
+ 'name': 'etc',
+ 'provided': {'module': 'zope.traversing.interfaces',
+ 'name': 'ITraversable'},
+ 'required': [{'module': 'zope.interface',
+ 'name': 'Interface'},
+ {'module': 'zope.interface',
+ 'name': 'Interface'}],
+ 'zcml': None},
+ {'doc': u'',
+ 'factory': 'zope.traversing.namespace.etc',
+ 'factory_url': 'zope/traversing/namespace/etc',
+ 'name': 'etc',
+ 'provided': {'module': 'zope.traversing.interfaces',
+ 'name': 'ITraversable'},
+ 'required': [{'module': 'zope.interface',
+ 'name': 'Interface'},
+ {'module': 'zope.interface',
+ 'name': 'Interface'}],
+ 'zcml': None},
+ {'doc': u'',
+ 'factory': 'zope.traversing.namespace.etc',
+ 'factory_url': 'zope/traversing/namespace/etc',
+ 'name': 'etc',
+ 'provided': {'module': 'zope.traversing.interfaces',
+ 'name': 'ITraversable'},
+ 'required': [{'module': 'zope.interface',
+ 'name': 'Interface'},
+ {'module': 'zope.interface',
+ 'name': 'Interface'}],
+ 'zcml': None},
+ {'doc': u'',
+ 'factory': 'zope.traversing.namespace.etc',
+ 'factory_url': 'zope/traversing/namespace/etc',
+ 'name': 'etc',
+ 'provided': {'module': 'zope.traversing.interfaces',
+ 'name': 'ITraversable'},
+ 'required': [{'module': 'zope.interface',
+ 'name': 'Interface'},
+ {'module': 'zope.interface',
+ 'name': 'Interface'}],
+ 'zcml': None}]
`getProvidedAdapters()`
@@ -309,7 +398,7 @@
Get adapters where this interface is provided.
>>> pprint(details.getProvidedAdapters())
- [{'doc': '',
+ [{'doc': u'',
'factory': '__builtin__.Foo',
'factory_url': None,
'name': '',
@@ -349,4 +438,4 @@
'name': 'The Foo',
'path': '__builtin__.Foo',
'url': None,
- 'url_name': 'VGhlIEZvbw=='}]
\ No newline at end of file
+ 'url_name': 'VGhlIEZvbw=='}]
Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/ftests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/ftests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,11 +25,11 @@
response = self.publish(
'/++apidoc++/Interface/menu.html',
basic='mgr:mgrpw',
- env = {'name_only': True, 'search_str': 'IComponent'})
+ env = {'name_only': True, 'search_str': 'IDoc'})
self.assertEqual(response.getStatus(), 200)
body = response.getBody()
self.assert_(body.find(
- 'zope.app.component.interfaces.registration.IComponent') > 0)
+ 'zope.app.apidoc.interfaces.IDocumentationModule') > 0)
self.checkForBrokenLinks(body, '/++apidoc++/Interface/menu.html',
basic='mgr:mgrpw')
Modified: Zope3/trunk/src/zope/app/apidoc/ifacemodule/ifacemodule.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/ifacemodule/ifacemodule.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/ifacemodule/ifacemodule.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -24,11 +24,12 @@
from zope.app import zapi
from zope.interface import implements
+from zope.location import LocationProxy
+from zope.component.interface import queryInterface
+from zope.component.interface import searchInterfaceUtilities
+
from zope.app.apidoc.interfaces import IDocumentationModule
from zope.app.apidoc.utilities import ReadContainerBase
-from zope.app.location import LocationProxy
-from zope.app.component.interface \
- import queryInterface, searchInterfaceUtilities
from zope.app.i18n import ZopeMessageFactory as _
class IInterfaceModule(IDocumentationModule):
Modified: Zope3/trunk/src/zope/app/apidoc/presentation.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/presentation.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/presentation.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,7 +16,7 @@
$Id$
"""
from types import ClassType, FunctionType
-from zope.component.site import AdapterRegistration
+from zope.component.registry import AdapterRegistration
from zope.interface import Interface
from zope.app import zapi
@@ -59,6 +59,7 @@
base = factory.__bases__[0]
info['path'] = base.__module__ + '.' + base.__name__
info['template'] = relativizePath(factory.index.filename)
+ info['template_obj'] = factory.index
# Basic Type is a factory
elif isinstance(factory, (str, unicode, float, int, list, tuple)):
@@ -120,9 +121,8 @@
def getViews(iface, type=IRequest):
"""Get all view registrations for a particular interface."""
gsm = zapi.getGlobalSiteManager()
- for reg in gsm.registrations():
- if (isinstance(reg, AdapterRegistration) and
- len(reg.required) > 0 and
+ for reg in gsm.registeredAdapters():
+ if (len(reg.required) > 0 and
reg.required[-1] is not None and
reg.required[-1].isOrExtends(type)):
@@ -157,16 +157,16 @@
def getViewInfoDictionary(reg):
"""Build up an information dictionary for a view registration."""
# get configuration info
- if isinstance(reg.doc, (str, unicode)):
- doc = reg.doc
+ if isinstance(reg.info, (str, unicode)):
+ doc = reg.info
zcml = None
else:
doc = None
- zcml = getParserInfoInfoDictionary(reg.doc)
+ zcml = getParserInfoInfoDictionary(reg.info)
info = {'name' : reg.name or '<i>no name</i>',
'type' : getPythonPath(getPresentationType(reg.required[-1])),
- 'factory' : getViewFactoryData(reg.value),
+ 'factory' : getViewFactoryData(reg.factory),
'required': [getInterfaceInfoDictionary(iface)
for iface in reg.required],
'provided' : getInterfaceInfoDictionary(reg.provided),
@@ -175,6 +175,6 @@
}
# Educated guess of the attribute name
- info.update(getPermissionIds('publishTraverse', klass=reg.value))
+ info.update(getPermissionIds('publishTraverse', klass=reg.factory))
return info
Modified: Zope3/trunk/src/zope/app/apidoc/presentation.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/presentation.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/presentation.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -32,6 +32,7 @@
'referencable': True,
'resource': None,
'template': 'zope/app/apidoc/browser/index.pt',
+ 'template_obj': <BoundPageTemplateFile of None>,
'url': 'zope/app/pagetemplate/simpleviewclass/simple'}
So in the result above we see what the function returns. It is a dictionary
@@ -265,26 +266,18 @@
>>> regs = list(presentation.getViews(IFoo))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
- [AdapterRegistration(('IFoo', 'IBrowserRequest'), 'Interface',
- 'blah', None, ''),
- AdapterRegistration(('IFoo', 'IHTTPRequest'), 'Interface',
- 'foo', None, ''),
- AdapterRegistration(('Interface', 'IHTTPRequest'), 'Interface',
- 'bar', None, ''),
- AdapterRegistration((None, 'IDefaultBrowserLayer'), 'IAbsoluteURL',
- '', <class '...browser.absoluteurl.AbsoluteURL'>, ''),
- AdapterRegistration((None, 'IDefaultBrowserLayer'), 'Interface',
- 'absolute_url', <class ...absoluteurl.AbsoluteURL'>, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBrowserRequest], Interface, 'blah', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IHTTPRequest], Interface, 'foo', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [Interface, IHTTPRequest], Interface, 'bar', None, u'')]
>>> regs = list(presentation.getViews(Interface, IHTTPRequest))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
- [AdapterRegistration(('Interface', 'IHTTPRequest'), 'Interface',
- 'bar', None, ''),
- AdapterRegistration((None, 'IDefaultBrowserLayer'), 'IAbsoluteURL',
- '', <class '...browser.absoluteurl.AbsoluteURL'>, ''),
- AdapterRegistration((None, 'IDefaultBrowserLayer'), 'Interface',
- 'absolute_url', <class ...absoluteurl.AbsoluteURL'>, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [Interface, IHTTPRequest], Interface, 'bar', None, u'')]
`filterViewRegistrations(regs, iface, level=SPECIFC_INTERFACE_LEVEL)`
@@ -336,24 +329,24 @@
... regs, IFile, level=presentation.SPECIFIC_INTERFACE_LEVEL))
>>> result.sort()
>>> result
- [AdapterRegistration(('IFile', 'IHTTPRequest'), 'Interface',
- 'view.html', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFile, IHTTPRequest], Interface, 'view.html', None, u'')]
>>> result = list(presentation.filterViewRegistrations(
... regs, IFile, level=presentation.EXTENDED_INTERFACE_LEVEL))
>>> result.sort()
>>> result
- [AdapterRegistration(('IContent', 'IHTTPRequest'), 'Interface', 'edit.html',
- None, ''),
- AdapterRegistration(('IContent', 'IHTTPRequest'), 'Interface', 'view.html',
- None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IContent, IHTTPRequest], Interface, 'edit.html', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IContent, IHTTPRequest], Interface, 'view.html', None, u'')]
>>> result = list(presentation.filterViewRegistrations(
... regs, IFile, level=presentation.GENERIC_INTERFACE_LEVEL))
>>> result.sort()
>>> result
- [AdapterRegistration(('Interface', 'IHTTPRequest'), 'Interface', 'view.html',
- None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [Interface, IHTTPRequest], Interface, 'view.html', None, u'')]
You can also specify multiple levels at once using the Boolean OR operator,
since all three levels are mutually exclusive.
@@ -363,22 +356,22 @@
... presentation.EXTENDED_INTERFACE_LEVEL))
>>> result.sort()
>>> result
- [AdapterRegistration(('IContent', 'IHTTPRequest'), 'Interface',
- 'edit.html', None, ''),
- AdapterRegistration(('IContent', 'IHTTPRequest'), 'Interface',
- 'view.html', None, ''),
- AdapterRegistration(('IFile', 'IHTTPRequest'), 'Interface',
- 'view.html', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IContent, IHTTPRequest], Interface, 'edit.html', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IContent, IHTTPRequest], Interface, 'view.html', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFile, IHTTPRequest], Interface, 'view.html', None, u'')]
>>> result = list(presentation.filterViewRegistrations(
... regs, IFile, level=presentation.SPECIFIC_INTERFACE_LEVEL |
... presentation.GENERIC_INTERFACE_LEVEL))
>>> result.sort()
>>> result
- [AdapterRegistration(('IFile', 'IHTTPRequest'), 'Interface',
- 'view.html', None, ''),
- AdapterRegistration(('Interface', 'IHTTPRequest'), 'Interface',
- 'view.html', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFile, IHTTPRequest], Interface, 'view.html', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [Interface, IHTTPRequest], Interface, 'view.html', None, u'')]
`getViewInfoDictionary(reg)`
@@ -391,8 +384,8 @@
Let's first create a registration:
- >>> from zope.component.site import AdapterRegistration
- >>> reg = AdapterRegistration((IFile, Interface, IHTTPRequest),
+ >>> from zope.component.registry import AdapterRegistration
+ >>> reg = AdapterRegistration(None, (IFile, Interface, IHTTPRequest),
... Interface, 'view.html', Factory, 'reg info')
>>> pprint(presentation.getViewInfoDictionary(reg))
Modified: Zope3/trunk/src/zope/app/apidoc/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,21 +18,21 @@
from pprint import PrettyPrinter
import unittest
+import zope.component.testing
from zope.component.interfaces import IFactory
from zope.interface import implements
from zope.testing import doctest, doctestunit
+from zope.traversing.interfaces import IContainmentRoot
+from zope.location import LocationProxy
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.app.location import LocationProxy
from zope.app.testing import placelesssetup, ztapi, setup
-
from zope.app.renderer.rest import ReStructuredTextSourceFactory
from zope.app.renderer.rest import IReStructuredTextSource
from zope.app.renderer.rest import ReStructuredTextToHTMLRenderer
def setUp(test):
- placelesssetup.setUp()
+ zope.component.testing.setUp()
# Register Renderer Components
ztapi.provideUtility(IFactory, ReStructuredTextSourceFactory,
'zope.source.rest')
@@ -85,8 +85,8 @@
globs={'pprint': doctestunit.pprint},
optionflags=doctest.NORMALIZE_WHITESPACE),
doctest.DocFileSuite('presentation.txt',
- setUp=placelesssetup.setUp,
- tearDown=placelesssetup.tearDown,
+ setUp=zope.component.testing.setUp,
+ tearDown=zope.component.testing.tearDown,
globs={'pprint': doctestunit.pprint},
optionflags=doctest.NORMALIZE_WHITESPACE),
doctest.DocFileSuite('utilities.txt',
Modified: Zope3/trunk/src/zope/app/apidoc/typemodule/type.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/typemodule/type.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/typemodule/type.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,17 +16,17 @@
$Id: __init__.py 29143 2005-02-14 22:43:16Z srichter $
"""
__docformat__ = 'restructuredtext'
-from zope.interface import implements
+
+from zope.interface import implements
+from zope.component import queryUtility, getUtilitiesFor
from zope.interface.interfaces import IInterface
+from zope.location import LocationProxy
+from zope.location.interfaces import ILocation
-from zope.app import zapi
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.location import LocationProxy
-from zope.app.location.interfaces import ILocation
from zope.app.apidoc.interfaces import IDocumentationModule
from zope.app.apidoc.utilities import ReadContainerBase
-
class TypeInterface(ReadContainerBase):
"""Representation of the special type interface.
@@ -62,13 +62,13 @@
def get(self, key, default=None):
"""See zope.app.container.interfaces.IReadContainer"""
return LocationProxy(
- zapi.queryUtility(self.interface, key, default=default),
+ queryUtility(self.interface, key, default=default),
self, key)
def items(self):
"""See zope.app.container.interfaces.IReadContainer"""
results = [(name, LocationProxy(iface, self, name))
- for name, iface in zapi.getUtilitiesFor(self.interface)]
+ for name, iface in getUtilitiesFor(self.interface)]
results.sort(lambda x, y: cmp(x[1].getName(), y[1].getName()))
return results
@@ -109,11 +109,11 @@
def get(self, key, default=None):
return TypeInterface(
- zapi.queryUtility(IInterface, key, default=default), self, key)
+ queryUtility(IInterface, key, default=default), self, key)
def items(self):
results = [(name, TypeInterface(iface, self, name))
- for name, iface in zapi.getUtilitiesFor(IInterface)
+ for name, iface in getUtilitiesFor(IInterface)
if iface.extends(IInterface)]
results.sort(lambda x, y: cmp(x[1].interface.getName(),
y[1].interface.getName()))
Modified: Zope3/trunk/src/zope/app/apidoc/utilitymodule/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilitymodule/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/utilitymodule/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,9 +18,9 @@
__docformat__ = 'restructuredtext'
from zope.security.proxy import removeSecurityProxy
+from zope.location import LocationProxy
from zope.app import zapi
-from zope.app.location import LocationProxy
from zope.app.apidoc.ifacemodule.browser import InterfaceDetails
from zope.app.apidoc.component import getUtilityInfoDictionary
from zope.app.apidoc.utilities import getPythonPath
Modified: Zope3/trunk/src/zope/app/apidoc/utilitymodule/browser.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilitymodule/browser.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/utilitymodule/browser.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -40,7 +40,7 @@
>>> foobar_reg = type(
... 'RegistrationStub', (),
... {'name': 'FooBar', 'provided': None,
- ... 'component': None, 'doc': ''})()
+ ... 'component': None, 'info': ''})()
which is then wrapped in a `Utility` documentation class and then in a node:
@@ -61,7 +61,7 @@
>>> noname_reg = type(
... 'RegistrationStub', (),
... {'name': NONAME, 'provided': None,
- ... 'component': None, 'doc': ''})()
+ ... 'component': None, 'info': ''})()
>>> util = Utility(uiface, noname_reg)
>>> node = Node(util)
@@ -109,7 +109,7 @@
>>> blah_reg = type(
... 'RegistrationStub', (),
... {'name': 'Blah', 'provided': IBlah,
- ... 'component': None, 'doc': ''})()
+ ... 'component': None, 'info': ''})()
Then we wrap the registration in the utility documentation class and create
the details view:
@@ -140,7 +140,7 @@
>>> foo_reg = type(
... 'RegistrationStub', (),
- ... {'name': '', 'provided': Interface, 'component': Foo(), 'doc': ''})()
+ ... {'name': '', 'provided': Interface, 'component': Foo(), 'info': ''})()
Then we create a utility documentation class and its details view:
Modified: Zope3/trunk/src/zope/app/apidoc/utilitymodule/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilitymodule/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/utilitymodule/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,14 +17,13 @@
"""
import unittest
from zope.testing import doctest, doctestunit
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.location.traversing import LocationPhysicallyLocatable
-from zope.app.location.traversing import LocationPhysicallyLocatable
from zope.app.testing import placelesssetup, ztapi
-from zope.app.traversing.interfaces import IPhysicallyLocatable
from zope.app.tree.interfaces import IUniqueId
from zope.app.tree.adapters import LocationUniqueId
-
def setUp(test):
placelesssetup.setUp()
Modified: Zope3/trunk/src/zope/app/apidoc/utilitymodule/utilitymodule.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilitymodule/utilitymodule.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/utilitymodule/utilitymodule.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,13 +19,13 @@
import base64, binascii
-from zope.component.site import UtilityRegistration
+import zope.component
+from zope.component.registry import UtilityRegistration
from zope.interface import implements
+from zope.location.interfaces import ILocation
-from zope.app import zapi
from zope.app.i18n import ZopeMessageFactory as _
from zope.app.component import queryNextSiteManager
-from zope.app.location.interfaces import ILocation
from zope.app.apidoc.interfaces import IDocumentationModule
from zope.app.apidoc.utilities import ReadContainerBase, getPythonPath
@@ -54,7 +54,7 @@
self.registration = reg
self.interface = reg.provided
self.component = reg.component
- self.doc = reg.doc
+ self.doc = reg.info
class UtilityInterface(ReadContainerBase):
@@ -68,23 +68,21 @@
def get(self, key, default=None):
"""See zope.app.container.interfaces.IReadContainer"""
- sm = zapi.getGlobalSiteManager()
+ sm = zope.component.getGlobalSiteManager()
key = decodeName(key)
if key == NONAME:
key = ''
utils = [Utility(self, reg)
- for reg in sm.registrations()
- if zapi.isinstance(reg, UtilityRegistration) and \
- reg.name == key and reg.provided == self.interface]
+ for reg in sm.registeredUtilities()
+ if reg.name == key and reg.provided == self.interface]
return utils and utils[0] or default
def items(self):
"""See zope.app.container.interfaces.IReadContainer"""
- sm = zapi.getGlobalSiteManager()
+ sm = zope.component.getGlobalSiteManager()
items = [(encodeName(reg.name or NONAME), Utility(self, reg))
- for reg in sm.registrations()
- if zapi.isinstance(reg, UtilityRegistration) and \
- self.interface == reg.provided]
+ for reg in sm.registeredUtilities()
+ if self.interface == reg.provided]
items.sort()
return items
@@ -122,13 +120,12 @@
return UtilityInterface(self, key, getattr(mod, parts[-1], default))
def items(self):
- sm = zapi.getSiteManager()
+ sm = zope.component.getSiteManager()
ifaces = {}
while sm is not None:
- for reg in sm.registrations():
- if isinstance(reg, UtilityRegistration):
- path = getPythonPath(reg.provided)
- ifaces[path] = UtilityInterface(self, path, reg.provided)
+ for reg in sm.registeredUtilities():
+ path = getPythonPath(reg.provided)
+ ifaces[path] = UtilityInterface(self, path, reg.provided)
sm = queryNextSiteManager(sm)
items = ifaces.items()
Modified: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/zcmlmodule/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -24,10 +24,10 @@
from zope.configuration import docutils, xmlconfig
from zope.interface import implements
+from zope.location.interfaces import ILocation
import zope.app.appsetup.appsetup
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.location.interfaces import ILocation
from zope.app.apidoc.interfaces import IDocumentationModule
from zope.app.apidoc.utilities import ReadContainerBase
Modified: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/zcmlmodule/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/zcmlmodule/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,9 +21,9 @@
from zope.configuration.xmlconfig import ParserInfo
from zope.security.proxy import removeSecurityProxy
+from zope.location import LocationProxy
from zope.app import zapi
-from zope.app.location import LocationProxy
from zope.app.apidoc.zcmlmodule import Directive, Namespace
from zope.app.apidoc.ifacemodule.browser import InterfaceDetails
from zope.app.apidoc.utilities import getPythonPath, isReferencable
Modified: Zope3/trunk/src/zope/app/apidoc/zcmlmodule/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/zcmlmodule/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/apidoc/zcmlmodule/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,15 +19,15 @@
import unittest
from zope.configuration import xmlconfig
from zope.testing import doctest, doctestunit
-from zope.app.testing import placelesssetup, ztapi
-from zope.app.apidoc.tests import Root
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.location.traversing import LocationPhysicallyLocatable
import zope.app.appsetup.appsetup
-from zope.app.location.traversing import LocationPhysicallyLocatable
-from zope.app.traversing.interfaces import IPhysicallyLocatable
from zope.app.tree.interfaces import IUniqueId
from zope.app.tree.adapters import LocationUniqueId
+from zope.app.testing import placelesssetup, ztapi
+from zope.app.apidoc.tests import Root
from zope.app.apidoc.zcmlmodule import Namespace, Directive
from zope.app.apidoc.zcmlmodule import ZCMLModule
from zope.app.apidoc.tests import Root
Modified: Zope3/trunk/src/zope/app/applicationcontrol/applicationcontrol.py
===================================================================
--- Zope3/trunk/src/zope/app/applicationcontrol/applicationcontrol.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/applicationcontrol/applicationcontrol.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,12 +16,12 @@
$Id$"""
__docformat__ = 'restructuredtext'
-from zope.app.applicationcontrol.interfaces import IApplicationControl
-from zope.app.location import Location
-from zope.security.checker import ProxyFactory, NamesChecker
import time
import zope.interface
-import zope.app.traversing.interfaces
+import zope.traversing.interfaces
+from zope.location import Location
+from zope.security.checker import ProxyFactory, NamesChecker
+from zope.app.applicationcontrol.interfaces import IApplicationControl
class ApplicationControl(Location):
@@ -37,7 +37,7 @@
applicationControllerRoot = Location()
zope.interface.directlyProvides(
applicationControllerRoot,
- zope.app.traversing.interfaces.IContainmentRoot,
+ zope.traversing.interfaces.IContainmentRoot,
)
applicationControllerRoot = ProxyFactory(applicationControllerRoot,
NamesChecker("__class__"))
Modified: Zope3/trunk/src/zope/app/applicationcontrol/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/applicationcontrol/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/applicationcontrol/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -49,7 +49,7 @@
<!-- add a action tab to the root folder for navigation -->
<menuItem
menu="zmi_actions"
- for="zope.app.traversing.interfaces.IContainmentRoot"
+ for="zope.traversing.interfaces.IContainmentRoot"
title="Manage Process"
action="++etc++process/index.html" />
Modified: Zope3/trunk/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py
===================================================================
--- Zope3/trunk/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -46,7 +46,7 @@
def test_ServerControlView(self):
control = ServerControlStub()
- zapi.getGlobalSiteManager().provideUtility(IServerControl, control)
+ zapi.getGlobalSiteManager().registerUtility(control, IServerControl)
test_serverctrl = self._TestView__newView(
applicationController,
Modified: Zope3/trunk/src/zope/app/applicationcontrol/browser/zodbcontrol.py
===================================================================
--- Zope3/trunk/src/zope/app/applicationcontrol/browser/zodbcontrol.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/applicationcontrol/browser/zodbcontrol.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,7 +19,7 @@
from ZODB.FileStorage.FileStorage import FileStorageError
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.size import byteDisplay
+from zope.size import byteDisplay
class ZODBControlView(object):
Modified: Zope3/trunk/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py
===================================================================
--- Zope3/trunk/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -80,9 +80,9 @@
# we expect that there is no utility
self.assertEqual(runtime_info.getZopeVersion(), u"Unavailable")
- zapi.getSiteManager().provideUtility(IZopeVersion, TestZopeVersion())
- self.assertEqual(runtime_info.getZopeVersion(),
- stupid_version_string)
+ zapi.getSiteManager().registerUtility(TestZopeVersion(), IZopeVersion)
+ self.assertEqual(runtime_info.getZopeVersion(), stupid_version_string)
+
def test_PythonVersion(self):
runtime_info = self._Test__new()
enc = self._getPreferredEncoding()
Modified: Zope3/trunk/src/zope/app/appsetup/appsetup.py
===================================================================
--- Zope3/trunk/src/zope/app/appsetup/appsetup.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/appsetup/appsetup.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -233,19 +233,3 @@
from zope.testing.cleanup import addCleanUp
addCleanUp(reset)
del addCleanUp
-
-
-# BBB
-import zope.deprecation
-IDatabaseOpenedEvent = interfaces.IDatabaseOpenedEvent
-DatabaseOpened = interfaces.DatabaseOpened
-IProcessStartingEvent = interfaces.IProcessStartingEvent
-ProcessStarting = interfaces.ProcessStarting
-zope.deprecation.deprecated(
- ['IDatabaseOpenedEvent', 'DatabaseOpened',
- 'IProcessStartingEvent', 'ProcessStarting'
- ],
- "The database opened and process starting events have moved to "
- "zope.app.appsetup.interfaces they will disappear from here in "
- "in Zope 3.3."
- )
Modified: Zope3/trunk/src/zope/app/appsetup/bootstrap.py
===================================================================
--- Zope3/trunk/src/zope/app/appsetup/bootstrap.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/appsetup/bootstrap.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,23 +21,23 @@
__docformat__ = 'restructuredtext'
import transaction
import logging
+import warnings
+import zope.deprecation
import zope.event
from zope.security.management import getSecurityPolicy
from zope.security.simplepolicies import ParanoidSecurityPolicy
+from zope.traversing.api import traverse
from zope.app.component.interfaces import ISite
from zope.app.component import site
from zope.app.container.interfaces import INameChooser
from zope.app.folder import rootFolder
from zope.app.publication.zopepublication import ZopePublication
-from zope.app.traversing.api import traverse
from zope.app.appsetup import interfaces
-#from zope.deprecation import deprecated
-import warnings
-
-def ensureObject(root_folder, object_name, object_type, object_factory, asObject=False):
+def ensureObject(root_folder, object_name, object_type, object_factory,
+ asObject=False):
"""Check that there's a basic object in the site
manager. If not, add one.
@@ -67,10 +67,12 @@
Returns the name added or ``None`` if nothing was added.
"""
if not asObject:
- warnings.warn("asObject=False is deprecated", DeprecationWarning, 2)
+ warnings.warn("asObject=False is deprecated and will not be "
+ "supported after Zope 3.5",
+ DeprecationWarning, 2)
sm = root_folder.getSiteManager()
- utils = [reg for reg in sm.utilities.registrations()
+ utils = [reg for reg in sm.registeredUtilities()
if reg.provided.isOrExtends(interface)]
if len(utils) == 0:
return addConfigureUtility(
@@ -81,32 +83,43 @@
return None
def addConfigureUtility(
- root_folder, interface, utility_type, utility_factory, name='', asObject=False, **kw):
+ root_folder, interface, utility_type, utility_factory, name='',
+ asObject=False, **kw):
"""Add and configure a utility to the root folder."""
if not asObject:
- warnings.warn("asObject=False is deprecated", DeprecationWarning, 2)
+ warnings.warn("asObject=False is deprecated and will not be "
+ "supported after Zope 3.5", DeprecationWarning, 2)
- utility = addUtility(root_folder, utility_type, utility_factory, True, **kw)
- configureUtility(root_folder, interface, utility_type, name, utility.__name__)
+ utility = addUtility(root_folder, utility_type, utility_factory, True,
+ **kw)
+ root_folder.getSiteManager().registerUtility(utility, interface, name)
if asObject:
return utility
else:
return utility.__name__
-def addUtility(root_folder, utility_type, utility_factory, asObject=False, **kw):
+def addUtility(root_folder, utility_type, utility_factory,
+ asObject=False, **kw):
""" Add a Utility to the root folder's site manager.
The utility is added to the default package and activated.
"""
if not asObject:
- warnings.warn("asObject=False is deprecated", DeprecationWarning, 2)
+ warnings.warn("asObject=False is deprecated and will not be "
+ "supported after Zope 3.5", DeprecationWarning, 2)
package = getSiteManagerDefault(root_folder)
chooser = INameChooser(package)
utility = utility_factory()
name = chooser.chooseName(utility_type, utility)
package[name] = utility
+
+ # the utility might have been location-proxied; we need the name
+ # information (__name__) so let's get it back again from the
+ # container
+ utility = package[name]
+
# Set additional attributes on the utility
for k, v in kw.iteritems():
setattr(utility, k, v)
@@ -115,15 +128,21 @@
else:
return name
+ at zope.deprecation.deprecate(
+ 'configureUtility is deprecated and will be removed in Zope 3.5. '
+ 'The registration APIs are simple enough now that this just makes things '
+ 'mor complicated,')
def configureUtility(
root_folder, interface, utility_type, name, folder_name,
initial_status=u'Active'):
"""Configure a utility in the root folder."""
+ # folder name is the name of the utility in the default folder. Sheesh
+ assert initial_status == u'Active'
package = getSiteManagerDefault(root_folder)
- registration_manager = package.registrationManager
- reg = site.UtilityRegistration(name, interface, package[folder_name])
- key = registration_manager.addRegistration(reg)
- reg.status = initial_status
+ root_folder.getSiteManager().registerUtility(
+ package[folder_name],
+ interface, name,
+ )
def getSiteManagerDefault(root_folder):
package = traverse(root_folder.getSiteManager(), 'default')
Modified: Zope3/trunk/src/zope/app/appsetup/bootstrap.txt
===================================================================
--- Zope3/trunk/src/zope/app/appsetup/bootstrap.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/appsetup/bootstrap.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -24,7 +24,7 @@
A DatabaseOpenedWithRoot is generated with the database.
- >>> from zope.app.event.tests.placelesssetup import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> [event] = getEvents(interfaces.IDatabaseOpenedWithRootEvent)
>>> event.database is db
True
Modified: Zope3/trunk/src/zope/app/appsetup/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/appsetup/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/appsetup/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,9 +17,10 @@
"""
import unittest
import transaction
-from zope.testing import doctest
from ZODB.tests.util import DB
+from zope.testing import doctest
+from zope.traversing.api import traverse
from zope.app import zapi
from zope.app.component import hooks
@@ -30,7 +31,6 @@
from zope.app.folder.interfaces import IRootFolder
from zope.app.publication.zopepublication import ZopePublication
from zope.app.component.site import LocalSiteManager
-from zope.app.traversing.api import traverse
from zope.app.appsetup.bootstrap import bootStrapSubscriber
from zope.app.appsetup.bootstrap import getInformationFromEvent, \
Modified: Zope3/trunk/src/zope/app/authentication/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/authentication/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -360,15 +360,15 @@
>>> print pau.getPrincipal('xyz_bob')
Traceback (most recent call last):
- PrincipalLookupError: 'bob'
+ PrincipalLookupError: bob
>>> print pau.getPrincipal('white')
Traceback (most recent call last):
- PrincipalLookupError: 'white'
+ PrincipalLookupError: white
>>> print pau.getPrincipal('black')
Traceback (most recent call last):
- PrincipalLookupError: 'black'
+ PrincipalLookupError: black
For a PAU to support search, it needs to be configured with one or more
authenticator plugins that support search. To illustrate, we'll create a new
@@ -422,7 +422,7 @@
>>> print pau.getPrincipal('black')
Traceback (most recent call last):
- PrincipalLookupError: 'black'
+ PrincipalLookupError: black
Found Principal Creates Events
------------------------------
Modified: Zope3/trunk/src/zope/app/authentication/authentication.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/authentication.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/authentication.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,19 +16,18 @@
$Id$
"""
import zope.interface
-
from zope import component
from zope.schema.interfaces import ISourceQueriables
+from zope.location.interfaces import ILocation
+
from zope.app.security.interfaces import IAuthentication, PrincipalLookupError
-from zope.app.location.interfaces import ILocation
from zope.app.component import queryNextUtility
-from zope.app.component.site import SiteManagementFolder
+import zope.app.container.btree
from zope.app.authentication import interfaces
+class PluggableAuthentication(zope.app.container.btree.BTreeContainer):
-class PluggableAuthentication(SiteManagementFolder):
-
zope.interface.implements(
IAuthentication,
interfaces.IPluggableAuthentication,
@@ -41,6 +40,16 @@
super(PluggableAuthentication, self).__init__()
self.prefix = prefix
+ @property
+ def registrationManager(self):
+ import warnings
+ warnings.warn(
+ "The registration manager is deprecated and will go away in "
+ "Zope 3.5. Use the simpler registration api (registerUtility) "
+ "instead.",
+ DeprecationWarning, 2)
+ return self.__parent__.registrationManager
+
def _plugins(self, names, interface):
for name in names:
plugin = self.get(name)
Copied: Zope3/trunk/src/zope/app/authentication/browser/adding.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/authentication/browser/adding.py)
Modified: Zope3/trunk/src/zope/app/authentication/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -29,6 +29,13 @@
permission="zope.ManageServices"
/>
+ <page
+ for="..interfaces.IPluggableAuthentication"
+ name="addRegistration.html"
+ permission="zope.ManageSite"
+ class=".register.AddAuthenticationRegistration"
+ />
+
<editform
schema="..interfaces.IPluggableAuthentication"
label="Edit Pluggable Authentication Utility"
@@ -46,6 +53,17 @@
attribute="contents"
/>
+ <view
+ name="+"
+ menu="zmi_actions" title="Add"
+ for="..interfaces.IPluggableAuthentication"
+ permission="zope.ManageSite"
+ class=".adding.Adding"
+ >
+ <page name="index.html" attribute="index" />
+ <page name="action.html" attribute="action" />
+ </view>
+
<menuItem
menu="zmi_views"
for="..interfaces.IPluggableAuthentication"
@@ -53,42 +71,6 @@
action=""
filter="python:False" />
- <addform
- label="New Pluggable Authentication Utility Registration"
- for="..interfaces.IPluggableAuthentication"
- name="addRegistration.html"
- schema="zope.app.component.interfaces.IUtilityRegistration"
- class="zope.app.component.browser.registration.AddComponentRegistration"
- permission="zope.ManageSite"
- content_factory=".register.pluggableAuthenticationRegistration"
- arguments="component"
- fields="component status permission"
- />
-
- <addform
- label="New Credentials Plugin Registration"
- for="..interfaces.ICredentialsPlugin"
- name="addRegistration.html"
- schema="zope.app.component.interfaces.IUtilityRegistration"
- class="zope.app.component.browser.registration.AddComponentRegistration"
- permission="zope.ManageSite"
- content_factory=".register.credentialsPluginRegistration"
- arguments="name component"
- fields="name component status permission"
- />
-
- <addform
- label="New Authenticator Plugin Registration"
- for="..interfaces.IAuthenticatorPlugin"
- name="addRegistration.html"
- schema="zope.app.component.interfaces.IUtilityRegistration"
- class="zope.app.component.browser.registration.AddComponentRegistration"
- permission="zope.ManageSite"
- content_factory=".register.authenticatorPluginRegistration"
- arguments="name component"
- fields="name component status permission"
- />
-
<zope:adapter
for="..interfaces.IQuerySchemaSearch
zope.publisher.interfaces.browser.IBrowserRequest"
@@ -96,14 +78,4 @@
factory=".schemasearch.QuerySchemaSearchView"
/>
- <tool
- interface="..interfaces.ICredentialsPlugin"
- title="Credentials Plugin"
- />
-
- <tool
- interface="..interfaces.IAuthenticatorPlugin"
- title="Authenticator Plugin"
- />
-
</zope:configure>
Modified: Zope3/trunk/src/zope/app/authentication/browser/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/ftests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/browser/ftests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,22 +16,18 @@
$Id$
"""
import unittest
-
-from zope.app.testing import ztapi
-from zope.app.testing import functional
-
import transaction
+from zope import copypastemove
from zope.interface import implements, Interface, directlyProvides
-from zope.app import copypastemove
+from zope.exceptions.interfaces import UserError
+from zope.app.testing import ztapi
+from zope.app.testing import functional
from zope.app.authentication.principalfolder import PrincipalFolder
from zope.app.authentication.principalfolder import Principal
from zope.app.authentication.principalfolder import IInternalPrincipal
-from zope.app.exception.interfaces import UserError
-
-
class FunkTest(functional.BrowserTestCase):
def test_copypaste_duplicated_id_object(self):
Modified: Zope3/trunk/src/zope/app/authentication/browser/group_searching_with_empty_string.txt
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/group_searching_with_empty_string.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/browser/group_searching_with_empty_string.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,25 +25,13 @@
... Referer: http://localhost:8081/++etc++site/default/PAU/addRegistration.html
...
... -----------------------------191720529414243436931796477300
- ... Content-Disposition: form-data; name="field.status"
+ ... Content-Disposition: form-data; name="field.comment"
...
- ... Active
- ... -----------------------------191720529414243436931796477300
- ... Content-Disposition: form-data; name="field.status-empty-marker"
...
- ... 1
... -----------------------------191720529414243436931796477300
- ... Content-Disposition: form-data; name="field.permission"
+ ... Content-Disposition: form-data; name="field.actions.register"
...
- ...
- ... -----------------------------191720529414243436931796477300
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... -----------------------------191720529414243436931796477300
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
+ ... Register
... -----------------------------191720529414243436931796477300--
... """)
HTTP/1.1 303 See Other
Modified: Zope3/trunk/src/zope/app/authentication/browser/groupfolder.txt
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/groupfolder.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/browser/groupfolder.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -47,25 +47,13 @@
... Referer: http://localhost:8081/++etc++site/default/PAU/addRegistration.html
...
... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.status"
+ ... Content-Disposition: form-data; name="field.comment"
...
- ... Active
+ ...
... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.status-empty-marker"
+ ... Content-Disposition: form-data; name="field.actions.register"
...
- ... 1
- ... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.permission"
- ...
- ...
- ... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
+ ... Register
... -----------------------------5559795404609280911441883437--
... """)
HTTP/1.1 303 See Other
@@ -98,46 +86,6 @@
HTTP/1.1 303 See Other
...
-
-Register Principal Folder as `users`.
-
- >>> print http(r"""
- ... POST /++etc++site/default/PAU/users/addRegistration.html HTTP/1.1
- ... Authorization: Basic bWdyOm1ncnB3
- ... Content-Length: 806
- ... Content-Type: multipart/form-data; boundary=---------------------------3658059809094229671187159254
- ... Cookie: zope3_cs_6a553b3=-j7C3CdeW9sUK8BP5x97u2d9o242xMJDzJd8HCQ5AAi9xeFcGTFkAs
- ... Referer: http://localhost:8081/++etc++site/default/PAU/users/addRegistration.html
- ...
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.name"
- ...
- ... users
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.status"
- ...
- ... Active
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.status-empty-marker"
- ...
- ... 1
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.permission"
- ...
- ...
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
- ... -----------------------------3658059809094229671187159254--
- ... """)
- HTTP/1.1 303 See Other
- ...
-
Next we will add some users.
>>> print http(r"""
Modified: Zope3/trunk/src/zope/app/authentication/browser/groupfolder.zcml
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/groupfolder.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/browser/groupfolder.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -29,12 +29,6 @@
view="AddGroupInformation.html"
/>
-<tool
- interface="..groupfolder.IGroupFolder"
- title="Groups Folder"
- description="Groups Folder"
- />
-
<addform
schema="..groupfolder.IGroupFolder"
content_factory="..groupfolder.GroupFolder"
Modified: Zope3/trunk/src/zope/app/authentication/browser/pau_prefix_and_searching.txt
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/pau_prefix_and_searching.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/browser/pau_prefix_and_searching.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -37,25 +37,13 @@
... Content-Type: multipart/form-data; boundary=---------------------------516441125097
...
... -----------------------------516441125097
- ... Content-Disposition: form-data; name="field.status"
+ ... Content-Disposition: form-data; name="field.comment"
...
- ... Active
+ ...
... -----------------------------516441125097
- ... Content-Disposition: form-data; name="field.status-empty-marker"
+ ... Content-Disposition: form-data; name="field.actions.register"
...
- ... 1
- ... -----------------------------516441125097
- ... Content-Disposition: form-data; name="field.permission"
- ...
- ...
- ... -----------------------------516441125097
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... -----------------------------516441125097
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
+ ... Register
... -----------------------------516441125097--
... """)
HTTP/1.1 303 See Other
@@ -86,41 +74,6 @@
HTTP/1.1 303 See Other
...
- >>> print http(r"""
- ... POST /++etc++site/default/PAU1/Users/addRegistration.html HTTP/1.1
- ... Authorization: Basic bWdyOm1ncnB3
- ... Content-Length: 701
- ... Content-Type: multipart/form-data; boundary=---------------------------1293260033248
- ...
- ... -----------------------------1293260033248
- ... Content-Disposition: form-data; name="field.name"
- ...
- ... Users
- ... -----------------------------1293260033248
- ... Content-Disposition: form-data; name="field.status"
- ...
- ... Active
- ... -----------------------------1293260033248
- ... Content-Disposition: form-data; name="field.status-empty-marker"
- ...
- ... 1
- ... -----------------------------1293260033248
- ... Content-Disposition: form-data; name="field.permission"
- ...
- ...
- ... -----------------------------1293260033248
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... -----------------------------1293260033248
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
- ... -----------------------------1293260033248--
- ... """)
- HTTP/1.1 303 See Other
- ...
-
and add a principal that we'll later search for:
>>> print http(r"""
Modified: Zope3/trunk/src/zope/app/authentication/browser/principalfolder.txt
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/principalfolder.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/browser/principalfolder.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -28,7 +28,8 @@
... Cookie: zope3_cs_6a553b3=-j7C3CdeW9sUK8BP5x97u2d9o242xMJDzJd8HCQ5AAi9xeFcGTFkAs
... Referer: http://localhost:8081/++etc++site/default/@@contents.html?type_name=BrowserAdd__zope.app.authentication.authentication.PluggableAuthentication
...
- ... type_name=BrowserAdd__zope.app.authentication.authentication.PluggableAuthentication&new_value=PAU""")
+ ... type_name=BrowserAdd__zope.app.authentication.authentication.PluggableAuthentication&new_value=PAU""",
+ ... handle_errors=False)
HTTP/1.1 303 See Other
...
@@ -52,27 +53,15 @@
... Referer: http://localhost:8081/++etc++site/default/PAU/addRegistration.html
...
... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.status"
+ ... Content-Disposition: form-data; name="field.comment"
...
- ... Active
- ... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.status-empty-marker"
...
- ... 1
... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.permission"
+ ... Content-Disposition: form-data; name="field.actions.register"
...
- ...
- ... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
+ ... Register
... -----------------------------5559795404609280911441883437--
- ... """)
+ ... """, handle_errors=False)
HTTP/1.1 303 See Other
...
@@ -108,46 +97,6 @@
name ths plugin `users`. This is the name we'll use when we configure
the pluggable authentiaction service.
-
-Register Principal Folder as `users`.
-
- >>> print http(r"""
- ... POST /++etc++site/default/PAU/users/addRegistration.html HTTP/1.1
- ... Authorization: Basic bWdyOm1ncnB3
- ... Content-Length: 806
- ... Content-Type: multipart/form-data; boundary=---------------------------3658059809094229671187159254
- ... Cookie: zope3_cs_6a553b3=-j7C3CdeW9sUK8BP5x97u2d9o242xMJDzJd8HCQ5AAi9xeFcGTFkAs
- ... Referer: http://localhost:8081/++etc++site/default/PAU/users/addRegistration.html
- ...
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.name"
- ...
- ... users
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.status"
- ...
- ... Active
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.status-empty-marker"
- ...
- ... 1
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.permission"
- ...
- ...
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
- ... -----------------------------3658059809094229671187159254--
- ... """)
- HTTP/1.1 303 See Other
- ...
-
Next we'll view the contents page of the principal folder:
>>> print http(r"""
@@ -250,7 +199,7 @@
...
... dXNlcnM=
... -----------------------------6519411471194050603270010787--
- ... """)
+ ... """, handle_errors=False)
HTTP/1.1 200 Ok
...
Modified: Zope3/trunk/src/zope/app/authentication/browser/register.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/register.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/browser/register.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,14 +1,30 @@
-from zope.app.component.site import UtilityRegistration
-from zope.app.security.interfaces import IAuthentication
-from zope.app.authentication.interfaces import ICredentialsPlugin
-from zope.app.authentication.interfaces import IAuthenticatorPlugin
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Improved registration UI for registering pluggable autentication utilities
-def pluggableAuthenticationRegistration(view, component):
- return UtilityRegistration(u'', IAuthentication, component)
+$Id$
+"""
-def credentialsPluginRegistration(view, name, component):
- return UtilityRegistration(name, ICredentialsPlugin, component)
+from zope.app.i18n import ZopeMessageFactory as _
+import zope.app.component.browser.registration
+import zope.app.security.interfaces
-def authenticatorPluginRegistration(view, name, component):
- return UtilityRegistration(name, IAuthenticatorPlugin, component)
+import zope.app.authentication.interfaces
+class AddAuthenticationRegistration(
+ zope.app.component.browser.registration.AddUtilityRegistration,
+ ):
+ label = _("Register a pluggable authentication utility")
+ name = ''
+ provided = zope.app.security.interfaces.IAuthentication
Modified: Zope3/trunk/src/zope/app/authentication/browser/special-groups.txt
===================================================================
--- Zope3/trunk/src/zope/app/authentication/browser/special-groups.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/browser/special-groups.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -39,25 +39,13 @@
... Referer: http://localhost:8081/++etc++site/default/PAU/addRegistration.html
...
... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.status"
+ ... Content-Disposition: form-data; name="field.comment"
...
- ... Active
- ... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.status-empty-marker"
...
- ... 1
... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.permission"
+ ... Content-Disposition: form-data; name="field.actions.register"
...
- ...
- ... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... -----------------------------5559795404609280911441883437
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
+ ... Register
... -----------------------------5559795404609280911441883437--
... """)
HTTP/1.1 303 See Other
@@ -90,46 +78,6 @@
HTTP/1.1 303 See Other
...
-
-Register Principal Folder.
-
- >>> print http(r"""
- ... POST /++etc++site/default/PAU/users/addRegistration.html HTTP/1.1
- ... Authorization: Basic bWdyOm1ncnB3
- ... Content-Length: 806
- ... Content-Type: multipart/form-data; boundary=---------------------------3658059809094229671187159254
- ... Cookie: zope3_cs_6a553b3=-j7C3CdeW9sUK8BP5x97u2d9o242xMJDzJd8HCQ5AAi9xeFcGTFkAs
- ... Referer: http://localhost:8081/++etc++site/default/PAU/users/addRegistration.html
- ...
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.name"
- ...
- ... users
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.status"
- ...
- ... Active
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.status-empty-marker"
- ...
- ... 1
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.permission"
- ...
- ...
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... -----------------------------3658059809094229671187159254
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
- ... -----------------------------3658059809094229671187159254--
- ... """)
- HTTP/1.1 303 See Other
- ...
-
Add a principal to it:
>>> print http(r"""
Modified: Zope3/trunk/src/zope/app/authentication/groupfolder.txt
===================================================================
--- Zope3/trunk/src/zope/app/authentication/groupfolder.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/groupfolder.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,7 +19,7 @@
Note that when group-info is added, a GroupAdded event is generated:
>>> from zope.app.authentication import interfaces
- >>> from zope.app.event.tests.placelesssetup import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> getEvents(interfaces.IGroupAdded)
[<GroupAdded 'group.g1'>]
Modified: Zope3/trunk/src/zope/app/authentication/groupfolder.zcml
===================================================================
--- Zope3/trunk/src/zope/app/authentication/groupfolder.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/groupfolder.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -13,7 +13,7 @@
set_schema=".groupfolder.IGroupInformation"
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
Modified: Zope3/trunk/src/zope/app/authentication/idpicker.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/idpicker.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/idpicker.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,11 +15,10 @@
$Id$
"""
-
+import re
+from zope.exceptions.interfaces import UserError
from zope.app.container.contained import NameChooser
-from zope.app.exception.interfaces import UserError
from zope.app.i18n import ZopeMessageFactory as _
-import re
ok = re.compile('[!-~]+$').match
class IdPicker(NameChooser):
Modified: Zope3/trunk/src/zope/app/authentication/password.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/password.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/password.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,7 +20,7 @@
import sha
from zope.interface import implements, classProvides
-from zope.app.schema.interfaces import IVocabularyFactory
+from zope.schema.interfaces import IVocabularyFactory
from zope.app.component.vocabulary import UtilityVocabulary
from zope.app.authentication.interfaces import IPasswordManager
Modified: Zope3/trunk/src/zope/app/authentication/principalfolder.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/principalfolder.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/principalfolder.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -461,7 +461,7 @@
It also fires an AuthenticatedPrincipalCreatedEvent:
- >>> from zope.app.event.tests.placelesssetup import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> [event] = getEvents(interfaces.IAuthenticatedPrincipalCreated)
>>> event.principal is principal, event.authentication is auth
(True, True)
@@ -524,7 +524,7 @@
It also fires a FoundPrincipalCreatedEvent:
- >>> from zope.app.event.tests.placelesssetup import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> [event] = getEvents(interfaces.IFoundPrincipalCreated)
>>> event.principal is principal, event.authentication is auth
(True, True)
Modified: Zope3/trunk/src/zope/app/authentication/session.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/session.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/session.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,15 +23,13 @@
from zope.interface import implements, Interface
from zope.schema import TextLine
from zope.publisher.interfaces.http import IHTTPRequest
+from zope.traversing.browser.absoluteurl import absoluteURL
from zope.app.component import hooks
from zope.app.container.contained import Contained
from zope.app.session.interfaces import ISession
-from zope.app.traversing.browser.absoluteurl import absoluteURL
-
from zope.app.authentication.interfaces import ICredentialsPlugin
-
class ISessionCredentials(Interface):
""" Interface for storing and accessing credentials in a session.
Modified: Zope3/trunk/src/zope/app/authentication/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,12 +22,11 @@
from zope.testing import doctest
from zope.interface import implements
from zope.component import provideUtility, provideAdapter
+from zope.component.eventtesting import getEvents, clearEvents
from zope.publisher.interfaces import IRequest
from zope.publisher.tests.httprequest import TestRequest
-from zope.app import zapi
from zope.app.testing import placelesssetup, ztapi
-from zope.app.event.tests.placelesssetup import getEvents, clearEvents
from zope.app.testing.setup import placefulSetUp, placefulTearDown
from zope.app.session.interfaces import \
IClientId, IClientIdManager, ISession, ISessionDataContainer, \
Modified: Zope3/trunk/src/zope/app/authentication/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/vocabulary.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/vocabulary.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,14 +19,13 @@
"""
__docformat__ = "reStructuredText"
+import zope.dublincore.interfaces
from zope import interface, component, i18n
from zope.interface.interfaces import IInterface
from zope.schema import vocabulary
+from zope.schema.interfaces import IVocabularyFactory
-import zope.app.dublincore.interfaces
-from zope.app.component.interfaces import ILocalUtility
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.schema.interfaces import IVocabularyFactory
from zope.app.authentication import interfaces
@@ -48,11 +47,10 @@
which is expected to be a pluggable authentication utility, hereafter
referred to as a PAU).
- These plugins may be objects contained within the PAU that do not provide
- zope.app.component.interfaces.ILocalUtility ("contained plugins"), or may
- be utilities registered for the specified interface, found in the context
- of the PAU ("utility plugins"). Contained plugins mask utility plugins of
- the same name.
+ These plugins may be objects contained within the PAU ("contained
+ plugins"), or may be utilities registered for the specified
+ interface, found in the context of the PAU ("utility plugins").
+ Contained plugins mask utility plugins of the same name.
The vocabulary also includes the current values of the PAU even if they do
not correspond to a contained or utility plugin.
@@ -61,8 +59,8 @@
isPAU = interfaces.IPluggableAuthentication.providedBy(context)
if isPAU:
for k, v in context.items():
- if interface.providedBy(v) and not ILocalUtility.providedBy(v):
- dc = zope.app.dublincore.interfaces.IDCDescriptiveProperties(
+ if interface.providedBy(v):
+ dc = zope.dublincore.interfaces.IDCDescriptiveProperties(
v, None)
if dc is not None and dc.title:
title = dc.title
Modified: Zope3/trunk/src/zope/app/authentication/vocabulary.txt
===================================================================
--- Zope3/trunk/src/zope/app/authentication/vocabulary.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/authentication/vocabulary.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -7,23 +7,20 @@
is expected to be a pluggable authentication utility, hereafter referred to as
a PAU.
-These names may be for objects contained within the PAU that do not provide
-zope.app.component.interfaces.ILocalUtility ("contained plugins"), or may
-be utilities registered for the specified interface, found in the context
-of the PAU ("utility plugins"). Contained plugins mask utility plugins of
-the same name. They also may be names currently selected in the PAU that do
-not actually have a corresponding plugin at this time.
+These names may be for objects contained within the PAU ("contained
+plugins"), or may be utilities registered for the specified interface,
+found in the context of the PAU ("utility plugins"). Contained
+plugins mask utility plugins of the same name. They also may be names
+currently selected in the PAU that do not actually have a
+corresponding plugin at this time.
Here is a short example of how the vocabulary should work. Let's say we're
working with authentication plugins. We'll create some faux
authentication plugins, and register some of them as utilities and put
-others in a faux PAU. Two of the contained plugins will provide
-zope.app.component.interfaces.ILocalUtility, and so should not be included in
-the vocabulary.
+others in a faux PAU.
>>> from zope.app.authentication import interfaces
>>> from zope import interface, component
- >>> from zope.app.component.interfaces import ILocalUtility
>>> class DemoPlugin(object):
... interface.implements(interfaces.IAuthenticatorPlugin)
... def __init__(self, name):
@@ -33,8 +30,6 @@
... (i, DemoPlugin(u'Plugin %d' % i)) for i in range(4))
>>> contained_plugins = dict(
... (i, DemoPlugin(u'Plugin %d' % i)) for i in range(1, 5))
- >>> interface.directlyProvides(contained_plugins[2], ILocalUtility)
- >>> interface.directlyProvides(contained_plugins[3], ILocalUtility)
>>> sorted(utility_plugins.keys())
[0, 1, 2, 3]
>>> for p in utility_plugins.values():
@@ -52,7 +47,7 @@
>>> auth = DemoAuth((p.name, p) for p in contained_plugins.values())
>>> @component.adapter(interface.Interface)
- ... @interface.implementer(component.ISiteManager)
+ ... @interface.implementer(component.IComponentLookup)
... def getSiteManager(context):
... return component.getGlobalSiteManager()
...
@@ -104,14 +99,14 @@
We'll give one of the plugins a dublin core title just to show the
functionality.
- >>> import zope.app.dublincore.interfaces
+ >>> import zope.dublincore.interfaces
>>> class ISpecial(interface.Interface):
... pass
...
>>> interface.directlyProvides(contained_plugins[1], ISpecial)
>>> class DemoDCAdapter(object):
... interface.implements(
- ... zope.app.dublincore.interfaces.IDCDescriptiveProperties)
+ ... zope.dublincore.interfaces.IDCDescriptiveProperties)
... component.adapts(ISpecial)
... def __init__(self, context):
... pass
@@ -132,8 +127,8 @@
>>> pprint.pprint([i18n.translate(term.title) for term in vocab])
[u'Plugin 0 (a utility)',
u'Special Title (in contents)',
- u'Plugin 2 (a utility)',
- u'Plugin 3 (a utility)',
+ u'Plugin 2 (in contents)',
+ u'Plugin 3 (in contents)',
u'Plugin 4 (in contents)',
u'Plugin X (not found; deselecting will remove)']
@@ -151,8 +146,6 @@
... (i, DemoPlugin(u'Plugin %d' % i)) for i in range(4))
>>> contained_plugins = dict(
... (i, DemoPlugin(u'Plugin %d' % i)) for i in range(1, 5))
- >>> interface.directlyProvides(contained_plugins[2], ILocalUtility)
- >>> interface.directlyProvides(contained_plugins[3], ILocalUtility)
>>> for p in utility_plugins.values():
... component.provideUtility(p, name=p.name)
...
@@ -200,7 +193,7 @@
>>> pprint.pprint([i18n.translate(term.title) for term in vocab])
[u'Plugin 0 (a utility)',
u'Special Title (in contents)',
- u'Plugin 2 (a utility)',
- u'Plugin 3 (a utility)',
+ u'Plugin 2 (in contents)',
+ u'Plugin 3 (in contents)',
u'Plugin 4 (in contents)',
u'Plugin X (not found; deselecting will remove)']
Modified: Zope3/trunk/src/zope/app/basicskin/standardmacros.py
===================================================================
--- Zope3/trunk/src/zope/app/basicskin/standardmacros.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/basicskin/standardmacros.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,8 +20,8 @@
__docformat__ = 'restructuredtext'
import zope.interface
-from zope.app import zapi
-from zope.app.publisher.browser import BrowserView
+from zope.component import getMultiAdapter
+from zope.publisher.browser import BrowserView
class Macros(object):
zope.interface.implements(zope.interface.common.mapping.IItemMapping)
@@ -38,7 +38,7 @@
context = self.context
request = self.request
for name in self.macro_pages:
- page = zapi.getMultiAdapter((context, request), name=name)
+ page = getMultiAdapter((context, request), name=name)
try:
v = page[key]
except KeyError:
Modified: Zope3/trunk/src/zope/app/basicskin/tests/sampleinterfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/basicskin/tests/sampleinterfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/basicskin/tests/sampleinterfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,9 +16,8 @@
$Id$
"""
from zope.interface import Interface, implements
+from zope.traversing.interfaces import ITraverser
-from zope.app.traversing.interfaces import ITraverser
-
class FakeTraverser(object):
implements(ITraverser)
Modified: Zope3/trunk/src/zope/app/basicskin/tests/test_standardmacros.py
===================================================================
--- Zope3/trunk/src/zope/app/basicskin/tests/test_standardmacros.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/basicskin/tests/test_standardmacros.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,13 +18,12 @@
import unittest
from zope.interface import implements, Interface
from zope.publisher.browser import TestRequest
+from zope.publisher.interfaces.browser import IBrowserView
from zope.app.basicskin.standardmacros import Macros
from zope.app.component.testing import PlacefulSetup
-from zope.app.publisher.interfaces.browser import IBrowserView
from zope.app.testing import ztapi
-
class ViewWithMacros(object):
implements(IBrowserView)
Modified: Zope3/trunk/src/zope/app/broken/broken.py
===================================================================
--- Zope3/trunk/src/zope/app/broken/broken.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/broken/broken.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,12 +19,11 @@
import ZODB.broken
import zope.interface
-import zope.app.location.interfaces
+import zope.location.interfaces
import zope.security.checker
+from zope.annotation.interfaces import IAnnotations
-from zope.app.annotation.interfaces import IAnnotations
-
class IBroken(zope.interface.Interface):
"""Marker interface for broken objects
"""
@@ -32,7 +31,7 @@
class Broken(ZODB.broken.Broken):
zope.interface.implements(
IBroken,
- zope.app.location.interfaces.ILocation,
+ zope.location.interfaces.ILocation,
IAnnotations,
)
@@ -96,7 +95,7 @@
It implements ILocation and IAnnotations::
- >>> zope.app.location.interfaces.ILocation.implementedBy(cls)
+ >>> zope.location.interfaces.ILocation.implementedBy(cls)
True
>>> IAnnotations.implementedBy(cls)
True
Modified: Zope3/trunk/src/zope/app/broken/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/broken/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/broken/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,7 +1,7 @@
<configure xmlns="http://namespaces.zope.org/zope">
<class class=".broken.Broken">
- <allow interface="zope.app.annotation.interfaces.IAnnotations" />
+ <allow interface="zope.annotation.interfaces.IAnnotations" />
<allow attributes="__module__" />
</class>
Modified: Zope3/trunk/src/zope/app/browser.zcml
===================================================================
--- Zope3/trunk/src/zope/app/browser.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/browser.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -6,7 +6,7 @@
<browser:defaultSkin name="Rotterdam" />
<include package="zope.app.exception.browser" />
- <include package="zope.app.traversing.browser" />
+ <include package="zope.traversing.browser" />
<include package="zope.app.security.browser" />
<include package="zope.app.container.browser" />
Modified: Zope3/trunk/src/zope/app/cache/annotationcacheable.py
===================================================================
--- Zope3/trunk/src/zope/app/cache/annotationcacheable.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/cache/annotationcacheable.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,11 +17,11 @@
"""
__docformat__ = 'restructuredtext'
+import zope.component
from zope.interface import implements
from zope.proxy import removeAllProxies
+from zope.annotation.interfaces import IAnnotations
-from zope.app import zapi
-from zope.app.annotation.interfaces import IAnnotations
from zope.app.cache.interfaces import ICacheable, ICache
annotation_key = 'zope.app.cache.CacheManager'
@@ -42,7 +42,7 @@
# Remove object from old cache
old_cache_id = self.getCacheId()
if old_cache_id and old_cache_id != id:
- cache = zapi.getUtility(ICache, old_cache_id)
+ cache = zope.component.getUtility(ICache, old_cache_id)
cache.invalidate(self._context)
annotations = IAnnotations(removeAllProxies(self._context))
annotations[annotation_key] = id
Modified: Zope3/trunk/src/zope/app/cache/browser/cacheable.py
===================================================================
--- Zope3/trunk/src/zope/app/cache/browser/cacheable.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/cache/browser/cacheable.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,15 +17,16 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app import zapi
+from zope.component import getMultiAdapter
+from zope.publisher.browser import BrowserView
+from zope.annotation.interfaces import IAnnotatable
+
from zope.app.cache.caching import getCacheForObject, getLocationForCache
from zope.app.form.utility import setUpEditWidgets
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.annotation.interfaces import IAnnotatable
from zope.app.cache.interfaces import ICacheable
from zope.app.form.interfaces import WidgetInputError
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.app.publisher.browser import BrowserView
class CacheableView(BrowserView):
@@ -45,8 +46,8 @@
def current_cache_url(self):
"Returns the current cache provider's URL."
cache = getCacheForObject(self.context)
- absolute_url = zapi.getMultiView((cache, self.request),
- name='absolute_url')
+ absolute_url = getMultiAdapter((cache, self.request),
+ name='absolute_url')
try:
return absolute_url()
except TypeError:
Modified: Zope3/trunk/src/zope/app/cache/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/cache/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/cache/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -3,12 +3,6 @@
xmlns="http://namespaces.zope.org/browser"
>
- <tool
- interface="zope.app.cache.interfaces.ICache"
- title="Caches"
- description="Caches can be used to make your site run faster."
- />
-
<addMenuItem
title="RAM Cache"
description="A RAM cache is a volatile (in memory) cache"
Modified: Zope3/trunk/src/zope/app/cache/browser/ram.py
===================================================================
--- Zope3/trunk/src/zope/app/cache/browser/ram.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/cache/browser/ram.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,7 +17,7 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app.publisher.browser import BrowserView
+from zope.publisher.browser import BrowserView
from zope.app.cache.interfaces.ram import IRAMCache
class RAMCacheView(BrowserView):
Modified: Zope3/trunk/src/zope/app/cache/caching.py
===================================================================
--- Zope3/trunk/src/zope/app/cache/caching.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/cache/caching.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,10 +19,10 @@
from zope.interface import classProvides
from zope.component import ComponentLookupError
+from zope.schema.interfaces import IVocabularyFactory
from zope.app import zapi
from zope.app.cache.interfaces import ICacheable, ICache
from zope.app.component.vocabulary import UtilityVocabulary
-from zope.app.schema.interfaces import IVocabularyFactory
def getCacheForObject(obj):
"""Returns the cache associated with `obj` or ``None``."""
Modified: Zope3/trunk/src/zope/app/cache/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/cache/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/cache/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -3,7 +3,7 @@
i18n_domain="zope">
<adapter
- for="zope.app.annotation.interfaces.IAnnotatable"
+ for="zope.annotation.interfaces.IAnnotatable"
provides="zope.app.cache.interfaces.ICacheable"
factory="zope.app.cache.annotationcacheable.AnnotationCacheable"
/>
Modified: Zope3/trunk/src/zope/app/cache/interfaces/ram.py
===================================================================
--- Zope3/trunk/src/zope/app/cache/interfaces/ram.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/cache/interfaces/ram.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,9 +20,8 @@
from zope.interface import Attribute
from zope.app.cache.interfaces import ICache
-from zope.app.component.interfaces.registration import IRegisterable
-class IRAMCache(ICache, IRegisterable):
+class IRAMCache(ICache):
"""Interface for the RAM Cache."""
maxEntries = Attribute("""A maximum number of cached values.""")
Modified: Zope3/trunk/src/zope/app/cache/tests/test_annotationcacheable.py
===================================================================
--- Zope3/trunk/src/zope/app/cache/tests/test_annotationcacheable.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/cache/tests/test_annotationcacheable.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,10 +17,10 @@
"""
import unittest
from zope.interface import implements
+from zope.annotation.interfaces import IAnnotations, IAttributeAnnotatable
+from zope.annotation.attribute import AttributeAnnotations
from zope.app.testing import ztapi, placelesssetup
-from zope.app.annotation.interfaces import IAnnotations, IAttributeAnnotatable
-from zope.app.annotation.attribute import AttributeAnnotations
from zope.app.cache.annotationcacheable import AnnotationCacheable
from zope.app.cache.interfaces import ICache
Modified: Zope3/trunk/src/zope/app/cache/tests/test_caching.py
===================================================================
--- Zope3/trunk/src/zope/app/cache/tests/test_caching.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/cache/tests/test_caching.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,10 +17,10 @@
"""
import unittest
from zope.interface import implements
+from zope.annotation.interfaces import IAnnotatable, IAnnotations
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.annotation.attribute import AttributeAnnotations
-from zope.app.annotation.interfaces import IAnnotatable, IAnnotations
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.annotation.attribute import AttributeAnnotations
from zope.app.cache.interfaces import ICacheable, ICache
from zope.app.cache.caching import getCacheForObject
from zope.app.cache.annotationcacheable import AnnotationCacheable
Modified: Zope3/trunk/src/zope/app/cache/tests/test_ramcache.py
===================================================================
--- Zope3/trunk/src/zope/app/cache/tests/test_ramcache.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/cache/tests/test_ramcache.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,12 +20,12 @@
from zope.interface.verify import verifyClass, verifyObject
from zope.interface import implements
+from zope.traversing.interfaces import IPhysicallyLocatable
from zope.app.cache.ram import RAMCache
from zope.app.cache.tests.test_icache import BaseICacheTest
from zope.app.cache.interfaces import ICache
from zope.app.cache.interfaces.ram import IRAMCache
-from zope.app.traversing.interfaces import IPhysicallyLocatable
from zope.app.testing.placelesssetup import PlacelessSetup
class Locatable(object):
Modified: Zope3/trunk/src/zope/app/catalog/browser/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/catalog/browser/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/catalog/browser/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,7 +23,8 @@
... Content-Type: application/x-www-form-urlencoded
... Referer: http://localhost:8081/++etc++site/default/@@+
...
- ... type_name=BrowserAdd__zope.app.intid.IntIds&id=&add=+Add+""")
+ ... type_name=BrowserAdd__zope.app.intid.IntIds&id=&add=+Add+""",
+ ... handle_errors=False)
HTTP/1.1 303 ...
And register it:
@@ -47,31 +48,17 @@
...
... 1
... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
- ... Content-Disposition: form-data; name="field.status"
+ ... Content-Disposition: form-data; name="field.comment"
...
- ... Active
- ... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
- ... Content-Disposition: form-data; name="field.status-empty-marker"
...
- ... 1
... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
- ... Content-Disposition: form-data; name="field.permission"
+ ... Content-Disposition: form-data; name="field.actions.register"
...
- ...
- ... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
+ ... Register
... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ--
- ... """)
+ ... """, handle_errors=False)
HTTP/1.1 303 See Other
...
- Location: @@SelectedManagementView.html
- ...
Moving short-id management outside of catalogs make it possible to
@@ -123,25 +110,13 @@
...
... 1
... ------------61t9UJyoacebBevQVdNrlvXP6T9Ik3Xo4RyXkwJJWvuhao65RTuAPRa
- ... Content-Disposition: form-data; name="field.status"
+ ... Content-Disposition: form-data; name="field.comment"
...
- ... Active
- ... ------------61t9UJyoacebBevQVdNrlvXP6T9Ik3Xo4RyXkwJJWvuhao65RTuAPRa
- ... Content-Disposition: form-data; name="field.status-empty-marker"
...
- ... 1
... ------------61t9UJyoacebBevQVdNrlvXP6T9Ik3Xo4RyXkwJJWvuhao65RTuAPRa
- ... Content-Disposition: form-data; name="field.permission"
+ ... Content-Disposition: form-data; name="field.actions.register"
...
- ... zope.Public
- ... ------------61t9UJyoacebBevQVdNrlvXP6T9Ik3Xo4RyXkwJJWvuhao65RTuAPRa
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... ------------61t9UJyoacebBevQVdNrlvXP6T9Ik3Xo4RyXkwJJWvuhao65RTuAPRa
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
+ ... Register
... ------------61t9UJyoacebBevQVdNrlvXP6T9Ik3Xo4RyXkwJJWvuhao65RTuAPRa--
... """)
HTTP/1.1 303 ...
Modified: Zope3/trunk/src/zope/app/catalog/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/catalog/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/catalog/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -4,12 +4,6 @@
i18n_domain="zope"
>
-<tool
- interface="..interfaces.ICatalog"
- title="Catalog"
- description="Objects that support indexed searching"
- />
-
<!-- Allow a catalog to be added to content space -->
<addMenuItem
title="Catalog"
Modified: Zope3/trunk/src/zope/app/catalog/catalog.py
===================================================================
--- Zope3/trunk/src/zope/app/catalog/catalog.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/catalog/catalog.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,13 +15,13 @@
$Id$
"""
+import zope.index.interfaces
from zope.interface import implements
-from zope.app.container.btree import BTreeContainer
-import zope.index.interfaces
+from zope.annotation.interfaces import IAttributeAnnotatable
from zope.app import zapi
-from zope.app.annotation.interfaces import IAttributeAnnotatable
from zope.app.container.interfaces import IContainer
+from zope.app.container.btree import BTreeContainer
from zope.app.catalog.interfaces import ICatalog
from zope.app.intid.interfaces import IIntIds
from BTrees.IFBTree import weightedIntersection
Modified: Zope3/trunk/src/zope/app/catalog/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/catalog/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/catalog/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -41,7 +41,7 @@
<subscriber
handler=".catalog.reindexDocSubscriber"
- for="zope.app.event.objectevent.IObjectModifiedEvent"
+ for="zope.lifecycleevent.interfaces.IObjectModifiedEvent"
/>
<subscriber
Modified: Zope3/trunk/src/zope/app/catalog/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/catalog/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/catalog/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -28,6 +28,7 @@
from zope.app.testing import ztapi, setup, placelesssetup
from BTrees.IFBTree import IFSet
from zope.app.intid.interfaces import IIntIds
+from zope.app.component.hooks import setSite
from zope.index.interfaces import IInjection, IIndexSearch
from zope.app.catalog.interfaces import ICatalog
@@ -227,6 +228,7 @@
sm = self.root.getSiteManager()
self.utility = setup.addUtility(sm, '', IIntIds, IntIdsStub())
self.cat = setup.addUtility(sm, '', ICatalog, CatalogStub())
+ setSite(self.root)
def tearDown(self):
setup.placefulTearDown()
@@ -247,7 +249,7 @@
def test_reindexDocSubscriber(self):
from zope.app.catalog.catalog import reindexDocSubscriber
- from zope.app.event.objectevent import ObjectModifiedEvent
+ from zope.lifecycleevent import ObjectModifiedEvent
ob = Stub()
id = self.utility.register(ob)
Modified: Zope3/trunk/src/zope/app/component/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/component/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -69,7 +69,7 @@
>>> component.getNextSiteManager(object())
Traceback (most recent call last):
...
- ComponentLookupError: 'No more site managers have been found.'
+ ComponentLookupError: No more site managers have been found.
If you use the `queryNextSiteManager()` function, you can specify a `default`
return value:
@@ -94,7 +94,7 @@
... return "%s('%s')" %(self.__class__.__name__, self.id)
>>> gutil = MyUtility('global')
- >>> gsm.provideUtility(IMyUtility, gutil, 'myutil')
+ >>> gsm.registerUtility(gutil, IMyUtility, 'myutil')
>>> util1 = setup.addUtility(folder1_sm, 'myutil', IMyUtility,
... MyUtility('one'))
@@ -120,8 +120,8 @@
Traceback (most recent call last):
...
ComponentLookupError:
- "No more utilities for <InterfaceClass __builtin__.IMyUtility>,
- 'myutil' have been found."
+ No more utilities for <InterfaceClass __builtin__.IMyUtility>,
+ 'myutil' have been found.
or you can simply use the `queryNextUtility` and specify a default:
Modified: Zope3/trunk/src/zope/app/component/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/component/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,13 +17,7 @@
"""
__docformat__ = "reStructuredText"
import zope.component
-from zope.app import zapi
-# BBB: Will go away in 3.3.
-from zope.app.component.bbb import localservice
-import sys
-sys.modules['zope.app.component.localservice'] = localservice
-
_marker = object()
def getNextSiteManager(context):
@@ -41,14 +35,16 @@
If the site manager of the given context is the global site manager, then
`default` is returned.
"""
- sm = zapi.getSiteManager(context)
- if zope.component.site.IGlobalSiteManager.providedBy(sm):
+ sm = zope.component.getSiteManager(context)
+ if sm is zope.component.getGlobalSiteManager():
return default
- if sm.next is None:
- return zapi.getGlobalSiteManager()
- return sm.next
+ bases = sm.__bases__
+ if not bases:
+ return zope.component.getGlobalSiteManager()
+ return bases[0]
+
def getNextUtility(context, interface, name=''):
"""Get the next available utility.
Modified: Zope3/trunk/src/zope/app/component/adapter.py
===================================================================
--- Zope3/trunk/src/zope/app/component/adapter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/adapter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -11,200 +11,15 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Local/Persistent Adapter Registry
+"""DEPRECATED"""
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-import persistent
+import zope.deferredimport
-import zope.interface
-from zope.security.proxy import removeSecurityProxy
+zope.deferredimport.deprecated(
+ "Local registration is now much simpler. The old baroque APIs "
+ "will go away in Zope 3.5. See the new component-registration APIs "
+ "defined in zope.component, especially IComponentRegistry.",
+ LocalAdapterRegistry = 'zope.app.component.site:_LocalAdapterRegistry',
+ AdapterRegistration = 'zope.app.component.back35:AdapterRegistration2',
+ )
-from zope.app.component import registration
-from zope.app.component import interfaces
-
-
-class LocalSurrogate(zope.interface.adapter.Surrogate):
- """Local Surrogate
-
- Local surrogates are transient, rather than persistent. Their adapter
- data are stored in their registry objects.
- """
- def __init__(self, spec, registry):
- super(LocalSurrogate, self).__init__(spec, registry)
- self.registry = registry
- registry.baseFor(spec).subscribe(self)
-
- def clean(self):
- spec = self.spec()
- base = self.registry.baseFor(spec)
- ladapters = self.registry.adapters.get(spec)
- if ladapters:
- adapters = base.adapters.copy()
- adapters.update(ladapters)
- else:
- adapters = base.adapters
- self.adapters = adapters
- super(LocalSurrogate, self).clean()
-
-
-class LocalAdapterRegistry(zope.interface.adapter.AdapterRegistry,
- persistent.Persistent):
- """Local/persistent surrogate registry"""
- zope.interface.implements(interfaces.ILocalAdapterRegistry)
-
- _surrogateClass = LocalSurrogate
-
- # See interfaces.registration.ILocatedRegistry
- next = None
- subs = ()
-
- def __init__(self, base, next=None):
- # Base registry. This is always a global registry
- self.base = base
- # `adapters` is simple dict, since it is populated during every load
- self.adapters = {}
- self._registrations = ()
- super(LocalAdapterRegistry, self).__init__()
- self.setNext(next)
-
- def addSub(self, sub):
- """See interfaces.registration.ILocatedRegistry"""
- self.subs += (sub, )
-
- def removeSub(self, sub):
- """See interfaces.registration.ILocatedRegistry"""
- self.subs = tuple(
- [s for s in self.subs if s is not sub] )
-
- def setNext(self, next, base=None):
- """See interfaces.registration.ILocatedRegistry"""
- if base is not None:
- self.base = base
- if self.next is not None:
- self.next.removeSub(self)
- if next is not None:
- next.addSub(self)
- self.next = next
- self.adaptersChanged()
-
- def register(self, registration):
- """See zope.app.component.interfaces.registration.IRegistry"""
- self._registrations += (registration,)
- self.adaptersChanged()
-
- def unregister(self, registration):
- """See zope.app.component.interfaces.registration.IRegistry"""
- self._registrations = tuple([reg for reg in self._registrations
- if reg is not registration])
- self.adaptersChanged()
-
- def registered(self, registration):
- """See zope.app.component.interfaces.registration.IRegistry"""
- return registration in self._registrations
-
- def registrations(self):
- """See zope.app.component.interfaces.registration.IRegistry"""
- return self._registrations
-
- def __getstate__(self):
- state = persistent.Persistent.__getstate__(self).copy()
-
- for name in ('_default', '_null', 'adapter_hook',
- 'lookup', 'lookup1', 'queryAdapter', 'get',
- 'subscriptions', 'queryMultiAdapter', 'subscribers'
- ):
- del state[name]
- return state
-
- def __setstate__(self, state):
- persistent.Persistent.__setstate__(self, state)
- zope.interface.adapter.AdapterRegistry.__init__(self)
-
- def baseFor(self, spec):
- """Used by LocalSurrogate"""
- return self.base.get(spec)
-
- def _updateAdaptersFromRegistration(self, radapters, registration):
- """Only to be used by _updateAdaptersFromLocalData, but can be
- overridden to implement custom behavior."""
- key = (False, registration.with, registration.name,
- registration.provided)
- radapters[key] = removeSecurityProxy(registration.component)
-
- def _updateAdaptersFromLocalData(self, adapters):
- """Update all adapter surrogates locally."""
- for registration in self._registrations:
- required = registration.required
- if required is None:
- required = zope.interface.adapter.Default
- radapters = adapters.get(required)
- if not radapters:
- radapters = {}
- adapters[required] = radapters
-
- # Needs more thought:
- # We have to remove the proxy because we're
- # storing the value amd we can't store proxies.
- # (Why can't we?) we need to think more about
- # why/if this is truly safe
- self._updateAdaptersFromRegistration(radapters, registration)
-
-
- def adaptersChanged(self):
- """See interfaces.registration.ILocalAdapterRegistry"""
- adapters = {}
- if self.next is not None:
- for required, radapters in self.next.adapters.iteritems():
- adapters[required] = radapters.copy()
-
- self._updateAdaptersFromLocalData(adapters)
-
- if adapters != self.adapters:
- self.adapters = adapters
-
- # Throw away all of our surrogates, rather than dirtrying
- # them individually
- super(LocalAdapterRegistry, self).__init__()
-
- for sub in self.subs:
- sub.adaptersChanged()
-
- def baseChanged(self):
- """See interfaces.registration.ILocalAdapterRegistry"""
- super(LocalAdapterRegistry, self).__init__()
- for sub in self.subs:
- sub.baseChanged()
-
-
-class AdapterRegistration(registration.ComponentRegistration):
- """A simple implementation of the adapter registration interface."""
- zope.interface.implements(interfaces.IAdapterRegistration)
-
- def __init__(self, required, provided, factory,
- name='', permission=None, registry=None):
- if not isinstance(required, (tuple, list)):
- self.required = required
- self.with = ()
- else:
- self.required = required[0]
- self.with = tuple(required[1:])
- self.provided = provided
- self.name = name
- self.component = factory
- self.permission = permission
- self.registry = registry
-
- def getRegistry(self):
- return self.registry
-
- def __repr__(self):
- return ('<%s: ' %self.__class__.__name__ +
- 'required=%r, ' %self.required +
- 'with=' + `self.with` + ', ' +
- 'provided=%r, ' %self.provided +
- 'name=%r, ' %self.name +
- 'component=%r, ' %self.component +
- 'permission=%r' %self.permission +
- '>')
Deleted: Zope3/trunk/src/zope/app/component/adapterregistry.txt
===================================================================
--- Zope3/trunk/src/zope/app/component/adapterregistry.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/adapterregistry.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,213 +0,0 @@
-==========================
-The Local Adapter Registry
-==========================
-
-The local adapter registry, like its global parent at
-`zope.interface.adapter`, is responsible for managing registered
-adapters. However, local adapter registries must always be instantiated by
-providing their base (or global registry), which will always be a global
-adapter registry isntance:
-
- >>> import zope.interface
- >>> gar = zope.interface.adapter.AdapterRegistry()
-
- >>> from zope.app.component import adapter
- >>> lar = adapter.LocalAdapterRegistry(gar)
- >>> lar.base is gar
- True
-
-The local adapter registry uses the registration framework (introduced in
-`registration.txt`) to manage the adapter registrations. To demonstrate we
-need to create an adapter first. Let's say we have a file
-
- >>> class IFile(zope.interface.Interface):
- ... content = zope.interface.Attribute('File Content')
-
-and we want to know the size of the file, which can be gotten by having a
-component providing the `ISized` interface:
-
- >>> class ISized(zope.interface.Interface):
- ... def getSize():
- ... """Return the size of the component."""
-
- >>> FileSize = '<FileSize>'
-
-As you can see, the adapter itself has no meaning in the adapter registry,
-which is merely responsible for looking up the component, but asserts no
-interpretation. Thus the adapter component can be any Python object.
-
-Instead of registering the adapter with the registry directly, we use an
-adapter registration to register the adapter with the local adapter registry:
-
- >>> reg = adapter.AdapterRegistration(
- ... required = (IFile,),
- ... provided = ISized,
- ... factory = FileSize,
- ... registry = lar)
- >>> reg.status
- u'Inactive'
-
-The adapter registration is an extended `ComponentRegistration`. Here the
-factory is the component. We can register the registration with the adapter
-registry using
-
- >>> lar.register(reg)
-
-Note that the registration's status is automatically set to active, when you
-register a registration:
-
- >>> reg.status
- u'Active'
-
-What really happens behind the scene is that the registry keeps track of a
-list of registrations and the registration's status property calls the
-registry's `registered()` method to determine whether the registration is
-activated.
-
- >>> lar.registered(reg)
- True
-
-You can also ask the registry for all of its registrations:
-
- >>> lar.registrations() #doctest: +NORMALIZE_WHITESPACE
- (<AdapterRegistration:
- required=<InterfaceClass __builtin__.IFile>,
- with=(),
- provided=<InterfaceClass __builtin__.ISized>,
- name='',
- component='<FileSize>',
- permission=None>,)
-
-Later you can unregister the adapter registration:
-
- >>> lar.unregister(reg)
- >>> lar.registered(reg)
- False
- >>> lar.registrations()
- ()
- >>> reg.status
- u'Inactive'
-
-Of course, the same can be achieved by setting the registration's status:
-
- >>> from zope.app.component import interfaces
- >>> reg.status = interfaces.registration.ActiveStatus
- >>> lar.registered(reg)
- True
-
- >>> reg.status = interfaces.registration.InactiveStatus
- >>> lar.registered(reg)
- False
-
-But the true flexibility of the local adapter registry is that it can be
-located in an adapter registry tree. Each node of the tree is a location and
-can override existing and register new adapters. The parent of a node can be
-accessed using
-
- >>> lar.next is None
- True
-
-In our case there is no nect registry, since the `lar` instance is the root
-node. The base registry, which is always a global one, can be accessed using
-
- >>> lar.base is gar
- True
-
-The node also knows about its children via
-
- >>> lar.subs
- ()
-
-Thus this is a double-linked tree. If I now create a second local adapter
-registry in which `lar` is the parent
-
- >>> lar2 = adapter.LocalAdapterRegistry(gar, lar)
-
-then we have
-
- >>> lar2.next is lar
- True
- >>> lar.subs == (lar2,)
- True
- >>> lar2.base is lar.base is gar
- True
-
-Let's now register our adapter with `lar` again:
-
- >>> reg.status = interfaces.registration.ActiveStatus
-
-On the second level, however, the size should be a word count instead of a
-character count:
-
- >>> FileWordCount = '<FileWordCount>'
-
-
- >>> reg2 = adapter.AdapterRegistration(
- ... required = (IFile,),
- ... provided = ISized,
- ... factory = FileWordCount,
- ... registry = lar2)
- >>> reg2.status = interfaces.registration.ActiveStatus
-
-If we now lookup the adapter in `lar`, we get the original `ISized` adapter:
-
- >>> lar.lookup((IFile,), ISized)
- '<FileSize>'
-
-but from the second registry we get
-
- >>> lar2.lookup((IFile,), ISized)
- '<FileWordCount>'
-
-If we now unregister the word counting size adapter
-
- >>> reg2.status = interfaces.registration.InactiveStatus
-
-then `lar2` will get the adapter from its parent:
-
- >>> lar2.lookup((IFile,), ISized)
- '<FileSize>'
-
-We can also change the location of a local adapter registry using
-
- >>> lar2.setNext(None)
- >>> lar2.next
- >>> lar.subs
- ()
-
-In this case we made `lar2` a root node itself. Clearly, now the `FileSize`
-adapter should not be available anymore:
-
- >>> lar2.lookup((IFile,), ISized)
-
-Now we make `lar` a sub registry of `lar2`:
-
- >>> lar.setNext(lar2)
- >>> lar.next is lar2
- True
- >>> lar2.subs == (lar,)
- True
-
-Note that you should never set the next attribute directly, but always use the
-`setNext()` method, since it ensures the integrety of all the links in the
-tree and updates the adapter lookup caches.
-
-The global adapter registry is taken into account during the lookup too, of
-course. Let's say we want to have an adapter that determines the type of the
-file and register it globally:
-
- >>> class IFileType(zope.interface.Interface):
- ... def getType():
- ... """Return the type of the file."""
-
- >>> FileType = '<FileType>'
-
- >>> gar.register((IFile,), IFileType, '', FileType)
-
-Then this adapter will be available in any local adapter registry:
-
- >>> lar.lookup((IFile,), IFileType, '')
- '<FileType>'
- >>> lar2.lookup((IFile,), IFileType, '')
- '<FileType>'
-
Copied: Zope3/trunk/src/zope/app/component/back35.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/component/back35.py)
Modified: Zope3/trunk/src/zope/app/component/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,26 +15,23 @@
$Id$
"""
-from zope.component.interfaces import ISiteManager
+import zope.component
+from zope.exceptions.interfaces import UserError
from zope.security.proxy import removeSecurityProxy
-from zope.app import zapi
-from zope.app.container.browser.adding import Adding
-from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.container.interfaces import INameChooser
-from zope.app.component.interfaces.registration import ActiveStatus
-from zope.app.component.interfaces.registration import InactiveStatus
-from zope.app.component.interfaces import ILocalUtility
-from zope.app.publisher.browser import BrowserView
-from zope.app.component.interfaces import ISite
-from zope.app.component.site import LocalSiteManager
-from zope.component.exceptions import ComponentLookupError
+from zope.publisher.browser import BrowserView
+from zope.component.interfaces import ComponentLookupError
from zope.component.interfaces import IFactory
+from zope.component.interface import getInterface, provideInterface
+from zope.component.interface import searchInterface
from zope.interface.interfaces import IMethod
from zope.schema.interfaces import IField
+
+from zope.app.i18n import ZopeMessageFactory as _
+from zope.app.container.interfaces import INameChooser
+from zope.app.container.browser.adding import Adding
from zope.app.interface.interfaces import IInterfaceBasedRegistry
-from zope.app.component.interface import searchInterface
-from zope.app.component.interface import getInterface
-from zope.app.component.interface import provideInterface
+from zope.app.component.site import LocalSiteManager
+from zope.app.component.interfaces import ISite
class ComponentAdding(Adding):
"""Adding subclass used for registerable components."""
@@ -47,10 +44,10 @@
return self.added_object
def nextURL(self):
- v = zapi.queryMultiAdapter(
+ v = zope.component.queryMultiAdapter(
(self.added_object, self.request), name="registration.html")
if v is not None:
- url = str(zapi.getMultiAdapter(
+ url = str(zope.component.getMultiAdapter(
(self.added_object, self.request), name='absolute_url'))
return url + "/@@registration.html"
@@ -85,7 +82,7 @@
if extra:
factoryname = extra.get('factory')
if factoryname:
- factory = zapi.getUtility(IFactory, factoryname)
+ factory = zope.component.getUtility(IFactory, factoryname)
intf = factory.getInterfaces()
if not intf.extends(self._addFilterInterface):
# We only skip new addMenuItem style objects
@@ -103,19 +100,11 @@
menu_id = None
title = _("Add Utility")
- _addFilterInterface = ILocalUtility
-
- def add(self, content):
- # Override so as to check the type of the new object.
- if not ILocalUtility.providedBy(content):
- raise TypeError("%s is not a local utility" % content)
- return super(UtilityAdding, self).add(content)
-
def nextURL(self):
- v = zapi.queryMultiAdapter(
+ v = zope.component.queryMultiAdapter(
(self.added_object, self.request), name="addRegistration.html")
if v is not None:
- url = zapi.absoluteURL(self.added_object, self.request)
+ url = zope.component.absoluteURL(self.added_object, self.request)
return url + "/addRegistration.html"
return super(UtilityAdding, self).nextURL()
@@ -127,7 +116,7 @@
def addSiteManager(self):
"""Convert a possible site to a site
- >>> from zope.app.traversing.interfaces import IContainmentRoot
+ >>> from zope.traversing.interfaces import IContainmentRoot
>>> from zope.interface import implements
>>> class PossibleSite(object):
@@ -168,7 +157,7 @@
"""
if ISite.providedBy(self.context):
- raise zapi.UserError('This is already a site')
+ raise UserError('This is already a site')
# We don't want to store security proxies (we can't,
# actually), so we have to remove proxies here before passing
Modified: Zope3/trunk/src/zope/app/component/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,115 +1,50 @@
-<zope:configure
- xmlns:zope="http://namespaces.zope.org/zope"
- xmlns="http://namespaces.zope.org/browser">
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ >
- <zope:interface
- interface="zope.app.component.browser.tools.IToolType" />
+ <browser:addMenuItem
+ class=".tests.Sample"
+ permission="zope.ManageSite"
+ title="Sample"
+ />
<!-- Registration Managemenet -->
- <!-- BBB: Gone with 3.3 -->
- <!--
- <zope:view
- for="zope.app.component.interfaces.registration.IComponentPath"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- provides="zope.app.form.interfaces.IInputWidget"
- factory=".registration.ComponentPathWidget"
- permission="zope.Public"
- />
-
- <zope:view
- for="zope.app.component.interfaces.registration.IComponentPath"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- provides="zope.app.form.interfaces.IDisplayWidget"
- factory=".registration.ComponentPathWidget"
- permission="zope.Public"
- />
- -->
- <!-- BBB: End of backward-compatibility block -->
-
- <zope:view
- for="zope.app.component.interfaces.registration.IComponent"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- provides="zope.app.form.interfaces.IInputWidget"
- factory=".registration.ComponentWidget"
- permission="zope.Public"
- />
-
- <zope:view
- for="zope.app.component.interfaces.registration.IComponent"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- provides="zope.app.form.interfaces.IDisplayWidget"
- factory=".registration.ComponentWidget"
- permission="zope.Public"
- />
-
- <page
- name="index.html"
- for="zope.app.component.interfaces.registration.IRegistrationManager"
+ <browser:page
+ for="*"
+ name="registration.html"
menu="zmi_views" title="Registration"
permission="zope.ManageSite"
- class=".registration.EditRegistration"
- template="editregistration.pt" />
-
- <!-- For now, we'll allow CMs to be added -->
-
- <view
- for="zope.app.component.interfaces.registration.IRegistrationManager"
- name="+"
- menu="zmi_actions" title="Add"
- permission="zope.ManageSite"
- class=".registration.RegistrationAdding"
- >
- <page name="index.html" attribute="index" />
- <page name="action.html" attribute="action" />
- </view>
-
- <!-- Generic page for objects that keep track of their registrations.
- Objects that need to override one of these may need to override
- both. The "registrations.html" page is only used for objects
- that have more than one registration. -->
-
- <page
- for="zope.app.component.interfaces.registration.IRegisterable"
- name="registrations.html"
- template="registered.pt"
- class=".registration.Registered"
- permission="zope.ManageSite"
- />
-
- <page
- for="zope.app.component.interfaces.registration.IRegisterable"
- name="registration.html"
- template="registration.pt"
class=".registration.RegistrationView"
- permission="zope.ManageSite"
- menu="zmi_views" title="Registration"
/>
- <menuItem
- menu="zmi_actions"
- for="zope.app.component.interfaces.registration.IRegisterableContainer"
- title="Registrations"
- action="++registrations++/@@SelectedManagementView.html"
+ <browser:page
+ for="*"
+ name="addRegistration.html"
permission="zope.ManageSite"
+ class=".registration.AddUtilityRegistration"
/>
+ <adapter factory=".registration.UtilityRegistrationDisplay" />
+ <adapter factory=".registration.UtilitySiteRegistrationDisplay" />
+
<!-- Site Management Folder -->
- <addMenuItem
+ <browser:addMenuItem
class="zope.app.component.site.SiteManagementFolder"
permission="zope.ManageSite"
title="Site-Management Folder"
/>
- <page
+ <browser:page
for="zope.app.component.interfaces.ISiteManagementFolder"
permission="zope.ManageSite"
class="zope.app.container.browser.contents.JustContents"
name="index.html" attribute="index"
/>
- <page
+ <browser:page
name="contents.html"
for="zope.app.component.interfaces.ISiteManagementFolder"
menu="zmi_views" title="Contents"
@@ -118,20 +53,20 @@
attribute="contents"
/>
- <view
+ <browser:view
name="+"
menu="zmi_actions" title="Add"
for="zope.app.component.interfaces.ISiteManagementFolder"
permission="zope.ManageSite"
class="zope.app.component.browser.ComponentAdding"
>
- <page name="index.html" attribute="index" />
- <page name="action.html" attribute="action" />
- </view>
+ <browser:page name="index.html" attribute="index" />
+ <browser:page name="action.html" attribute="action" />
+ </browser:view>
<!-- Site Manager navigation action -->
- <page
+ <browser:page
for="zope.app.component.interfaces.IPossibleSite"
name="addSiteManager.html"
permission="zope.ManageSite"
@@ -139,16 +74,16 @@
attribute="addSiteManager"
/>
- <menuItem
+ <browser:menuItem
menu="zmi_actions" title="Make a site"
for="zope.app.component.interfaces.IPossibleSite"
action="addSiteManager.html"
filter="python:
- not modules['zope.app.component.interfaces'].ISite.providedBy(context)"
+ not modules['zope.app.component.interfaces'].ISite.providedBy(context)"
permission="zope.ManageSite"
/>
- <menuItem
+ <browser:menuItem
menu="zmi_actions"
title="Manage Site"
for="zope.app.component.interfaces.ISite"
@@ -158,127 +93,47 @@
<!-- SiteManager -->
- <menuItems
- menu="zmi_actions"
- for="zope.app.component.interfaces.ILocalSiteManager">
-
- <menuItem
- title="Visit default folder"
- action="default/@@SelectedManagementView.html"
- permission="zope.ManageSite"
- />
- </menuItems>
-
- <page
+ <browser:page
name="contents.html"
for="zope.app.component.interfaces.ILocalSiteManager"
- menu="zmi_views" title="Software"
+ menu="zmi_views" title="Contents"
permission="zope.ManageSite"
class="zope.app.container.browser.contents.Contents"
attribute="contents" />
- <view
+ <browser:view
name="+"
menu="zmi_actions" title="Add Site Management Folder"
for="zope.app.component.interfaces.ILocalSiteManager"
permission="zope.ManageSite"
class="zope.app.container.browser.adding.Adding"
>
- <page name="index.html" attribute="index"/>
- <page name="action.html" attribute="action"/>
- </view>
+ <browser:page name="index.html" attribute="index"/>
+ <browser:page name="action.html" attribute="action"/>
+ </browser:view>
- <pages
+ <browser:pages
for="zope.app.component.interfaces.ILocalSiteManager"
permission="zope.ManageSite"
class="zope.app.container.browser.contents.JustContents"
>
- <page name="index.html" attribute="index" />
- </pages>
+ <browser:page name="index.html" attribute="index" />
+ </browser:pages>
- <view
- name="SiteManagement"
+ <browser:page
for="zope.app.component.interfaces.ILocalSiteManager"
- menu="zmi_views" title="Site Management"
- class=".tools.SiteManagementView"
+ name="registrations.html"
+ menu="zmi_views" title="Registrations"
permission="zope.ManageSite"
- >
- <page name="index.html" template="site_management.pt" />
- </view>
+ class=".registration.SiteRegistrationView"
+ />
-
-<!-- Utility Registration -->
-
- <!-- When creating a new utility object, you are taken to this
- form to configure it. The form lets you choose a name,
- an interface, a permission, and a registration status
- (Inactive or Active). -->
- <addform
- label="New Utility Registration"
- for="zope.app.component.interfaces.ILocalUtility"
- name="addRegistration.html"
- schema="zope.app.component.interfaces.IUtilityRegistration"
- class=".registration.AddComponentRegistration"
+ <browser:menuItem
+ menu="zmi_views" title="Registration"
+ for="zope.app.component.interfaces.ILocalSiteManager"
+ action="registration.html"
+ filter="python:False"
permission="zope.ManageSite"
- content_factory="zope.app.component.site.UtilityRegistration"
- arguments="name provided component"
- fields="name provided component status permission"
- >
- <widget
- field="name"
- class="zope.app.form.browser.TextWidget"
- required="False"
- convert_missing_value="False"
- />
- </addform>
-
- <!-- When editing the registration of an existing utility object,
- you are taken to this form. It is similar to the above add
- form, but doesn't let you change the name, interface or path.
- (Thus leaving only permission and registration status.) -->
- <editform
- menu="zmi_views" title="Edit"
- label="Edit Utility Registration"
- name="index.html"
- schema="zope.app.component.interfaces.IUtilityRegistration"
- permission="zope.ManageSite"
- fields="name provided component status permission" />
-
- <page
- for="..interfaces.IUtilityRegistration"
- name="details"
- template="utilreg_details.pt"
- class=".site.UtilityRegistrationDetails"
- permission="zope.Public"
/>
-
-<!-- Adapter Registration -->
-
- <!-- addform
- label="New Adapter Registration"
- schema="zope.app.component.interfaces.IAdapterRegistration"
- name="addRegistration.html"
- content_factory="zope.app.component.site.AdapterRegistration"
- arguments="required provided factoryName"
- keyword_arguments="name permission"
- permission="zope.ManageServices"
- fields="required provided name permission factoryName"
- /-->
-
- <!-- addMenuItem
- view="addAdapterRegistration.html"
- class="zope.app.component.site.AdapterRegistration"
- permission="zope.ManageSite"
- title="Adapter Registration"
- /-->
-
- <editform
- schema="..interfaces.IAdapterRegistration"
- name="index.html"
- menu="zmi_views"
- label="Change adapter"
- permission="zope.ManageSite"
- />
-
-</zope:configure>
+</configure>
Deleted: Zope3/trunk/src/zope/app/component/browser/editregistration.pt
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/editregistration.pt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/editregistration.pt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,57 +0,0 @@
-<html metal:use-macro="context/@@standard_macros/view"
- i18n:domain="zope">
-<head>
- <title metal:fill-slot="title" i18n:translate="">
- Registration Manager
- </title>
-</head>
-<body>
-<div metal:fill-slot="body">
-
- <h2 i18n:translate="">Registration Manager</h2>
-
- <form action="." method="POST"
- tal:define="message view/update"
- tal:attributes="action request/URL">
-
- <p tal:condition="message" tal:content="message" />
-
- <table>
- <thead>
- <tr>
- <th></th>
- <th align="left" i18n:translate="">Summary</th>
- </tr>
- </thead>
- <tbody>
- <tr tal:repeat="reg view/registrationInfo">
- <td valign="top">
- <input type="checkbox" name="keys:list" value="1"
- tal:attributes="value reg/name" />
- </td>
- <td>
- <a href="." tal:attributes="href reg/name" i18n:translate="">
- Config item <span tal:content="reg/name" i18n:name="name"/>
- </a>
- <span tal:condition="not:reg/active"
- i18n:translate="">(disabled)</span>
- <br />
- <span tal:content="structure reg/details">
- Registration Details
- </span>
- </td>
- </tr>
- </tbody>
- </table>
-
- <div class="row">
- <input type="submit" name="refresh_submit" value="Refresh"
- i18n:attributes="value refresh-button" />
- <input type="submit" name="remove_submit" value="Remove"
- i18n:attributes="value remove-button" />
- </div>
- </form>
-
-</div>
-</body>
-</html>
Deleted: Zope3/trunk/src/zope/app/component/browser/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/ftests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/ftests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,39 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Functional tests
-
-$Id$
-"""
-import unittest
-from zope.app.testing import functional
-
-
-class RegistrationViewTests(functional.BrowserTestCase):
-
- def testRegistrationView(self):
- response = self.publish(
- '/++etc++site/default/++registrations++/@@index.html',
- basic='mgr:mgrpw',
- handle_errors=True)
- self.assertEqual(response.getStatus(), 200)
- body = response.getBody()
- self.assert_('Registration Manager' in body)
-
-
-def test_suite():
- return unittest.makeSuite(RegistrationViewTests)
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Modified: Zope3/trunk/src/zope/app/component/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,17 +15,12 @@
$Id$
"""
-from zope.app.component.metaconfigure import utility
-from zope.app.component.metaconfigure import interface as ifaceDirective
-from tools import IToolType, IToolConfiguration, ToolConfiguration
+import warnings
+
def tool(_context, interface, title, description=None,
folder="tools", unique=False):
- name = interface.getName()
- permission = 'zope.ManageContent'
- tool = ToolConfiguration(interface, title, description, unique)
-
- ifaceDirective(_context, interface, IToolType)
- utility(_context, IToolConfiguration, tool,
- permission=permission, name=name)
+ warnings.warn("Tools are deprecated and no-longer used. "
+ "The tool directive will go away in Zope 3.5",
+ DeprecationWarning)
Deleted: Zope3/trunk/src/zope/app/component/browser/registered.pt
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/registered.pt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/registered.pt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,25 +0,0 @@
-<html metal:use-macro="context/@@standard_macros/view"
- i18n:domain="zope">
-<body>
-<div metal:fill-slot="body">
-
- <p i18n:translate="">Registrations for this object:</p>
-
- <ul>
- <li tal:repeat="reg view/registrations">
-
- <a href=""
- tal:attributes="href reg/url"
- tal:content="reg/name">Name</a>
- (<span tal:replace="reg/status">Active</span>)
- <span tal:replace="structure reg/details" />
- </li>
- </ul>
-
- <p><a href="addRegistration.html" i18n:translate="">
- Add a registration for this object
- </a></p>
-
-</div>
-</body>
-</html>
Modified: Zope3/trunk/src/zope/app/component/browser/registration.pt
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/registration.pt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/registration.pt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -2,53 +2,48 @@
i18n:domain="zope">
<body>
<div metal:fill-slot="body">
+<form tal:attributes="action request/URL"
+ method="POST"
+ >
-<form tal:attributes="action request/URL" method="POST"
- tal:define="ignored view/update">
-
- <div tal:condition="view/registered">
- <div tal:define="registration view/registration">
- <p i18n:translate="">This object is registered as:</p>
-
- <div class="registrationSummary">
- <div tal:content="structure registration/details">
- Details
- </div>
- <div class="modificationLink">
- <a tal:attributes="href registration/url"
- i18n:translate="">(modify)</a>
- </div>
- </div>
-
- <tal:block condition="view/active">
- <p i18n:translate="">This object is currently active.</p>
- <input type="submit" i18n:attributes="value deactivate-button"
- value="Deactivate" name="deactivate" />
- </tal:block>
- <tal:block condition="not:view/active">
- <p i18n:translate="">This object is currently inactive.</p>
- <input type="submit" i18n:attributes="value activate-button"
- value="Activate" name="activate" />
- </tal:block>
- </div>
-
- <hr />
- <a href="registrations.html" i18n:translate="">
- Advanced Options
- </a>
-
+ <div tal:condition="not:view/registrations">
+ <p i18n:translate="">
+ This object isn't yet registered. Click
+ <a href="@@addRegistration.html">here</a>
+ to register the object.
+ </p>
</div>
-
- <div tal:condition="not:view/registered">
- <p i18n:translate="">This object is not currently active.</p>
-
+ <div tal:condition="view/registrations">
<p i18n:translate="">
- This object won't actually be used unless it is registered to
- perform a specific function and is activated.
+ This object is registered:
</p>
-
- <input type="submit" value="Register" name="activate"
- i18n:attributes="value register-button" />
+ <table>
+ <tr tal:repeat="registration view/registrations">
+ <td>
+ <input type="checkbox"
+ class="noborder" name="ids:list"
+ tal:attributes="value registration/id;
+ id registration/id;
+ "
+ />
+ </td>
+ <td tal:content="structure registration/render">
+ zope.app.fooIFoo utility named bob
+ comment: needed a bob
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ <input type="submit" value="Unregister" name="deactivate"
+ i18n:attributes="value unregister-button" />
+ </td>
+ </tr>
+ </table>
+ <p>
+ Click <a href="@@addRegistration.html">here</a>
+ to register the object again.
+ </p>
</div>
</form>
Modified: Zope3/trunk/src/zope/app/component/browser/registration.py
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/registration.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/registration.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,262 +17,251 @@
"""
import warnings
+from zope import interface, component, deprecation, schema
+from zope.formlib import form
+from zope.publisher.browser import BrowserPage
from zope.security.proxy import removeSecurityProxy
+import zope.component.interfaces
+import zope.publisher.interfaces.browser
+import zope.app.pagetemplate
+import zope.app.form
from zope.app import zapi
-from zope.app.container.browser.adding import Adding
-from zope.app.container.interfaces import INameChooser
-from zope.app.form.browser.widget import SimpleInputWidget
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.publisher.browser import BrowserView
-from zope.app.component import interfaces
-from zope.app.component.interfaces.registration import ActiveStatus
-from zope.app.component.interfaces.registration import InactiveStatus
-class RegistrationView(BrowserView):
- """View for registerable objects that have at most one registration.
+def _registrations(context, comp):
+ sm = component.getSiteManager(context)
+ for r in sm.registeredUtilities():
+ if r.component == comp or comp is None:
+ yield r
+ for r in sm.registeredAdapters():
+ if r.factory == comp or comp is None:
+ yield r
+ for r in sm.registeredSubscriptionAdapters():
+ if r.factory == comp or comp is None:
+ yield r
+ for r in sm.registeredHandlers():
+ if r.factory == comp or comp is None:
+ yield r
- If the object has more than one registration, this performs a
- redirection to the 'registrations.html' view.
+class IRegistrationDisplay(interface.Interface):
+ """Display registration information
"""
- def __init__(self, context, request):
- super(RegistrationView, self).__init__(context, request)
- useconfig = interfaces.registration.IRegistered(self.context)
- self.registrations = useconfig.registrations()
- def update(self):
- """Make changes based on the form submission."""
- if len(self.registrations) > 1:
- self.request.response.redirect("registrations.html")
- return
- if "deactivate" in self.request:
- self.registrations[0].status = InactiveStatus
- elif "activate" in self.request:
- if not self.registrations:
- # create a registration:
- self.request.response.redirect("addRegistration.html")
- return
- self.registrations[0].status = ActiveStatus
+ def id():
+ """Return an identifier suitable for use in mapping
+ """
- def active(self):
- return self.registrations[0].status == ActiveStatus
+ def render():
+ "Return an HTML view of a registration object"
- def registered(self):
- return bool(self.registrations)
+ def unregister():
+ "Remove the registration by unregistering the component"
- def registration(self):
- """Return the first registration.
+class ISiteRegistrationDisplay(IRegistrationDisplay):
+ """Display registration information, including the component registered
+ """
+
+class RegistrationView(BrowserPage):
- If there are no registrations, raises an error.
- """
- return {'url': zapi.absoluteURL(self.registrations[0], self.request),
- 'details': zapi.queryMultiAdapter(
- (self.registrations[0], self.request), name='details')
- }
+ component.adapts(None, zope.publisher.interfaces.browser.IBrowserRequest)
+ render = zope.app.pagetemplate.ViewPageTemplateFile('registration.pt')
-class Registered(object):
- """View for registerable objects with more than one registration."""
-
def registrations(self):
- registered = interfaces.registration.IRegistered(self.context)
- return [
- {'name': zapi.name(reg),
- 'url': zapi.absoluteURL(reg, self.request),
- 'status': reg.status,
- 'details': zapi.queryMultiAdapter((reg, self.request),
- name='details')}
- for reg in registered.registrations()]
+ registrations = [
+ component.getMultiAdapter((r, self.request), IRegistrationDisplay)
+ for r in sorted(_registrations(self.context, self.context))
+ ]
+ return registrations
+ def update(self):
+ registrations = dict([(r.id(), r) for r in self.registrations()])
+ for id in self.request.form.get('ids', ()):
+ r = registrations.get(id)
+ if r is not None:
+ r.unregister()
-#############################################################################
-# BBB: Only for backward compatibility. 12/07/2004
-class ComponentPathWidget(SimpleInputWidget):
- """Widget for displaying component paths
-
- The widget doesn't actually allow editing. Rather it gets the
- value by inspecting its field's context. If the context is an
- IComponentRegistration, then it just gets its value from the
- component using the field's name. Otherwise, it uses the path to
- the context.
- """
-
- def __init__(self, *args, **kw):
- warnings.warn(
- "Use of `ComponentPathWidget` deprecated, since the "
- "registration code now uses the component directly instead "
- "of using the component's path.",
- DeprecationWarning, stacklevel=2,
- )
- super(ComponentPathWidget, self).__init__(*args, **kw)
-
def __call__(self):
- """See zope.app.browser.interfaces.form.IBrowserWidget"""
- # Render as a link to the component
- field = self.context
- context = field.context
- if interfaces.registration.IRegistration.providedBy(context):
- # It's a registration object. Just get the corresponding attr
- path = getattr(context, field.__name__)
- # The path may be relative; then interpret relative to ../..
- if not path.startswith("/"):
- context = zapi.traverse(context, "../..")
- component = zapi.traverse(context, path)
- else:
- # It must be a component that is about to be configured.
- component = context
- # Always use a relative path (just the component name)
- path = zapi.name(context)
+ self.update()
+ return self.render()
- url = zapi.absoluteURL(component, self.request)
+class UtilityRegistrationDisplay(object):
+ """Utility Registration Details"""
- return ('<a href="%s/@@SelectedManagementView.html">%s</a>'
- % (url, path))
+ component.adapts(zope.component.interfaces.IUtilityRegistration,
+ zope.publisher.interfaces.browser.IBrowserRequest)
+ interface.implements(IRegistrationDisplay)
- def hidden(self):
- """See zope.app.browser.interfaces.form.IBrowserWidget"""
- return ''
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
- def hasInput(self):
- """See zope.app.form.interfaces.IWidget"""
- return 1
+ def provided(self):
+ provided = self.context.provided
+ return provided.__module__ + '.' + provided.__name__
- def getInputValue(self):
- """See zope.app.form.interfaces.IWidget"""
- field = self.context
- context = field.context
- if interfaces.registration.IRegistration.providedBy(context):
- # It's a registration object. Just get the corresponding attr
- path = getattr(context, field.getName())
- else:
- # It must be a component that is about to be configured.
- # Always return a relative path (just the component name)
- path = zapi.name(context)
+ def id(self):
+ return 'R' + (("%s %s" % (self.provided(), self.context.name))
+ .encode('utf8')
+ .encode('base64')
+ .replace('+', '_')
+ .replace('=', '')
+ .replace('\n', '')
+ )
- return path
-#############################################################################
+ def _comment(self):
+ comment = self.context.info or ''
+ if comment:
+ comment = '<br />comment: ' + comment
+ return comment
+ def render(self):
+ name = self.context.name
+ return "%s utility%s%s" % (
+ self.provided(),
+ name and (' named ' + name) or '',
+ self._comment(),
+ )
-class ComponentWidget(SimpleInputWidget):
- """Widget for displaying/entering component paths that point to components.
+ def unregister(self):
+ self.context.registry.unregisterUtility(
+ self.context.component,
+ self.context.provided,
+ self.context.name,
+ )
+
+class SiteRegistrationView(RegistrationView):
- The widget doesn't actually allow editing. Rather it gets the
- value by inspecting its field's context. If the context is an
- IComponentRegistration, then it just gets its value from the
- component using the field's name. Otherwise, it uses the path to
- the context.
- """
+ render = zope.app.pagetemplate.ViewPageTemplateFile('siteregistration.pt')
- def __call__(self):
- """See zope.app.browser.interfaces.form.IBrowserWidget"""
- # Render as a link to the component
- field = self.context
- context = field.context
- if interfaces.registration.IRegistration.providedBy(context):
- # It's a registration object. Just get the corresponding attr
- component = getattr(context, field.__name__)
- path = zapi.getPath(component)
- else:
- # It must be a component that is about to be configured.
- component = context
- # Always use a relative path (just the component name)
- path = zapi.name(context)
+ def registrations(self):
+ registrations = [
+ component.getMultiAdapter((r, self.request),
+ ISiteRegistrationDisplay)
+ for r in sorted(_registrations(self.context, None))
+ ]
+ return registrations
- url = zapi.absoluteURL(component, self.request)
+class UtilitySiteRegistrationDisplay(UtilityRegistrationDisplay):
+ """Utility Registration Details"""
- return ('<a href="%s/@@SelectedManagementView.html">%s</a>'
- % (url, path))
+ interface.implementsOnly(ISiteRegistrationDisplay)
- def hidden(self):
- """See zope.app.browser.interfaces.form.IBrowserWidget"""
- return ''
+ def render(self):
+ url = component.getMultiAdapter(
+ (self.context.component, self.request), name='absolute_url')
+ try:
+ url = url()
+ except TypeError:
+ url = None
- def hasInput(self):
- """See zope.app.form.interfaces.IWidget"""
- return 1
+ cname = getattr(self.context.component, '__name__', '(unknown name)')
+ if cname is None:
+ cname = ''
+ if url:
+ cname = '<a href="%s/@@SelectedManagementView.html">%s</a>' % (
+ url, cname)
+ else:
+ cname = '%s (moved or deleted)' % cname
- def getInputValue(self):
- """See zope.app.form.interfaces.IWidget"""
- field = self.context
- context = field.context
- if interfaces.registration.IRegistration.providedBy(context):
- # It's a registration object. Just get the corresponding attr
- return getattr(context, field.getName())
+ name = self.context.name
+ comment = self.context.info
+
+ return ('%s<br />%s utility%s%s'
+ % (cname,
+ self.provided(),
+ name and (' named ' + name) or '',
+ self._comment(),
+ )
+ )
- # It must be a component that is about to be configured.
- return context
+class AddUtilityRegistration(form.Form):
+ """View for registering utilities
+ Normally, the provided interface and name are input.
-class AddComponentRegistration(BrowserView):
- """View for adding component registrations
+ A subclass can provide an empty 'name' attribute if the component should
+ always be registered without a name.
- This class is used to define registration add forms. It provides
- the ``add`` and ``nextURL`` methods needed when creating add forms
- for non-IAdding objects. We need this here because registration
- add forms are views of the component being configured.
+ A subclass can provide a 'provided' attribute if a component
+ should always be registered with the same interface.
+
"""
+ component.adapts(None, zope.publisher.interfaces.browser.IBrowserRequest)
- def add(self, registration):
- """Add a registration
+ form_fields = form.Fields(
+ schema.Choice(
+ __name__ = 'provided',
+ title=_("Provided interface"),
+ description=_("The interface provided by the utility"),
+ vocabulary="Utility Component Interfaces",
+ required=True,
+ ),
+ schema.TextLine(
+ __name__ = 'name',
+ title=_("Register As"),
+ description=_("The name under which the utility will be known."),
+ required=False,
+ default=u'',
+ missing_value=u''
+ ),
+ schema.Text(
+ __name__ = 'comment',
+ title=_("Comment"),
+ required=False,
+ default=u'',
+ missing_value=u''
+ ),
+ )
- We are going to add the registration to the local
- registration manager. We don't want to hard code the name of
- this, so we'll simply scan the containing folder and add the
- registration to the first registration manager we find.
- """
- component = self.context
+ name = provided = None
- # Get the registration manager for this folder
- rm = component.__parent__.registrationManager
- rm.addRegistration(registration)
- return registration
+ prefix = 'field' # in hopes of making old tests pass. :)
- def nextURL(self):
- return "@@SelectedManagementView.html"
+ def __init__(self, context, request):
+ if self.name is not None:
+ self.form_fields = self.form_fields.omit('name')
+ if self.provided is not None:
+ self.form_fields = self.form_fields.omit('provided')
+ super(AddUtilityRegistration, self).__init__(context, request)
-
-class RegistrationAdding(Adding):
- """Adding subclass for adding registrations."""
- menu_id = "add_registration"
-
- def nextURL(self):
- return zapi.absoluteURL(self.context, self.request)
-
-
-class EditRegistration(BrowserView):
- """A view on a registration manager, used by registrations.pt."""
-
def update(self):
- """Perform actions depending on user input."""
+ # hack to make work with old tests
+ if 'UPDATE_SUBMIT' in self.request.form:
+ warnings.warn(
+ "Old test needs to be updated.",
+ DeprecationWarning)
+ self.request.form['field.actions.register'] = 'Register'
+ self.request.form['field.comment'] = u''
+ super(AddUtilityRegistration, self).update()
- if 'keys' in self.request:
- k = self.request['keys']
- else:
- k = []
+ @property
+ def label(self):
+ return _("Register a $classname",
+ mapping=dict(classname=self.context.__class__.__name__)
+ )
- msg = 'You must select at least one item to use this action'
-
- if 'remove_submit' in self.request:
- if not k: return msg
- self.remove_objects(k)
- elif 'refresh_submit' in self.request:
- pass # Nothing to do
-
- return ''
-
- def remove_objects(self, key_list):
- """Unregister and remove the directives from the container."""
- container = self.context
- for name in key_list:
- container[name].status = InactiveStatus
- del container[name]
-
- def registrationInfo(self):
- """Render View for each directives."""
- return [
- {'name': name,
- 'url': zapi.absoluteURL(reg, self.request),
- 'active': reg.status == ActiveStatus,
- 'details': zapi.queryMultiAdapter((reg, self.request),
- name='details')}
- for name, reg in self.context.items()]
+ @form.action(_("Register"))
+ def register(self, action, data):
+ sm = component.getSiteManager(self.context)
+ name = self.name
+ if name is None:
+ name = data['name']
+ provided = self.provided
+ if provided is None:
+ provided = data['provided']
+
+
+ # We have to remove the security proxy to save the registration
+ sm.registerUtility(
+ removeSecurityProxy(self.context),
+ provided, name,
+ data['comment'] or '')
+
+ if 'UPDATE_SUBMIT' in self.request.form:
+ # Backward compat until 3.5
+ self.request.response.redirect('@@SelectedManagementView.html')
+ return
+
+ self.request.response.redirect('@@registration.html')
Copied: Zope3/trunk/src/zope/app/component/browser/registration.txt (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.txt)
Deleted: Zope3/trunk/src/zope/app/component/browser/site.py
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/site.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/site.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,39 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Site Management view code
-
-$Id$
-"""
-
-__docformat__ = "reStructuredText"
-
-from zope.app import zapi
-from zope.app.i18n import ZopeMessageFactory as _
-
-
-class UtilityRegistrationDetails(object):
- """Utility Registration Details"""
-
- def provided(self):
- provided = self.context.provided
- return provided.__module__ + '.' + provided.__name__
-
- def name(self):
- return self.context.name or _('<no name>')
-
- def component(self):
- url = zapi.getMultiAdapter(
- (self.context.component, self.request), name='absolute_url')
- name = zapi.name(self.context.component)
- return {'url': url, 'name': name}
Deleted: Zope3/trunk/src/zope/app/component/browser/site_management.pt
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/site_management.pt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/site_management.pt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,150 +0,0 @@
-<html metal:use-macro="context/@@standard_macros/page"
- i18n:domain="zope">
-<body>
-<div metal:fill-slot="body">
-
- <h1 i18n:translate="">
- <b>Site Management</b>
- </h1>
-
- <div class="message"
- tal:define="message view/update"
- tal:condition="message"
- tal:content="message" i18n:translate="">
- Status Message
- </div>
-
- <h2>
- <b i18n:translate="">Unique Utilities</b>
- </h2>
- <div i18n:translate="">
- Unique utilities can only exist once per site manager and have no name.
- </div>
- <br/>
- <form action="." method="post">
- <div tal:repeat="tool view/getUniqueTools">
- <input type="checkbox" name="selected:list" value=""
- tal:attributes="value tool/name" />
- <span
- tal:content="tool/title"
- tal:condition="not:tool/exists" i18n:translate="">
- Authentication
- </span>
- <a href="" style="color: green"
- tal:content="tool/title"
- tal:condition="tool/exists" i18n:translate="">
- Authentication
- </a>
- </div>
- <br/>
- <input type="submit" name="INSTALL-SUBMIT" value="Install"
- i18n:attributes="value INSTALL-SUBMIT">
- <input type="submit" name="UNINSTALL-SUBMIT" value="Uninstall"
- i18n:attributes="value UNINSTALL-SUBMIT">
- </form>
-
- <form action="." method="post"
- tal:repeat="tool view/getTools"
- tal:attributes="action string:#${tool/name}">
- <a name="" tal:attributes="name tool/name" />
- <input type="hidden" name="activeTool" value=""
- tal:attributes="value tool/name" />
- <h3>
- <b tal:content="tool/title" i18n:translate="">Caches</b>
- </h3>
- <div tal:content="tool/description" i18n:translate="">
- Description of the tool
- </div>
- <br/>
- <div class="message"
- tal:define="message tool/message"
- tal:condition="message"
- tal:content="message" i18n:translate="">
- Status Message
- </div>
- <br/>
- <div tal:define="instances tool/instances">
- <div tal:repeat="instance instances"
- tal:condition="instances">
- <input type="checkbox" name="selected:list" value=""
- tal:attributes="value instance/name" />
-
- <span tal:condition="not:instance/rename">
- <span tal:condition="instance/active" i18n:translate="">
- <a href="" style="color: green"
- tal:attributes="href string:${instance/url}/@@SelectedManagementView.html"
- tal:content="instance/name" i18n:name="name">
- sql-queries
- </a>
- (Active)
- </span>
- <span tal:condition="not:instance/active" i18n:translate="">
- <a href="" style="color: red"
- tal:attributes="href string:${instance/url}/@@SelectedManagementView.html"
- tal:content="instance/name" i18n:name="name">
- sql-queries
- </a>
- (Inactive)
- </span>
- </span>
- <span tal:condition="instance/rename">
- <input type="hidden" name="old_names:list" value=""
- tal:attributes="value instance/name" />
- <input type="text" size="20" name="new_names:list" value=""
- tal:condition="not:instance/renameNew"
- tal:attributes="value instance/name" />
- <input type="text" size="20" name="new_names:list" value=""
- tal:condition="instance/renameNew"
- tal:attributes="value instance/renameNew" />
- </span>
-
- </div>
- <div tal:condition="not:instances"
- i18n:translate="">
- <i>No instances of this utility are available yet.</i>
- </div>
- </div>
- <div tal:condition="tool/add">
- <div tal:define="info view/addingInfo">
- <input type="text" width="20" name="id" value=""
- tal:attributes="value tool/addname"
- />
- <select name="type_name">
- <option tal:repeat="entry info"
- tal:attributes="value entry/action"
- tal:content="entry/title" i18n:translate="">RAM Cache</option>
- </select>
-
- <input type="submit" name="ADD-TOOL-SUBMIT" value="Add"
- i18n:attributes="value ADD-TOOL-SUBMIT">
- <input type="submit" name="CANCEL-ADD-TOOL-SUBMIT" value="Cancel"
- i18n:attributes="value CANCEL-ADD-TOOL-SUBMIT">
- </div>
- </div>
- <br/>
- <div>
- <input type="submit" name="ACTIVATE-SUBMIT" value="Activate"
- i18n:attributes="value ACTIVATE-SUBMIT"
- tal:condition="not:tool/rename">
- <input type="submit" name="DEACTIVATE-SUBMIT" value="Deactivate"
- i18n:attributes="value DEACTIVATE-SUBMIT"
- tal:condition="not:tool/rename">
-
- <input type="submit" name="ADD-SUBMIT" value="Add"
- i18n:attributes="value ADD-SUBMIT"
- tal:condition="not:tool/rename">
- <input type="submit" name="DELETE-SUBMIT" value="Delete"
- i18n:attributes="value DELETE-SUBMIT"
- tal:condition="not:tool/rename">
- <input type="submit" name="RENAME-SUBMIT" value="Rename"
- i18n:attributes="value RENAME-SUBMIT">
- <input type="submit" name="RENAME-CANCEL-SUBMIT" value="Cancel"
- i18n:attributes="value RENAME-CANCEL-SUBMIT"
- tal:condition="tool/rename">
- </div>
- <br/>
- </form>
-
-</div>
-</body>
-</html>
Copied: Zope3/trunk/src/zope/app/component/browser/siteregistration.pt (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/component/browser/siteregistration.pt)
Copied: Zope3/trunk/src/zope/app/component/browser/tests.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/component/browser/tests.py)
Deleted: Zope3/trunk/src/zope/app/component/browser/tools.py
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/tools.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/tools.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,295 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Tools View
-
-$Id$
-"""
-import zope.interface
-import zope.event
-
-from zope.app import zapi
-from zope.app.component import site, interfaces, browser
-from zope.app.event import objectevent
-from zope.app.exception.interfaces import UserError
-
-from zope.app.i18n import ZopeMessageFactory as _
-
-
-class IToolType(zope.interface.interfaces.IInterface):
- """Interfaces implementing the tool type are considered tools."""
-
-
-class IToolConfiguration(zope.interface.Interface):
- """This is an object that represents a tool configuration"""
-
- #title
- #
- #description
- #
- #interface
- #
- #unique
-
-
-class ToolConfiguration(object):
- """ """
- zope.interface.implements(IToolConfiguration)
-
- def __init__(self, interface, title, description=None, unique=False,
- folder='tools'):
- self.interface = interface
- self.title = title
- self.description = description
- self.unique = unique
- self.folder = folder
-
-
-class SiteManagementView(browser.ComponentAdding):
- """A Site Management via Tools"""
-
- activeTool = None
- addTool = False
- addName = u''
- renameTool = False
- renameList = []
- newNames = []
- msg = u''
-
- def __init__(self, context, request):
- super(SiteManagementView, self).__init__(context, request)
- if 'activeTool' in request:
- request.response.setCookie('SetActiveTool', request['activeTool'],
- path="/")
- self.activeTool = zapi.getUtility(IToolConfiguration,
- request['activeTool'])
- elif 'SetActiveTool' in request:
- self.activeTool = zapi.getUtility(IToolConfiguration,
- request['SetActiveTool'])
-
- def update(self):
- """ """
- msg = u''
- if "INSTALL-SUBMIT" in self.request:
- self.install()
- msg = _(u'Tools successfully installed.')
- if "UNINSTALL-SUBMIT" in self.request:
- self.uninstall()
- msg = _(u'Tools successfully uninstalled.')
- if "ADD-TOOL-SUBMIT" in self.request:
- try:
- self.action(self.request['type_name'], self.request['id'])
- except UserError, err:
- self.addTool = True
- self.addName = self.contentName
- msg=err
- elif "CANCEL-ADD-TOOL-SUBMIT" in self.request:
- self.request.response.expireCookie('SetActiveTool')
- self.activeTool = None
- elif "ACTIVATE-SUBMIT" in self.request:
- self.changeStatus(interfaces.registration.ActiveStatus)
- msg = _(u'Tools successfully activated.')
- elif "DEACTIVATE-SUBMIT" in self.request:
- self.changeStatus(interfaces.registration.InactiveStatus)
- msg = _(u'Tools successfully deactivated.')
- elif "ADD-SUBMIT" in self.request:
- self.addTool = True
- elif "DELETE-SUBMIT" in self.request:
- if 'selected' in self.request:
- self.delete()
- msg = _(u'Tools successfully deleted.')
- else:
- msg = _(u'No tools selected.')
- elif "RENAME-SUBMIT" in self.request:
- if 'selected' in self.request:
- self.renameList = self.request['selected']
- if 'new_names' in self.request:
- self.renameList = self.request['old_names']
- self.newNames = self.request['new_names']
- try:
- self.rename()
- except UserError, err:
- msg=err
- else:
- msg = _(u'Tools successfully renamed.')
- elif "RENAME-CANCEL-SUBMIT" in self.request:
- self.activeTool = None
- self.msg=msg
- return msg
-
- def getSiteManagementFolder(self, tool):
- """Get the site management folder for this tool."""
- sm = zapi.getSiteManager()
- if not tool.folder in sm:
- folder = site.SiteManagementFolder()
- zope.event.notify(objectevent.ObjectCreatedEvent(folder))
- sm[tool.folder] = folder
- return sm[tool.folder]
-
- def toolExists(self, interface, name=''):
- """Check whether a tool already exists in this site"""
- sm = zapi.getSiteManager()
- for reg in sm.registrations():
- if isinstance(reg, site.UtilityRegistration):
- if reg.name == name and reg.provided == interface:
- return True
- return False
-
- def getUniqueTools(self):
- """Get unique tools info for display."""
- results = [{'name': tool.interface.getName(),
- 'title': tool.title,
- 'description': tool.description,
- 'exists': self.toolExists(tool.interface)
- }
- for name, tool in zapi.getUtilitiesFor(IToolConfiguration)
- if tool.unique]
- results.sort(lambda x, y: cmp(x['title'], y['title']))
- return results
-
- def getToolInstances(self, tool):
- """Find every registered utility for a given tool configuration."""
- regManager = self.getSiteManagementFolder(tool).registrationManager
- return [
- {'name': reg.name,
- 'url': zapi.absoluteURL(reg.component, self.request),
- 'rename': tool is self.activeTool and reg.name in self.renameList,
- 'renameNew': tool is self.activeTool and \
- reg.name in self.renameList and \
- self.newNames and \
- self.newNames[self.renameList.index(reg.name)],
- 'active': reg.status == u'Active',
- }
- for reg in regManager.values()
- if (zapi.isinstance(reg, site.UtilityRegistration) and
- reg.provided.isOrExtends(tool.interface))]
-
- def getTools(self):
- """Return a list of all tools"""
- results = [{'name': tool.interface.getName(),
- 'title': tool.title,
- 'description': tool.description,
- 'instances': self.getToolInstances(tool),
- 'add': tool is self.activeTool and self.addTool,
- 'addname': tool is self.activeTool and self.addTool and self.addName,
- 'rename': tool is self.activeTool and self.renameList,
- 'message': tool is self.activeTool and self.msg,
- }
- for name, tool in zapi.getUtilitiesFor(IToolConfiguration)
- if not tool.unique]
- results.sort(lambda x, y: cmp(x['title'], y['title']))
- return results
-
- def install(self):
- tool_names = self.request['selected']
- for tool_name in tool_names:
- self.activeTool = zapi.getUtility(IToolConfiguration, tool_name)
- type_name = list(self.addingInfo())[0]['extra']['factory']
- self.action(type_name)
- self.activeTool = None
-
- def uninstall(self):
- type_names = self.request['selected']
- self.request.form['selected'] = [u'']
- for name, tool in zapi.getUtilitiesFor(IToolConfiguration):
- if name in type_names:
- self.activeTool = tool
- self.delete()
- self.activeTool = None
-
- def changeStatus(self, status):
- tool = self.activeTool
- regManager = self.context[tool.folder].registrationManager
- names = self.request.form['selected']
- for reg in regManager.values():
- if reg.provided.isOrExtends(tool.interface) and reg.name in names:
- reg.status = status
-
- def delete(self):
- tool = self.activeTool
- regManager = self.context[tool.folder].registrationManager
- names = self.request.form['selected']
- for reg in list(regManager.values()):
- if reg.provided.isOrExtends(tool.interface) and reg.name in names:
- component = reg.component
- reg.status = interfaces.registration.InactiveStatus
- del regManager[zapi.name(reg)]
- del zapi.getParent(component)[zapi.name(component)]
-
- def rename(self):
- tool = self.activeTool
- regManager = self.context[tool.folder].registrationManager
- new_names = self.request['new_names']
- old_names = self.request['old_names']
- msg=''
- for reg in regManager.values():
- if reg.provided.isOrExtends(tool.interface) and \
- reg.name in old_names:
- old_name=reg.name
- new_name = new_names[old_names.index(old_name)]
- if new_name!=reg.name:
- if self.toolExists(self.activeTool.interface,new_name):
- if not msg:
- msg=_(u'The given tool name is already being used.')
- else:
- orig_status = reg.status
- reg.status = interfaces.registration.InactiveStatus
- reg.name = new_names[old_names.index(old_name)]
- reg.status = orig_status
- self.renameList.remove(old_name)
- self.newNames.remove(new_name)
- else:
- self.renameList.remove(old_name)
- self.newNames.remove(new_name)
- if msg:
- raise UserError(msg)
-
- def add(self, content):
- """See zope.app.container.interfaces.IAdding"""
-
- name = self.contentName
- if self.toolExists(self.activeTool.interface,name):
- raise UserError(_(u'The given tool name is already being used.'))
-
- sm = self.context
-
- self.context = self.getSiteManagementFolder(self.activeTool)
-
- self.contentName = '' # always use a unique name
- util = super(SiteManagementView, self).add(content)
- self.contentName = name
-
- # Add registration
- name = not self.activeTool.unique and self.contentName or u''
- registration = site.UtilityRegistration(
- name, self.activeTool.interface, util)
- self.context.registrationManager.addRegistration(registration)
- registration.status = interfaces.registration.ActiveStatus
-
- self.context = sm
- return util
-
- def nextURL(self):
- """See zope.app.container.interfaces.IAdding"""
- return (zapi.absoluteURL(self.context, self.request)
- + '/@@SiteManagement')
-
- def addingInfo(self):
- """See zope.app.container.interfaces.IAdding"""
- sm = self.context
- self.context = self.getSiteManagementFolder(self.activeTool)
- self._addFilterInterface = self.activeTool.interface
- results = super(SiteManagementView, self).addingInfo()
- self.context = sm
- self._addFilterInterface = None
- return results
Deleted: Zope3/trunk/src/zope/app/component/browser/tools.txt
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/tools.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/tools.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,160 +0,0 @@
-==============
-The Tools View
-==============
-
- >>> from zope import interface
-
-First we define a utility to work with :
-
- >>> from zope.app.content.interfaces import IContentType
- >>> from zope.app.component.interfaces.registration import IRegisterable
- >>> class IFooUtil(interface.Interface):
- ... pass
- >>> class FooUtil(object):
- ... __parent__ = None
- ... __name__ = u''
- ... interface.implements(IFooUtil, IRegisterable, IContentType)
-
- >>> from zope.app.component.browser import tools
- >>> from zope import component
-
- >>> toolConfig = tools.ToolConfiguration(IFooUtil, 'FooUtil')
- >>> component.provideUtility(toolConfig, tools.IToolConfiguration, 'IFooUtil')
-
-We need a factory to create our new utility :
-
- >>> from zope.component.interfaces import IFactory
- >>> from zope.component.factory import Factory
-
- >>> from zope.app.security import protectclass
- >>> protectclass.protectName(Factory, '__call__', 'zope.public')
-
- >>> factory = Factory(FooUtil,
- ... 'Utility for foo',
- ... 'This factory creates a foo utility.')
- >>> component.provideUtility(factory, IFactory, 'IFooUtil')
-
-Let's now invoke our site management :
-
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> request.form['activeTool']='IFooUtil'
-
- >>> from zope.app import zapi
- >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
- >>> view.update()
- u''
- >>> request.form['ADD-TOOL-SUBMIT']='submit'
- >>> request.form['type_name']='IFooUtil'
- >>> request.form['id']='foo1'
- >>> view.update()
- u''
- >>> util = component.getUtility(IFooUtil, 'foo1')
- >>> util is not None
- True
- >>> current_tools = view.getTools()
- >>> len(current_tools)
- 1
- >>> current_tools[0]['instances'][0]['name']
- 'foo1'
-
-Registering with the same name
-------------------------------
-
- >>> print view.update()
- The given tool name is already being used.
-
- >>> request.form['id']='foo2'
- >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
- >>> view.update()
- u''
- >>> current_tools = view.getTools()
- >>> current_tools[0]['instances'][0]['name']
- 'foo1'
- >>> current_tools[0]['instances'][1]['name']
- 'foo2'
-
-Creating a utility without a name
----------------------------------
-
- >>> request.form['id']=''
- >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
- >>> view.update()
- u''
- >>> current_tools = view.getTools()
- >>> current_tools[0]['instances'][0]['name']
- 'foo1'
- >>> current_tools[0]['instances'][1]['name']
- 'foo2'
- >>> current_tools[0]['instances'][2]['name']
- u''
-
-Renaming utilities
-------------------
-
- >>> request = TestRequest()
- >>> request.form['activeTool']='IFooUtil'
- >>> request.form['RENAME-SUBMIT']='submit'
-
-First we rename a single utility :
-
- >>> request.form['old_names']=['foo1']
- >>> request.form['new_names']=['JohnDoe']
- >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
- >>> view.update()
- u'Tools successfully renamed.'
- >>> current_tools = view.getTools()
- >>> current_tools[0]['instances'][0]['name']
- 'JohnDoe'
- >>> current_tools[0]['instances'][1]['name']
- 'foo2'
- >>> current_tools[0]['instances'][2]['name']
- u''
-
- >>> request.form['old_names']=['JohnDoe', 'foo2']
- >>> request.form['new_names']=['foo1', 'Tres']
- >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
- >>> view.update()
- u'Tools successfully renamed.'
- >>> current_tools = view.getTools()
- >>> current_tools[0]['instances'][0]['name']
- 'foo1'
- >>> current_tools[0]['instances'][1]['name']
- 'Tres'
- >>> current_tools[0]['instances'][2]['name']
- u''
-
-Deleting utilities
-------------------
-
- >>> request = TestRequest()
- >>> request.form['activeTool']='IFooUtil'
- >>> request.form['DELETE-SUBMIT']='submit'
-
-First we try without a selected utility :
-
- >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
- >>> view.update()
- u'No tools selected.'
-
-Now select one utility :
-
- >>> request.form['selected']=['']
- >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
- >>> view.update()
- u'Tools successfully deleted.'
- >>> current_tools = view.getTools()
- >>> current_tools[0]['instances'][0]['name']
- 'foo1'
- >>> current_tools[0]['instances'][1]['name']
- 'Tres'
-
-Select all the remaining utilities :
-
- >>> request.form['selected']=['foo1', 'Tres']
- >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
- >>> view.update()
- u'Tools successfully deleted.'
- >>> view.getTools()[0]['instances']
- []
-
Deleted: Zope3/trunk/src/zope/app/component/browser/utility.py
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/utility.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/utility.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,33 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Use-Registration view for utilities.
-
-$Id$
-"""
-from zope.app.component.browser.registration import AddComponentRegistration
-from zope.app.component.interfaces.registration import ActiveStatus
-
-class AddRegistration(AddComponentRegistration):
- """View for adding a utility registration.
-
- We could just use AddComponentRegistration, except that we need a
- custom interface widget.
-
- This is a view on a local utility, configured by an <addform>
- directive.
- """
- def add(self, registration):
- reg = super(AddRegistration, self).add(registration)
- reg.status = ActiveStatus
- return reg
Deleted: Zope3/trunk/src/zope/app/component/browser/utilreg_details.pt
===================================================================
--- Zope3/trunk/src/zope/app/component/browser/utilreg_details.pt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/browser/utilreg_details.pt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,17 +0,0 @@
-<ul style="margin-top: 0; margin-bottom: 0" i18n:domain="zope">
- <li>
- <i i18n:translate="">provided:</i>
- <span tal:content="view/provided">zope.app.interfaces.IMyUtility</span>
- </li>
- <li>
- <i i18n:translate="">name:</i>
- <span tal:content="view/name" i18n:translate="">myutility</span>
- </li>
- <li tal:define="component view/component">
- <i i18n:translate="">component:</i>
- <a href=""
- tal:attributes="href
- string:${component/url}/@@SelectedManagementView.html"
- tal:content="component/name" i18n:translate="">myutility</a>
- </li>
-</ul>
Modified: Zope3/trunk/src/zope/app/component/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/component/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -3,14 +3,10 @@
<interface interface="zope.interface.Interface" />
- <!-- Registration Framework -->
-
- <class class=".registration.RegistrationManager">
- <factory
- id="zope.app.component.RegistrationManager"
- title="Registration Manager" />
+ <!-- Registration Framework Goes away in 3.5-->
+ <class class=".back35.RegistrationManager">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
<require
permission="zope.ManageSite"
@@ -24,53 +20,18 @@
<!-- ++registrations++ namespace registrations -->
<view
name="registrations" type="*"
- for=".interfaces.registration.IRegisterableContainer"
- provides="zope.app.traversing.interfaces.ITraversable"
- factory=".registration.RegistrationManagerNamespace"
+ for=".back35.IRegisterableContainer"
+ provides="zope.traversing.interfaces.ITraversable"
+ factory=".back35.RegistrationManagerNamespace"
/>
<adapter
name="registrations"
- for=".interfaces.registration.IRegisterableContainer"
- provides="zope.app.traversing.interfaces.ITraversable"
- factory=".registration.RegistrationManagerNamespace"
+ for=".back35.IRegisterableContainer"
+ provides="zope.traversing.interfaces.ITraversable"
+ factory=".back35.RegistrationManagerNamespace"
/>
- <class class=".registration.Registered">
- <allow attributes="registrations" />
- </class>
- <adapter
- for=".interfaces.registration.IRegisterable"
- provides=".interfaces.registration.IRegistered"
- factory=".registration.Registered"
- trusted="true"
- />
-
- <subscriber
- for=".interfaces.registration.IComponentRegistration
- zope.app.container.interfaces.IObjectRemovedEvent"
- handler=".registration.ComponentRegistrationRemoveSubscriber"
- />
-
- <subscriber
- for=".interfaces.registration.IComponentRegistration
- zope.app.container.interfaces.IObjectAddedEvent"
- handler=".registration.ComponentRegistrationAddSubscriber"
- />
-
- <subscriber
- for=".interfaces.registration.IComponentRegistration
- .interfaces.registration.IRegistrationEvent"
- handler=".registration.componentRegistrationEventNotify"
- />
-
- <subscriber
- for=".interfaces.registration.IRegisterable
- zope.app.container.interfaces.IObjectMovedEvent"
- handler=".registration.RegisterableMoveSubscriber"
- />
-
-
<!-- Site and Site Manager Framework -->
<module module=".interfaces">
@@ -79,38 +40,27 @@
<class class=".site.LocalSiteManager">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
+ interface="zope.annotation.interfaces.IAttributeAnnotatable" />
<require
permission="zope.ManageSite"
interface="zope.app.container.interfaces.IReadContainer" />
<require
permission="zope.ManageSite"
- interface="zope.component.interfaces.ISiteManager
+ interface="zope.component.interfaces.IComponentLookup
zope.app.container.interfaces.IWriteContainer" />
</class>
- <!-- TODO: We allow these attributes to be changed. We need some subscriber
- that updated the registries once attributes change. -->
- <class class=".site.AdapterRegistration">
+ <class class="zope.component.registry.UtilityRegistration">
<require
permission="zope.ManageSite"
- interface=".interfaces.IAdapterRegistration"
- set_schema=".interfaces.IAdapterRegistration"
+ interface="zope.component.interfaces.IUtilityRegistration"
/>
</class>
- <class class=".site.UtilityRegistration">
- <require
- permission="zope.ManageSite"
- interface=".interfaces.IUtilityRegistration"
- set_schema=".interfaces.IUtilityRegistration"
- />
- </class>
-
<class class=".site.SiteManagementFolder">
<factory />
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
<require
permission="zope.ManageSite"
@@ -123,15 +73,15 @@
</class>
<adapter
- for="zope.component.interfaces.ISiteManager"
- provides="zope.app.filerepresentation.interfaces.IDirectoryFactory"
+ for="zope.component.interfaces.IComponentLookup"
+ provides="zope.filerepresentation.interfaces.IDirectoryFactory"
factory=".site.SMFolderFactory"
permission="zope.ManageContent"
/>
<adapter
for="zope.interface.Interface"
- provides="zope.component.interfaces.ISiteManager"
+ provides="zope.component.interfaces.IComponentLookup"
factory=".site.SiteManagerAdapter"
/>
@@ -167,7 +117,7 @@
<utility
component=".vocabulary.UtilityComponentInterfacesVocabulary"
- provides="zope.app.schema.interfaces.IVocabularyFactory"
+ provides="zope.schema.interfaces.IVocabularyFactory"
name="Utility Component Interfaces"
/>
Modified: Zope3/trunk/src/zope/app/component/contentdirective.py
===================================================================
--- Zope3/trunk/src/zope/app/component/contentdirective.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/contentdirective.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,21 +20,20 @@
import warnings
from types import ModuleType
from persistent.interfaces import IPersistent
+
from zope.component.interfaces import IFactory
from zope.component.factory import Factory
+from zope.component.interface import provideInterface
+from zope.component.zcml import utility
from zope.interface import classImplements
from zope.schema.interfaces import IField
from zope.configuration.exceptions import ConfigurationError
+from zope.location.interfaces import ILocation
+from zope.annotation.interfaces import IAttributeAnnotatable
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.component.interface import provideInterface
-from zope.app.component.interfaces import ILocalUtility
-from zope.app.location.interfaces import ILocation
from zope.app.security.protectclass import protectLikeUnto, protectName
from zope.app.security.protectclass import protectSetAttribute
-from zope.app.component.metaconfigure import utility
-
PublicPermission = 'zope.Public'
def dottedName(klass):
@@ -207,8 +206,6 @@
>>> dir = LocalUtilityDirective(None, LU4)
>>> IAttributeAnnotatable.implementedBy(LU4)
True
- >>> ILocalUtility.implementedBy(LU4)
- True
>>> LocalUtilityDirective(None, LU3)
Traceback (most recent call last):
@@ -237,6 +234,5 @@
'`IPersistent`.' % class_.__name__)
classImplements(class_, IAttributeAnnotatable)
- classImplements(class_, ILocalUtility)
super(LocalUtilityDirective, self).__init__(_context, class_)
Modified: Zope3/trunk/src/zope/app/component/fields.py
===================================================================
--- Zope3/trunk/src/zope/app/component/fields.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/fields.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -13,109 +13,16 @@
##############################################################################
"""Component-related fields
+This module will be gone in Zope 3.5.
+
$Id$
"""
__docformat__ = 'restructuredtext'
-import zope.schema
-from zope.component.exceptions import ComponentLookupError
-from zope.configuration.exceptions import ConfigurationError
-from zope.configuration.fields import GlobalObject
-
-from zope.app import zapi
-
# BBB 2006/02/18, to be removed after 12 months
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.publisher.interfaces import ILayer
-zope.deprecation.__show__.on()
-
-class LayerField(GlobalObject):
- r"""This field represents a layer.
-
- Besides being able to look up the layer by importing it, we also try
- to look up the name in the site manager.
-
- >>> from zope.interface import directlyProvides
- >>> from zope.interface.interface import InterfaceClass
-
- >>> layer1 = InterfaceClass('layer1', (),
- ... __doc__='Layer: layer1',
- ... __module__='zope.app.layers')
- >>> directlyProvides(layer1, ILayer)
-
- >>> layers = None
- >>> class Resolver(object):
- ... def resolve(self, path):
- ... if '..' in path:
- ... raise ValueError('Empty module name')
- ... if (path.startswith('zope.app.layers') and
- ... hasattr(layers, 'layer1') or
- ... path == 'zope.app.component.fields.layer1' or
- ... path == '.fields.layer1'):
- ... return layer1
- ... raise ConfigurationError('layer1')
-
- >>> field = LayerField()
- >>> field = field.bind(Resolver())
-
- Test 1: Import the layer
- ------------------------
-
- >>> field.fromUnicode('zope.app.component.fields.layer1') is layer1
- True
-
- Test 2: We have a shortcut name. Import the layer from `zope.app.layers`.
- -------------------------------------------------------------------------
-
- >>> from types import ModuleType as module
- >>> import sys
- >>> layers = module('layers')
- >>> old = sys.modules.get('zope.app.layers', None)
- >>> sys.modules['zope.app.layers'] = layers
- >>> setattr(layers, 'layer1', layer1)
-
- >>> field.fromUnicode('layer1') is layer1
- True
-
- >>> if old is not None:
- ... sys.modules['zope.app.layers'] = old
-
- Test 3: Get the layer from the site manager
- -------------------------------------------
-
- >>> from zope.app.testing import ztapi
- >>> ztapi.provideUtility(ILayer, layer1, 'layer1')
-
- >>> field.fromUnicode('layer1') is layer1
- True
-
- Test 4: Import the layer by using a short name
- ----------------------------------------------
-
- >>> field.fromUnicode('.fields.layer1') is layer1
- True
- """
-
- def fromUnicode(self, u):
- name = str(u.strip())
-
- try:
- value = zapi.queryUtility(ILayer, name)
- except ComponentLookupError:
- # The component architecture is not up and running.
- pass
- else:
- if value is not None:
- return value
-
- try:
- value = self.context.resolve('zope.app.layers.'+name)
- except (ConfigurationError, ValueError), v:
- try:
- value = self.context.resolve(name)
- except ConfigurationError, v:
- raise zope.schema.ValidationError(v)
-
- self.validate(value)
- return value
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "It will no longer be available in Zope 3.5. Layers are just simple "
+ "interfaces now; use the GlobalInterface field instead.",
+ LayerField = 'zope.app.component.back35:LayerField',
+ )
Modified: Zope3/trunk/src/zope/app/component/hooks.py
===================================================================
--- Zope3/trunk/src/zope/app/component/hooks.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/hooks.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -86,7 +86,7 @@
# We should really look look at this again though, especially
# once site managers do less. There's probably no good reason why
# they can't be proxied. Well, except maybe for performance.
- sm = zope.component.interfaces.ISiteManager(
+ sm = zope.component.interfaces.IComponentLookup(
context, zope.component.getGlobalSiteManager())
return zope.security.proxy.removeSecurityProxy(sm)
@@ -94,25 +94,18 @@
def adapter_hook(interface, object, name='', default=None):
try:
return siteinfo.adapter_hook(interface, object, name, default)
- except zope.component.exceptions.ComponentLookupError:
+ except zope.component.interfaces.ComponentLookupError:
return default
def setHooks():
zope.component.adapter_hook.sethook(adapter_hook)
zope.component.getSiteManager.sethook(getSiteManager)
- # BBB: Goes away in 3.3.
- zope.deprecation.__show__.off()
- from bbb import hooks
- zope.component.getServices.sethook(hooks.getServices_hook)
- zope.deprecation.__show__.on()
def resetHooks():
# Reset hookable functions to original implementation.
zope.component.adapter_hook.reset()
zope.component.getSiteManager.reset()
- # BBB: Goes away in 3.3.
- zope.component.getServices.reset()
# Clear the site thread global
clearSite = setSite
Modified: Zope3/trunk/src/zope/app/component/interface.py
===================================================================
--- Zope3/trunk/src/zope/app/component/interface.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/interface.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,284 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Interface utility functions
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-from types import ClassType
-from zope.component.exceptions import ComponentLookupError
-from zope.interface import directlyProvides, directlyProvidedBy
-from zope.interface.interfaces import IInterface
-from zope.app import zapi
-
-def provideInterface(id, interface, iface_type=None, info=''):
- """register Interface with global site manager as utility
-
- >>> from zope.app.testing import placelesssetup
- >>> placelesssetup.setUp()
- >>> gsm = zapi.getGlobalSiteManager()
-
- >>> from zope.interface import Interface
- >>> from zope.interface.interfaces import IInterface
- >>> from zope.app.content.interfaces import IContentType
-
- >>> class I(Interface):
- ... pass
- >>> IInterface.providedBy(I)
- True
- >>> IContentType.providedBy(I)
- False
- >>> interfaces = gsm.getUtilitiesFor(IContentType)
- >>> list(interfaces)
- []
-
- # provide first interface type
- >>> provideInterface('', I, IContentType)
- >>> IContentType.providedBy(I)
- True
- >>> interfaces = list(gsm.getUtilitiesFor(IContentType))
- >>> [name for (name, iface) in interfaces]
- [u'zope.app.component.interface.I']
- >>> [iface.__name__ for (name, iface) in interfaces]
- ['I']
-
- # provide second interface type
- >>> class IOtherType(IInterface):
- ... pass
- >>> provideInterface('', I, IOtherType)
-
- >>> IContentType.providedBy(I)
- True
- >>> IOtherType.providedBy(I)
- True
- >>> interfaces = list(gsm.getUtilitiesFor(IContentType))
- >>> [name for (name, iface) in interfaces]
- [u'zope.app.component.interface.I']
- >>> interfaces = list(gsm.getUtilitiesFor(IOtherType))
- >>> [name for (name, iface) in interfaces]
- [u'zope.app.component.interface.I']
-
- >>> class I1(Interface):
- ... pass
- >>> provideInterface('', I1)
- >>> IInterface.providedBy(I1)
- True
- >>> IContentType.providedBy(I1)
- False
- >>> interfaces = list(gsm.getUtilitiesFor(IContentType))
- >>> [name for (name, iface) in interfaces]
- [u'zope.app.component.interface.I']
- >>> [iface.__name__ for (name, iface) in interfaces]
- ['I']
- >>> placelesssetup.tearDown()
- """
- if not id:
- id = "%s.%s" % (interface.__module__, interface.__name__)
-
- if not IInterface.providedBy(interface):
- if not isinstance(interface, (type, ClassType)):
- raise TypeError(id, "is not an interface or class")
- return
-
- if iface_type is not None:
- if not iface_type.extends(IInterface):
- raise TypeError(iface_type, "is not an interface type")
- directlyProvides(interface, iface_type, directlyProvidedBy(interface))
- else:
- iface_type = IInterface
-
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(iface_type, interface, id, info)
-
-
-def getInterface(context, id):
- """return interface or ComponentLookupError
-
- >>> from zope.app.testing import placelesssetup
- >>> placelesssetup.setUp()
-
- >>> from zope.interface import Interface
- >>> from zope.app.content.interfaces import IContentType
-
- >>> class I4(Interface):
- ... pass
- >>> IInterface.providedBy(I4)
- True
- >>> IContentType.providedBy(I4)
- False
- >>> getInterface(None, 'zope.app.component.interface.I4')
- Traceback (most recent call last):
- ...
- ComponentLookupError: 'zope.app.component.interface.I4'
- >>> provideInterface('', I4, IContentType)
- >>> IContentType.providedBy(I4)
- True
- >>> iface = queryInterface( """\
- """ 'zope.app.component.interface.I4')
- >>> iface.__name__
- 'I4'
- >>> placelesssetup.tearDown()
- """
- iface = queryInterface(id, None)
- if iface is None:
- raise ComponentLookupError(id)
- return iface
-
-
-def queryInterface(id, default=None):
- """return interface or ``None``
-
- >>> from zope.app.testing import placelesssetup
- >>> placelesssetup.tearDown()
- >>> placelesssetup.setUp()
-
- >>> from zope.interface import Interface
- >>> from zope.interface.interfaces import IInterface
- >>> from zope.app.content.interfaces import IContentType
-
- >>> class I3(Interface):
- ... pass
- >>> IInterface.providedBy(I3)
- True
- >>> IContentType.providedBy(I3)
- False
- >>> queryInterface('zope.app.component.interface.I3')
-
- >>> provideInterface('', I3, IContentType)
- >>> IContentType.providedBy(I3)
- True
- >>> iface = queryInterface('zope.app.component.interface.I3')
- >>> iface.__name__
- 'I3'
- >>> placelesssetup.tearDown()
- """
- return zapi.queryUtility(IInterface, id, default)
-
-
-def searchInterface(context, search_string=None, base=None):
- """Interfaces search
-
- >>> from zope.app.testing import placelesssetup
- >>> placelesssetup.setUp()
-
- >>> from zope.interface import Interface
- >>> from zope.interface.interfaces import IInterface
- >>> from zope.app.content.interfaces import IContentType
-
- >>> class I5(Interface):
- ... pass
- >>> IInterface.providedBy(I5)
- True
- >>> IContentType.providedBy(I5)
- False
- >>> searchInterface(None, 'zope.app.component.interface.I5')
- []
- >>> provideInterface('', I5, IContentType)
- >>> IContentType.providedBy(I5)
- True
- >>> iface = searchInterface(None, 'zope.app.component.interface.I5')
- >>> iface[0].__name__
- 'I5'
- >>> placelesssetup.tearDown()
- """
- return [iface_util[1]
- for iface_util in
- searchInterfaceUtilities(context, search_string, base)]
-
-
-def searchInterfaceIds(context, search_string=None, base=None):
- """Interfaces search
-
- >>> from zope.app.testing import placelesssetup
- >>> placelesssetup.setUp()
-
- >>> from zope.interface import Interface
- >>> from zope.interface.interfaces import IInterface
- >>> from zope.app.content.interfaces import IContentType
-
- >>> class I5(Interface):
- ... pass
- >>> IInterface.providedBy(I5)
- True
- >>> IContentType.providedBy(I5)
- False
- >>> searchInterface(None, 'zope.app.component.interface.I5')
- []
- >>> provideInterface('', I5, IContentType)
- >>> IContentType.providedBy(I5)
- True
- >>> iface = searchInterfaceIds(None,
- ... 'zope.app.component.interface.I5')
- >>> iface
- [u'zope.app.component.interface.I5']
- >>> placelesssetup.tearDown()
- """
- return [iface_util[0]
- for iface_util in
- searchInterfaceUtilities(context, search_string, base)]
-
-
-def searchInterfaceUtilities(context, search_string=None, base=None):
- gsm = zapi.getGlobalSiteManager()
- iface_utilities = gsm.getUtilitiesFor(IInterface)
-
- if search_string:
- search_string = search_string.lower()
- iface_utilities = [iface_util for iface_util in iface_utilities
- if (getInterfaceAllDocs(iface_util[1]).\
- find(search_string) >= 0)]
- if base:
- res = [iface_util for iface_util in iface_utilities
- if iface_util[1].extends(base)]
- else:
- res = [iface_util for iface_util in iface_utilities]
- return res
-
-
-def getInterfaceAllDocs(interface):
- iface_id = '%s.%s' %(interface.__module__, interface.__name__)
- docs = [str(iface_id).lower(),
- str(interface.__doc__).lower()]
-
- if IInterface.providedBy(interface):
- for name in interface:
- docs.append(
- str(interface.getDescriptionFor(name).__doc__).lower())
-
- return '\n'.join(docs)
-
-
-def nameToInterface(context, id):
- if id == 'None':
- return None
- iface = getInterface(context, id)
- return iface
-
-def interfaceToName(context, interface):
- if interface is None:
- return 'None'
- items = searchInterface(context, base=interface)
- ids = [('%s.%s' %(iface.__module__, iface.__name__))
- for iface in items
- if iface == interface]
-
- if not ids:
- # Do not fail badly, instead resort to the standard
- # way of getting the interface name, cause not all interfaces
- # may be registered as utilities.
- return interface.__module__ + '.' + interface.__name__
-
- assert len(ids) == 1, "Ambiguous interface names: %s" % ids
- return ids[0]
-
+# This module has moved to zope.component.interface
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.component.interface',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/component/interface.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.3
Modified: Zope3/trunk/src/zope/app/component/interfaces/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/component/interfaces/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/interfaces/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,27 +15,26 @@
$Id$
"""
+
+
import zope.interface
-import zope.schema
-import zope.component
-from zope.app.container.interfaces import IContainer
-from zope.app.container.constraints import ContainerTypesConstraint
-from zope.app.container.constraints import ItemTypePrecondition
+import zope.component.interfaces
+import zope.app.container.interfaces
+import zope.app.container.constraints
from zope.app.i18n import ZopeMessageFactory as _
import registration
-class ILocalAdapterRegistry(registration.IRegistry,
- registration.ILocatedRegistry):
+import zope.deferredimport
- def adaptersChanged():
- """Update the adapter surrogates, since the registrations changed."""
+zope.deferredimport.deprecatedFrom(
+ "Local registration is now much simpler. The old baroque APIs "
+ "will go away in Zope 3.5. See the new component-registration APIs "
+ "defined in zope.component, especially IComponentRegistry.",
+ 'zope.app.component.back35',
+ 'ILocalAdapterRegistry', 'ILocalUtility', 'IAdapterRegistration',
+ 'IUtilityRegistration',
+ )
- def baseChanged():
- """Someone changed the base registry
-
- This should only happen during testing
- """
-
class IPossibleSite(zope.interface.Interface):
"""An object that could be a site
"""
@@ -53,125 +52,58 @@
class ISite(IPossibleSite):
"""Marker interface to indicate that we have a site"""
-class ILocalSiteManager(zope.component.interfaces.ISiteManager,
- registration.ILocatedRegistry,
- registration.IRegistry):
- """Site Managers act as containers for registerable components.
-
- If a Site Manager is asked for an adapter or utility, it checks for those
- it contains before using a context-based lookup to find another site
- manager to delegate to. If no other site manager is found they defer to
- the global site manager which contains file based utilities and adapters.
+class INewLocalSite(zope.interface.Interface):
+ """Event: a local site was created
"""
-class INewLocalSite(zope.interface.Interface):
-
manager = zope.interface.Attribute("The new site manager")
class NewLocalSite:
+ """Event: a local site was created
+ """
zope.interface.implements(INewLocalSite)
def __init__(self, manager):
self.manager = manager
-class ISiteManagementFolder(registration.IRegisterableContainer,
- IContainer):
- """Component and component registration containers."""
+class ILocalSiteManager(zope.component.interfaces.IComponents):
+ """Site Managers act as containers for registerable components.
- __parent__ = zope.schema.Field(
- constraint = ContainerTypesConstraint(
- ILocalSiteManager,
- registration.IRegisterableContainer,
- ),
- )
-
-class ILocalUtility(registration.IRegisterable):
- """Local utility marker.
-
- A marker interface that indicates that a component can be used as
- a local utility.
-
- Utilities should usually also declare they implement
- IAttributeAnnotatable, so that the standard adapter to
- IRegistered can be used; otherwise, they must provide
- another way to be adaptable to IRegistered.
+ If a Site Manager is asked for an adapter or utility, it checks for those
+ it contains before using a context-based lookup to find another site
+ manager to delegate to. If no other site manager is found they defer to
+ the global site manager which contains file based utilities and adapters.
"""
+ subs = zope.interface.Attribute(
+ "A collection of registries that describe the next level "
+ "of the registry tree. They are the children of this "
+ "registry node. This attribute should never be "
+ "manipulated manually. Use `addSub()` and `removeSub()` "
+ "instead.")
-class IAdapterRegistration(registration.IComponentRegistration):
- """Local Adapter Registration for Local Adapter Registry
+ def addSub(sub):
+ """Add a new sub-registry to the node.
- The adapter registration is used to provide local adapters via the
- adapter registry. It is an extended component registration, whereby the
- component is the adapter factory in this case.
- """
- required = zope.schema.Choice(
- title = _("For interface"),
- description = _("The interface of the objects being adapted"),
- vocabulary="Interfaces",
- readonly = True,
- required=False,
- default=None)
+ Important: This method should *not* be used manually. It is
+ automatically called by `setNext()`. To add a new registry to the
+ tree, use `sub.setNext(self, self.base)` instead!
+ """
- with = zope.schema.Tuple(
- title = _("With interfaces"),
- description = _("Additionally required interfaces"),
- readonly=True,
- value_type = zope.schema.Choice(vocabulary='Interfaces'),
- required=False,
- default=())
+ def removeSub(sub):
+ """Remove a sub-registry to the node.
- provided = zope.schema.Choice(
- title = _("Provided interface"),
- description = _("The interface provided"),
- vocabulary="Interfaces",
- readonly = True,
- required = True)
+ Important: This method should *not* be used manually. It is
+ automatically called by `setNext()`. To remove a registry from the
+ tree, use `sub.setNext(None)` instead!
+ """
+
- name = zope.schema.TextLine(
- title=_(u"Name"),
- readonly=False,
- required=True,
- default=u''
- )
+class ISiteManagementFolder(zope.app.container.interfaces.IContainer):
+ """Component and component registration containers."""
- permission = zope.schema.Choice(
- title=_("The permission required for use"),
- vocabulary="Permission Ids",
- readonly=False,
- required=False,
- )
+ # XXX we need to figure out how to constrain this or, alternatively,
+ # just use regular folders, which is probably the beter choice.
+ # zope.app.container.constraints.containers(ILocalSiteManager)
- # TODO: for now until we figure out a way to specify the factory directly
- factoryName = zope.schema.TextLine(
- title=_(u"Factory Name"),
- readonly=False,
- required=False,
- )
-
-
-class IUtilityRegistration(IAdapterRegistration):
- """Utility registration object.
-
- Adapter registries are also used to to manage utilities, since utilities
- are adapters that are instantiated and have no required interfaces. Thus,
- utility registrations must fulfill all requirements of an adapter
- registration as well.
- """
-
- name = zope.schema.TextLine(
- title=_("Register As"),
- description=_("The name under which the utility will be known."),
- readonly=False,
- required=True,
- default=u''
- )
-
- provided = zope.schema.Choice(
- title=_("Provided interface"),
- description=_("The interface provided by the utility"),
- vocabulary="Utility Component Interfaces",
- readonly=True,
- required=True,
- )
Modified: Zope3/trunk/src/zope/app/component/interfaces/registration.py
===================================================================
--- Zope3/trunk/src/zope/app/component/interfaces/registration.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/interfaces/registration.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,231 +15,51 @@
$Id$
"""
-import zope.component.interfaces
-from zope.interface import Interface, Attribute, implements
-from zope.schema import Field, Choice, vocabulary
-from zope.schema.interfaces import IField
+from zope import interface, schema
+import zope.schema.interfaces
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.container.interfaces import IContainerNamesContainer
-from zope.app.container.interfaces import IContained, IContainer
-from zope.app.container.constraints import contains, containers
-from zope.app.event.interfaces import IObjectEvent
-from zope.app.i18n import ZopeMessageFactory as _
+import zope.deferredimport
-from zope.app.component import bbb
+zope.deferredimport.deprecatedFrom(
+ "Local registration is now much simpler. The old baroque APIs "
+ "will go away in Zope 3.5. See the new component-registration APIs "
+ "defined in zope.component, especially IComponentRegistry.",
+ 'zope.app.component.back35',
+ 'IRegistration',
+ 'InactiveStatus',
+ 'ActiveStatus',
+ 'IComponentRegistration',
+ 'IRegistry',
+ 'ILocatedRegistry',
+ 'IRegistrationManager',
+ 'IRegistrationManagerContained',
+ 'IRegisterableContainer',
+ 'IRegisterable',
+ 'IRegisterableContainerContaining',
+ 'IRegistered',
+ )
-InactiveStatus = _('Inactive')
-ActiveStatus = _('Active')
+zope.deferredimport.deprecated(
+ "Registration events are not defined in zope.component.interfaces. "
+ "Importing them from zope.app.component.registration will be disallowed "
+ "in Zope 3.5",
+ IRegistrationEvent = 'zope.component.interfaces:IRegistrationEvent',
+ IRegistrationActivatedEvent = 'zope.component.interfaces:IRegistered',
+ IRegistrationDeactivatedEvent = 'zope.component.interfaces:IUnregistered',
+ )
+class IComponent(zope.schema.interfaces.IField):
+ """A component
-class IRegistrationEvent(IObjectEvent):
- """An event that involves a registration"""
-
-class IRegistrationActivatedEvent(IRegistrationEvent):
- """This event is fired, when a component's registration is activated."""
-
-class IRegistrationDeactivatedEvent(IRegistrationEvent):
- """This event is fired, when a component's registration is deactivated."""
-
-
-class IRegistration(Interface):
- """Registration object
-
- A registration object represents a specific registration
- decision, such as registering an adapter or defining a permission.
-
- In addition to the attributes or methods defined here,
- registration objects will include additional attributes
- identifying how they should be used. For example, a service
- registration will provide a service type. An adapter
- registration will specify a used-for interface and a provided
- interface.
- """
-
- status = Choice(
- title=_("Registration status"),
- vocabulary=vocabulary.SimpleVocabulary(
- (vocabulary.SimpleTerm(InactiveStatus, title=InactiveStatus),
- vocabulary.SimpleTerm(ActiveStatus, title=ActiveStatus))),
- default=ActiveStatus
- )
-
-class IComponent(IField):
- """A component path
-
This is just the interface for the ComponentPath field below. We'll use
this as the basis for looking up an appropriate widget.
"""
-class Component(Field):
- """A component path
+class Component(schema.Field):
+ """A component
Values of the field are absolute unicode path strings that can be
traversed to get an object.
"""
- implements(IComponent)
+ interface.implements(IComponent)
-
-class IComponentRegistration(IRegistration):
- """Registration object that uses a component.
-
- An interface can optionally be specified that describes the interface the
- component provides for the registry.
-
- The interface will be used to produce a proxy for the component, if
- the permission is also specified.
- """
- component = Component(
- title=_("Registration Component"),
- description=_("The component the registration is for."),
- required=True)
-
- interface = Field(
- title=_("Component Interface"),
- description=_("The interface the component provides through this "
- "registration."),
- required=False,
- default=None)
-
- permission = Choice(
- title=_("The permission needed to use the component"),
- vocabulary="Permissions",
- required=False
- )
-
-
-class IRegistry(zope.component.interfaces.IRegistry):
- """A component that can be configured using a registration manager."""
-
- def register(registration):
- """Register a component with the registry using a registration.
-
- Once the registration is added to the registry, it will be active. If
- the registration is already registered with the registry, this method
- will quietly return.
- """
-
- def unregister(registration):
- """Unregister a component from the registry.
-
- Unregistering a registration automatically makes the component
- inactive. If the registration is not registered, this method will
- quietly return.
- """
-
- def registered(registration):
- """Determine whether a registration is registered with the registry.
-
- The method will return a Boolean value.
- """
-
-
-class ILocatedRegistry(zope.component.interfaces.IRegistry):
- """A registry that is located in a tree of registries.
-
-
- """
- next = Attribute("Set the next local registry in the tree. This attribute "
- "represents the parent of this registry node. If the "
- "value is `None`, then this registry represents the "
- "root of the tree")
-
- subs = Attribute("A collection of registries that describe the next level "
- "of the registry tree. They are the children of this "
- "registry node. This attribute should never be "
- "manipulated manually. Use `addSub()` and `removeSub()` "
- "instead.")
-
- base = Attribute("Outside of the local registry tree lies the global "
- "registry, which is known as the base to every local "
- "registry in the tree.")
-
- def addSub(sub):
- """Add a new sub-registry to the node.
-
- Important: This method should *not* be used manually. It is
- automatically called by `setNext()`. To add a new registry to the
- tree, use `sub.setNext(self, self.base)` instead!
- """
-
- def removeSub(sub):
- """Remove a sub-registry to the node.
-
- Important: This method should *not* be used manually. It is
- automatically called by `setNext()`. To remove a registry from the
- tree, use `sub.setNext(None)` instead!
- """
-
- def setNext(next, base=None):
- """Set the next/parent registry in the tree.
-
- This method should ensure that all relevant registies are updated
- correctly as well.
- """
-
-
-class IRegistrationManager(IContainerNamesContainer):
- """Manage Registrations"""
- contains(IRegistration)
-
- def addRegistration(registration):
- """Add a registration to the manager.
-
- The function will automatically choose a name as which the
- registration will be known. The name of the registration inside this
- manager is returned.
- """
-
-
-class IRegistrationManagerContained(IContained):
- """Objects that can be contained by the registration manager should
- implement this interface."""
- containers(IRegistrationManager)
-
-
-class IRegisterableContainer(IContainer):
- """Containers with registration managers
-
- These are site-management folders of one sort or another.
-
- The container allows clients to access the registration manager
- without knowing it's name.
-
- The registration manager container *also* supports local-module
- lookup.
- """
-
- registrationManager = Field(
- title=_("Registration Manager"),
- description=_("The registration manager keeps track of all component "
- "registrations."))
-
-
-class IRegisterable(IContained):
- """Mark a component as registerable.
-
- All registerable components need to implement this interface.
- """
- containers(IRegisterableContainer)
-
-
-class IRegisterableContainerContaining(IContainer):
- """A container that can only contain `IRegisterable`s and
- `IRegisterableContainer`s.
-
- This interface was designed to be always used together with the
- `IRegisterableContainer`.
- """
- contains(IRegisterable, IRegisterableContainer)
-
-
-class IRegistered(Interface, bbb.interfaces.IBBBRegistered):
- """An object that can track down its registrations.
-
- The object need not implement this functionality itself, but must at
- least support doing so via an adapter.
- """
-
- def registrations():
- """Return a sequence of registration objects for this object."""
Modified: Zope3/trunk/src/zope/app/component/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/component/meta.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/meta.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -2,33 +2,10 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta">
+ <include package="zope.component" file="meta.zcml" />
+
<meta:directives namespace="http://namespaces.zope.org/zope">
- <meta:directive
- name="interface"
- schema=".metadirectives.IInterfaceDirective"
- handler="zope.app.component.metaconfigure.interface"
- />
-
- <meta:directive
- name="adapter"
- schema=".metadirectives.IAdapterDirective"
- handler="zope.app.component.metaconfigure.adapter"
- />
-
- <meta:directive
- name="subscriber"
- schema=".metadirectives.ISubscriberDirective"
- handler="zope.app.component.metaconfigure.subscriber"
- />
-
-
- <meta:directive
- name="utility"
- schema=".metadirectives.IUtilityDirective"
- handler="zope.app.component.metaconfigure.utility"
- />
-
<!-- BBB 2006/02/24, to be removed after 12 months -->
<meta:directive
name="factory"
Modified: Zope3/trunk/src/zope/app/component/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/component/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,255 +18,28 @@
__docformat__ = 'restructuredtext'
import warnings
-import zope.interface
+import zope.component
from zope import component
+from zope.interface import Interface
+from zope.component.zcml import handler, proxify, utility
+from zope.component.interface import provideInterface
from zope.component.interfaces import IDefaultViewName, IFactory
from zope.configuration.exceptions import ConfigurationError
-from zope.interface import Interface, providedBy
-from zope.interface.interfaces import IInterface
-from zope.proxy import ProxyBase, getProxiedObject
-
-from zope.security.checker import InterfaceChecker, CheckerPublic
+from zope.security.checker import CheckerPublic
from zope.security.checker import Checker, NamesChecker
-from zope.security.proxy import Proxy
+import zope.deferredimport
-from zope.app import zapi
-from zope.app.security.adapter import LocatingTrustedAdapterFactory
-from zope.app.security.adapter import LocatingUntrustedAdapterFactory
-from zope.app.security.adapter import TrustedAdapterFactory
-
PublicPermission = 'zope.Public'
-def handler(methodName, *args, **kwargs):
- method=getattr(zapi.getGlobalSiteManager(), methodName)
- method(*args, **kwargs)
+zope.deferredimport.deprecatedFrom(
+ "Moved to zope.component.zcml. Importing from here will stop working "
+ "in Zope 3.5",
+ "zope.component.zcml",
+ "handler", "adapter", "subscriber", "utility", "interface",
+ )
+
-from zope.app.component.interface import provideInterface
-def interface(_context, interface, type=None, name=''):
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = (name, interface, type)
- )
-
-class PermissionProxy(ProxyBase):
-
- __slots__ = ('__Security_checker__', )
-
- def __providedBy__(self):
- return providedBy(getProxiedObject(self))
- __providedBy__ = property(__providedBy__)
-
-def proxify(ob, checker):
- """Try to get the object proxied with the `checker`, but not too soon
-
- We really don't want to proxy the object unless we need to.
- """
-
- ob = PermissionProxy(ob)
- ob.__Security_checker__ = checker
- return ob
-
-_handler=handler
-def subscriber(_context, for_=None, factory=None, handler=None, provides=None,
- permission=None, trusted=False, locate=False):
-
-
- if factory is None:
- if handler is None:
- raise TypeError("No factory or handler provided")
- if provides is not None:
- raise TypeError("Cannot use handler with provides")
- factory = handler
- else:
- if handler is not None:
- raise TypeError("Cannot use handler with factory")
- if provides is None:
- import warnings
- warnings.warn(
- "\n %s\n"
- "Use of factory without provides to indicate a handler "
- "is deprecated and will change it's meaning in Zope 3.3. "
- "Use the handler attribute instead."
- % _context.info,
- DeprecationWarning)
-
- if for_ is None:
- for_ = component.adaptedBy(factory)
- if for_ is None:
- raise TypeError("No for attribute was provided and can't "
- "determine what the factory (or handler) adapts.")
-
- if permission is not None:
- if permission == PublicPermission:
- permission = CheckerPublic
- checker = InterfaceChecker(provides, permission)
- factory = _protectedFactory(factory, checker)
-
- for_ = tuple(for_)
-
- # invoke custom adapter factories
- if locate or (permission is not None and permission is not CheckerPublic):
- if trusted:
- factory = LocatingTrustedAdapterFactory(factory)
- else:
- factory = LocatingUntrustedAdapterFactory(factory)
- else:
- if trusted:
- factory = TrustedAdapterFactory(factory)
-
- _context.action(
- discriminator = None,
- callable = _handler,
- args = ('subscribe',
- for_, provides, factory, _context.info),
- )
-
- if provides is not None:
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = ('', provides)
- )
-
- # For each interface, state that the adapter provides that interface.
- for iface in for_:
- if iface is not None:
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = ('', iface)
- )
-
-def adapter(_context, factory, provides=None, for_=None, permission=None,
- name='', trusted=False, locate=False):
-
- if for_ is None:
- if len(factory) == 1:
- for_ = component.adaptedBy(factory[0])
-
- if for_ is None:
- raise TypeError("No for attribute was provided and can't "
- "determine what the factory adapts.")
-
- for_ = tuple(for_)
-
- if provides is None:
- if len(factory) == 1:
- p = list(zope.interface.implementedBy(factory[0]))
- if len(p) == 1:
- provides = p[0]
-
- if provides is None:
- raise TypeError("Missing 'provides' attribute")
-
- # Generate a single factory from multiple factories:
- factories = factory
- if len(factories) == 1:
- factory = factories[0]
- elif len(factories) < 1:
- raise ValueError("No factory specified")
- elif len(factories) > 1 and len(for_) != 1:
- raise ValueError("Can't use multiple factories and multiple for")
- else:
- factory = _rolledUpFactory(factories)
-
- if permission is not None:
- if permission == PublicPermission:
- permission = CheckerPublic
- checker = InterfaceChecker(provides, permission)
- factory = _protectedFactory(factory, checker)
-
- # invoke custom adapter factories
- if locate or (permission is not None and permission is not CheckerPublic):
- if trusted:
- factory = LocatingTrustedAdapterFactory(factory)
- else:
- factory = LocatingUntrustedAdapterFactory(factory)
- else:
- if trusted:
- factory = TrustedAdapterFactory(factory)
-
- _context.action(
- discriminator = ('adapter', for_, provides, name),
- callable = handler,
- args = ('provideAdapter',
- for_, provides, name, factory, _context.info),
- )
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = ('', provides)
- )
- if for_:
- for iface in for_:
- if iface is not None:
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = ('', iface)
- )
-
-def _rolledUpFactory(factories):
- # This has to be named 'factory', aparently, so as not to confuse
- # apidoc :(
- def factory(ob):
- for f in factories:
- ob = f(ob)
- return ob
- # Store the original factory for documentation
- factory.factory = factories[0]
- return factory
-
-def _protectedFactory(original_factory, checker):
- # This has to be named 'factory', aparently, so as not to confuse
- # apidoc :(
- def factory(*args):
- ob = original_factory(*args)
- try:
- ob.__Security_checker__ = checker
- except AttributeError:
- ob = Proxy(ob, checker)
-
- return ob
- factory.factory = original_factory
- return factory
-
-
-def utility(_context, provides=None, component=None, factory=None,
- permission=None, name=''):
- if factory:
- if component:
- raise TypeError("Can't specify factory and component.")
- component = factory()
-
- if provides is None:
- provides = list(zope.interface.providedBy(component))
- if len(provides) == 1:
- provides = provides[0]
- else:
- raise TypeError("Missing 'provides' attribute")
-
- if permission is not None:
- if permission == PublicPermission:
- permission = CheckerPublic
- checker = InterfaceChecker(provides, permission)
-
- component = proxify(component, checker)
-
- _context.action(
- discriminator = ('utility', provides, name),
- callable = handler,
- args = ('provideUtility',
- provides, component, name),
- )
- _context.action(
- discriminator = None,
- callable = provideInterface,
- args = (provides.__module__ + '.' + provides.getName(), provides)
- )
-
# BBB 2006/02/24, to be removed after 12 months
def factory(_context, component, id, title=None, description=None):
try:
@@ -343,8 +116,8 @@
_context.action(
discriminator = ('resource', name, type, provides),
callable = handler,
- args = ('provideAdapter',
- (type,), provides, name, factory, _context.info),
+ args = ('registerAdapter',
+ factory, (type,), provides, name, _context.info),
)
_context.action(
discriminator = None,
@@ -420,8 +193,8 @@
_context.action(
discriminator = ('view', for_, name, provides),
callable = handler,
- args = ('provideAdapter',
- for_, provides, name, factory, _context.info),
+ args = ('registerAdapter',
+ factory, for_, provides, name, _context.info),
)
if type is not None:
_context.action(
@@ -444,16 +217,16 @@
callable = provideInterface,
args = ('', iface)
)
-
############################################################################
# BBB: Deprecated. Will go away in 3.3.
+
def defaultView(_context, type, name, for_):
_context.action(
discriminator = ('defaultViewName', for_, type, name),
callable = handler,
- args = ('provideAdapter',
- (for_, type), IDefaultViewName, '', name, _context.info)
+ args = ('registerAdapter',
+ name, (for_, type), IDefaultViewName, '',_context.info)
)
_context.action(
@@ -473,8 +246,8 @@
'The zope:defaultView directive has been deprecated in favor of '
'the browser:defaultView directive. '
'Will be gone in Zope 3.3.')
-############################################################################
+############################################################################
# BBB: Deprecated. Will go away in 3.4.
def defaultLayer(_context, type, layer):
import warnings
Modified: Zope3/trunk/src/zope/app/component/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/component/metadirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/metadirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,12 +18,12 @@
__docformat__ = 'restructuredtext'
import zope.configuration.fields
+import zope.security.zcml
import zope.interface
import zope.schema
+from zope.component.zcml import IBasicComponentInformation
-import zope.app.security.fields
-import zope.app.component.fields
-
+from zope.app.component.back35 import LayerField
from zope.app.i18n import ZopeMessageFactory as _
class IDefaultViewName(zope.interface.Interface):
@@ -33,33 +33,6 @@
specified one.
"""
-class IBasicComponentInformation(zope.interface.Interface):
-
- component = zope.configuration.fields.GlobalObject(
- title=_("Component to use"),
- description=_("Python name of the implementation object. This"
- " must identify an object in a module using the"
- " full dotted name. If specified, the"
- " ``factory`` field must be left blank."),
- required=False,
- )
-
- permission = zope.app.security.fields.Permission(
- title=_("Permission"),
- description=_("Permission required to use this component."),
- required=False,
- )
-
- factory = zope.configuration.fields.GlobalObject(
- title=_("Factory"),
- description=_("Python name of a factory which can create the"
- " implementation object. This must identify an"
- " object in a module using the full dotted name."
- " If specified, the ``component`` field must"
- " be left blank."),
- required=False,
- )
-
class IBasicViewInformation(zope.interface.Interface):
"""This is the basic information for all views."""
@@ -73,7 +46,7 @@
),
)
- permission = zope.app.security.fields.Permission(
+ permission = zope.security.zcml.Permission(
title=_("Permission"),
description=_("The permission needed to use the view."),
required=False,
@@ -86,7 +59,7 @@
)
# BBB 2006/02/18, to be removed after 12 months
- layer = zope.app.component.fields.LayerField(
+ layer = LayerField(
title=_("The layer the view is in."),
description=_("""
A skin is composed of layers. It is common to put skin
@@ -147,176 +120,7 @@
required=True
)
-class IInterfaceDirective(zope.interface.Interface):
- """
- Define an interface
- """
- interface = zope.configuration.fields.GlobalInterface(
- title=_("Interface"),
- required=True,
- )
-
- type = zope.configuration.fields.GlobalInterface(
- title=_("Interface type"),
- required=False,
- )
-
- name = zope.schema.TextLine(
- title=_("Name"),
- required=False,
- )
-
-class IAdapterDirective(zope.interface.Interface):
- """
- Register an adapter
- """
-
- factory = zope.configuration.fields.Tokens(
- title=_("Adapter factory/factories"),
- description=_("A list of factories (usually just one) that create"
- " the adapter instance."),
- required=True,
- value_type=zope.configuration.fields.GlobalObject()
- )
-
- provides = zope.configuration.fields.GlobalInterface(
- title=_("Interface the component provides"),
- description=_("This attribute specifies the interface the adapter"
- " instance must provide."),
- required=False,
- )
-
- for_ = zope.configuration.fields.Tokens(
- title=_("Specifications to be adapted"),
- description=_("This should be a list of interfaces or classes"),
- required=False,
- value_type=zope.configuration.fields.GlobalObject(
- missing_value=object(),
- ),
- )
-
- permission = zope.app.security.fields.Permission(
- title=_("Permission"),
- description=_("This adapter is only available, if the principal"
- " has this permission."),
- required=False,
- )
-
- name = zope.schema.TextLine(
- title=_("Name"),
- description=_("Adapters can have names.\n\n"
- "This attribute allows you to specify the name for"
- " this adapter."),
- required=False,
- )
-
- trusted = zope.configuration.fields.Bool(
- title=_("Trusted"),
- description=_("""Make the adapter a trusted adapter
-
- Trusted adapters have unfettered access to the objects they
- adapt. If asked to adapt security-proxied objects, then,
- rather than getting an unproxied adapter of security-proxied
- objects, you get a security-proxied adapter of unproxied
- objects.
- """),
- required=False,
- default=False,
- )
-
- locate = zope.configuration.fields.Bool(
- title=_("Locate"),
- description=_("""Make the adapter a locatable adapter
-
- Located adapter should be used if a non-public permission
- is used.
- """),
- required=False,
- default=False,
- )
-
-class ISubscriberDirective(zope.interface.Interface):
- """
- Register a subscriber
- """
-
- factory = zope.configuration.fields.GlobalObject(
- title=_("Subscriber factory"),
- description=_("A factory used to create the subscriber instance."),
- required=False,
- )
-
- handler = zope.configuration.fields.GlobalObject(
- title=_("Handler"),
- description=_("A callable object that handles events."),
- required=False,
- )
-
- provides = zope.configuration.fields.GlobalInterface(
- title=_("Interface the component provides"),
- description=_("This attribute specifies the interface the adapter"
- " instance must provide."),
- required=False,
- )
-
- for_ = zope.configuration.fields.Tokens(
- title=_("Interfaces or classes that this subscriber depends on"),
- description=_("This should be a list of interfaces or classes"),
- required=False,
- value_type=zope.configuration.fields.GlobalObject(
- missing_value = object(),
- ),
- )
-
- permission = zope.app.security.fields.Permission(
- title=_("Permission"),
- description=_("This subscriber is only available, if the"
- " principal has this permission."),
- required=False,
- )
-
- trusted = zope.configuration.fields.Bool(
- title=_("Trusted"),
- description=_("""Make the subscriber a trusted subscriber
-
- Trusted subscribers have unfettered access to the objects they
- adapt. If asked to adapt security-proxied objects, then,
- rather than getting an unproxied subscriber of security-proxied
- objects, you get a security-proxied subscriber of unproxied
- objects.
- """),
- required=False,
- default=False,
- )
-
- locate = zope.configuration.fields.Bool(
- title=_("Locate"),
- description=_("""Make the subscriber a locatable subscriber
-
- Located subscribers should be used if a non-public permission
- is used.
- """),
- required=False,
- default=False,
- )
-
-class IUtilityDirective(IBasicComponentInformation):
- """Register a utility."""
-
- provides = zope.configuration.fields.GlobalInterface(
- title=_("Provided interface"),
- description=_("Interface provided by the utility."),
- required=False,
- )
-
- name = zope.schema.TextLine(
- title=_("Name"),
- description=_("Name of the registration. This is used by"
- " application code when locating a utility."),
- required=False,
- )
-
# BBB 2006/02/24, to be removed after 12 months
class IFactoryDirective(zope.interface.Interface):
"""Define a factory"""
@@ -382,7 +186,7 @@
"""Register a resource"""
# BBB 2006/02/18, to be removed after 12 months
- layer = zope.app.component.fields.LayerField(
+ layer = LayerField(
title=_("The layer the resource is in. This argument has been "
"deprecated and will be removed in Zope 3.5. Use the "
"'type' argument instead."),
@@ -427,7 +231,7 @@
given Interface require a given permission for access.
"""
- permission = zope.app.security.fields.Permission(
+ permission = zope.security.zcml.Permission(
title=_("Permission"),
description=_("""
Specifies the permission by id that will be required to
Modified: Zope3/trunk/src/zope/app/component/registration.py
===================================================================
--- Zope3/trunk/src/zope/app/component/registration.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/registration.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,257 +15,30 @@
$Id$
"""
-from persistent import Persistent
-import zope.event
-from zope.component import subscribers
-from zope.interface import implements
-from zope.security.checker import InterfaceChecker, CheckerPublic
-from zope.security.proxy import Proxy, removeSecurityProxy
+import zope.deferredimport
-from zope.app import zapi
-from zope.app.component.interfaces import registration as interfaces
-from zope.app.container.btree import BTreeContainer
-from zope.app.container.contained import Contained
-from zope.app.dependable.interfaces import IDependable, DependencyError
-from zope.app.event import objectevent
-from zope.app.location import inside
-from zope.app.traversing.interfaces import TraversalError
-from zope.app.i18n import ZopeMessageFactory as _
+zope.deferredimport.deprecatedFrom(
+ """The old registration APIs, are deprecated and will go away in Zope 3.5
-# BBB: First introduced in 3.1; should go away in 3.3
-import bbb
+ See the newer component-registration APIs in
+ zope.component.interfaces.IComponentRegistry.
+ """,
+ "zope.app.component.back35",
+ 'RegistrationStatusProperty',
+ 'SimpleRegistration',
+ 'ComponentRegistration',
+ 'Registered',
+ 'RegistrationManager',
+ 'RegisterableContainer',
+ 'RegistrationManagerNamespace',
+ )
-
-class RegistrationEvent(objectevent.ObjectEvent):
- """An event that is created when a registration-related activity occurred.
- """
- implements(interfaces.IRegistrationEvent)
-
-class RegistrationActivatedEvent(RegistrationEvent):
- """An event that is created when a registration is activated."""
- implements(interfaces.IRegistrationActivatedEvent)
-
-class RegistrationDeactivatedEvent(RegistrationEvent):
- """An event that is created when a registration is deactivated."""
- implements(interfaces.IRegistrationDeactivatedEvent)
-
-
-class RegistrationStatusProperty(object):
- """A descriptor used to implement `IRegistration`'s `status` property."""
- def __get__(self, inst, klass):
- registration = inst
- if registration is None:
- return self
-
- registry = registration.getRegistry()
- if registry and registry.registered(registration):
- return interfaces.ActiveStatus
-
- return interfaces.InactiveStatus
-
- def __set__(self, inst, value):
- registration = inst
- registry = registration.getRegistry()
- if registry is None:
- raise ValueError('No registry found.')
-
- if value == interfaces.ActiveStatus:
- if not registry.registered(registration):
- registry.register(registration)
- zope.event.notify(RegistrationActivatedEvent(registration))
-
- elif value == interfaces.InactiveStatus:
- if registry.registered(registration):
- registry.unregister(registration)
- zope.event.notify(RegistrationDeactivatedEvent(registration))
- else:
- raise ValueError(value)
-
-
-class SimpleRegistration(Persistent, Contained):
- """Registration objects that just contain registration data"""
- implements(interfaces.IRegistration,
- interfaces.IRegistrationManagerContained)
-
- # See interfaces.IRegistration
- status = RegistrationStatusProperty()
-
- def getRegistry(self):
- """See interfaces.IRegistration"""
- raise NotImplementedError(
- 'This method must be implemented by each specific regstration.')
-
-
-class ComponentRegistration(bbb.registration.BBBComponentRegistration,
- SimpleRegistration):
- """Component registration.
-
- Subclasses should define a getInterface() method returning the interface
- of the component.
- """
- implements(interfaces.IComponentRegistration)
-
- def __init__(self, component, permission=None):
- # BBB: Will go away in 3.3.
- super(ComponentRegistration, self).__init__(component, permission)
- # self.component = component
- if permission == 'zope.Public':
- permission = CheckerPublic
- self.permission = permission
-
- def _getComponent(self):
- if self.permission and self.interface:
- checker = InterfaceChecker(self.interface, self.permission)
- return Proxy(self._component, checker)
- return self._component
-
- def _setComponent(self, component):
- # We always want to set the plain component. Untrusted code will
- # get back a proxied component anyways.
- self._component = removeSecurityProxy(component)
-
- # See zope.app.component.interfaces.registration.IComponentRegistration
- component = property(_getComponent, _setComponent)
-
- # See zope.app.component.interfaces.registration.IComponentRegistration
- interface = None
-
-
-def SimpleRegistrationRemoveSubscriber(registration, event):
- """Receive notification of remove event."""
- sm = zapi.getSiteManager(registration)
- removed = event.object
- if (sm == removed) or inside(sm, removed):
- # we don't really care if the registration is active, since the site
- # is going away.
- return
-
- objectstatus = registration.status
-
- if objectstatus == interfaces.ActiveStatus:
- try:
- objectpath = zapi.getPath(registration)
- except: # TODO decide if this is really the best fall-back plan
- objectpath = str(registration)
- msg = _("Can't delete active registration (${path})",
- mapping={u'path': objectpath})
- raise DependencyError(msg)
-
-
-def ComponentRegistrationRemoveSubscriber(componentRegistration, event):
- """Receive notification of remove event."""
- component = componentRegistration.component
- try:
- dependents = IDependable(component)
- except TypeError:
- return
- objectpath = zapi.getPath(componentRegistration)
- dependents.removeDependent(objectpath)
-
-
-def ComponentRegistrationAddSubscriber(componentRegistration, event):
- """Receive notification of add event."""
- component = componentRegistration.component
- try:
- dependents = IDependable(component)
- except TypeError:
- return
- objectpath = zapi.getPath(componentRegistration)
- dependents.addDependent(objectpath)
-
-
-def componentRegistrationEventNotify(componentReg, event):
- """Subscriber to dispatch registration events for components."""
- adapters = subscribers((componentReg.component, event), None)
- for adapter in adapters:
- pass # getting them does the work
-
-
-def RegisterableMoveSubscriber(registerable, event):
- """A registerable cannot be moved as long as it has registrations in the
- registration manager."""
- if event.oldParent is not None and event.newParent is not None:
- if event.oldParent is not event.newParent:
- raise DependencyError(
- _("Can't move a registered component from its container."))
-
-
-class Registered(bbb.registration.BBBRegistered, object):
- """An adapter from IRegisterable to IRegistered.
-
- This class is the only place that knows how 'Registered'
- data is represented.
- """
- implements(interfaces.IRegistered)
- __used_for__ = interfaces.IRegisterable
-
- def __init__(self, registerable):
- self.registerable = registerable
-
- def registrations(self):
- rm = zapi.getParent(self.registerable).registrationManager
- return [reg for reg in rm.values()
- if (interfaces.IComponentRegistration.providedBy(reg) and
- reg.component is self.registerable)]
-
-
-class RegistrationManager(bbb.registration.BBBRegistrationManager,
- BTreeContainer):
- """Registration manager
-
- Manages registrations within a package.
- """
- implements(interfaces.IRegistrationManager)
-
- def addRegistration(self, reg):
- "See IWriteContainer"
- key = self._chooseName('', reg)
- self[key] = reg
- return key
-
- def _chooseName(self, name, reg):
- """Choose a name for the registration."""
- if not name:
- name = reg.__class__.__name__
-
- i = 1
- chosenName = name
- while chosenName in self:
- i += 1
- chosenName = name + str(i)
-
- return chosenName
-
-
-class RegisterableContainer(bbb.registration.BBBRegisterableContainer):
- """Mix-in to implement `IRegisterableContainer`"""
- implements(interfaces.IRegisterableContainer,
- interfaces.IRegisterableContainerContaining)
-
- def __init__(self):
- super(RegisterableContainer, self).__init__()
- self.__createRegistrationManager()
-
- def __createRegistrationManager(self):
- "Create a registration manager and store it as `registrationManager`"
- # See interfaces.IRegisterableContainer
- self.registrationManager = RegistrationManager()
- self.registrationManager.__parent__ = self
- self.registrationManager.__name__ = '++registrations++'
- zope.event.notify(
- objectevent.ObjectCreatedEvent(self.registrationManager))
-
-
-class RegistrationManagerNamespace(object):
- """Used to traverse to a Registration Manager from a
- Registerable Container."""
- __used_for__ = interfaces.IRegisterableContainer
-
- def __init__(self, ob, request=None):
- self.context = ob.registrationManager
-
- def traverse(self, name, ignore):
- if name == '':
- return self.context
- raise TraversalError(self.context, name)
+zope.deferredimport.deprecated(
+ "Registration events are now defined in zope.component.interfaces. "
+ "Importing them from zope.app.component.registration will be disallowed "
+ "in Zope 3.5",
+ RegistrationEvent = 'zope.component.interfaces:RegistrationEvent',
+ RegistrationActivatedEvent = 'zope.component.interfaces:Registered',
+ RegistrationDeactivatedEvent = 'zope.component.interfaces:Unregistered',
+ )
Deleted: Zope3/trunk/src/zope/app/component/registration.txt
===================================================================
--- Zope3/trunk/src/zope/app/component/registration.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/registration.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,461 +0,0 @@
-==========================
-The Registration Framework
-==========================
-
-The registration framework's task is to manage registrations and ensure that
-the correct registrations are inserted into the correct registries. Each
-registration knows to which registry it belongs. If a registration is set
-active, then the registration is added to the regstry; when inactive, it is
-removed from the registry. Please see `statusproperty.txt` for a demonstration
-on how the setting of the registration's status affects the registry.
-
-The true power of the registration framework, however, comes from the ability
-to provide registrations for registerable components. In the context of Zope
-3's component architecture, registerable components are adapters and
-utilities. Since the registration framework can be used for any kind of
-component registration, I am going to refer to registerable components
-(including adapters and interface) as components.
-
-The first task is to create a simple component registry. It will implement all
-required `IRegistry` methods and a `getComponents()` method, which will return
-a list of all registered (active) components.
-
- >>> import zope.interface
- >>> from zope.app.component import interfaces
- >>> class ComponentRegistry(object):
- ... zope.interface.implements(interfaces.registration.IRegistry)
- ...
- ... def __init__(self):
- ... self._registrations = []
- ...
- ... def registrations(self):
- ... """See zope.component.interfaces.IRegistry"""
- ... return self._registrations
- ...
- ... def register(self, registration):
- ... """See interfaces.registration.IRegistry"""
- ... self._registrations.append(registration)
- ...
- ... def unregister(self, registration):
- ... """See interfaces.registration.IRegistry"""
- ... del self._registrations[self._registrations.index(registration)]
- ...
- ... def registered(self, registration):
- ... """See interfaces.registration.IRegistry"""
- ... return registration in self._registrations
- ...
- ... def getComponents(self):
- ... return [reg.component for reg in self.registrations()]
-
- >>> registry = ComponentRegistry()
-
-Effectively, a registry manages a set of active registrations. A simple
-UML diagram would be::
-
- ---------------------------
- --------------- * 1 | IRegistration |
- | IRegistry |-------| - - - - - - - - - - - - |
- --------------- | status = ActiveStatus |
- ---------------------------
-
-Next we need to create a registration object that can register components with
-our new registry. The framework already provides a base-class for
-component-based registrations, so that we only need to implement the
-`getRegistry()` method:
-
- >>> from zope.app.component.registration import ComponentRegistration
- >>> class Registration(ComponentRegistration):
- ...
- ... def getRegistry(self):
- ... global registry
- ... return registry
- ...
- ... def __repr__(self):
- ... return "<Registration for '%s'>" %self.component
-
-In the implementation above, all `Registration` instances are simply going to
-use the global `registry` object. Now that we have a registry and a suitable
-registration class, let's test what we have so far. To do that we have to
-create a component that we would like to register:
-
- >>> from zope.app.container.contained import Contained
- >>> class Component(Contained):
- ... zope.interface.implements(interfaces.registration.IRegisterable)
- ... def __init__(self, title=u''):
- ... self.title = title
- ... def __repr__(self):
- ... return "<Component: '%s'>" %self.title
-
-Note that `Contained` is used as a base class, since `IRegisterable` requires
-it to be. We will later see why this is the case.
-
-Before we are registering any component, the registry is empty:
-
- >>> registry.getComponents()
- []
-
-Now we create a component and a registration:
-
- >>> foo = Component('Foo')
- >>> regFoo = Registration(foo)
- >>> regFoo.component
- <Component: 'Foo'>
- >>> regFoo.status
- u'Inactive'
-
-Finally, we activate the registration:
-
-
- >>> regFoo.status = interfaces.registration.ActiveStatus
- >>> regFoo.status
- u'Active'
- >>> registry.getComponents()
- [<Component: 'Foo'>]
-
-Of course, we can add a second registered component:
-
- >>> bar = Component('Bar')
- >>> regBar = Registration(bar)
- >>> regBar.component
- <Component: 'Bar'>
- >>> regBar.status
- u'Inactive'
- >>> regBar.status = interfaces.registration.ActiveStatus
- >>> regBar.status
- u'Active'
- >>> registry.getComponents()
- [<Component: 'Foo'>, <Component: 'Bar'>]
-
-Of course, when deactivating a registration, it will be gone from the registry
-as well:
-
- >>> regFoo.status = interfaces.registration.InactiveStatus
- >>> regFoo.status
- u'Inactive'
- >>> registry.getComponents()
- [<Component: 'Bar'>]
-
-This is everything that there is about registrations and their interaction
-with a registry. However, the point of registrations and registerable
-components is that they should be persistent (otherwise we could use
-ZCML). Thus we need a way of managing local components and their
-registrations.
-
-
-Management of Local Components and Registrations
-------------------------------------------------
-
-The starting point here is the `IRegisterableContainer`, which can contain
-`IRegiserable` and other `IRegisterableContainer` components.
-
- >>> from zope.app.container.btree import BTreeContainer
- >>> from zope.app.component.registration import RegisterableContainer
-
- >>> class RegisterableManager(RegisterableContainer, BTreeContainer):
- ... pass
- >>> registerables = RegisterableManager()
-
-The `RegisterableContainer` class is merely a mixin and leaves it up to the
-developer to implement the `IContainer` interface. In our case, we simply used
-the default btree container implementation to provide the container
-interface. However, the `RegisterableContainer` class does implement the
-`IRegisterableContainer` interface, which means it ensures the existance of
-the `registrationManager` attribute, which always contains an
-`IRegistrationManager` instance:
-
- >>> registerables.registrationManager is not None
- True
- >>> interfaces.registration.IRegistrationManager.providedBy(
- ... registerables.registrationManager)
- True
-
-The registration manager is a simple container that can only contain
-components providing `IRegistration` and implements a method called
-`addRegistration(registration)` that lets you add a registration to the
-manager without specifying a name. The name will be automatically chosen for
-you and is returned. So let's add our two existing components and their
-registrations:
-
- >>> regManager = registerables.registrationManager
-
- >>> registerables['foo'] = foo
- >>> regManager.addRegistration(regFoo)
- 'Registration'
-
- >>> registerables['bar'] = bar
- >>> regManager.addRegistration(regBar)
- 'Registration2'
-
- >>> items = list(registerables.items())
- >>> items.sort()
- >>> items
- [(u'bar', <Component: 'Bar'>), (u'foo', <Component: 'Foo'>)]
- >>> regs = list(regManager.items())
- >>> regs.sort()
- >>> regs #doctest: +NORMALIZE_WHITESPACE
- [(u'Registration', <Registration for '<Component: 'Foo'>'>),
- (u'Registration2', <Registration for '<Component: 'Bar'>'>)]
-
-Of course, adding a registration to the registration manager does not mean the
-registration is added to the registry, since it still may not be active:
-
- >>> registry.getComponents()
- [<Component: 'Bar'>]
-
-Also, there are no restrictions on how many registrations you can create for a
-single component. For example, we can register the `foo` one more time:
-
- >>> regFoo2 = Registration(foo)
- >>> regManager.addRegistration(regFoo2)
- 'Registration3'
- >>> regs = list(regManager.items())
- >>> regs.sort()
- >>> regs #doctest: +NORMALIZE_WHITESPACE
- [(u'Registration', <Registration for '<Component: 'Foo'>'>),
- (u'Registration2', <Registration for '<Component: 'Bar'>'>),
- (u'Registration3', <Registration for '<Component: 'Foo'>'>)]
-
-This also means that our registry can provide a component multiple times:
-
- >>> regFoo.status = interfaces.registration.ActiveStatus
- >>> regFoo2.status = interfaces.registration.ActiveStatus
- >>> registry.getComponents()
- [<Component: 'Bar'>, <Component: 'Foo'>, <Component: 'Foo'>]
-
-Here is a UML diagram of the registerable container and registration manager
-and their relationships to the other registration-related components we
-discussed.
-
-::
-
- ----------------------------
- | IRegisterableContainer |
- | - - - - - - - - - - - - -|
- | 1 | 1 --------------------------
- | registrationManager ----+------| IRegistrationManager |
- | | --------------------------
- ---------------------------+ | *
- | * | * | 1 |
- | | | | 1
- | 1 +----+ -------------------
- ------------------- | IRegistration |
- | IRegisterable | -------------------
- ------------------- | *
- |
- --------------- 1 |
- | IRegistry |------+ if status == Active
- ---------------
-
-
-The ++registrations++ traversal namespace
------------------------------------------
-
-To make the registration manager easier accessible via a traversal path, a
-special traversal namespace has been implemented. But first we have to
-register the traversal namespace:
-
- >>> from zope.app.traversing.interfaces import ITraversable
- >>> from zope.app.component.registration import RegistrationManagerNamespace
- >>> from zope.app.testing import ztapi
- >>> ztapi.provideAdapter(
- ... interfaces.registration.IRegisterableContainer,
- ... ITraversable,
- ... RegistrationManagerNamespace,
- ... 'registrations')
-
-Now we can use the namespace during traversal:
-
- >>> from zope.app.traversing.api import traverse
- >>> traverse(registerables, '++registrations++') is regManager
- True
-
-
-The Component Registration
---------------------------
-
-Until now we have only discussed the most primitive usage of the
-`ComponentRegistration`. Usually, a registry is not just interested in a
-component, but a set of methods which are specified by a particular
-interface. Thus the component registration supports the `interface`
-attribute. By default it is `None`:
-
- >>> regFoo.interface is None
- True
-
-We can now write another `IComponentRegistration` implementation that knows
-about the interface; in fact, it will pick the most specific one of the
-component:
-
- >>> from zope.interface import providedBy
- >>> class SomethingRegistration(Registration):
- ...
- ... def interface(self):
- ... return list(providedBy(self._component))[0]
- ... interface = property(interface)
-
-Next we create an interface and its implementation:
-
- >>> class ISomething(zope.interface.Interface):
- ... pass
-
- >>> class Something(Component):
- ... zope.interface.implements(ISomething)
-
-Creating a "something registration", we can see that the interface attribute
-is now available:
-
- >>> something = Something('Something')
- >>> reg = SomethingRegistration(something)
- >>> reg.interface
- <InterfaceClass __builtin__.ISomething>
-
-But hold on, we are not done yet! The component registration also supports a
-`permission` attribute. When set and an interface is available, the component
-will always be proxied using an interface checker for the specified
-permission. By default the permission is `None`:
-
- >>> reg.permission is None
- True
-
-Now we set a permission for the registration and the component should be
-proxies when returned:
-
- >>> from zope.security.checker import CheckerPublic
- >>> reg.permission = CheckerPublic
- >>> reg.component is something
- False
- >>> type(reg.component)
- <type 'zope.security._proxy._Proxy'>
-
-You can also, specify a permission in the constructor:
-
- >>> regNone = SomethingRegistration(None, 'zope.Public')
- >>> regNone.permission is CheckerPublic
- True
-
-If the interface is not available, the permission is ignored and the bare
-component is returned:
-
- >>> regSomething2 = Registration(something, 'zope.Public')
- >>> regSomething2.permission is CheckerPublic
- True
- >>> regSomething2.component is something
- True
-
-
-The `Registered` Adapter
-------------------------
-
-Registerable components are able to get a list of all their
-registrations. However, the adapter only works for components and
-registrations that are stored in the registerable container and registration
-manager, respectively.
-
- >>> from zope.app.component.registration import Registered
- >>> registered = Registered(foo)
- >>> registered.registrations() #doctest: +NORMALIZE_WHITESPACE
- [<Registration for '<Component: 'Foo'>'>,
- <Registration for '<Component: 'Foo'>'>]
-
-If the registerable component is not stored in a registrable container, a
-type error is raised, since no parent can be found:
-
- >>> registered = Registered(something)
- >>> registered.registrations() #doctest: +NORMALIZE_WHITESPACE
- Traceback (most recent call last):
- ...
- TypeError: ('Not enough context information to get parent',
- <Component: 'Something'>)
-
-
-Registrations and Dependencies
-------------------------------
-
-Registerable objects and registrations have a very close dependence. For
-example, it makes no sense to delete a registerable component and leave its
-registrations around. Instead, registrations always are required to be removed
-before the component. Thus, it is also not allowed to simply copy a
-registerable component to another registerable container:
-
- >>> orig = RegisterableManager()
- >>> new = RegisterableManager()
- >>> comp = Component('comp')
-
- >>> from zope.app.container.contained import ObjectMovedEvent
- >>> event = ObjectMovedEvent(comp, orig, 'comp', new, 'comp')
-
- >>> from zope.app.component.registration import RegisterableMoveSubscriber
- >>> RegisterableMoveSubscriber(comp, event)
- Traceback (most recent call last):
- ...
- DependencyError: Can't move a registered component from its container.
-
-Hoever, renaming the component is no problem:
-
- >>> event = ObjectMovedEvent(comp, orig, 'comp', orig, 'comp-new')
- >>> RegisterableMoveSubscriber(comp, event)
-
-Whenever a registration is created it is added as a dependence to the
-registerable component, which is removed once the registration is removed. Two
-subscribers handle the management of the dependemcies.
-
-Since the default `IDependable` adapter uses annotations to store the
-dependents, our component has to provide `IAttrbuteAnnotatable`:
-
- >>> from zope.app.annotation.interfaces import IAttributeAnnotatable
- >>> from zope.interface import directlyProvides
- >>> directlyProvides(comp, IAttributeAnnotatable)
-
-Make sure that we do not initially have any dependencies:
-
- >>> from zope.app.dependable.interfaces import IDependable
- >>> dependents = IDependable(comp)
- >>> dependents.getPaths()
- ()
-
-Since the path of the registration is used to store the dependency, we need to
-make sure that we have a containment root; so make the registration itself the
-root:
-
- >>> reg = Registration(comp)
- >>> from zope.app.traversing.interfaces import IContainmentRoot
- >>> directlyProvides(reg, IContainmentRoot)
-
-The component registration add subscriber adds a dependent.
-
- >>> from zope.app.container.contained import ObjectAddedEvent
- >>> from zope.app.component.registration import RegistrationManager
- >>> event = ObjectAddedEvent(reg, RegistrationManager(), 'reg1')
-
- >>> from zope.app.component.registration import \
- ... ComponentRegistrationAddSubscriber
- >>> ComponentRegistrationAddSubscriber(reg, event)
-
- >>> dependents = IDependable(comp)
- >>> dependents.getPaths()
- (u'/',)
-
-We simply got a slash here, since the registration is a root object. Now we
-remove the dependency again by calling the component registration remove
-subscriber:
-
- >>> from zope.app.container.contained import ObjectRemovedEvent
- >>> event = ObjectRemovedEvent(reg, RegistrationManager(), 'reg1')
-
- >>> from zope.app.component.registration import \
- ... ComponentRegistrationRemoveSubscriber
- >>> ComponentRegistrationRemoveSubscriber(reg, event)
-
- >>> dependents = IDependable(comp)
- >>> dependents.getPaths()
- ()
-
-Note that not all components of a registration must be adaptable to
-`IDependable`. This might be the case for components that are
-autogenerated. If this is the case, the subscribers should simply ignore those
-components:
-
- >>> reg.component = object()
- >>> ComponentRegistrationAddSubscriber(reg, event)
- >>> ComponentRegistrationRemoveSubscriber(reg, event)
-
\ No newline at end of file
Modified: Zope3/trunk/src/zope/app/component/site.py
===================================================================
--- Zope3/trunk/src/zope/app/component/site.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/site.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -28,19 +28,27 @@
import zope.event
import zope.interface
import zope.component
-from zope.component.exceptions import ComponentLookupError
+import zope.component.registry
+import zope.component.persistentregistry
+import zope.component.interfaces
+import zope.traversing.api
+import zope.deprecation
+import zope.deferredimport
+import zope.location
+
+from zope.component.interfaces import ComponentLookupError
+from zope.traversing.interfaces import IContainmentRoot
from zope.security.proxy import removeSecurityProxy
+from zope.lifecycleevent import ObjectCreatedEvent
+from zope.filerepresentation.interfaces import IDirectoryFactory
+import zope.app.component.back35
from zope.app import zapi
-from zope.app.component import adapter
from zope.app.component import interfaces
from zope.app.component import registration
from zope.app.component.hooks import setSite
from zope.app.container.btree import BTreeContainer
from zope.app.container.contained import Contained
-from zope.app.event import objectevent
-from zope.app.filerepresentation.interfaces import IDirectoryFactory
-from zope.app.traversing.interfaces import IContainmentRoot
##############################################################################
# from zope.app.module import resolve
@@ -65,10 +73,7 @@
# from zope.app.module import resolve
##############################################################################
-# Goes away in 3.3.
-import bbb.site
-
-class SiteManagementFolder(registration.RegisterableContainer,
+class SiteManagementFolder(zope.app.component.back35.RegisterableContainer,
BTreeContainer):
zope.interface.implements(interfaces.ISiteManagementFolder)
@@ -83,7 +88,7 @@
return SiteManagementFolder()
-class SiteManagerContainer(bbb.site.BBBSiteManagerContainer, Contained):
+class SiteManagerContainer(Contained):
"""Implement access to the site manager (++etc++site).
This is a mix-in that implements the IPossibleSite
@@ -91,8 +96,7 @@
"""
zope.interface.implements(interfaces.IPossibleSite)
- # BBB: Deactive in 3.3 again. Now provided by BBBSiteManagerContainer
- #_sm = None
+ _sm = None
def getSiteManager(self):
if self._sm is not None:
@@ -104,12 +108,12 @@
if interfaces.ISite.providedBy(self):
raise TypeError("Already a site")
- if zope.component.interfaces.ISiteManager.providedBy(sm):
+ if zope.component.interfaces.IComponentLookup.providedBy(sm):
self._sm = sm
sm.__name__ = '++etc++site'
sm.__parent__ = self
else:
- raise ValueError('setSiteManager requires an ISiteManager')
+ raise ValueError('setSiteManager requires an IComponentLookup')
zope.interface.directlyProvides(
self, interfaces.ISite,
@@ -124,7 +128,7 @@
return None
try:
- site = zapi.getParent(site)
+ site = zope.traversing.api.getParent(site)
except TypeError:
# there was not enough context; probably run from a test
return None
@@ -133,56 +137,67 @@
return site.getSiteManager()
-class LocalUtilityRegistry(adapter.LocalAdapterRegistry):
- """Custom local adapter registry for utilities, since utilities do not
- just register themselves as null adapters, but also as subscribers."""
+class _LocalAdapterRegistry(
+ zope.app.component.back35._LocalAdapterRegistryGeneration3SupportMixin,
+ zope.component.persistentregistry.PersistentAdapterRegistry,
+ zope.location.Location,
+ ):
+ pass
- def _updateAdaptersFromRegistration(self, radapters, registration):
- # Register as null adapter
- key = (False, registration.with, registration.name,
- registration.provided)
- radapters[key] = removeSecurityProxy(registration.component)
- # Register as subscriber
- key = (True, registration.with, '', registration.provided)
- radapters[key] = radapters.get(key, ()) + (
- removeSecurityProxy(registration.component), )
-
-
-class LocalSiteManager(BTreeContainer,
- bbb.site.BBBSiteManager,
- zope.component.site.SiteManager):
+class LocalSiteManager(
+ BTreeContainer,
+ zope.app.component.back35.LocalSiteGeneration3SupportMixin,
+ zope.component.persistentregistry.PersistentComponents,
+ ):
"""Local Site Manager implementation"""
- zope.interface.implements(
- interfaces.ILocalSiteManager,
- interfaces.registration.IRegisterableContainerContaining)
+ zope.interface.implements(interfaces.ILocalSiteManager)
- # See interfaces.registration.ILocatedRegistry
- next = None
subs = ()
- base = None
+ @property
+ @zope.deprecation.deprecate("Goes away in Zope 3.5. Use __bases__[0]")
+ def next(self):
+ if self.__bases__:
+ return self.__bases__[0]
+
+ def _setBases(self, bases):
+
+ # Update base subs
+ for base in self.__bases__:
+ if ((base not in bases)
+ and interfaces.ILocalSiteManager.providedBy(base)
+ ):
+ base.removeSub(self)
+
+ for base in bases:
+ if ((base not in self.__bases__)
+ and interfaces.ILocalSiteManager.providedBy(base)
+ ):
+ base.addSub(self)
+
+ super(LocalSiteManager, self)._setBases(bases)
+
def __init__(self, site):
# Locate the site manager
self.__parent__ = site
self.__name__ = '++etc++site'
- # Make sure everything is setup correctly
BTreeContainer.__init__(self)
-
- # Set up adapter registries
- gsm = zapi.getGlobalSiteManager()
- self.adapters = adapter.LocalAdapterRegistry(gsm.adapters)
- self.utilities = LocalUtilityRegistry(gsm.utilities)
-
- # Setup located registry attributes
+ zope.component.persistentregistry.PersistentComponents.__init__(self)
+
next = _findNextSiteManager(site)
- self.setNext(next)
+ if next is None:
+ next = zope.component.getGlobalSiteManager()
+ self.__bases__ = (next, )
# Setup default site management folder
folder = SiteManagementFolder()
- zope.event.notify(objectevent.ObjectCreatedEvent(folder))
+ zope.event.notify(ObjectCreatedEvent(folder))
self['default'] = folder
+ def _init_registries(self):
+ self.adapters = _LocalAdapterRegistry()
+ self.utilities = _LocalAdapterRegistry()
def addSub(self, sub):
"""See interfaces.registration.ILocatedRegistry"""
@@ -193,19 +208,9 @@
self.subs = tuple(
[s for s in self.subs if s is not sub] )
+ @zope.deprecation.deprecate("Will go away in Zope 3.5")
def setNext(self, next, base=None):
- """See interfaces.registration.ILocatedRegistry"""
- if self.next is not None:
- self.next.removeSub(self)
- if next is not None:
- next.addSub(self)
- self.next = next
- if next is not None:
- self.adapters.setNext(next.adapters)
- self.utilities.setNext(next.utilities)
- else:
- self.adapters.setNext(None)
- self.utilities.setNext(None)
+ self.__bases__ = tuple([b for b in (next, base) if b is not None])
def __getRegistry(self, registration):
"""Determine the correct registry for the registration."""
@@ -218,87 +223,150 @@
"provide `IAdapterRegistration` or "
"`IUtilityRegistration`.")
+ @zope.deprecation.deprecate(
+ "Local registration is now much simpler. The old baroque APIs "
+ "will go away in Zope 3.5. See the new component-registration APIs "
+ "defined in zope.component, especially IComponentRegistry.",
+ )
def register(self, registration):
- """See zope.app.component.interfaces.registration.IRegistry"""
- registry = self.__getRegistry(registration)
- registry.register(registration)
+ if interfaces.IUtilityRegistration.providedBy(registration):
+ self.registerUtility(
+ registration.component,
+ registration.provided,
+ registration.name,
+ )
+ elif interfaces.IAdapterRegistration.providedBy(registration):
+ self.registerAdapter(
+ registration.component,
+ (registration.required, ) + registration.with,
+ registration.provided,
+ registration.name,
+ )
+ try:
+ f = registration.activated
+ except AttributeError:
+ pass
+ else:
+ f()
+ @zope.deprecation.deprecate(
+ "Local registration is now much simpler. The old baroque APIs "
+ "will go away in Zope 3.5. See the new component-registration APIs "
+ "defined in zope.component, especially IComponentRegistry.",
+ )
def unregister(self, registration):
- """See zope.app.component.interfaces.registration.IRegistry"""
- registry = self.__getRegistry(registration)
- registry.unregister(registration)
+ if interfaces.IUtilityRegistration.providedBy(registration):
+ self.unregisterUtility(
+ registration.component,
+ registration.provided,
+ registration.name,
+ )
+ elif interfaces.IAdapterRegistration.providedBy(registration):
+ self.unregisterAdapter(
+ registration.component,
+ (registration.required, ) + registration.with,
+ registration.provided,
+ registration.name,
+ )
+ try:
+ f = registration.deactivated
+ except AttributeError:
+ pass
+ else:
+ f()
+ @zope.deprecation.deprecate(
+ "Local registration is now much simpler. The old baroque APIs "
+ "will go away in Zope 3.5. See the new component-registration APIs "
+ "defined in zope.component, especially IComponentRegistry.",
+ )
def registered(self, registration):
- """See zope.app.component.interfaces.registration.IRegistry"""
- return self.adapters.registered(registration) or \
- self.utilities.registered(registration)
+ if zope.component.interfaces.IUtilityRegistration.providedBy(
+ registration):
+ return bool([
+ r for r in self.registeredUtilities()
+ if (
+ r.component == registration.component
+ and
+ r.provided == registration.provided
+ and
+ r.name == registration.name
+ )
+ ])
+ elif zope.component.interfaces.IAdapterRegistration.providedBy(
+ registration):
+ return bool([
+ r for r in self.registeredAdapters()
+ if (
+ r.factory == registration.component
+ and
+ r.provided == registration.provided
+ and
+ r.name == registration.name
+ and
+ r.required == ((registration.required, )
+ + registration.with)
+ )
+ ])
+ elif (
+ zope.component.interfaces.ISubscriptionAdapterRegistration.providedBy(
+ registration)):
+ return bool([
+ r for r in self.registeredSubscriptionAdapters()
+ if (
+ r.factory == registration.component
+ and
+ r.provided == registration.provided
+ and
+ r.name == registration.name
+ and
+ r.required == ((registration.required, )
+ + registration.with)
+ )
+ ])
+ elif zope.component.interfaces.IHandlerRegistration.providedBy(
+ registration):
+ return bool([
+ r for r in self.registeredHandlers()
+ if (
+ r.factory == registration.component
+ and
+ r.provided == registration.provided
+ and
+ r.name == registration.name
+ and
+ r.required == ((registration.required, )
+ + registration.with)
+ )
+ ])
+ return False
+ @zope.deprecation.deprecate(
+ "Local registration is now much simpler. The old baroque APIs "
+ "will go away in Zope 3.5. See the new component-registration APIs "
+ "defined in zope.component, especially IComponentRegistry.",
+ )
def registrations(self):
"""See zope.component.interfaces.IRegistry"""
- for reg in self.adapters.registrations():
- yield reg
- for reg in self.utilities.registrations():
- yield reg
+ for r in self.registeredUtilities():
+ yield r
+ for r in self.registeredAdapters():
+ yield r
+ for r in self.registeredHandlers():
+ yield r
+ for r in self.registeredSubscriptionAdapters():
+ yield r
+zope.deferredimport.deprecated(
+ "Local registration is now much simpler. The old baroque APIs "
+ "will go away in Zope 3.5. See the new component-registration APIs "
+ "defined in zope.component, especially IComponentRegistry.",
+ LocalAdapterRegistry = 'zope.app.component.site:_LocalAdapterRegistry',
+ LocalUtilityRegistry = 'zope.app.component.site:_LocalAdapterRegistry',
+ UtilityRegistration = 'zope.app.component.back35:UtilityRegistration',
+ AdaptersRegistration = 'zope.app.component.back35:AdaptersRegistration',
+ )
-class AdapterRegistration(registration.ComponentRegistration):
- """Adapter component registration for persistent components
-
- This registration configures persistent components in packages to
- be adapters.
- """
- zope.interface.implements(interfaces.IAdapterRegistration)
-
- def __init__(self, required, provided, factoryName,
- name='', permission=None):
- if not isinstance(required, (tuple, list)):
- self.required = required
- self.with = ()
- else:
- self.required = required[0]
- self.with = tuple(required[1:])
- self.provided = provided
- self.name = name
- self.factoryName = factoryName
- self.permission = permission
-
- def component(self):
-# Didn't work ... tests failed
-## # Import here, so that we only have a soft dependence on
-## # zope.app.module
-## from zope.app.module import resolve
- factory = resolve(self.factoryName, self)
- return factory
- component = property(component)
-
- def getRegistry(self):
- return zapi.getSiteManager(self)
-
-
-class UtilityRegistration(bbb.site.BBBUtilityRegistration,
- registration.ComponentRegistration):
- """Utility component registration for persistent components
-
- This registration configures persistent components in packages to
- be utilities.
- """
- zope.interface.implements(interfaces.IUtilityRegistration)
-
- ############################################################
- # Make the adapter code happy.
- required = zope.interface.adapter.Null
- with = ()
- ############################################################
-
- def __init__(self, name, provided, component, permission=None):
- super(UtilityRegistration, self).__init__(component, permission)
- self.name = name
- self.provided = provided
-
- def getRegistry(self):
- return zapi.getSiteManager(self)
-
-
def threadSiteSubscriber(ob, event):
"""A subscriber to BeforeTraverseEvent
@@ -321,7 +389,7 @@
def SiteManagerAdapter(ob):
- """An adapter from ILocation to ISiteManager.
+ """An adapter from ILocation to IComponentLookup.
The ILocation is interpreted flexibly, we just check for
``__parent__``.
@@ -334,11 +402,11 @@
if current is None:
# It is not a location or has no parent, so we return the global
# site manager
- return zapi.getGlobalSiteManager()
+ return zope.component.getGlobalSiteManager()
def changeSiteConfigurationAfterMove(site, event):
"""After a site is moved, its site manager links have to be updated."""
next = None
if event.newParent is not None:
next = _findNextSiteManager(site)
- site.getSiteManager().setNext(next)
+ site.getSiteManager().__bases__ = (next, )
Modified: Zope3/trunk/src/zope/app/component/site.txt
===================================================================
--- Zope3/trunk/src/zope/app/component/site.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/site.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -52,7 +52,7 @@
Note that an event is generated when a local site manager is created:
- >>> from zope.app.event.tests.placelesssetup import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> from zope.app.component.interfaces import INewLocalSite
>>> [event] = getEvents(INewLocalSite)
>>> event.manager is sm
@@ -64,7 +64,7 @@
>>> myfolder2.setSiteManager(object)
Traceback (most recent call last):
...
- ValueError: setSiteManager requires an ISiteManager
+ ValueError: setSiteManager requires an IComponentLookup
Also, if the possible site has been changed to a site already, a `TypeError`
is raised, when one attempts to add a new site manager:
@@ -79,12 +79,12 @@
>>> myfolder['mysubfolder'] = folder.Folder()
>>> import zope.component
- >>> zope.component.interfaces.ISiteManager(myfolder['mysubfolder']) is sm
+ >>> zope.component.interfaces.IComponentLookup(myfolder['mysubfolder']) is sm
True
If the location passed is a site, the site manager of that site is returned:
- >>> zope.component.interfaces.ISiteManager(myfolder) is sm
+ >>> zope.component.interfaces.IComponentLookup(myfolder) is sm
True
During traversal,
@@ -136,30 +136,19 @@
>>> import persistent
>>> from zope.app.container.contained import Contained
>>> class MyUtility(persistent.Persistent, Contained):
- ... zope.interface.implements(IMyUtility,
- ... interfaces.ILocalUtility)
+ ... zope.interface.implements(IMyUtility)
... def __init__(self, title):
... self.title = title
... def __repr__(self):
... return "%s('%s')" %(self.__class__.__name__, self.title)
Now we can create an instance of our utility and put it in the site
-management folder:
+management folder and register it:
>>> myutil = MyUtility('My custom utility')
>>> default['myutil'] = myutil
+ >>> sm.registerUtility(myutil, IMyUtility, 'u1')
-Then we have to create a registration for the utility and activate it:
-
- >>> reg = site.UtilityRegistration('u1', IMyUtility, myutil)
- >>> default.registrationManager.addRegistration(reg)
- 'UtilityRegistration'
- >>> reg.status = interfaces.registration.ActiveStatus
-
-Note that you can only change the status *after* you have added the
-registration to the registration manager, since registration component uses
-its location to determine the correct registry to add the component to.
-
Now we can ask the site manager for the utility:
>>> sm.queryUtility(IMyUtility, 'u1')
@@ -171,13 +160,13 @@
>>> gutil = MyUtility('Global Utility')
>>> from zope.app import zapi
>>> gsm = zapi.getGlobalSiteManager()
- >>> gsm.provideUtility(IMyUtility, gutil, 'gutil')
+ >>> gsm.registerUtility(gutil, IMyUtility, 'gutil')
>>> sm.queryUtility(IMyUtility, 'gutil')
MyUtility('Global Utility')
Next let's see whether we can also successfully register an adapter as
-well. Here the adpater will provide the size of a file:
+well. Here the adapter will provide the size of a file:
>>> class IFile(zope.interface.Interface):
... pass
@@ -193,20 +182,10 @@
... def __init__(self, context):
... self.context = context
-We place the adapter in a particular module, so that adapter registration will
-be able to look it up by name.
+Now that we have the adapter we need to register it:
- >>> import sys
- >>> sys.modules['zope.app.component.tests'].FileSize = FileSize
+ >>> sm.registerAdapter(FileSize, [IFile])
-Now that we the adapter we need to register it:
-
- >>> areg = site.AdapterRegistration(IFile, ISized,
- ... 'zope.app.component.tests.FileSize')
- >>> default.registrationManager.addRegistration(areg)
- 'AdapterRegistration'
- >>> areg.status = interfaces.registration.ActiveStatus
-
Finally, we can get the adapter for a file:
>>> file = File()
@@ -257,7 +236,7 @@
If we ask the second site manager for its next, we get
- >>> sm11.next is sm
+ >>> sm11.__bases__ == (sm, )
True
and the first site manager should have the folling sub manager:
@@ -272,10 +251,7 @@
>>> myutil11 = MyUtility('Utility, uno & uno')
>>> default11['myutil'] = myutil11
- >>> reg11 = site.UtilityRegistration('u1', IMyUtility, myutil11)
- >>> default11.registrationManager.addRegistration(reg11)
- 'UtilityRegistration'
- >>> reg11.status = interfaces.registration.ActiveStatus
+ >>> sm11.registerUtility(myutil11, IMyUtility, 'u1')
then it will will be available in the second site manager
@@ -307,8 +283,10 @@
that manage the wiring of site managers after moving or copying:
>>> from zope.app import container
- >>> gsm.subscribe((interfaces.ISite, container.interfaces.IObjectMovedEvent),
- ... None, site.changeSiteConfigurationAfterMove)
+ >>> gsm.registerHandler(
+ ... site.changeSiteConfigurationAfterMove,
+ ... (interfaces.ISite, container.interfaces.IObjectMovedEvent),
+ ... )
We only have to register one event listener, since the copy action causes an
`IObjectAddedEvent` to be created, which is just a special type of
@@ -316,7 +294,7 @@
First, make sure that everything is setup correctly in the first place:
- >>> myfolder11.getSiteManager().next is myfolder.getSiteManager()
+ >>> myfolder11.getSiteManager().__bases__ == (myfolder.getSiteManager(), )
True
>>> myfolder.getSiteManager().subs[0] is myfolder11.getSiteManager()
True
@@ -331,7 +309,7 @@
Now the next site manager for `myfolder11`'s site manager should have changed:
>>> myfolder21 = myfolder11
- >>> myfolder21.getSiteManager().next is myfolder2.getSiteManager()
+ >>> myfolder21.getSiteManager().__bases__ == (myfolder2.getSiteManager(), )
True
>>> myfolder2.getSiteManager().subs[0] is myfolder21.getSiteManager()
True
@@ -343,16 +321,17 @@
# Make sure that our interfaces and classes are picklable.
+ >>> import sys
>>> sys.modules['zope.app.component.tests'].IMyUtility = IMyUtility
>>> IMyUtility.__module__ = 'zope.app.component.tests'
>>> sys.modules['zope.app.component.tests'].MyUtility = MyUtility
>>> MyUtility.__module__ = 'zope.app.component.tests'
- >>> from zope.app.location.pickling import locationCopy
+ >>> from zope.location.pickling import locationCopy
>>> myfolder['myfolder11'] = locationCopy(myfolder2['myfolder21'])
>>> myfolder11 = myfolder['myfolder11']
- >>> myfolder11.getSiteManager().next is myfolder.getSiteManager()
+ >>> myfolder11.getSiteManager().__bases__ == (myfolder.getSiteManager(), )
True
>>> myfolder.getSiteManager().subs[0] is myfolder11.getSiteManager()
True
Deleted: Zope3/trunk/src/zope/app/component/statusproperty.txt
===================================================================
--- Zope3/trunk/src/zope/app/component/statusproperty.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/statusproperty.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,124 +0,0 @@
-============================
-Registration Status Property
-============================
-
-The registratio status property is a descriptor used to implement the
-`IRegistration`' interface's `status` property.
-
-The property accepts two possible values: `ActiveStatus` and
-`InactiveStatus`. When the registration is active, then the registration is
-also activated in the registry.
-
- >>> from zope.app.component.interfaces.registration import ActiveStatus
- >>> from zope.app.component.interfaces.registration import InactiveStatus
-
-When setting the `status` property to `ActiveStatus`, then the registration
-should be added to the nearest matching registry. Here, the registration's
-`getRegistry()` method is used to determine the registry. On the same token,
-if the value is set to `InactiveStatus` the registration should be removed
-from the registry.
-
-To demonstrate this functionality, we first have to create a stub registry
-
- >>> class Registry(object):
- ... registrations = []
- ... def register(self, registration):
- ... self.registrations.append(registration)
- ...
- ... def unregister(self, registration):
- ... del self.registrations[self.registrations.index(registration)]
- ...
- ... def registered(self, registration):
- ... return registration in self.registrations
-
- >>> registry = Registry()
-
-and a simple registration object
-
- >>> from zope.app.component.registration import RegistrationStatusProperty
- >>> class Registration(object):
- ... status = RegistrationStatusProperty()
- ...
- ... def __init__(self, registry):
- ... self.registry = registry
- ...
- ... def getRegistry(self):
- ... return self.registry
-
-Note that here only the `getRegistry()` is part of the registration API.
-
-Now that we have a registry and a registration class, let's create a
-registration:
-
- >>> reg = Registration(registry)
-
-At the beginning the registration is inactive:
-
- >>> reg.status
- u'Inactive'
- >>> reg.status is InactiveStatus
- True
- >>> reg in registry.registrations
- False
-
-Once we activate the registration, it appears in the registry:
-
- >>> reg.status = ActiveStatus
- >>> reg.status
- u'Active'
- >>> reg.status is ActiveStatus
- True
- >>> reg in registry.registrations
- True
-
-Now, once we deactivate the registration, it is not available in the registry
-anymore:
-
- >>> reg.status = InactiveStatus
- >>> reg.status
- u'Inactive'
- >>> reg.status is InactiveStatus
- True
- >>> reg in registry.registrations
- False
-
-
-Registration Events
--------------------
-
-When a registration is activated or deactivated, an
-`RegistrationActivatedEvent` or `RegistrationDeactivatedEvent` is created,
-respectively. Listening to these events can be useful for cases where you want
-to change the component based on registration status.
-
-To catch the events, we have to register a subscriber with the event
-framework:
-
- >>> events = []
- >>> def subscriber(event):
- ... global events
- ... events.append(event)
-
- >>> import zope.event
- >>> zope.event.subscribers.append(subscriber)
-
-Now we switch our registration to active:
-
- >>> reg.status = ActiveStatus
- >>> event = events.pop()
- >>> event.__class__
- <class 'zope.app.component.registration.RegistrationActivatedEvent'>
- >>> event.object is reg
- True
-
-and deactivate it again:
-
- >>> reg.status = InactiveStatus
- >>> events.pop().__class__
- <class 'zope.app.component.registration.RegistrationDeactivatedEvent'>
- >>> event.object is reg
- True
-
-Now make sure that we remove the subscriber again:
-
- >>> del zope.event.subscribers[zope.event.subscribers.index(subscriber)]
Modified: Zope3/trunk/src/zope/app/component/testing.py
===================================================================
--- Zope3/trunk/src/zope/app/component/testing.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/testing.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,8 +16,8 @@
$Id$
"""
import zope.interface
-from zope.component import site
-from zope.component.interfaces import ISiteManager
+from zope.component.interfaces import IComponentLookup
+from zope.app.component.interfaces import ILocalSiteManager
from zope.app import zapi
from zope.app.testing import setup
from zope.app.testing.placelesssetup import PlacelessSetup
@@ -96,15 +96,15 @@
class SiteManagerStub(object):
- zope.interface.implements(ISiteManager)
+ zope.interface.implements(ILocalSiteManager)
- next = None
+ __bases__ = ()
def __init__(self):
self._utils = {}
def setNext(self, next):
- self.next = next
+ self.__bases__ = (next, )
def provideUtility(self, iface, util, name=''):
self._utils[(iface, name)] = util
@@ -176,8 +176,12 @@
sitemanager.setNext(nextsitemanager)
sitemanager.provideUtility(interface, utility, name)
- utility.__conform__ = \
- lambda iface: iface.isOrExtends(ISiteManager) and sitemanager or None
+ utility.__conform__ = (
+ lambda iface:
+ iface.isOrExtends(IComponentLookup) and sitemanager or None
+ )
nextsitemanager.provideUtility(interface, nextutility, name)
- nextutility.__conform__ = \
- lambda iface: iface.isOrExtends(ISiteManager) and nextsitemanager or None
+ nextutility.__conform__ = (
+ lambda iface:
+ iface.isOrExtends(IComponentLookup) and nextsitemanager or None
+ )
Copied: Zope3/trunk/src/zope/app/component/tests/deprecated35_registration.txt (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/component/tests/deprecated35_registration.txt)
Copied: Zope3/trunk/src/zope/app/component/tests/deprecated35_statusproperty.txt (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/component/tests/deprecated35_statusproperty.txt)
Copied: Zope3/trunk/src/zope/app/component/tests/gen3.fs (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/component/tests/gen3.fs)
Deleted: Zope3/trunk/src/zope/app/component/tests/test_adapter.py
===================================================================
--- Zope3/trunk/src/zope/app/component/tests/test_adapter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/tests/test_adapter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,712 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Registration Tests
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-import unittest
-import transaction
-from ZODB.tests.util import DB
-
-import zope.component.testing as placelesssetup
-import zope.interface
-from zope.interface.adapter import AdapterRegistry
-from zope.testing import doctest
-
-from zope.app.component import interfaces
-from zope.app.component.adapter import LocalAdapterRegistry, AdapterRegistration
-from zope.app.testing import setup
-
-class IF0(zope.interface.Interface):
- pass
-
-class IF1(IF0):
- pass
-
-class IF2(IF1):
- pass
-
-class IB0(zope.interface.Interface):
- pass
-
-class IB1(IB0):
- pass
-
-class IR0(zope.interface.Interface):
- pass
-
-class IR1(IR0):
- pass
-
-class R1(object):
- zope.interface.implements(IR1)
-
-class F0(object):
- zope.interface.implements(IF0)
-
-class F2(object):
- zope.interface.implements(IF2)
-
-# Create a picklable global registry. The pickleability of other
-# global adapter registries is beyond the scope of these tests:
-class GlobalAdapterRegistry(AdapterRegistry):
- def __reduce__(self):
- return 'globalAdapterRegistry'
-
-globalAdapterRegistry = GlobalAdapterRegistry()
-
-def test_local_adapter():
- """Local Adapter Tests
-
- Local surrogates and adapter registries share declarations with
- those "above" them.
-
- Suppose we have a global AdapterRegistry:
-
- >>> G = AdapterRegistry()
-
- we also have a local adapter registry, with G as it's base:
-
- >>> L1 = LocalAdapterRegistry(G)
-
- and so on:
-
- >>> L2 = LocalAdapterRegistry(G, L1)
-
- Now, if we declare an adapter globally:
-
- >>> G.register([IF1], IB1, '', 'A11G')
-
- we can query it locally:
-
- >>> L1.lookup([IF2], IB1)
- 'A11G'
-
- >>> L2.lookup([IF2], IB1)
- 'A11G'
-
- We can add local definitions:
-
- >>> ra011 = AdapterRegistration(required=IF0, provided=IB1, factory='A011',
- ... registry=L1)
- >>> ra011.status = interfaces.registration.ActiveStatus
-
- and use it:
-
- >>> L1.lookup([IF0], IB1)
- 'A011'
-
- >>> L2.lookup([IF0], IB1)
- 'A011'
-
- but not outside L1:
-
- >>> G.lookup([IF0], IB1)
-
- Note that it doesn't override the non-local adapter:
-
- >>> L1.lookup([IF2], IB1)
- 'A11G'
-
- >>> L2.lookup([IF2], IB1)
- 'A11G'
-
- because it was more specific.
-
- Let's override the adapter in L2:
-
- >>> ra112 = AdapterRegistration(required=IF1, provided=IB1, factory='A112',
- ... registry=L2)
- >>> ra112.status = interfaces.registration.ActiveStatus
-
- Now, in L2, we get the new adapter, because it's as specific and more
- local than the one from G:
-
- >>> L2.lookup([IF2], IB1)
- 'A112'
-
- But we still get the old one in L1
-
- >>> L1.lookup([IF2], IB1)
- 'A11G'
-
- Note that we can ask for less specific interfaces and still get the adapter:
-
- >>> L2.lookup([IF2], IB0)
- 'A112'
-
- >>> L1.lookup([IF2], IB0)
- 'A11G'
-
- We get the more specific adapter even if there is a less-specific
- adapter to B0:
-
- >>> G.register([IF1], IB1, '', 'A10G')
-
- >>> L2.lookup([IF2], IB0)
- 'A112'
-
- But if we have an equally specific and equally local adapter to B0, it
- will win:
-
- >>> ra102 = AdapterRegistration(required=IF1, provided=IB0, factory='A102',
- ... registry=L2)
- >>> ra102.status = interfaces.registration.ActiveStatus
-
- >>> L2.lookup([IF2], IB0)
- 'A102'
-
- We can deactivate registrations, which has the effect of deleting adapters:
-
-
- >>> ra112.status = interfaces.registration.InactiveStatus
-
- >>> L2.lookup([IF2], IB0)
- 'A102'
-
- >>> L2.lookup([IF2], IB1)
- 'A10G'
-
- >>> ra102.status = interfaces.registration.InactiveStatus
-
- >>> L2.lookup([IF2], IB0)
- 'A10G'
-
- We can ask for all of the registrations :
-
- >>> L1.registrations() #doctest: +NORMALIZE_WHITESPACE
- (<AdapterRegistration:
- required=<InterfaceClass zope.app.component.tests.test_adapter.IF0>,
- with=(),
- provided=<InterfaceClass zope.app.component.tests.test_adapter.IB1>,
- name='',
- component='A011',
- permission=None>,)
-
- This shows only the local registrations in L1.
- """
-
-def test_named_adapters():
- """
- Suppose we have a global AdapterRegistry:
-
- >>> G = AdapterRegistry()
-
- we also have a local adapter registry, with G as it's base:
-
- >>> L1 = LocalAdapterRegistry(G)
-
- and so on:
-
- >>> L2 = LocalAdapterRegistry(G, L1)
-
- Now, if we declare an adapter globally:
-
- >>> G.register([IF1], IB1, 'bob', 'A11G')
-
- we can query it locally:
-
- >>> L1.lookup([IF2], IB1)
- >>> L1.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- >>> L2.lookup([IF2], IB1)
- >>> L2.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- We can add local definitions:
-
- >>> ra011 = AdapterRegistration(required = IF0, provided=IB1,
- ... factory='A011', name='bob',
- ... registry=L1)
- >>> ra011.status = interfaces.registration.ActiveStatus
-
- and use it:
-
- >>> L1.lookup([IF0], IB1)
- >>> L1.lookup([IF0], IB1, 'bob')
- 'A011'
-
- >>> L2.lookup([IF0], IB1)
- >>> L2.lookup([IF0], IB1, 'bob')
- 'A011'
-
- but not outside L1:
-
- >>> G.lookup([IF0], IB1, 'bob')
-
- Note that it doesn't override the non-local adapter:
-
- >>> L1.lookup([IF2], IB1)
- >>> L1.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- >>> L2.lookup([IF2], IB1)
- >>> L2.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- because it was more specific.
-
- Let's override the adapter in L2:
-
- >>> ra112 = AdapterRegistration(required=IF1, provided=IB1,
- ... factory='A112', name='bob',
- ... registry=L2)
- >>> ra112.status = interfaces.registration.ActiveStatus
-
- Now, in L2, we get the new adapter, because it's as specific and more
- local than the one from G:
-
- >>> L2.lookup([IF2], IB1)
- >>> L2.lookup([IF2], IB1, 'bob')
- 'A112'
-
- But we still get thye old one in L1
-
- >>> L1.lookup([IF2], IB1)
- >>> L1.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- Note that we can ask for less specific interfaces and still get the adapter:
-
- >>> L2.lookup([IF2], IB0)
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A112'
-
- >>> L1.lookup([IF2], IB0)
- >>> L1.lookup([IF2], IB0, 'bob')
- 'A11G'
-
- We get the more specific adapter even if there is a less-specific
- adapter to B0:
-
- >>> G.register([IF1], IB1, 'bob', 'A10G')
-
- >>> L2.lookup([IF2], IB0)
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A112'
-
- But if we have an equally specific and equally local adapter to B0, it
- will win:
-
- >>> ra102 = AdapterRegistration(required = IF1, provided=IB0,
- ... factory='A102', name='bob',
- ... registry=L2)
- >>> ra102.status = interfaces.registration.ActiveStatus
-
- >>> L2.lookup([IF2], IB0)
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A102'
-
- We can deactivate registrations, which has the effect of deleting adapters:
-
-
- >>> ra112.status = interfaces.registration.InactiveStatus
-
- >>> L2.lookup([IF2], IB0)
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A102'
-
- >>> L2.lookup([IF2], IB1)
- >>> L2.lookup([IF2], IB1, 'bob')
- 'A10G'
-
- >>> ra102.status = interfaces.registration.InactiveStatus
-
- >>> L2.lookup([IF2], IB0)
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A10G'
- """
-
-def test_multi_adapters():
- """
- Suppose we have a global AdapterRegistry:
-
- >>> G = AdapterRegistry()
-
- we also have a local adapter registry, with G as it's base:
-
- >>> L1 = LocalAdapterRegistry(G)
-
- and so on:
-
- >>> L2 = LocalAdapterRegistry(G, L1)
-
- Now, if we declare an adapter globally:
-
- >>> G.register([IF1, IR0], IB1, 'bob', 'A11G')
-
- we can query it locally:
-
- >>> L1.lookup([IF2, IR1], IB1, 'bob')
- 'A11G'
-
- >>> L2.lookup([IF2, IR1], IB1, 'bob')
- 'A11G'
-
- We can add local definitions:
-
- >>> ra011 = AdapterRegistration(required=(IF0, IR0), provided=IB1,
- ... factory='A011', name='bob',
- ... registry=L1)
- >>> ra011.status = interfaces.registration.ActiveStatus
-
- and use it:
-
- >>> L1.lookup([IF0, IR1], IB1, 'bob')
- 'A011'
-
- >>> L2.lookup([IF0, IR1], IB1, 'bob')
- 'A011'
-
- but not outside L1:
-
- >>> G.lookup((IF0, IR1), IB1, 'bob')
-
- Note that it doesn't override the non-local adapter:
-
- >>> L1.lookup([IF2, IR1], IB1, 'bob')
- 'A11G'
-
- >>> L2.lookup((IF2, IR1), IB1, 'bob')
- 'A11G'
-
- because it was more specific.
-
- Let's override the adapter in L2:
-
- >>> ra112 = AdapterRegistration(required=(IF1, IR0), provided=IB1,
- ... factory='A112', name='bob',
- ... registry=L2)
- >>> ra112.status = interfaces.registration.ActiveStatus
-
- Now, in L2, we get the new adapter, because it's as specific and more
- local than the one from G:
-
- >>> L2.lookup((IF2, IR1), IB1, 'bob')
- 'A112'
-
- But we still get the old one in L1
-
- >>> L1.lookup((IF2, IR1), IB1, 'bob')
- 'A11G'
-
- Note that we can ask for less specific interfaces and still get
- the adapter:
-
- >>> L2.lookup((IF2, IR1), IB0, 'bob')
- 'A112'
-
- >>> L1.lookup((IF2, IR1), IB0, 'bob')
- 'A11G'
-
- We get the more specific adapter even if there is a less-specific
- adapter to B0:
-
- >>> G.register([IF1, IR0], IB1, 'bob', 'A10G')
-
- >>> L2.lookup((IF2, IR1), IB0, 'bob')
- 'A112'
-
- But if we have an equally specific and equally local adapter to B0, it
- will win:
-
- >>> ra102 = AdapterRegistration(required=(IF1, IR0), provided=IB0,
- ... factory='A102', name='bob',
- ... registry=L2)
- >>> ra102.status = interfaces.registration.ActiveStatus
-
- >>> L2.lookup((IF2, IR1), IB0, 'bob')
- 'A102'
-
- We can deactivate registrations, which has the effect of deleting adapters:
-
- >>> ra112.status = interfaces.registration.InactiveStatus
-
- >>> L2.lookup((IF2, IR1), IB0, 'bob')
- 'A102'
-
- >>> L2.lookup((IF2, IR1), IB1, 'bob')
- 'A10G'
-
- >>> ra102.status = interfaces.registration.InactiveStatus
-
- >>> L2.lookup([IF2], IB0)
- >>> L2.lookup((IF2, IR1), IB0, 'bob')
- 'A10G'
- """
-
-def test_persistence():
- """
- >>> db = DB()
- >>> conn1 = db.open()
-
- >>> G = globalAdapterRegistry
- >>> L1 = LocalAdapterRegistry(G)
- >>> L2 = LocalAdapterRegistry(G, L1)
-
- >>> conn1.root()['L1'] = L1
- >>> conn1.root()['L2'] = L2
-
- >>> G.register([IF1], IB1, 'bob', 'A11G')
- >>> L1.lookup([IF2], IB1)
- >>> L1.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- >>> L2.lookup([IF2], IB1)
- >>> L2.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- We can add local definitions:
-
- >>> ra011 = AdapterRegistration(required=IF0, provided=IB1,
- ... factory='A011', name='bob',
- ... registry=L1)
- >>> ra011.status = interfaces.registration.ActiveStatus
-
- and use it:
-
- >>> L1.lookup([IF0], IB1)
- >>> L1.lookup([IF0], IB1, 'bob')
- 'A011'
-
- >>> L2.lookup([IF0], IB1)
- >>> L2.lookup([IF0], IB1, 'bob')
- 'A011'
-
- but not outside L1:
-
- >>> G.lookup([IF0], IB1)
-
- Note that it doesn't override the non-local adapter:
-
- >>> L1.lookup([IF2], IB1)
- >>> L1.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- >>> L2.lookup([IF2], IB1)
- >>> L2.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- because it was more specific.
-
- Let's override the adapter in L2:
-
- >>> ra112 = AdapterRegistration(required=IF1, provided=IB1,
- ... factory='A112', name='bob',
- ... registry=L2)
- >>> ra112.status = interfaces.registration.ActiveStatus
-
- Now, in L2, we get the new adapter, because it's as specific and more
- local than the one from G:
-
- >>> L2.lookup([IF2], IB1)
- >>> L2.lookup([IF2], IB1, 'bob')
- 'A112'
-
- But we still get the old one in L1
-
- >>> L1.lookup([IF2], IB1)
- >>> L1.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- Note that we can ask for less specific interfaces and still get
- the adapter:
-
- >>> L2.lookup([IF2], IB0)
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A112'
-
- >>> L1.lookup([IF2], IB0)
- >>> L1.lookup([IF2], IB0, 'bob')
- 'A11G'
-
- We get the more specific adapter even if there is a less-specific
- adapter to B0:
-
- >>> G.register([IF0], IB0, 'bob', 'A00G')
-
- >>> L2.lookup([IF2], IB0)
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A112'
-
- But if we have an equally specific and equally local adapter to B0, it
- will win:
-
- >>> ra102 = AdapterRegistration(required=IF1, provided=IB0,
- ... factory='A102', name='bob',
- ... registry=L2)
- >>> ra102.status = interfaces.registration.ActiveStatus
-
- >>> L2.lookup([IF2], IB0)
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A102'
-
- >>> L1.lookup([IF2], IB0, 'bob')
- 'A11G'
- >>> L1.lookup([IF2], IB1, 'bob')
- 'A11G'
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A102'
- >>> L2.lookup([IF2], IB1, 'bob')
- 'A112'
-
- >>> transaction.commit()
-
- Now, let's open another transaction:
-
- >>> conn2 = db.open()
-
- >>> L1 = conn2.root()['L1']
- >>> L2 = conn2.root()['L2']
- >>> ra112 = L2._registrations[0]
- >>> ra102 = L2._registrations[1]
-
- We should get the same outputs:
-
- >>> L1.lookup([IF2], IB0, 'bob')
- 'A11G'
- >>> L1.lookup([IF2], IB1, 'bob')
- 'A11G'
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A102'
- >>> L2.lookup([IF2], IB1, 'bob')
- 'A112'
-
- We can deactivate registrations, which has the effect of deleting
- adapters:
-
- >>> ra112.status = interfaces.registration.InactiveStatus
- >>> ra102.status = interfaces.registration.InactiveStatus
-
- >>> L1.lookup([IF2], IB0, 'bob')
- 'A11G'
- >>> L1.lookup([IF2], IB1, 'bob')
- 'A11G'
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A11G'
- >>> L2.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- >>> transaction.commit()
-
- If we look back at the first connection, we should get the same data:
-
- >>> conn1.sync()
- >>> L1 = conn1.root()['L1']
- >>> L2 = conn1.root()['L2']
-
- We should see the result of the deactivations:
-
- >>> L1.lookup([IF2], IB0, 'bob')
- 'A11G'
- >>> L1.lookup([IF2], IB1, 'bob')
- 'A11G'
- >>> L2.lookup([IF2], IB0, 'bob')
- 'A11G'
- >>> L2.lookup([IF2], IB1, 'bob')
- 'A11G'
-
- Cleanup:
- >>> G.__init__()
- >>> db.close()
- """
-
-
-def test_local_default():
- """
- >>> G = AdapterRegistry()
- >>> L1 = LocalAdapterRegistry(G)
-
- >>> r = AdapterRegistration(required=None, provided=IB1,
- ... factory='Adapter', registry=L1)
- >>> r.status = interfaces.registration.ActiveStatus
- >>> L1.lookup([IF2], IB1)
- 'Adapter'
- """
-
-
-def test_changing_next():
- """
- >>> G = AdapterRegistry()
- >>> L1 = LocalAdapterRegistry(G)
- >>> L2 = LocalAdapterRegistry(G, L1)
- >>> f2 = F2()
-
- >>> L2.lookup([IF2], IB1)
-
- >>> G.register([IF1], IB1, '', 'A11G')
- >>> L2.lookup([IF2], IB1)
- 'A11G'
-
-
- >>> ra111 = AdapterRegistration(required=IF1, provided=IB1,
- ... factory='A111', registry=L1)
- >>> ra111.status = interfaces.registration.ActiveStatus
- >>> L2.lookup([IF2], IB1)
- 'A111'
-
- >>> L1.next
- >>> L2.next == L1
- True
- >>> L1.subs == (L2,)
- True
- >>> L3 = LocalAdapterRegistry(G, L1)
- >>> L2.setNext(L3)
- >>> L2.next == L3
- True
- >>> L3.next == L1
- True
- >>> L1.subs == (L3,)
- True
- >>> L3.subs == (L2,)
- True
-
- >>> ra113 = AdapterRegistration(required=IF1, provided=IB1,
- ... factory='A113', registry=L3)
- >>> ra113.status = interfaces.registration.ActiveStatus
-
- >>> L2.lookup([IF2], IB1)
- 'A113'
- >>> L2.setNext(L1)
- >>> L2.next == L1
- True
- >>> L3.next == L1
- True
- >>> L1.subs == (L3, L2)
- True
- >>> L3.subs == ()
- True
- >>> L2.lookup([IF2], IB1)
- 'A111'
-
- """
-
-def setUp(test):
- placelesssetup.setUp(test)
- setup.setUpAnnotations()
- setup.setUpDependable()
- setup.setUpTraversal()
-
-def test_suite():
- return unittest.TestSuite((
- doctest.DocTestSuite(),
- doctest.DocFileSuite('../adapterregistry.txt',
- setUp=setUp, tearDown=placelesssetup.tearDown),
- ))
-
-if __name__ == "__main__":
- unittest.main(defaultTest='test_suite')
-
Modified: Zope3/trunk/src/zope/app/component/tests/test_contentdirective.py
===================================================================
--- Zope3/trunk/src/zope/app/component/tests/test_contentdirective.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/tests/test_contentdirective.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,15 +18,15 @@
import unittest
from StringIO import StringIO
+from zope.component.interfaces import IFactory
+from zope.component.interfaces import ComponentLookupError
+from zope.component.interface import queryInterface
+from zope.configuration.xmlconfig import xmlconfig, XMLConfig
+
import zope.app.security
import zope.app.component
-
from zope.app import zapi
-from zope.component.interfaces import IFactory
-from zope.component.exceptions import ComponentLookupError
-from zope.configuration.xmlconfig import xmlconfig, XMLConfig
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.component.interface import queryInterface
# explicitly import ExampleClass and IExample using full paths
# so that they are the same objects as resolve will get.
Modified: Zope3/trunk/src/zope/app/component/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/component/tests/test_directives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/tests/test_directives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,35 +23,29 @@
from zope.interface import Interface, implements
from zope.testing.doctestunit import DocTestSuite
-from zope.component.tests.request import Request
from zope.component import createObject
from zope.component.interfaces import IDefaultViewName
-from zope.component.site import SubscriptionRegistration
+from zope.component.registry import SubscriptionRegistration
+from zope.component.interfaces import ComponentLookupError
+from zope.component.interface import queryInterface
from zope.configuration.xmlconfig import xmlconfig, XMLConfig
from zope.configuration.exceptions import ConfigurationError
from zope.configuration.xmlconfig import ZopeXMLConfigurationError
+from zope.security.proxy import removeSecurityProxy, getTestProxyItems
+from zope.security.checker import ProxyFactory, selectChecker
-from zope.security.proxy import removeSecurityProxy
-from zope.security.proxy import getTestProxyItems
-from zope.security.checker import ProxyFactory
-from zope.security.checker import selectChecker
-
import zope.app.component
-from zope.component.exceptions import ComponentLookupError
-
from zope.app import zapi
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.component.interface import queryInterface
-from zope.app.component.metaconfigure import interface
-from zope.app.component.tests.adapter import A1, A2, A3, I1, I3, IS, Handler
+from zope.app.component.tests.adapter import A1, A2, A3, Handler
+from zope.app.component.tests.adapter import I1, I2, I3, IS
from zope.app.component.tests.components import IContent, Content, Comp, comp
from zope.app.component.tests.components import IApp
-from zope.app.component.tests.views import IV, IC, V1, R1, IR
+from zope.app.component.tests.views import Request, IV, IC, V1, R1, IR
from zope.app.content.interfaces import IContentType
from zope.app.component.tests import module, exampleclass
-from zope.app.component.interface import queryInterface
# TODO: tests for other directives needed
@@ -71,27 +65,6 @@
return (''.join(atre.split(r))).strip()
-def testInterface():
- """
- >>> context = Context()
- >>> class I(Interface):
- ... pass
- >>> IContentType.providedBy(I)
- False
- >>> interface(context, I, IContentType)
- >>> context
- ((None,
- <function provideInterface>,
- ('',
- <InterfaceClass zope.app.component.tests.test_directives.I>,
- <InterfaceClass zope.app.content.interfaces.IContentType>)),)
- >>> from zope.interface.interfaces import IInterface
- >>> IContentType.extends(IInterface)
- True
- >>> IInterface.providedBy(I)
- True
- """
-
template = """<configure
xmlns='http://namespaces.zope.org/zope'
xmlns:test='http://www.zope.org/NS/Zope3/test'
@@ -113,867 +86,6 @@
XMLConfig('meta.zcml', zope.app.component)()
XMLConfig('meta.zcml', zope.app.security)()
- def testSubscriber(self):
- xmlconfig(StringIO(template % (
- '''
- <subscriber
- provides="zope.app.component.tests.adapter.IS"
- factory="zope.app.component.tests.adapter.A3"
- for="zope.app.component.tests.components.IContent
- zope.app.component.tests.adapter.I1"
- />
- '''
- )))
-
- content = Content()
- a1 = A1()
- subscribers = zapi.subscribers((content, a1), IS)
-
- a3 = subscribers[0]
-
- self.assertEqual(a3.__class__, A3)
- self.assertEqual(a3.context, (content, a1))
-
-
- def testSubscriberDocumentation(self):
- xmlconfig(StringIO(template % (
- '''
- <subscriber
- provides="zope.app.component.tests.adapter.IS"
- factory="zope.app.component.tests.adapter.A3"
- for="zope.app.component.tests.components.IContent
- zope.app.component.tests.adapter.I1"
- />
- '''
- )))
-
- gsm = zapi.getGlobalSiteManager()
- doc = [reg.doc
- for reg in gsm.registrations()
- if (isinstance(reg, SubscriptionRegistration) and
- reg.provided is IS)][0]
-
- self.assertEqual(`doc`, 'File "<string>", line 6.12-11.16')
-
- def testSubscriberWithPermission(self):
- xmlconfig(StringIO(template % (
- '''
- <permission
- id="y.x"
- title="XY"
- description="Allow XY." />
-
- <subscriber
- provides="zope.app.component.tests.adapter.IS"
- factory="zope.app.component.tests.adapter.A3"
- for="zope.app.component.tests.components.IContent
- zope.app.component.tests.adapter.I1"
- permission="y.x"
- />
- '''
- )))
-
- content = Content()
- a1 = A1()
- subscribers = zapi.subscribers((content, a1), IS)
-
- a3 = subscribers[0]
-
- self.assertEqual(a3.__class__, A3)
- self.assertEqual(a3.context, (content, a1))
- self.assertEqual(type(a3).__name__, 'LocationProxy')
-
- def testSubscriber_wo_for(self):
- xmlconfig(StringIO(template % (
- '''
- <subscriber
- provides="zope.app.component.tests.adapter.IS"
- factory="zope.app.component.tests.adapter.A3"
- />
- '''
- )))
-
- content = Content()
- a1 = A1()
- a2 = A2()
- subscribers = zapi.subscribers((content, a1, a2), IS)
-
- a3 = subscribers[0]
-
- self.assertEqual(a3.__class__, A3)
- self.assertEqual(a3.context, (content, a1, a2))
-
- def testHandlerSubscriber_no_for(self):
- xmlconfig(StringIO(template % (
- '''
- <subscriber
- handler="zope.app.component.tests.adapter.A3"
- />
- '''
- )))
-
- content = Content()
- a1 = A1()
- a2 = A2()
- subscribers = zapi.subscribers((content, a1, a2), None)
-
- a3 = subscribers[0]
-
- self.assertEqual(a3.__class__, A3)
- self.assertEqual(a3.context, (content, a1, a2))
-
-
- def testTrustedSubscriber(self):
- xmlconfig(StringIO(template % (
- '''
- <subscriber
- provides="zope.app.component.tests.adapter.IS"
- factory="zope.app.component.tests.adapter.A3"
- for="zope.app.component.tests.components.IContent
- zope.app.component.tests.adapter.I1"
- trusted="yes"
- />
- '''
- )))
- # With an unproxied object, business as usual
- content = Content()
- a1 = A1()
- subscribers = zapi.subscribers((content, a1), IS)
-
- a3 = subscribers[0]
-
- self.assertEqual(a3.__class__, A3)
- self.assertEqual(type(a3).__name__, 'A3')
- self.assertEqual(a3.context, (content, a1))
-
- # Now with a proxied object:
- from zope.security.checker import ProxyFactory
- p = ProxyFactory(content)
-
- # we get a proxied subscriber:
- a3 = zapi.subscribers((p, a1), IS)[0]
- from zope.security.proxy import Proxy
- self.assertEqual(type(a3), Proxy)
-
-
- # behind the security proxy is no locatin proxy:
- from zope.security.proxy import removeSecurityProxy
- self.assert_(removeSecurityProxy(a3).context[0] is content)
- self.assertEqual(type(removeSecurityProxy(a3)).__name__, 'A3')
-
-
- def testLocatableTrustedSubscriber(self):
- xmlconfig(StringIO(template % (
- '''
- <subscriber
- provides="zope.app.component.tests.adapter.IS"
- factory="zope.app.component.tests.adapter.A3"
- for="zope.app.component.tests.components.IContent
- zope.app.component.tests.adapter.I1"
- trusted="yes"
- locate="yes"
- />
- '''
- )))
- # With an unproxied object, business as usual
- content = Content()
- a1 = A1()
- subscribers = zapi.subscribers((content, a1), IS)
-
- a3 = subscribers[0]
-
- self.assertEqual(a3.__class__, A3)
- self.assertEqual(type(a3).__name__, 'A3')
- self.assertEqual(a3.context, (content, a1))
-
- # Now with a proxied object:
- from zope.security.checker import ProxyFactory
- p = ProxyFactory(content)
-
- # we get a proxied subscriber:
- a3 = zapi.subscribers((p, a1), IS)[0]
- from zope.security.proxy import Proxy
- self.assertEqual(type(a3), Proxy)
-
- # behind the security proxy is a locatio proxy:
- from zope.security.proxy import removeSecurityProxy
- self.assert_(removeSecurityProxy(a3).context[0] is content)
- self.assertEqual(type(removeSecurityProxy(a3)).__name__,
- 'LocationProxy')
-
- def testSubscriber_w_no_provides(self):
- xmlconfig(StringIO(template % (
- '''
- <subscriber
- for="zope.app.component.tests.components.IContent
- zope.app.component.tests.adapter.I1"
- handler="zope.app.component.tests.adapter.Handler"
- />
- '''
- )))
-
- content = Content()
- a1 = A1()
- list(zapi.subscribers((content, a1), None))
-
- self.assertEqual(content.args, ((a1,),))
-
- def testSubscriberHavingARequiredClass(self):
- xmlconfig(StringIO(template % (
- '''
- <subscriber
- for="zope.app.component.tests.components.Content"
- provides="zope.app.component.tests.adapter.I1"
- factory="zope.app.component.tests.adapter.A1"
- />
- '''
- )))
-
- subs = zapi.subscribers((Content(),), I1)
- self.assert_(isinstance(subs[0], A1))
-
- class MyContent:
- implements(IContent)
-
- self.assertEqual(zapi.subscribers((MyContent(),), I1), [])
-
- def testMultiSubscriber(self):
- xmlconfig(StringIO(template % (
- '''
- <subscriber
- provides="zope.app.component.tests.adapter.IS"
- factory="zope.app.component.tests.adapter.A3"
- for="zope.app.component.tests.components.IContent
- zope.app.component.tests.adapter.I1"
- />
- <subscriber
- provides="zope.app.component.tests.adapter.IS"
- factory="zope.app.component.tests.adapter.A2"
- for="zope.app.component.tests.components.IContent
- zope.app.component.tests.adapter.I1"
- />
- '''
- )))
-
- content = Content()
- a1 = A1()
- subscribers = zapi.subscribers((content, a1), IS)
-
- expectedLength = 2
- self.assertEqual(len(subscribers), expectedLength)
- classesNotFound = [A2, A3]
- for a in subscribers:
- classesNotFound.remove(a.__class__)
- self.failIf(classesNotFound)
-
- def testAdapter(self):
- # Full import is critical!
- self.assertEqual(IV(Content(), None), None)
-
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.components.Comp"
- provides="zope.app.component.tests.components.IApp"
- for="zope.app.component.tests.components.IContent"
- />
- '''
- )))
-
- self.assertEqual(IApp(Content()).__class__, Comp)
-
- def testAdapterWithPermission(self):
- # Full import is critical!
- self.assertEqual(IV(Content(), None), None)
-
- xmlconfig(StringIO(template % (
- '''
- <permission
- id="y.x"
- title="XY"
- description="Allow XY." />
-
- <adapter
- factory="zope.app.component.tests.components.Comp"
- provides="zope.app.component.tests.components.IApp"
- for="zope.app.component.tests.components.IContent"
- permission="y.x"
- />
- '''
- )))
-
- self.assertEqual(IApp(Content()).__class__, Comp)
- self.assertEqual(type(IApp(Content())).__name__, 'LocationProxy')
-
- def testAdapter_wo_provides_or_for(self):
- # Full import is critical!
- self.assertEqual(IV(Content(), None), None)
-
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.components.Comp"
- />
- '''
- )))
-
- self.assertEqual(IApp(Content()).__class__, Comp)
-
- def testAdapter_wo_provides_and_no_implented_fails(self):
- try:
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A4"
- for="zope.app.component.tests.components.IContent"
- />
- '''
- )))
- except ConfigurationError, v:
- self.assert_("Missing 'provides' attribute" in str(v))
-
- def testAdapter_wo_provides_and_too_many_implented_fails(self):
- try:
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A4"
- for="zope.app.component.tests.components.IContent"
- />
- '''
- )))
- except ConfigurationError, v:
- self.assert_("Missing 'provides' attribute" in str(v))
-
- def testTrustedAdapter(self):
- # Full import is critical!
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A1"
- provides="zope.app.component.tests.adapter.I1"
- for="zope.app.component.tests.components.IContent"
- trusted="yes"
- />
- '''
- )))
-
- # With an unproxied object, business as usual
- ob = Content()
- self.assertEqual(type(I1(ob)).__name__, 'A1')
-
- # Now with a proxied object:
- from zope.security.checker import ProxyFactory
- p = ProxyFactory(ob)
-
- # we get a proxied adapter:
- a = I1(p)
- from zope.security.proxy import Proxy
- self.assertEqual(type(a), Proxy)
-
- # around an unproxied object:
- from zope.security.proxy import removeSecurityProxy
- a = removeSecurityProxy(a)
- self.assertEqual(type(a).__name__, 'A1')
- self.assert_(a.context[0] is ob)
-
-
- def testTrustedAdapterWithPermission(self):
- # Full import is critical!
- xmlconfig(StringIO(template % (
- '''
- <permission
- id="y.x"
- title="XY"
- description="Allow XY." />
-
- <adapter
- factory="zope.app.component.tests.adapter.A1"
- provides="zope.app.component.tests.adapter.I1"
- for="zope.app.component.tests.components.IContent"
- permission="y.x"
- trusted="yes"
- />
- '''
- )))
-
- # With an unproxied object, business as usual
- ob = Content()
- self.assertEqual(type(I1(ob)).__name__, 'A1')
-
- # Now with a proxied object:
- from zope.security.checker import ProxyFactory
- p = ProxyFactory(ob)
-
- # we get a proxied adapter:
- a = I1(p)
- from zope.security.proxy import Proxy
- self.assertEqual(type(a), Proxy)
-
- # behind the security proxy is location proxy
- # if non-public permission is used
- from zope.security.proxy import removeSecurityProxy
- a = removeSecurityProxy(a)
- self.assertEqual(type(a).__name__, 'LocationProxy')
- self.assert_(a.context[0] is ob)
-
-
- def testTrustedAdapterWithPublicPermission(self):
- # Full import is critical!
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A1"
- provides="zope.app.component.tests.adapter.I1"
- for="zope.app.component.tests.components.IContent"
- permission="zope.Public"
- trusted="yes"
- />
- '''
- )))
-
- # With an unproxied object, business as usual
- ob = Content()
- self.assertEqual(type(I1(ob)).__name__, 'A1')
-
- # Now with a proxied object:
- from zope.security.checker import ProxyFactory
- p = ProxyFactory(ob)
-
- # we get a proxied adapter:
- a = I1(p)
- from zope.security.proxy import Proxy
- self.assertEqual(type(a), Proxy)
-
- # behind the security proxy is no location proxy
- from zope.security.proxy import removeSecurityProxy
- a = removeSecurityProxy(a)
- self.assertEqual(type(a).__name__, 'A1')
- self.assert_(a.context[0] is ob)
-
-
- def testLocatableTrustedAdapter(self):
- # Full import is critical!
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A1"
- provides="zope.app.component.tests.adapter.I1"
- for="zope.app.component.tests.components.IContent"
- trusted="yes"
- locate="yes"
- />
- '''
- )))
-
- # With an unproxied object, business as usual
- ob = Content()
- self.assertEqual(type(I1(ob)).__name__, 'A1')
-
- # Now with a proxied object:
- from zope.security.checker import ProxyFactory
- p = ProxyFactory(ob)
-
- # we get a proxied adapter:
- a = I1(p)
- from zope.security.proxy import Proxy
- self.assertEqual(type(a), Proxy)
-
- # behind the security proxy is always location proxy:
- from zope.security.proxy import removeSecurityProxy
- a = removeSecurityProxy(a)
- self.assertEqual(type(a).__name__, 'LocationProxy')
- self.assert_(a.context[0] is ob)
-
- def testAdapter_w_multiple_factories(self):
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A1
- zope.app.component.tests.adapter.A2
- zope.app.component.tests.adapter.A3
- "
- provides="zope.app.component.tests.components.IApp"
- for="zope.app.component.tests.components.IContent"
- />
- '''
- )))
-
- # The resulting adapter should be an A3, around an A2, around
- # an A1, andround the content:
-
- content = Content()
- a3 = IApp(content)
- self.assertEqual(a3.__class__, A3)
- a2 = a3.context[0]
- self.assertEqual(a2.__class__, A2)
- a1 = a2.context[0]
- self.assertEqual(a1.__class__, A1)
- self.assertEqual(a1.context[0], content)
-
- def testAdapter_fails_w_no_factories(self):
- self.assertRaises(ConfigurationError,
- xmlconfig,
- StringIO(template % (
- '''
- <adapter
- factory="
- "
- provides="zope.app.component.tests.components.IApp"
- for="zope.app.component.tests.components.IContent"
- />
- '''
- )),
- )
-
- def testAdapterHavingARequiredClass(self):
- xmlconfig(StringIO(template % (
- '''
- <adapter
- for="zope.app.component.tests.components.Content"
- provides="zope.app.component.tests.adapter.I1"
- factory="zope.app.component.tests.adapter.A1"
- />
- '''
- )))
-
- content = Content()
- a1 = zapi.getAdapter(content, I1, '')
- self.assert_(isinstance(a1, A1))
-
- class MyContent:
- implements(IContent)
-
- self.assertRaises(ComponentLookupError, zapi.getAdapter,
- MyContent(), I1, '')
-
-
- def testMultiAdapter(self):
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A3
- "
- provides="zope.app.component.tests.adapter.I3"
- for="zope.app.component.tests.components.IContent
- zope.app.component.tests.adapter.I1
- zope.app.component.tests.adapter.I2"
- />
- '''
- )))
- content = Content()
- a1 = A1()
- a2 = A2()
- a3 = zapi.queryMultiAdapter((content, a1, a2), I3)
- self.assertEqual(a3.__class__, A3)
- self.assertEqual(a3.context, (content, a1, a2))
-
- def testProtectedMultiAdapter(self):
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A3
- "
- provides="zope.app.component.tests.adapter.I3"
- for="zope.app.component.tests.components.IContent
- zope.app.component.tests.adapter.I1
- zope.app.component.tests.adapter.I2
- "
- permission="zope.Public"
- />
- '''
- )))
- content = Content()
- a1 = A1()
- a2 = A2()
- a3 = ProxyFactory(zapi.queryMultiAdapter((content, a1, a2), I3))
- self.assertEqual(a3.__class__, A3)
- items = [item[0] for item in getTestProxyItems(a3)]
- self.assertEqual(items, ['f1', 'f2', 'f3'])
-
- def testMultiAdapter_wo_for_or_provides(self):
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A3"
- />
- '''
- )))
-
- content = Content()
- a1 = A1()
- a2 = A2()
- a3 = zapi.queryMultiAdapter((content, a1, a2), I3)
- self.assertEqual(a3.__class__, A3)
- self.assertEqual(a3.context, (content, a1, a2))
-
- def testNullAdapter(self):
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A3"
- provides="zope.app.component.tests.adapter.I3"
- for=""
- />
- '''
- )))
-
- a3 = zapi.queryMultiAdapter((), I3)
- self.assertEqual(a3.__class__, A3)
- self.assertEqual(a3.context, ())
-
- def testMultiAdapterFails_w_multiple_factories(self):
- self.assertRaises(ConfigurationError,
- xmlconfig,
- StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A1
- zope.app.component.tests.adapter.A2
- "
- for="zope.app.component.tests.components.IContent
- zope.app.component.tests.adapter.I1
- zope.app.component.tests.adapter.I2
- "
- provides="zope.app.component.tests.components.IApp"
- />
- '''
- )),
- )
-
- self.assertRaises(ConfigurationError,
- xmlconfig,
- StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.adapter.A1
- zope.app.component.tests.adapter.A2
- "
- for=""
- provides="zope.app.component.tests.components.IApp"
- />
- '''
- )),
- )
-
-
- def testNamedAdapter(self):
- self.testAdapter()
- self.assertEqual(IApp(Content()).__class__, Comp)
- self.assertEqual(zapi.queryAdapter(Content(), IV, 'test'), None)
-
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.components.Comp"
- provides="zope.app.component.tests.components.IApp"
- for="zope.app.component.tests.components.IContent"
- name="test"
- />
- '''
- )))
-
- self.assertEqual(
- zapi.getAdapter(Content(), IApp, "test").__class__, Comp)
-
- def testProtectedAdapter(self):
- self.assertEqual(IV(Content(), None), None)
-
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.components.Comp"
- provides="zope.app.component.tests.components.IApp"
- for="zope.app.component.tests.components.IContent"
- permission="zope.Public"
- />
- '''
- )))
-
- adapter = ProxyFactory(IApp(Content()))
- items = [item[0] for item in getTestProxyItems(adapter)]
- self.assertEqual(items, ['a', 'f'])
- self.assertEqual(removeSecurityProxy(adapter).__class__, Comp)
-
- def testProtectedAdapter_wo_for_or_provides(self):
- self.assertEqual(IV(Content(), None), None)
- xmlconfig(StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.components.Comp"
- permission="zope.Public"
- />
- '''
- )))
-
- adapter = ProxyFactory(IApp(Content()))
- items = [item[0] for item in getTestProxyItems(adapter)]
- self.assertEqual(items, ['a', 'f'])
- self.assertEqual(removeSecurityProxy(adapter).__class__, Comp)
-
- def testAdapterUndefinedPermission(self):
- config = StringIO(template % (
- '''
- <adapter
- factory="zope.app.component.tests.components.Comp"
- provides="zope.app.component.tests.components.IApp"
- for="zope.app.component.tests.components.IContent"
- permission="zope.UndefinedPermission"
- />
- '''
- ))
- self.assertRaises(ValueError, xmlconfig, config, testing=1)
-
- def testUtility(self):
- self.assertEqual(zapi.queryUtility(IV), None)
-
- xmlconfig(StringIO(template % (
- '''
- <utility
- component="zope.app.component.tests.components.comp"
- provides="zope.app.component.tests.components.IApp"
- />
- '''
- )))
-
- self.assertEqual(zapi.getUtility(IApp), comp)
-
- def testUtility_wo_provides(self):
- self.assertEqual(zapi.queryUtility(IV), None)
-
- xmlconfig(StringIO(template % (
- '''
- <utility
- component="zope.app.component.tests.components.comp"
- />
- '''
- )))
-
- self.assertEqual(zapi.getUtility(IApp), comp)
-
- def testUtility_wo_provides_fails_if_no_provides(self):
- try:
- xmlconfig(StringIO(template % (
- '''
- <utility
- component="zope.app.component.tests.adapter.a4"
- />
- '''
- )))
- except ConfigurationError, v:
- self.assert_("Missing 'provides' attribute" in str(v))
-
- def testUtility_wo_provides_fails_if_too_many_provided(self):
- try:
- xmlconfig(StringIO(template % (
- '''
- <utility
- component="zope.app.component.tests.adapter.a5"
- />
- '''
- )))
- except ConfigurationError, v:
- self.assert_("Missing 'provides' attribute" in str(v))
-
- def testUtility_wo_provides_fails_if_no_implemented(self):
- try:
- xmlconfig(StringIO(template % (
- '''
- <utility
- factory="zope.app.component.tests.adapter.A4"
- />
- '''
- )))
- except ConfigurationError, v:
- self.assert_("Missing 'provides' attribute" in str(v))
-
- def testUtility_wo_provides_fails_if_too_many_implemented(self):
- try:
- xmlconfig(StringIO(template % (
- '''
- <utility
- factory="zope.app.component.tests.adapter.A5"
- />
- '''
- )))
- except ConfigurationError, v:
- self.assert_("Missing 'provides' attribute" in str(v))
-
- def testNamedUtility(self):
- self.testUtility()
- self.assertEqual(zapi.queryUtility(IV, 'test'), None)
- xmlconfig(StringIO(template % (
- '''
- <utility
- component="zope.app.component.tests.components.comp"
- provides="zope.app.component.tests.components.IApp"
- name="test"
- />
- '''
- )))
-
- self.assertEqual(zapi.getUtility(IApp, "test"), comp)
-
- def testUtilityFactory(self):
- self.assertEqual(zapi.queryUtility(IV), None)
-
- xmlconfig(StringIO(template % (
- '''
- <utility
- factory="zope.app.component.tests.components.Comp"
- provides="zope.app.component.tests.components.IApp"
- />
- '''
- )))
-
- self.assertEqual(zapi.getUtility(IApp).__class__, Comp)
-
- def testProtectedUtility(self):
- """Test that we can protect a utility.
-
- Also:
- Check that multiple configurations for the same utility and
- don't interfere.
- """
- self.assertEqual(zapi.queryUtility(IV), None)
- xmlconfig(StringIO(template % (
- '''
- <permission id="tell.everyone" title="Yay" />
- <utility
- component="zope.app.component.tests.components.comp"
- provides="zope.app.component.tests.components.IApp"
- permission="tell.everyone"
- />
- <permission id="top.secret" title="shhhh" />
- <utility
- component="zope.app.component.tests.components.comp"
- provides="zope.app.component.tests.components.IAppb"
- permission="top.secret"
- />
- '''
- )))
-
- utility = ProxyFactory(zapi.getUtility(IApp))
- items = getTestProxyItems(utility)
- self.assertEqual(items, [('a', 'tell.everyone'),
- ('f', 'tell.everyone')
- ])
- self.assertEqual(removeSecurityProxy(utility), comp)
-
- def testUtilityUndefinedPermission(self):
- config = StringIO(template % (
- '''
- <utility
- component="zope.app.component.tests.components.comp"
- provides="zope.app.component.tests.components.IApp"
- permission="zope.UndefinedPermission"
- />
- '''
- ))
- self.assertRaises(ValueError, xmlconfig, config,
- testing=1)
-
-
def testView(self):
ob = Ob()
request = Request(IV)
Modified: Zope3/trunk/src/zope/app/component/tests/test_fields.py
===================================================================
--- Zope3/trunk/src/zope/app/component/tests/test_fields.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/tests/test_fields.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,7 +21,7 @@
def test_suite():
return unittest.TestSuite((
- DocTestSuite('zope.app.component.fields',
+ DocTestSuite('zope.app.component.back35',
setUp=placelesssetup.setUp,
tearDown=placelesssetup.tearDown),
))
Deleted: Zope3/trunk/src/zope/app/component/tests/test_interface.py
===================================================================
--- Zope3/trunk/src/zope/app/component/tests/test_interface.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/tests/test_interface.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,28 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Interface utility tests
-
-$Id$
-"""
-import unittest
-from zope.testing.doctestunit import DocTestSuite
-
-def test_suite():
- return unittest.TestSuite((
- DocTestSuite('zope.app.component.interface'),
- ))
-
-if __name__ == "__main__":
- unittest.TextTestRunner().run(test_suite())
-
Modified: Zope3/trunk/src/zope/app/component/tests/test_registration.py
===================================================================
--- Zope3/trunk/src/zope/app/component/tests/test_registration.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/tests/test_registration.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,24 +16,329 @@
$Id$
"""
__docformat__ = "reStructuredText"
+
+import os
import unittest
+import warnings
+from ZODB.DB import DB
+import ZODB.FileStorage
+from ZODB.DemoStorage import DemoStorage
+import transaction
+import persistent
+
import zope.component.testing as placelesssetup
from zope.testing import doctest
from zope.app.testing import setup
+import zope.app.container.contained
+from zope import interface
-def setUp(test):
+# test class for testing data conversion
+class IFoo(interface.Interface):
+ pass
+class Foo(persistent.Persistent, zope.app.container.contained.Contained):
+ interface.implements(IFoo)
+ name = ''
+ def __init__(self, name=''):
+ self.name = name
+
+def setUpOld(test):
placelesssetup.setUp(test)
setup.setUpAnnotations()
setup.setUpDependable()
setup.setUpTraversal()
+ test.globs['showwarning'] = warnings.showwarning
+ warnings.showwarning = lambda *a, **k: None
+def tearDown(test):
+ warnings.showwarning = test.globs['showwarning']
+ placelesssetup.tearDown(test)
+
+def setUp(test):
+ placelesssetup.setUp(test)
+ test.globs['showwarning'] = warnings.showwarning
+ warnings.showwarning = lambda *a, **k: None
+
+def oldfs():
+ return FileStorage(
+ os.path.join(os.path.dirname(__file__), 'gen3.fs'),
+ read_only=True,
+ )
+
+# Work around a bug in ZODB
+# XXX fix ZODB
+class FileStorage(ZODB.FileStorage.FileStorage):
+
+ def new_oid(self):
+ self._lock_acquire()
+ try:
+ last = self._oid
+ d = ord(last[-1])
+ if d < 255: # fast path for the usual case
+ last = last[:-1] + chr(d+1)
+ else: # there's a carry out of the last byte
+ last_as_long, = _structunpack(">Q", last)
+ last = _structpack(">Q", last_as_long + 1)
+ self._oid = last
+ return last
+ finally:
+ self._lock_release()
+
+
+def test_old_databases_backward_compat():
+ """
+
+Let's open an old database and get the 3 site managers in it:
+
+ >>> fs = oldfs()
+ >>> demo = DemoStorage(base=fs)
+ >>> db = DB(demo)
+ >>> tm = transaction.TransactionManager()
+ >>> root = db.open(transaction_manager=tm).root()
+ >>> _ = tm.begin()
+
+ >>> sm1 = root['Application'].getSiteManager()
+ >>> [sm2] = sm1.subs
+ >>> [sm3] = sm2.subs
+
+We can look up utilities as we expect:
+
+ >>> sm1.getUtility(IFoo, '1') is sm1['default']['1']
+ True
+
+ >>> sm3.getUtility(IFoo, '3') is sm3['default']['3']
+ True
+
+ >>> sm2.getUtility(IFoo, '2') is sm2['default']['2']
+ True
+
+ >>> sm1.getUtility(IFoo, '2') is sm1['default']['2']
+ True
+
+ >>> sm1.getUtility(IFoo, '3') is sm1['default']['3']
+ True
+
+ >>> sm2.getUtility(IFoo, '3') is sm2['default']['3']
+ True
+
+ >>> sm2.getUtility(IFoo, '4') is sm2['default']['4']
+ True
+
+ >>> sm3.getUtility(IFoo, '4') is sm3['default']['4']
+ True
+
+ >>> sm3.getUtility(IFoo, '5') is sm3['default']['5']
+ True
+
+and we get registration info:
+
+ >>> sorted([r.name for r in sm2.registeredUtilities()])
+ [u'2', u'3', u'4']
+
+We don't have any adapter or subscriber information, because it wasn't
+previously supported to register those:
+
+ >>> len(list(sm2.registeredAdapters()))
+ 0
+ >>> len(list(sm2.registeredSubscriptionAdapters()))
+ 0
+ >>> len(list(sm2.registeredHandlers()))
+ 0
+
+We haven't modified anything yet. We can see this in a number of
+ways. If we look at the internal data structured used, we can see
+that they are weird:
+
+ >>> sm2._utility_registrations.__class__.__name__
+ '_OldUtilityRegistrations'
+
+ >>> sm2._adapter_registrations.__class__.__name__
+ '_OldAdapterRegistrations'
+
+ >>> sm2._subscription_registrations.__class__.__name__
+ '_OldSubscriberRegistrations'
+
+ >>> sm2._handler_registrations.__class__.__name__
+ '_OldSubscriberRegistrations'
+
+and the registries have a _registrations attribute, which is a sign
+that they haven't been converted yet:
+
+ >>> hasattr(sm2.utilities, '_registrations')
+ True
+
+ >>> hasattr(sm2.adapters, '_registrations')
+ True
+
+We'll commit the transaction and make sure the database hasn't
+grown. (This relies on a buglet in DemoStorage length computation.)
+
+ >>> tm.commit()
+ >>> len(demo) == len(fs)
+ True
+
+Of course, we can register new utilities:
+
+ >>> _ = tm.begin()
+ >>> sm1.registerUtility(Foo('one'), IFoo, '1')
+ >>> sm2.registerUtility(Foo('two'), IFoo, '2')
+ >>> tm.commit()
+
+We should then be able to look up the newly registered utilities.
+Let's try to do so in a separate connection:
+
+ >>> tm2 = transaction.TransactionManager()
+ >>> root2 = db.open(transaction_manager=tm2).root()
+ >>> _ = tm2.begin()
+
+ >>> sm1 = root2['Application'].getSiteManager()
+ >>> [sm2] = sm1.subs
+ >>> [sm3] = sm2.subs
+
+ >>> sm1.getUtility(IFoo, '1').name
+ 'one'
+
+ >>> sm2.getUtility(IFoo, '2').name
+ 'two'
+
+ >>> sm1.getUtility(IFoo, '2') is sm1['default']['2']
+ True
+
+ >>> sm1.getUtility(IFoo, '3') is sm1['default']['3']
+ True
+
+ >>> sm2.getUtility(IFoo, '3') is sm2['default']['3']
+ True
+
+ >>> sm2.getUtility(IFoo, '4') is sm2['default']['4']
+ True
+
+ >>> sm3.getUtility(IFoo, '4') is sm3['default']['4']
+ True
+
+ >>> sm3.getUtility(IFoo, '5') is sm3['default']['5']
+ True
+
+ >>> sorted([r.name for r in sm2.registeredUtilities()])
+ [u'2', u'3', u'4']
+
+
+Because we registered utilities, the corresponding data structures
+have been updated:
+
+ >>> sm2._utility_registrations.__class__.__name__
+ 'PersistentMapping'
+
+ >>> hasattr(sm2.utilities, '_registrations')
+ False
+
+But other data structures haven't been effected:
+
+ >>> sm2._adapter_registrations.__class__.__name__
+ '_OldAdapterRegistrations'
+
+ >>> hasattr(sm2.adapters, '_registrations')
+ True
+
+Nor, of course, have the data structures for sites that we haven't
+changed:
+
+ >>> sm3._utility_registrations.__class__.__name__
+ '_OldUtilityRegistrations'
+
+ >>> hasattr(sm3.utilities, '_registrations')
+ True
+
+The _evolve_to_generation_4 method actually converts the remaining
+data structures. It also evolves all of it's subinterfaces:
+
+ >>> sm1._evolve_to_generation_4()
+ >>> tm2.commit()
+
+and we see that all of the data structures have been converted:
+
+ >>> sm1._utility_registrations.__class__.__name__
+ 'PersistentMapping'
+ >>> sm1._adapter_registrations.__class__.__name__
+ 'PersistentMapping'
+ >>> sm1._subscription_registrations.__class__.__name__
+ 'PersistentList'
+ >>> sm1._handler_registrations.__class__.__name__
+ 'PersistentList'
+ >>> hasattr(sm1.utilities, '_registrations')
+ False
+ >>> hasattr(sm1.adapters, '_registrations')
+ False
+
+ >>> sm2._utility_registrations.__class__.__name__
+ 'PersistentMapping'
+ >>> sm2._adapter_registrations.__class__.__name__
+ 'PersistentMapping'
+ >>> sm2._subscription_registrations.__class__.__name__
+ 'PersistentList'
+ >>> sm2._handler_registrations.__class__.__name__
+ 'PersistentList'
+ >>> hasattr(sm2.utilities, '_registrations')
+ False
+ >>> hasattr(sm2.adapters, '_registrations')
+ False
+
+ >>> sm3._utility_registrations.__class__.__name__
+ 'PersistentMapping'
+ >>> sm3._adapter_registrations.__class__.__name__
+ 'PersistentMapping'
+ >>> sm3._subscription_registrations.__class__.__name__
+ 'PersistentList'
+ >>> sm3._handler_registrations.__class__.__name__
+ 'PersistentList'
+ >>> hasattr(sm3.utilities, '_registrations')
+ False
+ >>> hasattr(sm3.adapters, '_registrations')
+ False
+
+and that lookups still work as expected:
+
+
+ >>> sm1.getUtility(IFoo, '1').name
+ 'one'
+
+ >>> sm2.getUtility(IFoo, '2').name
+ 'two'
+
+ >>> sm1.getUtility(IFoo, '2') is sm1['default']['2']
+ True
+
+ >>> sm1.getUtility(IFoo, '3') is sm1['default']['3']
+ True
+
+ >>> sm2.getUtility(IFoo, '3') is sm2['default']['3']
+ True
+
+ >>> sm2.getUtility(IFoo, '4') is sm2['default']['4']
+ True
+
+ >>> sm3.getUtility(IFoo, '4') is sm3['default']['4']
+ True
+
+ >>> sm3.getUtility(IFoo, '5') is sm3['default']['5']
+ True
+
+
+Cleanup:
+
+ >>> db.close()
+
+"""
+
def test_suite():
- return unittest.TestSuite((
- doctest.DocFileSuite('../statusproperty.txt'),
- doctest.DocFileSuite('../registration.txt',
- setUp=setUp, tearDown=placelesssetup.tearDown),
+ suite = unittest.TestSuite((
+ doctest.DocFileSuite('deprecated35_statusproperty.txt',
+ 'deprecated35_registration.txt',
+ setUp=setUpOld, tearDown=tearDown),
+ doctest.DocTestSuite(setUp=setUp, tearDown=tearDown)
))
+ return suite
+
if __name__ == "__main__":
unittest.main(defaultTest='test_suite')
Modified: Zope3/trunk/src/zope/app/component/tests/test_site.py
===================================================================
--- Zope3/trunk/src/zope/app/component/tests/test_site.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/tests/test_site.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,6 +19,7 @@
import unittest
import zope.interface
+import zope.interface.verify
from zope.testing import doctest
from zope.app.testing import setup
Modified: Zope3/trunk/src/zope/app/component/tests/views.py
===================================================================
--- Zope3/trunk/src/zope/app/component/tests/views.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/tests/views.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,8 +15,13 @@
$Id: views.py 26551 2004-07-15 07:06:37Z srichter $
"""
-from zope.interface import Interface, implements
+from zope.interface import Interface, implements, directlyProvides
+class Request(object):
+
+ def __init__(self, type):
+ directlyProvides(self, type)
+
class IR(Interface):
pass
Modified: Zope3/trunk/src/zope/app/component/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/component/vocabulary.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/component/vocabulary.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,20 +19,17 @@
"""
__docformat__ = "reStructuredText"
+import zope.component
from zope.interface import implements, classProvides, Interface
from zope.interface.interfaces import IInterface
from zope.interface.verify import verifyObject
from zope.schema.interfaces import IVocabulary, IVocabularyTokenized
-from zope.schema.interfaces import ITokenizedTerm
+from zope.schema.interfaces import ITokenizedTerm, IVocabularyFactory
-from zope.app import zapi
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.schema.interfaces import IVocabularyFactory
from zope.app.interface.vocabulary import ObjectInterfacesVocabulary
+from zope.component.interfaces import IUtilityRegistration
-from zope.app.component.interfaces import IUtilityRegistration
-
-
class UtilityTerm(object):
"""A term representing a utility.
@@ -191,10 +188,10 @@
self.nameOnly = bool(kw.get('nameOnly', False))
interface = kw.get('interface', Interface)
if isinstance(interface, (str, unicode)):
- interface = zapi.getUtility(IInterface, interface)
+ interface = zope.component.getUtility(IInterface, interface)
self.interface = interface
- utils = zapi.getUtilitiesFor(self.interface, context)
+ utils = zope.component.getUtilitiesFor(self.interface, context)
self._terms = dict(
(name, UtilityTerm(self.nameOnly and name or util, name))
for name, util in utils)
@@ -349,7 +346,7 @@
self.interface = interface
def __contains__(self, value):
- return zapi.queryUtility(self.interface, value) is not None
+ return zope.component.queryUtility(self.interface, value) is not None
def getTerm(self, value):
if value in self:
@@ -357,7 +354,7 @@
raise ValueError(value)
def getTermByToken(self, token):
- for name, ut in zapi.getUtilitiesFor(self.interface):
+ for name, ut in zope.component.getUtilitiesFor(self.interface):
name = unicode(name)
if token == "t":
if not name:
@@ -369,9 +366,9 @@
return self.getTerm(name)
def __iter__(self):
- for name, ut in zapi.getUtilitiesFor(self.interface):
+ for name, ut in zope.component.getUtilitiesFor(self.interface):
yield UtilityNameTerm(name)
def __len__(self):
"""Return the number of valid terms, or sys.maxint."""
- return len(list(zapi.getUtilitiesFor(self.interface)))
+ return len(list(zope.component.getUtilitiesFor(self.interface)))
Modified: Zope3/trunk/src/zope/app/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,15 +18,15 @@
<include package="zope.app.interface" />
<include package="zope.app.security" />
<include package="zope.app.event" />
- <include package="zope.app.annotation" />
+ <include package="zope.annotation" />
<include package="zope.app.dependable" />
<include package="zope.app.content" />
<include file="menus.zcml" />
- <include package="zope.app.copypastemove" />
- <include package="zope.app.size" />
- <include package="zope.app.location" />
+ <include package="zope.copypastemove" />
+ <include package="zope.size" />
+ <include package="zope.location" />
<include package="zope.app.container" />
<include package="zope.app.publisher" />
@@ -35,7 +35,7 @@
<include package="zope.app.publication" />
- <include package="zope.app.traversing" />
+ <include package="zope.traversing" />
<include package="zope.app.pagetemplate" />
<include package=".generations" />
<include package=".zapi" />
@@ -69,7 +69,7 @@
<!-- Additional packages -->
<include package="zope.app.applicationcontrol" />
- <include package="zope.app.dublincore" />
+ <include package="zope.dublincore" />
<include package="zope.app.introspector" />
<include package="zope.app.wsgi" />
Modified: Zope3/trunk/src/zope/app/container/browser/adding.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/adding.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/browser/adding.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -26,19 +26,19 @@
from zope.event import notify
from zope.interface import implements
from zope.publisher.interfaces import IPublishTraverse
+from zope.publisher.browser import BrowserView
from zope.security.proxy import removeSecurityProxy
+from zope.exceptions.interfaces import UserError
+from zope.location import LocationProxy
+from zope.lifecycleevent import ObjectCreatedEvent
-from zope.app.exception.interfaces import UserError
from zope.app.container.interfaces import IAdding, INameChooser
from zope.app.container.interfaces import IContainerNamesContainer
from zope.app.container.constraints import checkFactory, checkObject
from zope.app import zapi
-from zope.app.event.objectevent import ObjectCreatedEvent
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.location import LocationProxy
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.app.publisher.browser import BrowserView
from zope.app.publisher.browser.menu import getMenu
Modified: Zope3/trunk/src/zope/app/container/browser/contents.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/contents.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/browser/contents.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,28 +19,26 @@
import urllib
-from zope.app.exception.interfaces import UserError
-from zope.app.traversing.interfaces import TraversalError
+from zope.exceptions.interfaces import UserError
from zope.security.interfaces import Unauthorized
from zope.security import canWrite
+from zope.size.interfaces import ISized
+from zope.traversing.interfaces import TraversalError
+from zope.publisher.browser import BrowserView
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.dublincore.interfaces import IDCDescriptiveProperties
+from zope.copypastemove.interfaces import IPrincipalClipboard
+from zope.copypastemove.interfaces import IObjectCopier, IObjectMover
+from zope.copypastemove.interfaces import IContainerItemRenamer
from zope.app import zapi
-from zope.app.size.interfaces import ISized
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.app.publisher.browser import BrowserView
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.dublincore.interfaces import IDCDescriptiveProperties
-from zope.app.copypastemove.interfaces import IPrincipalClipboard
-from zope.app.copypastemove.interfaces import IObjectCopier
-from zope.app.copypastemove.interfaces import IObjectMover
-from zope.app.copypastemove.interfaces import IContainerItemRenamer
from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility
from zope.app.container.browser.adding import Adding
-from zope.app.container.interfaces import IContainer
+from zope.app.container.interfaces import IContainer, DuplicateIDError
from zope.app.container.interfaces import IContainerNamesContainer
-from zope.app.container.interfaces import DuplicateIDError
class Contents(BrowserView):
Modified: Zope3/trunk/src/zope/app/container/browser/find.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/find.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/browser/find.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,11 +17,12 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app import zapi
+from zope.traversing.api import getName
+from zope.traversing.browser.absoluteurl import absoluteURL
+from zope.publisher.browser import BrowserView
+
from zope.app.container.find import SimpleIdFindFilter
from zope.app.container.interfaces import IFind
-from zope.app.traversing.api import getName
-from zope.app.publisher.browser import BrowserView
# Very simple implementation right now
class Find(BrowserView):
@@ -36,6 +37,6 @@
request = self.request
result = []
for object in finder.find([SimpleIdFindFilter(ids)]):
- url = zapi.absoluteURL(object, request)
+ url = absoluteURL(object, request)
result.append({ 'id': getName(object), 'url': url})
return result
Modified: Zope3/trunk/src/zope/app/container/browser/ftests/test_contents.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/ftests/test_contents.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/browser/ftests/test_contents.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,12 +20,12 @@
from persistent import Persistent
import transaction
+from zope import copypastemove
from zope.interface import implements, Interface
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.dublincore.interfaces import IZopeDublinCore
-from zope.app import copypastemove
-from zope.app.annotation.interfaces import IAttributeAnnotatable
from zope.app.container.interfaces import IReadContainer, IContained
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.testing import ztapi
from zope.app.testing.functional import BrowserTestCase
from zope.app.testing.functional import FunctionalDocFileSuite
Modified: Zope3/trunk/src/zope/app/container/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/browser/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,16 +18,16 @@
__docformat__ = 'restructuredtext'
-from zope.app.component.fields import LayerField
from zope.interface import Interface
from zope.configuration.fields import GlobalObject
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.schema import Id
+from zope.security.zcml import Permission
from zope.app.publisher.browser.viewmeta import page, view
from zope.app.container.browser.contents import Contents
from zope.app.container.browser.adding import Adding
+from zope.app.component.back35 import LayerField
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.security.fields import Permission
class IContainerViews(Interface):
Modified: Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/browser/tests/test_adding.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,21 +20,21 @@
import zope.interface
import zope.security.checker
from zope.component.interfaces import IFactory
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
from zope.interface import implements, Interface, directlyProvides
from zope.publisher.browser import TestRequest
from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.browser import BrowserView
from zope.security.interfaces import ForbiddenAttribute
from zope.testing.doctestunit import DocTestSuite
+from zope.exceptions.interfaces import UserError
+from zope.traversing.browser import AbsoluteURL
+from zope.traversing.browser.interfaces import IAbsoluteURL
+from zope.traversing.interfaces import IContainmentRoot
from zope.app import zapi
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup, setUp, tearDown
-from zope.app.traversing.browser import AbsoluteURL
-from zope.app.traversing.browser.interfaces import IAbsoluteURL
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.app.exception.interfaces import UserError
-from zope.app.publisher.browser import BrowserView
from zope.app.publisher.interfaces.browser import AddMenu
from zope.app.publisher.interfaces.browser import IMenuItemType, IBrowserMenu
from zope.app.publisher.browser.menu import BrowserMenuItem, BrowserMenu
Modified: Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/browser/tests/test_contents.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,20 +19,20 @@
from zope.interface import Interface, implements
from zope.security import checker
+from zope.traversing.api import traverse
+from zope.annotation.interfaces import IAnnotations
+from zope.copypastemove import ContainerItemRenamer
+from zope.copypastemove import ObjectMover, ObjectCopier
+from zope.copypastemove import PrincipalClipboard
+from zope.copypastemove.interfaces import IContainerItemRenamer
+from zope.copypastemove.interfaces import IObjectMover, IObjectCopier
+from zope.copypastemove.interfaces import IPrincipalClipboard
-from zope.app.annotation.interfaces import IAnnotations
from zope.app.component.testing import PlacefulSetup
from zope.app.container.contained import contained
-from zope.app.copypastemove import ContainerItemRenamer
-from zope.app.copypastemove import ObjectMover, ObjectCopier
-from zope.app.copypastemove import PrincipalClipboard
-from zope.app.copypastemove.interfaces import IContainerItemRenamer
-from zope.app.copypastemove.interfaces import IObjectMover, IObjectCopier
-from zope.app.copypastemove.interfaces import IPrincipalClipboard
from zope.app.principalannotation import PrincipalAnnotationUtility
from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility
from zope.app.testing import ztapi
-from zope.app.traversing.api import traverse
from zope.app.container.interfaces import IContainer, IContained
@@ -102,7 +102,7 @@
container['document'] = document
from datetime import datetime
- from zope.app.dublincore.interfaces import IZopeDublinCore
+ from zope.dublincore.interfaces import IZopeDublinCore
class FauxDCAdapter(object):
implements(IZopeDublinCore)
Modified: Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py
===================================================================
--- Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/browser/tests/test_directive.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -69,12 +69,12 @@
<InterfaceClass zope.app.menus.zmi_views>,
u'Contents'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.app.menus.zmi_views>,
u'Contents',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'')),
(None,
<function provideInterface>,
@@ -97,12 +97,12 @@
<InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <class 'zope.app.publisher.browser.viewmeta.Contents'>,
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.interface.Interface>,
'contents.html',
- <class 'zope.app.publisher.browser.viewmeta.Contents'>,
'info')),
(None,
<function provideInterface>,
@@ -114,12 +114,12 @@
<InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <class 'zope.app.publisher.browser.viewmeta.Contents'>,
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.interface.Interface>,
'index.html',
- <class 'zope.app.publisher.browser.viewmeta.Contents'>,
'info')),
(('adapter',
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
@@ -127,12 +127,12 @@
<InterfaceClass zope.app.menus.zmi_actions>,
u'Add'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.app.menus.zmi_actions>,
u'Add',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'info')),
(None,
<function provideInterface>,
@@ -158,12 +158,12 @@
'+',
<InterfaceClass zope.interface.Interface>),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <class 'zope.app.publisher.browser.viewmeta.+'>,
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.interface.Interface>,
'+',
- <class 'zope.app.publisher.browser.viewmeta.+'>,
'info')))
"""
@@ -186,12 +186,12 @@
<InterfaceClass zope.app.menus.zmi_views>,
u'Contents'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
<InterfaceClass zope.app.container.browser.tests.test_directive.ITestLayer>),
<InterfaceClass zope.app.menus.zmi_views>,
u'Contents',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'')),
(None,
<function provideInterface>,
@@ -214,12 +214,12 @@
<InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
<InterfaceClass zope.app.container.browser.tests.test_directive.ITestLayer>),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <class 'zope.app.publisher.browser.viewmeta.Contents'>,
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
<InterfaceClass zope.app.container.browser.tests.test_directive.ITestLayer>),
<InterfaceClass zope.interface.Interface>,
'contents.html',
- <class 'zope.app.publisher.browser.viewmeta.Contents'>,
'info')),
(None,
<function provideInterface>,
@@ -231,12 +231,12 @@
<InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>,
<InterfaceClass zope.app.container.browser.tests.test_directive.ITestLayer>),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <class 'zope.app.publisher.browser.viewmeta.Contents'>,
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
<InterfaceClass zope.app.container.browser.tests.test_directive.ITestLayer>),
<InterfaceClass zope.interface.Interface>,
'index.html',
- <class 'zope.app.publisher.browser.viewmeta.Contents'>,
'info')),
(('adapter',
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
@@ -244,12 +244,12 @@
<InterfaceClass zope.app.menus.zmi_actions>,
u'Add'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
<InterfaceClass zope.app.container.browser.tests.test_directive.ITestLayer>),
<InterfaceClass zope.app.menus.zmi_actions>,
u'Add',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'info')),
(None,
<function provideInterface>,
@@ -275,12 +275,12 @@
'+',
<InterfaceClass zope.interface.Interface>),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <class 'zope.app.publisher.browser.viewmeta.+'>,
(<InterfaceClass zope.app.container.browser.tests.test_directive.I>,
<InterfaceClass zope.app.container.browser.tests.test_directive.ITestLayer>),
<InterfaceClass zope.interface.Interface>,
'+',
- <class 'zope.app.publisher.browser.viewmeta.+'>,
'info')))
"""
Modified: Zope3/trunk/src/zope/app/container/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/container/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -14,26 +14,26 @@
<adapter
for=".interfaces.IReadContainer"
- provides="zope.app.filerepresentation.interfaces.IReadDirectory"
+ provides="zope.filerepresentation.interfaces.IReadDirectory"
factory=".directory.noop"
/>
<adapter
for=".interfaces.IWriteContainer"
- provides="zope.app.filerepresentation.interfaces.IWriteDirectory"
+ provides="zope.filerepresentation.interfaces.IWriteDirectory"
factory=".directory.noop"
/>
<adapter
factory="zope.app.container.traversal.ContainerTraversable"
- provides="zope.app.traversing.interfaces.ITraversable"
+ provides="zope.traversing.interfaces.ITraversable"
for="zope.app.container.interfaces.IReadContainer"
/>
<adapter
factory="zope.app.container.size.ContainerSized"
- provides="zope.app.size.interfaces.ISized"
+ provides="zope.size.interfaces.ISized"
for="zope.app.container.interfaces.IReadContainer"
/>
@@ -50,7 +50,7 @@
/>
<subscriber
- for="zope.app.location.interfaces.ILocation
+ for="zope.location.interfaces.ILocation
zope.app.container.interfaces.IObjectMovedEvent"
handler=".contained.dispatchToSublocations"
>
@@ -58,7 +58,7 @@
</subscriber>
<adapter
- provides="zope.app.location.interfaces.ISublocations"
+ provides="zope.location.interfaces.ISublocations"
for="zope.app.container.interfaces.IReadContainer"
factory=".contained.ContainerSublocations"
/>
@@ -67,4 +67,22 @@
<allow interface=".constraints.IItemTypePrecondition" />
</class>
+ <view
+ for="zope.app.container.interfaces.IItemContainer"
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.publisher.interfaces.browser.IBrowserPublisher"
+ factory="zope.app.container.traversal.ItemTraverser"
+ permission="zope.Public"
+ allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
+ />
+
+ <view
+ for="zope.app.container.interfaces.ISimpleReadContainer"
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.publisher.interfaces.browser.IBrowserPublisher"
+ factory="zope.app.container.traversal.ItemTraverser"
+ permission="zope.Public"
+ allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
+ />
+
</configure>
Modified: Zope3/trunk/src/zope/app/container/contained.py
===================================================================
--- Zope3/trunk/src/zope/app/container/contained.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/contained.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,19 +17,18 @@
"""
__docformat__ = 'restructuredtext'
-from zope.exceptions import DuplicationError
-from zope.security.checker import selectChecker, CombinedChecker
-
+import zope.component
import zope.interface.declarations
+from zope.interface import providedBy
from zope.interface.declarations import getObjectSpecification
from zope.interface.declarations import ObjectSpecification
-from zope.interface import providedBy
-
-from zope.app import zapi
-from zope.app.exception.interfaces import UserError
-from zope.app.event.objectevent import ObjectEvent
-from zope.app.event.objectevent import ObjectModifiedEvent
from zope.event import notify
+from zope.component.interfaces import ObjectEvent
+from zope.location.interfaces import ILocation, ISublocations
+from zope.exceptions.interfaces import DuplicationError, UserError
+from zope.security.checker import selectChecker, CombinedChecker
+from zope.lifecycleevent import ObjectModifiedEvent
+
from zope.app.i18n import ZopeMessageFactory as _
from zope.app.container.interfaces import IContained
from zope.app.container.interfaces import INameChooser
@@ -37,7 +36,6 @@
from zope.app.container.interfaces import IObjectMovedEvent
from zope.app.container.interfaces import IObjectRemovedEvent
from zope.app.container.interfaces import IContainerModifiedEvent
-from zope.app.location.interfaces import ILocation, ISublocations
from zope.app.container._zope_app_container_contained import ContainedProxyBase
from zope.app.container._zope_app_container_contained import getProxiedObject
from zope.app.broken.broken import IBroken
@@ -181,7 +179,7 @@
subs = ISublocations(object, None)
if subs is not None:
for sub in subs.sublocations():
- for ignored in zapi.subscribers((sub, event), None):
+ for ignored in zope.component.subscribers((sub, event), None):
pass # They do work in the adapter fetch
class ContainerSublocations(object):
@@ -283,7 +281,7 @@
`__parent__` and `__name__` attributes *and* declare that it
implements `IContained`:
- >>> from zope.app.location import Location
+ >>> from zope.location import Location
>>> item = Location()
>>> IContained.providedBy(item)
False
@@ -315,7 +313,7 @@
>>> from zope.interface import Interface, directlyProvides
>>> class IOther(Interface):
... pass
- >>> from zope.app.location import Location
+ >>> from zope.location import Location
>>> item = Location()
>>> directlyProvides(item, IOther)
>>> IOther.providedBy(item)
@@ -408,8 +406,8 @@
If we run this using the testing framework, we'll use `getEvents` to
track the events generated:
- >>> from zope.app.event.tests.placelesssetup import getEvents
- >>> from zope.app.event.interfaces import IObjectModifiedEvent
+ >>> from zope.component.eventtesting import getEvents
+ >>> from zope.lifecycleevent.interfaces import IObjectModifiedEvent
We have an added event:
@@ -498,7 +496,7 @@
`__parent__` and `__name__` attributes *and* declare that it
implements `IContained`:
- >>> from zope.app.location import Location
+ >>> from zope.location import Location
>>> item = Location()
>>> IContained.providedBy(item)
0
@@ -603,9 +601,9 @@
If we run this using the testing framework, we'll use `getEvents` to
track the events generated:
- >>> from zope.app.event.tests.placelesssetup import getEvents
+ >>> from zope.component.eventtesting import getEvents
+ >>> from zope.lifecycleevent.interfaces import IObjectModifiedEvent
>>> from zope.app.container.interfaces import IObjectRemovedEvent
- >>> from zope.app.event.interfaces import IObjectModifiedEvent
We'll start by creating a container with an item:
Modified: Zope3/trunk/src/zope/app/container/directory.py
===================================================================
--- Zope3/trunk/src/zope/app/container/directory.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/directory.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,7 +25,7 @@
"""
__docformat__ = 'restructuredtext'
-import zope.app.filerepresentation.interfaces
+import zope.filerepresentation.interfaces
from zope.security.proxy import removeSecurityProxy
from zope.interface import implements
@@ -45,7 +45,7 @@
of the same class as it's context.
"""
- implements(zope.app.filerepresentation.interfaces.IDirectoryFactory)
+ implements(zope.filerepresentation.interfaces.IDirectoryFactory)
def __init__(self, context):
self.context = context
Modified: Zope3/trunk/src/zope/app/container/ftests/test_view_permissions.py
===================================================================
--- Zope3/trunk/src/zope/app/container/ftests/test_view_permissions.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/ftests/test_view_permissions.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,7 +22,7 @@
from zope.app.testing.functional import BrowserTestCase
from zope.app.file import File
-from zope.app.dublincore.interfaces import IZopeDublinCore
+from zope.dublincore.interfaces import IZopeDublinCore
from zope.app.securitypolicy.interfaces import IRolePermissionManager
Modified: Zope3/trunk/src/zope/app/container/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/container/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,12 +20,11 @@
from zope.deprecation import deprecated
from zope.interface import Interface, Attribute, Invalid
-from zope.component.interfaces import IView
+from zope.component.interfaces import IView, IObjectEvent
from zope.interface.common.mapping import IItemMapping
from zope.interface.common.mapping import IReadMapping, IEnumerableMapping
-from zope.app.location.interfaces import ILocation
-from zope.app.event.interfaces import IObjectEvent
-from zope.app.event.interfaces import IObjectModifiedEvent
+from zope.location.interfaces import ILocation
+from zope.lifecycleevent.interfaces import IObjectModifiedEvent
deprecated('IContentContainer',
'This interface has been deprecated. '
Modified: Zope3/trunk/src/zope/app/container/size.py
===================================================================
--- Zope3/trunk/src/zope/app/container/size.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/size.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,7 +19,7 @@
__docformat__ = 'restructuredtext'
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.size.interfaces import ISized
+from zope.size.interfaces import ISized
from zope.interface import implements
class ContainerSized(object):
Modified: Zope3/trunk/src/zope/app/container/tests/test_containertraversable.py
===================================================================
--- Zope3/trunk/src/zope/app/container/tests/test_containertraversable.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/tests/test_containertraversable.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,12 +16,12 @@
$Id$
"""
import unittest
-from zope.app.container.traversal import ContainerTraversable
-from zope.app.traversing.interfaces import TraversalError
-from zope.app.container.interfaces import IContainer
from zope.testing.cleanup import CleanUp
from zope.interface import implements
+from zope.traversing.interfaces import TraversalError
+from zope.app.container.traversal import ContainerTraversable
+from zope.app.container.interfaces import IContainer
class Container(object):
Modified: Zope3/trunk/src/zope/app/container/tests/test_objectcopier.py
===================================================================
--- Zope3/trunk/src/zope/app/container/tests/test_objectcopier.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/tests/test_objectcopier.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,16 +16,16 @@
$Id$
"""
from unittest import TestCase, TestSuite, main, makeSuite
+
+import zope.component
from zope.testing import doctest
+from zope.traversing.api import traverse
+from zope.component.eventtesting import getEvents, clearEvents
+from zope.copypastemove import ObjectCopier
+from zope.copypastemove.interfaces import IObjectCopier
-from zope.app.event.tests.placelesssetup import getEvents
-from zope.app.event.tests.placelesssetup import clearEvents
from zope.app.component.testing import PlacefulSetup
-from zope.app.copypastemove import ObjectCopier
-from zope.app.copypastemove.interfaces import IObjectCopier
-from zope.app.testing import ztapi
from zope.app.testing import setup
-from zope.app.traversing.api import traverse
from zope.app.folder import Folder
class File(object):
@@ -36,7 +36,7 @@
Prepare the setup::
>>> root = setup.placefulSetUp(site=True)
- >>> ztapi.provideAdapter(None, IObjectCopier, ObjectCopier)
+ >>> zope.component.provideAdapter(ObjectCopier, (None,), IObjectCopier)
Prepare some objects::
@@ -83,7 +83,7 @@
def setUp(self):
PlacefulSetup.setUp(self)
PlacefulSetup.buildFolders(self)
- ztapi.provideAdapter(None, IObjectCopier, ObjectCopier)
+ zope.component.provideAdapter(ObjectCopier, (None,), IObjectCopier)
def test_copytosame(self):
root = self.rootFolder
Modified: Zope3/trunk/src/zope/app/container/tests/test_objectmover.py
===================================================================
--- Zope3/trunk/src/zope/app/container/tests/test_objectmover.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/tests/test_objectmover.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,16 +16,16 @@
$Id$
"""
from unittest import TestCase, TestSuite, main, makeSuite
+
+import zope.component
from zope.testing import doctest
+from zope.traversing.api import traverse
+from zope.component.eventtesting import getEvents, clearEvents
+from zope.copypastemove import ObjectMover
+from zope.copypastemove.interfaces import IObjectMover
-from zope.app.event.tests.placelesssetup import getEvents
-from zope.app.event.tests.placelesssetup import clearEvents
from zope.app.component.testing import PlacefulSetup
-from zope.app.copypastemove import ObjectMover
-from zope.app.copypastemove.interfaces import IObjectMover
-from zope.app.testing import ztapi
from zope.app.testing import setup
-from zope.app.traversing.api import traverse
from zope.app.folder import Folder
class File(object):
@@ -36,7 +36,7 @@
Prepare the setup::
>>> root = setup.placefulSetUp(site=True)
- >>> ztapi.provideAdapter(None, IObjectMover, ObjectMover)
+ >>> zope.component.provideAdapter(ObjectMover, (None,), IObjectMover)
Prepare some objects::
@@ -96,7 +96,7 @@
def setUp(self):
PlacefulSetup.setUp(self)
PlacefulSetup.buildFolders(self)
- ztapi.provideAdapter(None, IObjectMover, ObjectMover)
+ zope.component.provideAdapter(ObjectMover, (None,), )
def test_movetosame(self):
# Should be a noop, because "moving" to same location
Modified: Zope3/trunk/src/zope/app/container/tests/test_ordered.py
===================================================================
--- Zope3/trunk/src/zope/app/container/tests/test_ordered.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/tests/test_ordered.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,12 +16,9 @@
$Id$
"""
import unittest
-
from zope.testing.doctestunit import DocTestSuite
-from zope.app.testing import placelesssetup
-from zope.app.testing import setup
-from zope.app.event.tests.placelesssetup import getEvents
-from zope.app.event.tests.placelesssetup import clearEvents
+from zope.component.eventtesting import getEvents, clearEvents
+from zope.app.testing import placelesssetup, setup
def test_order_events():
"""
@@ -54,7 +51,7 @@
This is in fact a specialized modification event::
- >>> from zope.app.event.interfaces import IObjectModifiedEvent
+ >>> from zope.lifecycleevent.interfaces import IObjectModifiedEvent
>>> IObjectModifiedEvent.providedBy(events[0])
True
Modified: Zope3/trunk/src/zope/app/container/tests/test_size.py
===================================================================
--- Zope3/trunk/src/zope/app/container/tests/test_size.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/tests/test_size.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,9 +17,9 @@
"""
import unittest
-from zope.app.size.interfaces import ISized
+from zope.interface import implements
+from zope.size.interfaces import ISized
from zope.app.container.interfaces import IContainer
-from zope.interface import implements
class DummyContainer(object):
Modified: Zope3/trunk/src/zope/app/container/traversal.py
===================================================================
--- Zope3/trunk/src/zope/app/container/traversal.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/container/traversal.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,7 +18,8 @@
__docformat__ = 'restructuredtext'
from zope.interface import implements
-from zope.app.traversing.interfaces import TraversalError
+from zope.component import queryMultiAdapter
+from zope.traversing.interfaces import TraversalError, ITraversable
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.publisher.interfaces.xmlrpc import IXMLRPCPublisher
from zope.publisher.interfaces import NotFound
@@ -26,7 +27,6 @@
from zope.app import zapi
from zope.app.container.interfaces import ISimpleReadContainer, IItemContainer
from zope.app.container.interfaces import IReadContainer
-from zope.app.traversing.interfaces import ITraversable
# Note that the next two classes are included here because they
# can be used for multiple view types.
@@ -45,7 +45,7 @@
"""See zope.publisher.interfaces.IPublishTraverse"""
subob = self.context.get(name, None)
if subob is None:
- view = zapi.queryMultiAdapter((self.context, request), name=name)
+ view = queryMultiAdapter((self.context, request), name=name)
if view is not None:
return view
@@ -71,7 +71,7 @@
try:
return self.context[name]
except KeyError:
- view = zapi.queryMultiAdapter((self.context, request), name=name)
+ view = queryMultiAdapter((self.context, request), name=name)
if view is not None:
return view
Modified: Zope3/trunk/src/zope/app/content/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/content/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/content/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,8 +17,8 @@
"""
__docformat__ = 'restructuredtext'
from zope.interface import classProvides
+from zope.schema.interfaces import IVocabularyFactory
from zope.app.interface import queryType
-from zope.app.schema.interfaces import IVocabularyFactory
from zope.app.content.interfaces import IContentType
from zope.app.component.vocabulary import UtilityVocabulary
Modified: Zope3/trunk/src/zope/app/content_types.py
===================================================================
--- Zope3/trunk/src/zope/app/content_types.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/content_types.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,9 +1,7 @@
-from zope.app.contenttypes import text_type, guess_content_type, add_files
-from zope.deprecation import deprecated
-
-msg = ('zope.app.content_types has moved to zope.app.contenttypes. '
- 'This reference go away in Zope 3.4.')
-
-deprecated('text_type', msg)
-deprecated('guess_content_type', msg)
-deprecated('add_files', msg)
+# This module has moved to zope.contenttype
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.contenttype',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/content_types.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: Zope3/trunk/src/zope/app/copypastemove/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/copypastemove/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/copypastemove/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,718 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Copy, Paste and Move support for content components
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
+# This module has moved to zope.copypastemove
+# and will go away in Zope 3.5
import zope.deprecation
-
-from zope.interface import implements, Invalid
-from zope.exceptions import DuplicationError
-from zope.component import adapts
-from zope.event import notify
-
-from zope.app import zapi
-from zope.app.annotation.interfaces import IAnnotations
-from zope.app.annotation.interfaces import IAnnotations
-from zope.app.container.sample import SampleContainer
-from zope.app.event.objectevent import ObjectCopiedEvent
-from zope.app.location.pickling import locationCopy
-from zope.app.location.interfaces import ISublocations
-from zope.app.container.interfaces import IContainer, IOrderedContainer
-from zope.app.container.interfaces import IContained
-from zope.app.container.interfaces import INameChooser
-from zope.app.container.constraints import checkObject
-
-from zope.app.copypastemove.interfaces import IObjectMover
-from zope.app.copypastemove.interfaces import IObjectCopier
-from zope.app.copypastemove.interfaces import IContainerItemRenamer
-from zope.app.copypastemove.interfaces import IPrincipalClipboard
-from zope.app.copypastemove.interfaces import IItemNotFoundError
-
-# BBB (remove in 3.3)
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError
-zope.deprecation.__show__.on()
-
-import warnings # BBB (remove in 3.3)
-
-class ItemNotFoundError(NotFoundError):
- implements(IItemNotFoundError)
-
-class ObjectMover(object):
- """Adapter for moving objects between containers
-
- To use an object mover, pass a contained `object` to the class.
- The contained `object` should implement `IContained`. It should be
- contained in a container that has an adapter to `INameChooser`.
-
-
- >>> from zope.app.container.contained import Contained
- >>> ob = Contained()
- >>> container = ExampleContainer()
- >>> container[u'foo'] = ob
- >>> mover = ObjectMover(ob)
-
- In addition to moving objects, object movers can tell you if the
- object is movable:
-
- >>> mover.moveable()
- True
-
- which, at least for now, they always are. A better question to
- ask is whether we can move to a particular container. Right now,
- we can always move to a container of the same class:
-
- >>> container2 = ExampleContainer()
- >>> mover.moveableTo(container2)
- True
- >>> mover.moveableTo({})
- Traceback (most recent call last):
- ...
- TypeError: Container is not a valid Zope container.
-
- Of course, once we've decided we can move an object, we can use
- the mover to do so:
-
- >>> mover.moveTo(container2)
- u'foo'
- >>> list(container)
- []
- >>> list(container2)
- [u'foo']
- >>> ob.__parent__ is container2
- True
-
- We can also specify a name:
-
- >>> mover.moveTo(container2, u'bar')
- u'bar'
- >>> list(container2)
- [u'bar']
- >>> ob.__parent__ is container2
- True
- >>> ob.__name__
- u'bar'
-
- But we may not use the same name given, if the name is already in
- use:
-
- >>> container2[u'splat'] = 1
- >>> mover.moveTo(container2, u'splat')
- u'splat_'
- >>> l = list(container2)
- >>> l.sort()
- >>> l
- [u'splat', u'splat_']
- >>> ob.__name__
- u'splat_'
-
-
- If we try to move to an invalid container, we'll get an error:
-
- >>> mover.moveTo({})
- Traceback (most recent call last):
- ...
- TypeError: Container is not a valid Zope container.
-
-
- Do a test for preconditions:
-
- >>> import zope.interface
- >>> import zope.schema
- >>> def preNoZ(container, name, ob):
- ... "Silly precondition example"
- ... if name.startswith("Z"):
- ... raise zope.interface.Invalid("Invalid name.")
-
- >>> class I1(zope.interface.Interface):
- ... def __setitem__(name, on):
- ... "Add an item"
- ... __setitem__.precondition = preNoZ
-
- >>> from zope.app.container.interfaces import IContainer
- >>> class C1(object):
- ... zope.interface.implements(I1, IContainer)
- ... def __repr__(self):
- ... return 'C1'
-
- >>> from zope.app.container.constraints import checkObject
- >>> container3 = C1()
- >>> mover.moveableTo(container3, 'ZDummy')
- False
- >>> mover.moveableTo(container3, 'newName')
- True
-
- And a test for constraints:
-
- >>> def con1(container):
- ... "silly container constraint"
- ... if not hasattr(container, 'x'):
- ... return False
- ... return True
- ...
- >>> class I2(zope.interface.Interface):
- ... __parent__ = zope.schema.Field(constraint=con1)
- ...
- >>> class constrainedObject(object):
- ... zope.interface.implements(I2)
- ... def __init__(self):
- ... self.__name__ = 'constrainedObject'
- ...
- >>> cO = constrainedObject()
- >>> mover2 = ObjectMover(cO)
- >>> mover2.moveableTo(container)
- False
- >>> container.x = 1
- >>> mover2.moveableTo(container)
- True
-
- """
-
- adapts(IContained)
-
- implements(IObjectMover)
-
- def __init__(self, object):
- self.context = object
- self.__parent__ = object # TODO: see if we can automate this
-
- def moveTo(self, target, new_name=None):
- """Move this object to the `target` given.
-
- Returns the new name within the `target`
- Typically, the `target` is adapted to `IPasteTarget`."""
-
- obj = self.context
- container = obj.__parent__
-
- orig_name = obj.__name__
- if new_name is None:
- new_name = orig_name
-
- checkObject(target, new_name, obj)
-
- if target is container and new_name == orig_name:
- # Nothing to do
- return
-
- chooser = INameChooser(target)
- new_name = chooser.chooseName(new_name, obj)
-
- target[new_name] = obj
- del container[orig_name]
- return new_name
-
- def moveable(self):
- """Returns ``True`` if the object is moveable, otherwise ``False``."""
- return True
-
- def moveableTo(self, target, name=None):
- """Say whether the object can be moved to the given target.
-
- Returns ``True`` if it can be moved there. Otherwise, returns
- ``False``.
- """
- if name is None:
- name = self.context.__name__
- try:
- checkObject(target, name, self.context)
- except Invalid:
- return False
- return True
-
-class ObjectCopier(object):
- """Adapter for copying objects between containers
-
- To use an object copier, pass a contained `object` to the class.
- The contained `object` should implement `IContained`. It should be
- contained in a container that has an adapter to `INameChooser`.
-
- >>> from zope.app.container.contained import Contained
- >>> ob = Contained()
- >>> container = ExampleContainer()
- >>> container[u'foo'] = ob
- >>> copier = ObjectCopier(ob)
-
- In addition to moving objects, object copiers can tell you if the
- object is movable:
-
- >>> copier.copyable()
- True
-
- which, at least for now, they always are. A better question to
- ask is whether we can copy to a particular container. Right now,
- we can always copy to a container of the same class:
-
- >>> container2 = ExampleContainer()
- >>> copier.copyableTo(container2)
- True
- >>> copier.copyableTo({})
- Traceback (most recent call last):
- ...
- TypeError: Container is not a valid Zope container.
-
- Of course, once we've decided we can copy an object, we can use
- the copier to do so:
-
- >>> copier.copyTo(container2)
- u'foo'
- >>> list(container)
- [u'foo']
- >>> list(container2)
- [u'foo']
- >>> ob.__parent__ is container
- True
- >>> container2[u'foo'] is ob
- False
- >>> container2[u'foo'].__parent__ is container2
- True
- >>> container2[u'foo'].__name__
- u'foo'
-
- We can also specify a name:
-
- >>> copier.copyTo(container2, u'bar')
- u'bar'
- >>> l = list(container2)
- >>> l.sort()
- >>> l
- [u'bar', u'foo']
-
- >>> ob.__parent__ is container
- True
- >>> container2[u'bar'] is ob
- False
- >>> container2[u'bar'].__parent__ is container2
- True
- >>> container2[u'bar'].__name__
- u'bar'
-
- But we may not use the same name given, if the name is already in
- use:
-
- >>> copier.copyTo(container2, u'bar')
- u'bar_'
- >>> l = list(container2)
- >>> l.sort()
- >>> l
- [u'bar', u'bar_', u'foo']
- >>> container2[u'bar_'].__name__
- u'bar_'
-
-
- If we try to copy to an invalid container, we'll get an error:
-
- >>> copier.copyTo({})
- Traceback (most recent call last):
- ...
- TypeError: Container is not a valid Zope container.
-
- Do a test for preconditions:
-
- >>> import zope.interface
- >>> import zope.schema
- >>> def preNoZ(container, name, ob):
- ... "Silly precondition example"
- ... if name.startswith("Z"):
- ... raise zope.interface.Invalid("Invalid name.")
-
- >>> class I1(zope.interface.Interface):
- ... def __setitem__(name, on):
- ... "Add an item"
- ... __setitem__.precondition = preNoZ
-
- >>> from zope.app.container.interfaces import IContainer
- >>> class C1(object):
- ... zope.interface.implements(I1, IContainer)
- ... def __repr__(self):
- ... return 'C1'
-
- >>> from zope.app.container.constraints import checkObject
- >>> container3 = C1()
- >>> copier.copyableTo(container3, 'ZDummy')
- False
- >>> copier.copyableTo(container3, 'newName')
- True
-
- And a test for constraints:
-
- >>> def con1(container):
- ... "silly container constraint"
- ... if not hasattr(container, 'x'):
- ... return False
- ... return True
- ...
- >>> class I2(zope.interface.Interface):
- ... __parent__ = zope.schema.Field(constraint=con1)
- ...
- >>> class constrainedObject(object):
- ... zope.interface.implements(I2)
- ... def __init__(self):
- ... self.__name__ = 'constrainedObject'
- ...
- >>> cO = constrainedObject()
- >>> copier2 = ObjectCopier(cO)
- >>> copier2.copyableTo(container)
- False
- >>> container.x = 1
- >>> copier2.copyableTo(container)
- True
-
- """
-
- adapts(IContained)
-
- implements(IObjectCopier)
-
- def __init__(self, object):
- self.context = object
- self.__parent__ = object # TODO: see if we can automate this
-
- def copyTo(self, target, new_name=None):
- """Copy this object to the `target` given.
-
- Returns the new name within the `target`.
-
- Typically, the `target` is adapted to `IPasteTarget`.
- After the copy is added to the `target` container, publish
- an `IObjectCopied` event in the context of the target container.
- If a new object is created as part of the copying process, then
- an `IObjectCreated` event should be published.
- """
- obj = self.context
- container = obj.__parent__
-
- orig_name = obj.__name__
- if new_name is None:
- new_name = orig_name
-
- checkObject(target, new_name, obj)
-
- chooser = INameChooser(target)
- new_name = chooser.chooseName(new_name, obj)
-
- copy = locationCopy(obj)
- copy.__parent__ = copy.__name__ = None
- notify(ObjectCopiedEvent(copy, obj))
-
- target[new_name] = copy
- return new_name
-
- def _configureCopy(self, copy, target, new_name):
- """Configures the copied object before it is added to `target`.
-
- `target` and `new_name` are provided as additional information.
-
- By default, `copy.__parent__` and `copy.__name__` are set to ``None``.
-
- Subclasses may override this method to perform additional
- configuration of the copied object.
- """
- # BBB (remove in 3.3)
- warnings.warn(
- "_configureCopy is deprecated -- to configure a recently copied"
- "object, register a handler for IObjectCopiedEvent",
- DeprecationWarning)
- copy.__parent__ = copy.__name__ = None
-
- def copyable(self):
- """Returns True if the object is copyable, otherwise False."""
- return True
-
- def copyableTo(self, target, name=None):
- """Say whether the object can be copied to the given `target`.
-
- Returns ``True`` if it can be copied there. Otherwise, returns
- ``False``.
- """
- if name is None:
- name = self.context.__name__
- try:
- checkObject(target, name, self.context)
- except Invalid:
- return False
- return True
-
-
-class ContainerItemRenamer(object):
- """An IContainerItemRenamer adapter for containers.
-
- This adapter uses IObjectMover to move an item within the same container
- to a different name. We need to first setup an adapter for IObjectMover:
-
- >>> from zope.app.testing import ztapi
- >>> from zope.app.container.interfaces import IContained
- >>> ztapi.provideAdapter(IContained, IObjectMover, ObjectMover)
-
- To rename an item in a container, instantiate a ContainerItemRenamer
- with the container:
-
- >>> container = SampleContainer()
- >>> renamer = ContainerItemRenamer(container)
-
- For this example, we'll rename an item 'foo':
-
- >>> from zope.app.container.contained import Contained
- >>> foo = Contained()
- >>> container['foo'] = foo
- >>> container['foo'] is foo
- True
-
- to 'bar':
-
- >>> renamer.renameItem('foo', 'bar')
- >>> container['foo'] is foo
- Traceback (most recent call last):
- KeyError: 'foo'
- >>> container['bar'] is foo
- True
-
- If the item being renamed isn't in the container, a NotFoundError is raised:
-
- >>> renamer.renameItem('foo', 'bar') # doctest:+ELLIPSIS
- Traceback (most recent call last):
- ItemNotFoundError: (<...SampleContainer...>, 'foo')
-
- If the new item name already exists, a DuplicationError is raised:
-
- >>> renamer.renameItem('bar', 'bar')
- Traceback (most recent call last):
- DuplicationError: bar is already in use
-
- """
-
- adapts(IContainer)
-
- implements(IContainerItemRenamer)
-
- def __init__(self, container):
- self.container = container
-
- def renameItem(self, oldName, newName):
- object = self.container.get(oldName)
- if object is None:
- raise ItemNotFoundError(self.container, oldName)
- mover = IObjectMover(object)
-
- if newName in self.container:
- raise DuplicationError("%s is already in use" % newName)
-
- mover.moveTo(self.container, newName)
-
-
-class OrderedContainerItemRenamer(ContainerItemRenamer):
- """Renames items within an ordered container.
-
- This renamer preserves the original order of the contained items.
-
- To illustrate, we need to setup an IObjectMover, which is used in the
- renaming:
-
- >>> from zope.app.testing import ztapi
- >>> from zope.app.container.interfaces import IContained
- >>> ztapi.provideAdapter(IContained, IObjectMover, ObjectMover)
-
- To rename an item in an ordered container, we instantiate a
- OrderedContainerItemRenamer with the container:
-
- >>> from zope.app.container.ordered import OrderedContainer
- >>> container = OrderedContainer()
- >>> renamer = OrderedContainerItemRenamer(container)
-
- We'll add three items to the container:
-
- >>> container['1'] = 'Item 1'
- >>> container['2'] = 'Item 2'
- >>> container['3'] = 'Item 3'
- >>> container.items()
- [('1', 'Item 1'), ('2', 'Item 2'), ('3', 'Item 3')]
-
- When we rename one of the items:
-
- >>> renamer.renameItem('1', 'I')
-
- the order is preserved:
-
- >>> container.items()
- [('I', 'Item 1'), ('2', 'Item 2'), ('3', 'Item 3')]
-
- Renaming the other two items also preserves the origina order:
-
- >>> renamer.renameItem('2', 'II')
- >>> renamer.renameItem('3', 'III')
- >>> container.items()
- [('I', 'Item 1'), ('II', 'Item 2'), ('III', 'Item 3')]
-
- As with the standard renamer, trying to rename a non-existent item raises
- an error:
-
- >>> renamer.renameItem('IV', '4') # doctest:+ELLIPSIS
- Traceback (most recent call last):
- ItemNotFoundError: (<...OrderedContainer...>, 'IV')
-
- And if the new item name already exists, a DuplicationError is raised:
-
- >>> renamer.renameItem('III', 'I')
- Traceback (most recent call last):
- DuplicationError: I is already in use
-
- """
-
- adapts(IOrderedContainer)
-
- implements(IContainerItemRenamer)
-
- def renameItem(self, oldName, newName):
- order = list(self.container.keys())
- super(OrderedContainerItemRenamer, self).renameItem(oldName, newName)
- order[order.index(oldName)] = newName
- self.container.updateOrder(order)
-
-
-class PrincipalClipboard(object):
- """Principal clipboard
-
- Clipboard information consists of mappings of
- ``{'action':action, 'target':target}``.
- """
-
- adapts(IAnnotations)
-
- implements(IPrincipalClipboard)
-
- def __init__(self, annotation):
- self.context = annotation
-
- def clearContents(self):
- """Clear the contents of the clipboard"""
- self.context['clipboard'] = ()
-
- def addItems(self, action, targets):
- """Add new items to the clipboard"""
- contents = self.getContents()
- actions = []
- for target in targets:
- actions.append({'action':action, 'target':target})
- self.context['clipboard'] = contents + tuple(actions)
-
- def setContents(self, clipboard):
- """Replace the contents of the clipboard by the given value"""
- self.context['clipboard'] = clipboard
-
- def getContents(self):
- """Return the contents of the clipboard"""
- return self.context.get('clipboard', ())
-
-
-def rename(container, oldid, newid):
- """Renames an item with oldid in the container to newid.
-
- This function is deprecated. Use IContainerItemRenamer instead.
- """
- # BBB (remove in 3.3)
- warnings.warn(
- "rename is deprecated and will not be supported starting in "
- "Zope 3.3. Use IContainerItemRenamer(container).renameItem "
- "instead.", DeprecationWarning)
- IContainerItemRenamer(container).renameItem(oldid, newid)
-
-
-class ExampleContainer(SampleContainer):
- # Sample container used for examples in doc stringss in this module
-
- implements(INameChooser)
-
- def chooseName(self, name, ob):
- while name in self:
- name += '_'
- return name
-
-
-def dispatchToSublocations(object, event):
- """Dispatches an event to sublocations of a given object.
-
- This handler is used to dispatch copy events to sublocations.
-
- To illustrate, we'll first create a hierarchy of objects:
-
- >>> class L(object):
- ... def __init__(self, name):
- ... self.__name__ = name
- ... self.__parent__ = None
- ... def __repr__(self):
- ... return '%s(%s)' % (self.__class__.__name__, self.__name__)
-
- >>> class C(L):
- ... implements(ISublocations)
- ... def __init__(self, name, *subs):
- ... L.__init__(self, name)
- ... self.subs = subs
- ... for sub in subs:
- ... sub.__parent__ = self
- ... def sublocations(self):
- ... return self.subs
-
- >>> c = C(1,
- ... C(11,
- ... L(111),
- ... L(112),
- ... ),
- ... C(12,
- ... L(121),
- ... L(122),
- ... L(123),
- ... L(124),
- ... ),
- ... L(13),
- ... )
-
- and a handler for copy events that records the objects it's seen:
-
- >>> seen = []
- >>> def handler(ob, event):
- ... seen.append((ob, event.object))
-
- Finally, we need to register our handler for copy events:
-
- >>> from zope.app.tests import ztapi
- >>> from zope.app.event.interfaces import IObjectCopiedEvent
- >>> ztapi.subscribe([None, IObjectCopiedEvent], None, handler)
-
- and this function as a dispatcher:
-
- >>> ztapi.subscribe([None, IObjectCopiedEvent], None,
- ... dispatchToSublocations)
-
- When we notify that our root object has been copied:
-
- >>> notify(ObjectCopiedEvent(c, L('')))
-
- we see that our handler has seen all of the subobjects:
-
- >>> seenreprs = map(repr, seen)
- >>> seenreprs.sort()
- >>> seenreprs #doctest: +NORMALIZE_WHITESPACE
- ['(C(1), C(1))', '(C(11), C(1))', '(C(12), C(1))',
- '(L(111), C(1))', '(L(112), C(1))', '(L(121), C(1))',
- '(L(122), C(1))', '(L(123), C(1))', '(L(124), C(1))',
- '(L(13), C(1))']
- """
- subs = ISublocations(object, None)
- if subs is not None:
- for sub in subs.sublocations():
- for ignored in zapi.subscribers((sub, event), None):
- pass # They do work in the adapter fetch
+zope.deprecation.moved(
+ 'zope.copypastemove',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/copypastemove/__init__.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.2
Deleted: Zope3/trunk/src/zope/app/copypastemove/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/copypastemove/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/copypastemove/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,31 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:global_translation="http://namespaces.zope.org/gts"
- i18n_domain="zope"
- >
-
- <adapter
- factory=".ObjectMover"
- permission="zope.ManageContent"
- trusted="y"
- />
-
- <adapter
- factory=".ObjectCopier"
- permission="zope.ManageContent"
- trusted="y"
- />
-
- <adapter factory=".ContainerItemRenamer" />
-
- <adapter factory=".OrderedContainerItemRenamer" />
-
- <adapter factory=".PrincipalClipboard" />
-
- <subscriber
- for="zope.app.location.interfaces.ILocation
- zope.app.event.interfaces.IObjectCopiedEvent"
- handler=".dispatchToSublocations"
- />
-
-</configure>
Modified: Zope3/trunk/src/zope/app/copypastemove/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/copypastemove/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/copypastemove/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,95 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Copy and Move support
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.interface import Interface
-
-class IObjectMover(Interface):
- """Use `IObjectMover(obj)` to move an object somewhere."""
-
- def moveTo(target, new_name=None):
- """Move this object to the target given.
-
- Returns the new name within the target.
- Typically, the target is adapted to `IPasteTarget`."""
-
- def moveable():
- """Returns ``True`` if the object is moveable, otherwise ``False``."""
-
- def moveableTo(target, name=None):
- """Say whether the object can be moved to the given `target`.
-
- Returns ``True`` if it can be moved there. Otherwise, returns
- ``False``.
- """
-
-class IObjectCopier(Interface):
-
- def copyTo(target, new_name=None):
- """Copy this object to the `target` given.
-
- Returns the new name within the `target`.
- Typically, the target is adapted to `IPasteTarget`.
- After the copy is added to the target container, publish
- an `IObjectCopied` event in the context of the target container.
- If a new object is created as part of the copying process, then
- an `IObjectCreated` event should be published.
- """
-
- def copyable():
- """Returns ``True`` if the object is copyable, otherwise ``False``."""
-
- def copyableTo(target, name=None):
- """Say whether the object can be copied to the given `target`.
-
- Returns ``True`` if it can be copied there. Otherwise, returns
- ``False``.
- """
-
-class IContainerItemRenamer(Interface):
-
- def renameItem(oldName, newName):
- """Renames an object in the container from oldName to newName.
-
- Raises ItemNotFoundError if oldName doesn't exist in the container.
-
- Raises DuplicationError if newName is already used in the container.
- """
-
-class IPrincipalClipboard(Interface):
- """Interface for adapters that store/retrieve clipboard information
- for a principal.
-
- Clipboard information consists of mappings of
- ``{'action':action, 'target':target}``.
- """
-
- def clearContents():
- """Clear the contents of the clipboard"""
-
- def addItems(action, targets):
- """Add new items to the clipboard"""
-
- def setContents(clipboard):
- """Replace the contents of the clipboard by the given value"""
-
- def getContents():
- """Return the contents of the clipboard"""
-
-class IItemNotFoundError(Interface):
- pass
+# This module has moved to zope.copypastemove.interfaces
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.copypastemove.interfaces',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/copypastemove/interfaces.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.2
Modified: Zope3/trunk/src/zope/app/datetimeutils.py
===================================================================
--- Zope3/trunk/src/zope/app/datetimeutils.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/datetimeutils.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,948 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Commonly used utility functions.
-
-Encapsulation of date/time values
-
-$Id$
-"""
-import math
-import re
-import time as _time # there is a method definition that makes just "time"
- # problematic while executing a class definition
-
-from types import StringTypes
-
-try:
- from time import tzname
-except ImportError:
- tzname = ('UNKNOWN', 'UNKNOWN')
-
-# These are needed because the various date formats below must
-# be in english per the RFCs. That means we can't use strftime,
-# which is affected by different locale settings.
-weekday_abbr = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
-weekday_full = ['Monday', 'Tuesday', 'Wednesday', 'Thursday',
- 'Friday', 'Saturday', 'Sunday']
-monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
-
-
-def iso8601_date(ts=None):
- # Return an ISO 8601 formatted date string, required
- # for certain DAV properties.
- # '2000-11-10T16:21:09-08:00
- if ts is None:
- ts = _time.time()
- return _time.strftime('%Y-%m-%dT%H:%M:%SZ', _time.gmtime(ts))
-
-def rfc850_date(ts=None):
- # Return an HTTP-date formatted date string.
- # 'Friday, 10-Nov-00 16:21:09 GMT'
- if ts is None:
- ts = _time.time()
- year, month, day, hh, mm, ss, wd, y, z = _time.gmtime(ts)
- return "%s, %02d-%3s-%2s %02d:%02d:%02d GMT" % (
- weekday_full[wd],
- day, monthname[month],
- str(year)[2:],
- hh, mm, ss)
-
-def rfc1123_date(ts=None):
- # Return an RFC 1123 format date string, required for
- # use in HTTP Date headers per the HTTP 1.1 spec.
- # 'Fri, 10 Nov 2000 16:21:09 GMT'
- if ts is None:
- ts = _time.time()
- year, month, day, hh, mm, ss, wd, y, z = _time.gmtime(ts)
- return "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (weekday_abbr[wd],
- day, monthname[month],
- year,
- hh, mm, ss)
-
-
-
-from timezones import historical_zone_info as _data
-
-class DateTimeError(Exception): "Date-time error"
-class DateError(DateTimeError): 'Invalid Date Components'
-class TimeError(DateTimeError): 'Invalid Time Components'
-class SyntaxError(DateTimeError): 'Invalid Date-Time String'
-
-# Determine machine epoch
-tm=((0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334),
- (0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335))
-yr,mo,dy,hr,mn,sc = _time.gmtime(0)[:6]
-i=int(yr-1)
-to_year =int(i*365+i/4-i/100+i/400-693960.0)
-to_month=tm[yr%4==0 and (yr%100!=0 or yr%400==0)][mo]
-EPOCH =(to_year+to_month+dy+(hr/24.0+mn/1440.0+sc/86400.0))*86400
-jd1901 =2415385L
-
-
-numericTimeZoneMatch=re.compile(r'[+-][0-9][0-9][0-9][0-9]').match #TS
-
-class _timezone:
- def __init__(self,data):
- self.name,self.timect,self.typect, \
- self.ttrans,self.tindex,self.tinfo,self.az=data
-
- def default_index(self):
- if self.timect == 0: return 0
- for i in range(self.typect):
- if self.tinfo[i][1] == 0: return i
- return 0
-
- def index(self, t=None):
- t = t or _time.time()
- if self.timect == 0:
- idx = (0, 0, 0)
- elif t < self.ttrans[0]:
- i = self.default_index()
- idx = (i, ord(self.tindex[0]),i)
- elif t >= self.ttrans[-1]:
- if self.timect > 1:
- idx=(ord(self.tindex[-1]),ord(self.tindex[-1]),
- ord(self.tindex[-2]))
- else:
- idx=(ord(self.tindex[-1]),ord(self.tindex[-1]),
- self.default_index())
- else:
- for i in range(self.timect-1):
- if t < self.ttrans[i+1]:
- if i==0: idx=(ord(self.tindex[0]),ord(self.tindex[1]),
- self.default_index())
- else: idx=(ord(self.tindex[i]),ord(self.tindex[i+1]),
- ord(self.tindex[i-1]))
- break
- return idx
-
- def info(self,t=None):
- idx=self.index(t)[0]
- zs =self.az[self.tinfo[idx][2]:]
- return self.tinfo[idx][0],self.tinfo[idx][1],zs[: zs.find('\000')]
-
-
-
-
-class _cache:
-
- _zlst=['Brazil/Acre','Brazil/DeNoronha','Brazil/East',
- 'Brazil/West','Canada/Atlantic','Canada/Central',
- 'Canada/Eastern','Canada/East-Saskatchewan',
- 'Canada/Mountain','Canada/Newfoundland',
- 'Canada/Pacific','Canada/Yukon',
- 'Chile/Continental','Chile/EasterIsland','CST','Cuba',
- 'Egypt','EST','GB-Eire','Greenwich','Hongkong','Iceland',
- 'Iran','Israel','Jamaica','Japan','Mexico/BajaNorte',
- 'Mexico/BajaSur','Mexico/General','MST','Poland','PST',
- 'Singapore','Turkey','Universal','US/Alaska','US/Aleutian',
- 'US/Arizona','US/Central','US/Eastern','US/East-Indiana',
- 'US/Hawaii','US/Indiana-Starke','US/Michigan',
- 'US/Mountain','US/Pacific','US/Samoa','UTC','UCT','GMT',
-
- 'GMT+0100','GMT+0200','GMT+0300','GMT+0400','GMT+0500',
- 'GMT+0600','GMT+0700','GMT+0800','GMT+0900','GMT+1000',
- 'GMT+1100','GMT+1200','GMT+1300','GMT-0100','GMT-0200',
- 'GMT-0300','GMT-0400','GMT-0500','GMT-0600','GMT-0700',
- 'GMT-0800','GMT-0900','GMT-1000','GMT-1100','GMT-1200',
- 'GMT+1',
-
- 'GMT+0130', 'GMT+0230', 'GMT+0330', 'GMT+0430', 'GMT+0530',
- 'GMT+0630', 'GMT+0730', 'GMT+0830', 'GMT+0930', 'GMT+1030',
- 'GMT+1130', 'GMT+1230',
-
- 'GMT-0130', 'GMT-0230', 'GMT-0330', 'GMT-0430', 'GMT-0530',
- 'GMT-0630', 'GMT-0730', 'GMT-0830', 'GMT-0930', 'GMT-1030',
- 'GMT-1130', 'GMT-1230',
-
- 'UT','BST','MEST','SST','FST','WADT','EADT','NZDT',
- 'WET','WAT','AT','AST','NT','IDLW','CET','MET',
- 'MEWT','SWT','FWT','EET','EEST','BT','ZP4','ZP5','ZP6',
- 'WAST','CCT','JST','EAST','GST','NZT','NZST','IDLE']
-
-
- _zmap={'aest':'GMT+1000', 'aedt':'GMT+1100',
- 'aus eastern standard time':'GMT+1000',
- 'sydney standard time':'GMT+1000',
- 'tasmania standard time':'GMT+1000',
- 'e. australia standard time':'GMT+1000',
- 'aus central standard time':'GMT+0930',
- 'cen. australia standard time':'GMT+0930',
- 'w. australia standard time':'GMT+0800',
-
- 'brazil/acre':'Brazil/Acre',
- 'brazil/denoronha':'Brazil/Denoronha',
- 'brazil/east':'Brazil/East','brazil/west':'Brazil/West',
- 'canada/atlantic':'Canada/Atlantic',
- 'canada/central':'Canada/Central',
- 'canada/eastern':'Canada/Eastern',
- 'canada/east-saskatchewan':'Canada/East-Saskatchewan',
- 'canada/mountain':'Canada/Mountain',
- 'canada/newfoundland':'Canada/Newfoundland',
- 'canada/pacific':'Canada/Pacific','canada/yukon':'Canada/Yukon',
- 'central europe standard time':'GMT+0100',
- 'chile/continental':'Chile/Continental',
- 'chile/easterisland':'Chile/EasterIsland',
- 'cst':'US/Central','cuba':'Cuba','est':'US/Eastern','egypt':'Egypt',
- 'eastern standard time':'US/Eastern',
- 'us eastern standard time':'US/Eastern',
- 'central standard time':'US/Central',
- 'mountain standard time':'US/Mountain',
- 'pacific standard time':'US/Pacific',
- 'gb-eire':'GB-Eire','gmt':'GMT',
-
- 'gmt+0000':'GMT+0', 'gmt+0':'GMT+0',
-
-
- 'gmt+0100':'GMT+1', 'gmt+0200':'GMT+2', 'gmt+0300':'GMT+3',
- 'gmt+0400':'GMT+4', 'gmt+0500':'GMT+5', 'gmt+0600':'GMT+6',
- 'gmt+0700':'GMT+7', 'gmt+0800':'GMT+8', 'gmt+0900':'GMT+9',
- 'gmt+1000':'GMT+10','gmt+1100':'GMT+11','gmt+1200':'GMT+12',
- 'gmt+1300':'GMT+13',
- 'gmt-0100':'GMT-1', 'gmt-0200':'GMT-2', 'gmt-0300':'GMT-3',
- 'gmt-0400':'GMT-4', 'gmt-0500':'GMT-5', 'gmt-0600':'GMT-6',
- 'gmt-0700':'GMT-7', 'gmt-0800':'GMT-8', 'gmt-0900':'GMT-9',
- 'gmt-1000':'GMT-10','gmt-1100':'GMT-11','gmt-1200':'GMT-12',
-
- 'gmt+1': 'GMT+1', 'gmt+2': 'GMT+2', 'gmt+3': 'GMT+3',
- 'gmt+4': 'GMT+4', 'gmt+5': 'GMT+5', 'gmt+6': 'GMT+6',
- 'gmt+7': 'GMT+7', 'gmt+8': 'GMT+8', 'gmt+9': 'GMT+9',
- 'gmt+10':'GMT+10','gmt+11':'GMT+11','gmt+12':'GMT+12',
- 'gmt+13':'GMT+13',
- 'gmt-1': 'GMT-1', 'gmt-2': 'GMT-2', 'gmt-3': 'GMT-3',
- 'gmt-4': 'GMT-4', 'gmt-5': 'GMT-5', 'gmt-6': 'GMT-6',
- 'gmt-7': 'GMT-7', 'gmt-8': 'GMT-8', 'gmt-9': 'GMT-9',
- 'gmt-10':'GMT-10','gmt-11':'GMT-11','gmt-12':'GMT-12',
-
- 'gmt+130':'GMT+0130', 'gmt+0130':'GMT+0130',
- 'gmt+230':'GMT+0230', 'gmt+0230':'GMT+0230',
- 'gmt+330':'GMT+0330', 'gmt+0330':'GMT+0330',
- 'gmt+430':'GMT+0430', 'gmt+0430':'GMT+0430',
- 'gmt+530':'GMT+0530', 'gmt+0530':'GMT+0530',
- 'gmt+630':'GMT+0630', 'gmt+0630':'GMT+0630',
- 'gmt+730':'GMT+0730', 'gmt+0730':'GMT+0730',
- 'gmt+830':'GMT+0830', 'gmt+0830':'GMT+0830',
- 'gmt+930':'GMT+0930', 'gmt+0930':'GMT+0930',
- 'gmt+1030':'GMT+1030',
- 'gmt+1130':'GMT+1130',
- 'gmt+1230':'GMT+1230',
-
- 'gmt-130':'GMT-0130', 'gmt-0130':'GMT-0130',
- 'gmt-230':'GMT-0230', 'gmt-0230':'GMT-0230',
- 'gmt-330':'GMT-0330', 'gmt-0330':'GMT-0330',
- 'gmt-430':'GMT-0430', 'gmt-0430':'GMT-0430',
- 'gmt-530':'GMT-0530', 'gmt-0530':'GMT-0530',
- 'gmt-630':'GMT-0630', 'gmt-0630':'GMT-0630',
- 'gmt-730':'GMT-0730', 'gmt-0730':'GMT-0730',
- 'gmt-830':'GMT-0830', 'gmt-0830':'GMT-0830',
- 'gmt-930':'GMT-0930', 'gmt-0930':'GMT-0930',
- 'gmt-1030':'GMT-1030',
- 'gmt-1130':'GMT-1130',
- 'gmt-1230':'GMT-1230',
-
- 'greenwich':'Greenwich','hongkong':'Hongkong',
- 'iceland':'Iceland','iran':'Iran','israel':'Israel',
- 'jamaica':'Jamaica','japan':'Japan',
- 'mexico/bajanorte':'Mexico/BajaNorte',
- 'mexico/bajasur':'Mexico/BajaSur','mexico/general':'Mexico/General',
- 'mst':'US/Mountain','pst':'US/Pacific','poland':'Poland',
- 'singapore':'Singapore','turkey':'Turkey','universal':'Universal',
- 'utc':'Universal','uct':'Universal','us/alaska':'US/Alaska',
- 'us/aleutian':'US/Aleutian','us/arizona':'US/Arizona',
- 'us/central':'US/Central','us/eastern':'US/Eastern',
- 'us/east-indiana':'US/East-Indiana','us/hawaii':'US/Hawaii',
- 'us/indiana-starke':'US/Indiana-Starke','us/michigan':'US/Michigan',
- 'us/mountain':'US/Mountain','us/pacific':'US/Pacific',
- 'us/samoa':'US/Samoa',
-
- 'ut':'Universal',
- 'bst':'GMT+1', 'mest':'GMT+2', 'sst':'GMT+2',
- 'fst':'GMT+2', 'wadt':'GMT+8', 'eadt':'GMT+11', 'nzdt':'GMT+13',
- 'wet':'GMT', 'wat':'GMT-1', 'at':'GMT-2', 'ast':'GMT-4',
- 'nt':'GMT-11', 'idlw':'GMT-12', 'cet':'GMT+1', 'cest':'GMT+2',
- 'met':'GMT+1',
- 'mewt':'GMT+1', 'swt':'GMT+1', 'fwt':'GMT+1', 'eet':'GMT+2',
- 'eest':'GMT+3',
- 'bt':'GMT+3', 'zp4':'GMT+4', 'zp5':'GMT+5', 'zp6':'GMT+6',
- 'wast':'GMT+7', 'cct':'GMT+8', 'jst':'GMT+9', 'east':'GMT+10',
- 'gst':'GMT+10', 'nzt':'GMT+12', 'nzst':'GMT+12', 'idle':'GMT+12',
- 'ret':'GMT+4'
- }
-
- def __init__(self):
- self._db = _data
- self._d, self._zidx= {}, self._zmap.keys()
-
- def __getitem__(self,k):
- try: n=self._zmap[k.lower()]
- except KeyError:
- if numericTimeZoneMatch(k) == None:
- raise DateTimeError('Unrecognized timezone: %s' % k)
- return k
- try:
- return self._d[n]
- except KeyError:
- z = self._d[n] = _timezone(self._db[n])
- return z
-
-def _findLocalTimeZoneName(isDST):
- if not _time.daylight:
- # Daylight savings does not occur in this time zone.
- isDST = 0
- try:
- # Get the name of the current time zone depending
- # on DST.
- _localzone = _cache._zmap[tzname[isDST].lower()]
- except KeyError:
- try:
- # Generate a GMT-offset zone name.
- if isDST:
- localzone = _time.altzone
- else:
- localzone = _time.timezone
- offset=(-localzone/(60*60))
- majorOffset=int(offset)
- if majorOffset != 0 :
- minorOffset=abs(int((offset % majorOffset) * 60.0))
- else: minorOffset = 0
- m=majorOffset >= 0 and '+' or ''
- lz='%s%0.02d%0.02d' % (m, majorOffset, minorOffset)
- _localzone = _cache._zmap[('GMT%s' % lz).lower()]
- except:
- _localzone = ''
- return _localzone
-
-# Some utility functions for calculating dates:
-
-def _calcSD(t):
- # Returns timezone-independent days since epoch and the fractional
- # part of the days.
- dd = t + EPOCH - 86400.0
- d = dd / 86400.0
- s = d - math.floor(d)
- return s, d
-
-def _calcDependentSecond(tz, t):
- # Calculates the timezone-dependent second (integer part only)
- # from the timezone-independent second.
- fset = _tzoffset(tz, t)
- return fset + long(math.floor(t)) + long(EPOCH) - 86400L
-
-def _calcDependentSecond2(yr,mo,dy,hr,mn,sc):
- # Calculates the timezone-dependent second (integer part only)
- # from the date given.
- ss = int(hr) * 3600 + int(mn) * 60 + int(sc)
- x = long(_julianday(yr,mo,dy)-jd1901) * 86400 + ss
- return x
-
-def _calcIndependentSecondEtc(tz, x, ms):
- # Derive the timezone-independent second from the timezone
- # dependent second.
- fsetAtEpoch = _tzoffset(tz, 0.0)
- nearTime = x - fsetAtEpoch - long(EPOCH) + 86400L + ms
- # nearTime is now within an hour of being correct.
- # Recalculate t according to DST.
- fset = long(_tzoffset(tz, nearTime))
- x_adjusted = x - fset + ms
- d = x_adjusted / 86400.0
- t = x_adjusted - long(EPOCH) + 86400L
- millis = (x + 86400 - fset) * 1000 + \
- long(ms * 1000.0) - long(EPOCH * 1000.0)
- s = d - math.floor(d)
- return s,d,t,millis
-
-def _calcHMS(x, ms):
- # hours, minutes, seconds from integer and float.
- hr = x / 3600
- x = x - hr * 3600
- mn = x / 60
- sc = x - mn * 60 + ms
- return hr,mn,sc
-
-def _calcYMDHMS(x, ms):
- # x is a timezone-dependent integer of seconds.
- # Produces yr,mo,dy,hr,mn,sc.
- yr,mo,dy=_calendarday(x / 86400 + jd1901)
- x = int(x - (x / 86400) * 86400)
- hr = x / 3600
- x = x - hr * 3600
- mn = x / 60
- sc = x - mn * 60 + ms
- return yr,mo,dy,hr,mn,sc
-
-def _julianday(yr,mo,dy):
- y,m,d=long(yr),long(mo),long(dy)
- if m > 12L:
- y=y+m/12L
- m=m%12L
- elif m < 1L:
- m=-m
- y=y-m/12L-1L
- m=12L-m%12L
- if y > 0L: yr_correct=0L
- else: yr_correct=3L
- if m < 3L: y, m=y-1L,m+12L
- if y*10000L+m*100L+d > 15821014L: b=2L-y/100L+y/400L
- else: b=0L
- return (1461L*y-yr_correct)/4L+306001L*(m+1L)/10000L+d+1720994L+b
-
-def _calendarday(j):
- j=long(j)
- if(j < 2299160L):
- b=j+1525L
- else:
- a=(4L*j-7468861L)/146097L
- b=j+1526L+a-a/4L
- c=(20L*b-2442L)/7305L
- d=1461L*c/4L
- e=10000L*(b-d)/306001L
- dy=int(b-d-306001L*e/10000L)
- mo=(e < 14L) and int(e-1L) or int(e-13L)
- yr=(mo > 2) and (c-4716L) or (c-4715L)
- return int(yr),int(mo),int(dy)
-
-def _tzoffset(tz, t):
- try:
- return DateTimeParser._tzinfo[tz].info(t)[0]
- except:
- if numericTimeZoneMatch(tz) is not None:
- offset = int(tz[1:3])*3600+int(tz[3:5])*60
- if tz[0] == '-':
- return -offset
- else:
- return offset
- else:
- return 0 # Assume UTC
-
-def _correctYear(year):
- # Y2K patch.
- if year >= 0 and year < 100:
- # 00-69 means 2000-2069, 70-99 means 1970-1999.
- if year < 70:
- year = 2000 + year
- else:
- year = 1900 + year
- return year
-
-def safegmtime(t):
- '''gmtime with a safety zone.'''
- try:
- t_int = int(t)
- except OverflowError:
- raise TimeError('The time %f is beyond the range '
- 'of this Python implementation.' % float(t))
- return _time.gmtime(t_int)
-
-def safelocaltime(t):
- '''localtime with a safety zone.'''
- try:
- t_int = int(t)
- except OverflowError:
- raise TimeError('The time %f is beyond the range '
- 'of this Python implementation.' % float(t))
- return _time.localtime(t_int)
-
-class DateTimeParser:
-
- def parse(self, arg, local=1):
- """Parse a string containing some sort of date-time data.
-
- This function returns a tuple (year, month, day, hour, minute,
- second, timezone_string).
-
- As a general rule, any date-time representation that is
- recognized and unambigous to a resident of North America is
- acceptable.(The reason for this qualification is that
- in North America, a date like: 2/1/1994 is interpreted
- as February 1, 1994, while in some parts of the world,
- it is interpreted as January 2, 1994.) A date/time
- string consists of two components, a date component and
- an optional time component, separated by one or more
- spaces. If the time component is omited, 12:00am is
- assumed. Any recognized timezone name specified as the
- final element of the date/time string will be used for
- computing the date/time value. (If you create a DateTime
- with the string 'Mar 9, 1997 1:45pm US/Pacific', the
- value will essentially be the same as if you had captured
- time.time() at the specified date and time on a machine in
- that timezone)
-
- x=parse('1997/3/9 1:45pm')
- # returns specified time, represented in local machine zone.
-
- y=parse('Mar 9, 1997 13:45:00')
- # y is equal to x
-
- The function automatically detects and handles
- ISO8601 compliant dates (YYYY-MM-DDThh:ss:mmTZD).
- See http://www.w3.org/TR/NOTE-datetime for full specs.
-
- The date component consists of year, month, and day
- values. The year value must be a one-, two-, or
- four-digit integer. If a one- or two-digit year is
- used, the year is assumed to be in the twentieth
- century. The month may an integer, from 1 to 12, a
- month name, or a month abreviation, where a period may
- optionally follow the abreviation. The day must be an
- integer from 1 to the number of days in the month. The
- year, month, and day values may be separated by
- periods, hyphens, forward, shashes, or spaces. Extra
- spaces are permitted around the delimiters. Year,
- month, and day values may be given in any order as long
- as it is possible to distinguish the components. If all
- three components are numbers that are less than 13,
- then a a month-day-year ordering is assumed.
-
- The time component consists of hour, minute, and second
- values separated by colons. The hour value must be an
- integer between 0 and 23 inclusively. The minute value
- must be an integer between 0 and 59 inclusively. The
- second value may be an integer value between 0 and
- 59.999 inclusively. The second value or both the minute
- and second values may be ommitted. The time may be
- followed by am or pm in upper or lower case, in which
- case a 12-hour clock is assumed.
-
- If a string argument passed to the DateTime constructor cannot be
- parsed, it will raise SyntaxError. Invalid date components
- will raise a DateError, while invalid time or timezone components
- will raise a DateTimeError.
- """
- if not isinstance(arg, StringTypes):
- raise TypeError('Expected a string argument')
-
- if not arg:
- raise SyntaxError(arg)
-
- if arg.find(' ')==-1 and len(arg) >= 5 and arg[4]=='-':
- yr,mo,dy,hr,mn,sc,tz=self._parse_iso8601(arg)
- else:
- yr,mo,dy,hr,mn,sc,tz=self._parse(arg, local)
-
-
- if not self._validDate(yr,mo,dy):
- raise DateError(arg, yr, mo, dy)
- if not self._validTime(hr,mn,int(sc)):
- raise TimeError(arg)
-
- return yr, mo, dy, hr, mn, sc, tz
-
- def time(self, arg):
- """Parse a string containing some sort of date-time data.
-
- This function returns the time in seconds since the Epoch (in UTC).
-
- See date() for the description of allowed input values.
- """
-
- yr, mo, dy, hr, mn, sc, tz = self.parse(arg)
-
- ms = sc - math.floor(sc)
- x = _calcDependentSecond2(yr,mo,dy,hr,mn,sc)
-
- if tz:
- try:
- tz=self._tzinfo._zmap[tz.lower()]
- except KeyError:
- if numericTimeZoneMatch(tz) is None:
- raise DateTimeError('Unknown time zone in date: %s' % arg)
- else:
- tz = self._calcTimezoneName(x, ms)
- s,d,t,millisecs = _calcIndependentSecondEtc(tz, x, ms)
-
- return t
-
-
- int_pattern =re.compile(r'([0-9]+)') #AJ
- flt_pattern =re.compile(r':([0-9]+\.[0-9]+)') #AJ
- name_pattern =re.compile(r'([a-zA-Z]+)', re.I) #AJ
- space_chars =' \t\n'
- delimiters ='-/.:,+'
- _month_len =((0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
- (0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31))
- _until_month=((0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334),
- (0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335))
- _monthmap ={'january': 1, 'jan': 1,
- 'february': 2, 'feb': 2,
- 'march': 3, 'mar': 3,
- 'april': 4, 'apr': 4,
- 'may': 5,
- 'june': 6, 'jun': 6,
- 'july': 7, 'jul': 7,
- 'august': 8, 'aug': 8,
- 'september': 9, 'sep': 9, 'sept': 9,
- 'october': 10, 'oct': 10,
- 'november': 11, 'nov': 11,
- 'december': 12, 'dec': 12}
- _daymap ={'sunday': 1, 'sun': 1,
- 'monday': 2, 'mon': 2,
- 'tuesday': 3, 'tues': 3, 'tue': 3,
- 'wednesday': 4, 'wed': 4,
- 'thursday': 5, 'thurs': 5, 'thur': 5, 'thu': 5,
- 'friday': 6, 'fri': 6,
- 'saturday': 7, 'sat': 7}
-
- _localzone0 = _findLocalTimeZoneName(0)
- _localzone1 = _findLocalTimeZoneName(1)
- _multipleZones = (_localzone0 != _localzone1)
- # For backward compatibility only:
- _isDST = _time.localtime()[8]
- _localzone = _isDST and _localzone1 or _localzone0
-
- _tzinfo = _cache()
-
- def localZone(self, ltm=None):
- '''Returns the time zone on the given date. The time zone
- can change according to daylight savings.'''
- if not self._multipleZones:
- return self._localzone0
- if ltm == None:
- ltm = _time.localtime()
- isDST = ltm[8]
- lz = isDST and self._localzone1 or self._localzone0
- return lz
-
- def _calcTimezoneName(self, x, ms):
- # Derive the name of the local time zone at the given
- # timezone-dependent second.
- if not self._multipleZones:
- return self._localzone0
- fsetAtEpoch = _tzoffset(self._localzone0, 0.0)
- nearTime = x - fsetAtEpoch - long(EPOCH) + 86400L + ms
- # nearTime is within an hour of being correct.
- try:
- ltm = safelocaltime(nearTime)
- except:
- # We are beyond the range of Python's date support.
- # Hopefully we can assume that daylight savings schedules
- # repeat every 28 years. Calculate the name of the
- # time zone using a supported range of years.
- yr,mo,dy,hr,mn,sc = _calcYMDHMS(x, 0)
- yr = ((yr - 1970) % 28) + 1970
- x = _calcDependentSecond2(yr,mo,dy,hr,mn,sc)
- nearTime = x - fsetAtEpoch - long(EPOCH) + 86400L + ms
- ltm = safelocaltime(nearTime)
- tz = self.localZone(ltm)
- return tz
-
- def _parse(self, string, local=1):
- # Parse date-time components from a string
- month = year = tz = tm = None
- spaces = self.space_chars
- intpat = self.int_pattern
- fltpat = self.flt_pattern
- wordpat = self.name_pattern
- delimiters = self.delimiters
- MonthNumbers = self._monthmap
- DayOfWeekNames = self._daymap
- ValidZones = self._tzinfo._zidx
- TimeModifiers = ['am','pm']
-
- string = string.strip()
-
- # Find timezone first, since it should always be the last
- # element, and may contain a slash, confusing the parser.
-
-
- # First check for time zone of form +dd:dd
- tz = _iso_tz_re.search(string)
- if tz:
- tz = tz.start(0)
- tz, string = string[tz:], string[:tz].strip()
- tz = tz[:3]+tz[4:]
- else:
- # Look at last token
- sp=string.split()
- tz = sp[-1]
- if tz and (tz.lower() in ValidZones):
- string=' '.join(sp[:-1])
- else:
- tz = None # Decide later, since the default time zone
- # could depend on the date.
-
- ints,dels=[],[]
- i,l=0,len(string)
- while i < l:
- while i < l and string[i] in spaces : i=i+1
- if i < l and string[i] in delimiters:
- d=string[i]
- i=i+1
- else: d=''
- while i < l and string[i] in spaces : i=i+1
-
- # The float pattern needs to look back 1 character, because it
- # actually looks for a preceding colon like ':33.33'. This is
- # needed to avoid accidentally matching the date part of a
- # dot-separated date string such as '1999.12.31'.
- if i > 0: b=i-1
- else: b=i
-
- ts_results = fltpat.match(string, b)
- if ts_results:
- s=ts_results.group(1)
- i=i+len(s)
- ints.append(float(s))
- continue
-
- #AJ
- ts_results = intpat.match(string, i)
- if ts_results:
- s=ts_results.group(0)
-
- ls=len(s)
- i=i+ls
- if (ls==4 and d and d in '+-' and
- (len(ints) + (not not month) >= 3)):
- tz='%s%s' % (d,s)
- else:
- v=int(s)
- ints.append(v)
- continue
-
-
- ts_results = wordpat.match(string, i)
- if ts_results:
- o,s=ts_results.group(0),ts_results.group(0).lower()
- i=i+len(s)
- if i < l and string[i]=='.': i=i+1
- # Check for month name:
- if s in MonthNumbers:
- v=MonthNumbers[s]
- if month is None: month=v
- else: raise SyntaxError(string)
- continue
- # Check for time modifier:
- if s in TimeModifiers:
- if tm is None: tm=s
- else: raise SyntaxError(string)
- continue
- # Check for and skip day of week:
- if s in DayOfWeekNames:
- continue
- raise SyntaxError(string)
-
- day=None
- if ints[-1] > 60 and d not in ['.',':'] and len(ints) > 2:
- year=ints[-1]
- del ints[-1]
- if month:
- day=ints[0]
- del ints[:1]
- else:
- month=ints[0]
- day=ints[1]
- del ints[:2]
- elif month:
- if len(ints) > 1:
- if ints[0] > 31:
- year=ints[0]
- day=ints[1]
- else:
- year=ints[1]
- day=ints[0]
- del ints[:2]
- elif len(ints) > 2:
- if ints[0] > 31:
- year=ints[0]
- if ints[1] > 12:
- day=ints[1]
- month=ints[2]
- else:
- day=ints[2]
- month=ints[1]
- if ints[1] > 31:
- year=ints[1]
- if ints[0] > 12 and ints[2] <= 12:
- day=ints[0]
- month=ints[2]
- elif ints[2] > 12 and ints[0] <= 12:
- day=ints[2]
- month=ints[0]
- elif ints[2] > 31:
- year=ints[2]
- if ints[0] > 12:
- day=ints[0]
- month=ints[1]
- else:
- day=ints[1]
- month=ints[0]
- elif ints[0] <= 12:
- month=ints[0]
- day=ints[1]
- year=ints[2]
- del ints[:3]
-
- if day is None:
- # Use today's date.
- year,month,day = _time.localtime()[:3]
-
- year = _correctYear(year)
- if year < 1000: raise SyntaxError(string)
-
- leap = year%4==0 and (year%100!=0 or year%400==0)
- try:
- if not day or day > self._month_len[leap][month]:
- raise DateError(string)
- except IndexError:
- raise DateError(string)
- tod=0
- if ints:
- i=ints[0]
- # Modify hour to reflect am/pm
- if tm and (tm=='pm') and i<12: i=i+12
- if tm and (tm=='am') and i==12: i=0
- if i > 24: raise DateTimeError(string)
- tod = tod + int(i) * 3600
- del ints[0]
- if ints:
- i=ints[0]
- if i > 60: raise DateTimeError(string)
- tod = tod + int(i) * 60
- del ints[0]
- if ints:
- i=ints[0]
- if i > 60: raise DateTimeError(string)
- tod = tod + i
- del ints[0]
- if ints: raise SyntaxError(string)
-
-
- tod_int = int(math.floor(tod))
- ms = tod - tod_int
- hr,mn,sc = _calcHMS(tod_int, ms)
-
- if local and not tz:
- # Figure out what time zone it is in the local area
- # on the given date.
- x = _calcDependentSecond2(year,month,day,hr,mn,sc)
- tz = self._calcTimezoneName(x, ms)
-
- return year,month,day,hr,mn,sc,tz
-
- def _validDate(self,y,m,d):
- if m<1 or m>12 or y<0 or d<1 or d>31: return 0
- return d<=self._month_len[(y%4==0 and (y%100!=0 or y%400==0))][m]
-
- def _validTime(self,h,m,s):
- return h>=0 and h<=23 and m>=0 and m<=59 and s>=0 and s < 60
-
- def _parse_iso8601(self,s):
- try:
- return self.__parse_iso8601(s)
- except IndexError:
- raise DateError(
- 'Not an ISO 8601 compliant date string: "%s"' % s)
-
-
- def __parse_iso8601(self,s):
- """Parse an ISO 8601 compliant date.
-
- TODO: Not all allowed formats are recognized (for some examples see
- http://www.cl.cam.ac.uk/~mgk25/iso-time.html).
- """
- year=0
- month=day=1
- hour=minute=seconds=hour_off=min_off=0
- tzsign='+'
-
- datereg = re.compile(
- '([0-9]{4})(-([0-9][0-9]))?(-([0-9][0-9]))?')
- timereg = re.compile(
- '([0-9]{2})(:([0-9][0-9]))?(:([0-9][0-9]))?(\.[0-9]{1,20})?'
- '(\s*([-+])([0-9]{2})(:?([0-9]{2}))?)?')
-
- # Date part
-
- fields = datereg.split(s.strip())
- if fields[1]: year = int(fields[1])
- if fields[3]: month = int(fields[3])
- if fields[5]: day = int(fields[5])
-
- if s.find('T')>-1:
- fields = timereg.split(s[s.find('T')+1:])
-
- if fields[1]: hour = int(fields[1])
- if fields[3]: minute = int(fields[3])
- if fields[5]: seconds = int(fields[5])
- if fields[6]: seconds = seconds+float(fields[6])
-
- if fields[8]: tzsign = fields[8]
- if fields[9]: hour_off = int(fields[9])
- if fields[11]: min_off = int(fields[11])
-
- return (year,month,day,hour,minute,seconds,
- '%s%02d%02d' % (tzsign,hour_off,min_off))
-
-parser = DateTimeParser()
-parse = parser.parse
-time = parser.time
-
-######################################################################
-# Time-zone info based soley on offsets
-#
-# Share tzinfos for the same offset
-
-from datetime import tzinfo as _tzinfo, timedelta as _timedelta
-
-class _tzinfo(_tzinfo):
-
- def __init__(self, minutes):
- if abs(minutes) > 1439:
- raise ValueError("Time-zone offset is too large,", minutes)
- self.__minutes = minutes
- self.__offset = _timedelta(minutes=minutes)
-
- def utcoffset(self, dt):
- return self.__offset
-
- def __reduce__(self):
- return tzinfo, (self.__minutes, )
-
- def dst(self, dt):
- return None
-
- def tzname(self, dt):
- return None
-
- def __repr__(self):
- return 'tzinfo(%d)' % self.__minutes
-
-
-def tzinfo(offset, _tzinfos = {}):
-
- info = _tzinfos.get(offset)
- if info is None:
- # We haven't seen this one before. we need to save it.
-
- # Use setdefault to avoid a race condition and make sure we have
- # only one
- info = _tzinfos.setdefault(offset, _tzinfo(offset))
-
- return info
-
-tzinfo.__safe_for_unpickling__ = True
-
-#
-######################################################################
-
-from datetime import datetime as _datetime
-def parseDatetimetz(string):
- y, mo, d, h, m, s, tz = parse(string)
- s, micro = divmod(s, 1.0)
- micro = round(micro * 1000000)
- offset = _tzoffset(tz, None) / 60
- return _datetime(y, mo, d, h, m, int(s), int(micro), tzinfo(offset))
-
-_iso_tz_re = re.compile("[-+]\d\d:\d\d$")
+# This module has moved to zope.datetime
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.datetime',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/datetimeutils.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.10
Modified: Zope3/trunk/src/zope/app/dav/adapter.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/adapter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/adapter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,12 +21,12 @@
from zope.interface import implements
from zope.i18n import translate
+from zope.size.interfaces import ISized
+from zope.dublincore.interfaces import IDCTimes
+from zope.filerepresentation.interfaces import IReadDirectory
+from zope.traversing.api import getName
-from zope.app import zapi
from zope.app.dav.interfaces import IDAVSchema
-from zope.app.dublincore.interfaces import IDCTimes
-from zope.app.filerepresentation.interfaces import IReadDirectory
-from zope.app.size.interfaces import ISized
from zope.app.file.interfaces import IFile
class DAVSchemaAdapter(object):
@@ -38,7 +38,7 @@
self.context = object
def displayname(self):
- value = zapi.name(self.context)
+ value = getName(self.context)
if IReadDirectory(self.context, None) is not None:
value = value + '/'
return value
Modified: Zope3/trunk/src/zope/app/dav/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/dav/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -121,7 +121,7 @@
<adapter
factory=".opaquenamespaces.DAVOpaqueNamespacesAdapter"
provides=".opaquenamespaces.IDAVOpaqueNamespaces"
- for="zope.app.annotation.interfaces.IAnnotatable"
+ for="zope.annotation.interfaces.IAnnotatable"
trusted="true"
/>
@@ -134,7 +134,7 @@
<dav:provideInterface
for="http://purl.org/dc/1.1"
- interface="zope.app.dublincore.interfaces.IZopeDublinCore" />
+ interface="zope.dublincore.interfaces.IZopeDublinCore" />
<dav:provideInterface
for="DAV:"
Modified: Zope3/trunk/src/zope/app/dav/ftests/dav.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/ftests/dav.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/ftests/dav.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,13 +15,13 @@
$Id$
"""
+import transaction
from persistent import Persistent
-import transaction
from zope.interface import implements
+from zope.annotation.interfaces import IAttributeAnnotatable
+
from zope.app.testing.functional import HTTPTestCase
-
from zope.app.folder import Folder
-from zope.app.annotation.interfaces import IAttributeAnnotatable
class Page(Persistent):
implements(IAttributeAnnotatable)
Modified: Zope3/trunk/src/zope/app/dav/ftests/test_propfind.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/ftests/test_propfind.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/ftests/test_propfind.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,14 +16,14 @@
$Id$
"""
import unittest
+import transaction
from datetime import datetime
-import transaction
from zope.pagetemplate.tests.util import normalize_xml
+from zope.traversing.api import traverse
+from zope.dublincore.interfaces import IZopeDublinCore
from zope.app.dav.ftests.dav import DAVTestCase
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.dav.opaquenamespaces import IDAVOpaqueNamespaces
-from zope.app.traversing.api import traverse
class TestPROPFIND(DAVTestCase):
Modified: Zope3/trunk/src/zope/app/dav/ftests/test_proppatch.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/ftests/test_proppatch.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/ftests/test_proppatch.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,11 +19,11 @@
import transaction
from zope.pagetemplate.tests.util import normalize_xml
from zope.publisher.http import status_reasons
+from zope.traversing.api import traverse
+from zope.dublincore.interfaces import IZopeDublinCore
from zope.app.dav.ftests.dav import DAVTestCase
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.dav.opaquenamespaces import IDAVOpaqueNamespaces
-from zope.app.traversing.api import traverse
class TestPROPPATCH(DAVTestCase):
Modified: Zope3/trunk/src/zope/app/dav/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,9 +17,9 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app.component.metaconfigure import utility
+from zope.component.zcml import utility
from zope.interface import directlyProvides
-from interfaces import IDAVNamespace
+from zope.app.dav.interfaces import IDAVNamespace
def interface(_context, for_, interface):
directlyProvides(interface, IDAVNamespace)
Modified: Zope3/trunk/src/zope/app/dav/mkcol.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/mkcol.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/mkcol.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,10 +15,10 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app.filerepresentation.interfaces import IWriteDirectory
-from zope.app.filerepresentation.interfaces import IDirectoryFactory
+from zope.filerepresentation.interfaces import IWriteDirectory
+from zope.filerepresentation.interfaces import IDirectoryFactory
from zope.event import notify
-from zope.app.event.objectevent import ObjectCreatedEvent
+from zope.lifecycleevent import ObjectCreatedEvent
class NullResource(object):
"""MKCOL handler for creating collections"""
Modified: Zope3/trunk/src/zope/app/dav/opaquenamespaces.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/opaquenamespaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/opaquenamespaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,8 +25,8 @@
from zope.interface import implements
from zope.interface.common.mapping import IMapping
-from zope.app.annotation.interfaces import IAnnotations, IAnnotatable
-from zope.app.location import Location
+from zope.location import Location
+from zope.annotation.interfaces import IAnnotations, IAnnotatable
from BTrees.OOBTree import OOBTree
Modified: Zope3/trunk/src/zope/app/dav/tests/test_adapter.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/tests/test_adapter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/tests/test_adapter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,31 +16,29 @@
$Id$
"""
import unittest
-from zope.testing.doctestunit import DocTestSuite
+import zope.location
+from zope.location.interfaces import ILocation
+from zope.location.traversing import LocationPhysicallyLocatable
+from zope.testing.doctestunit import DocTestSuite
from zope.interface import Interface, implements
+from zope.size.interfaces import ISized
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.annotation.interfaces import IAnnotatable, IAttributeAnnotatable
+from zope.annotation.interfaces import IAnnotations
+from zope.annotation.attribute import AttributeAnnotations
+from zope.dublincore.interfaces import IWriteZopeDublinCore
+from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter
+from zope.filerepresentation.interfaces import IReadDirectory
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import setUp, tearDown
-from zope.app.size.interfaces import ISized
-from zope.app.filerepresentation.interfaces import IReadDirectory
from zope.app.i18n import ZopeMessageFactory as _
-import zope.app.location
-from zope.app.dublincore.interfaces import IWriteZopeDublinCore
-from zope.app.annotation.interfaces import IAnnotatable, IAttributeAnnotatable
-from zope.app.annotation.interfaces import IAnnotations
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
-
-from zope.app.location.interfaces import ILocation
-from zope.app.traversing.interfaces import IPhysicallyLocatable
-from zope.app.location.traversing import LocationPhysicallyLocatable
-
class IRobot(Interface):
pass
-class Robot(zope.app.location.Location):
+class Robot(zope.location.Location):
implements(IRobot, IAttributeAnnotatable)
class RobotSize(object):
Modified: Zope3/trunk/src/zope/app/dav/tests/test_mkcol.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/tests/test_mkcol.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/tests/test_mkcol.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,18 +16,15 @@
$Id$
"""
from unittest import TestCase, TestSuite, main, makeSuite
+from zope.traversing.api import traverse
+from zope.filerepresentation.interfaces import IWriteDirectory
+from zope.filerepresentation.interfaces import IDirectoryFactory
+
from zope.app.testing import ztapi
-from zope.app.traversing.api import traverse
from zope.app.component.testing import PlacefulSetup
-
from zope.app.container.interfaces import IWriteContainer
-from zope.app.filerepresentation.interfaces import IWriteDirectory
-from zope.app.container.directory import noop
-
+from zope.app.container.directory import noop, Cloner
from zope.app.folder.interfaces import IFolder
-from zope.app.filerepresentation.interfaces import IDirectoryFactory
-from zope.app.container.directory import Cloner
-
from zope.app.http.put import NullResource
from zope.app.dav import mkcol
from zope.app.dav.tests.test_propfind import _createRequest, File
Modified: Zope3/trunk/src/zope/app/dav/tests/test_propfind.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/tests/test_propfind.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/tests/test_propfind.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,26 +20,25 @@
from unittest import TestCase, TestSuite, main, makeSuite
from datetime import datetime
+import zope.component
from zope.interface import Interface, directlyProvides, implements
from zope.publisher.interfaces.http import IHTTPRequest
from zope.pagetemplate.tests.util import normalize_xml
from zope.schema import getFieldNamesInOrder
from zope.schema.interfaces import IText, ITextLine, IDatetime, ISequence
+from zope.size.interfaces import ISized
+from zope.traversing.api import traverse
+from zope.traversing.browser import AbsoluteURL, absoluteURL
+from zope.publisher.browser import TestRequest
+from zope.annotation.interfaces import IAnnotatable
+from zope.annotation.attribute import AttributeAnnotations
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter
-from zope.app import zapi
from zope.app.testing import ztapi
-
-from zope.app.traversing.api import traverse
from zope.app.container.interfaces import IReadContainer
-from zope.publisher.browser import TestRequest
from zope.app.component.testing import PlacefulSetup
-from zope.app.traversing.browser import AbsoluteURL
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
-from zope.app.annotation.interfaces import IAnnotatable, IAnnotations
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.size.interfaces import ISized
from zope.app.file.interfaces import IFile
from zope.app.dav import propfind
@@ -88,6 +87,7 @@
return request
class FileSized(object):
+ zope.component.adapts(IFile)
implements(ISized)
def __init__(self, context):
@@ -123,20 +123,21 @@
ztapi.browserViewProviding(IDatetime, TextDAVWidget, IDAVWidget)
ztapi.browserViewProviding(ISequence, SequenceDAVWidget, IDAVWidget)
ztapi.browserViewProviding(IXMLText, XMLDAVWidget, IXMLDAVWidget)
- ztapi.provideAdapter(IAnnotatable, IAnnotations, AttributeAnnotations)
- ztapi.provideAdapter(IAnnotatable, IZopeDublinCore,
- ZDCAnnotatableAdapter)
- ztapi.provideAdapter(IAnnotatable, IDAVOpaqueNamespaces,
- DAVOpaqueNamespacesAdapter)
- ztapi.provideAdapter(None, IDAVSchema,
- DAVSchemaAdapter)
- ztapi.provideAdapter(IFile, ISized, FileSized)
- sm = zapi.getGlobalSiteManager()
+
+ zope.component.provideAdapter(AttributeAnnotations, (IAnnotatable,))
+ zope.component.provideAdapter(ZDCAnnotatableAdapter, (IAnnotatable,),
+ IZopeDublinCore)
+ zope.component.provideAdapter(DAVOpaqueNamespacesAdapter,
+ (IAnnotatable,), IDAVOpaqueNamespaces)
+ zope.component.provideAdapter(DAVSchemaAdapter, (None,), IDAVSchema)
+ zope.component.provideAdapter(FileSized)
+
directlyProvides(IDAVSchema, IDAVNamespace)
- sm.provideUtility(IDAVNamespace, IDAVSchema, 'DAV:')
+ zope.component.provideUtility(IDAVSchema, IDAVNamespace, 'DAV:')
+
directlyProvides(IZopeDublinCore, IDAVNamespace)
- sm.provideUtility(IDAVNamespace, IZopeDublinCore,
- 'http://www.purl.org/dc/1.1')
+ zope.component.provideUtility(IZopeDublinCore, IDAVNamespace,
+ 'http://www.purl.org/dc/1.1')
def test_contenttype1(self):
file = self.file
@@ -249,7 +250,7 @@
body = ''
request = _createRequest(body=body, headers={
'Content-type': 'text/xml', 'Depth': depth})
- resource_url = zapi.absoluteURL(obj, request)
+ resource_url = absoluteURL(obj, request)
if IReadContainer.providedBy(obj):
resource_url += '/'
if resp is None:
Modified: Zope3/trunk/src/zope/app/dav/tests/test_proppatch.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/tests/test_proppatch.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/tests/test_proppatch.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,35 +21,31 @@
from StringIO import StringIO
import transaction
+from ZODB.tests.util import DB
+import zope.component
from zope.interface import Interface, implements, directlyProvides
from zope.schema import Text
+from zope.schema.interfaces import IText, ISequence
from zope.publisher.interfaces.http import IHTTPRequest
from zope.publisher.http import status_reasons
+from zope.publisher.browser import TestRequest
from zope.pagetemplate.tests.util import normalize_xml
-from ZODB.tests.util import DB
+from zope.traversing.api import traverse
+from zope.traversing.browser import AbsoluteURL, absoluteURL
+from zope.annotation.interfaces import IAnnotatable, IAnnotations
+from zope.annotation.attribute import AttributeAnnotations
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter
+from zope.dublincore.zopedublincore import ScalarProperty
-from zope.app import zapi
from zope.app.testing import ztapi
-
-from zope.app.traversing.api import traverse
-from zope.publisher.browser import TestRequest
from zope.app.component.testing import PlacefulSetup
-from zope.app.traversing.browser import AbsoluteURL
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
-from zope.app.dublincore.zopedublincore import ScalarProperty
-from zope.app.annotation.interfaces import IAnnotatable, IAnnotations
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.schema.interfaces import IText, ISequence
import zope.app.dav.tests
from zope.app.dav.tests.unitfixtures import File, Folder, FooZPT
-
from zope.app.dav import proppatch
-from zope.app.dav.interfaces import IDAVSchema
-from zope.app.dav.interfaces import IDAVNamespace
-from zope.app.dav.interfaces import IDAVWidget
+from zope.app.dav.interfaces import IDAVSchema, IDAVNamespace, IDAVWidget
from zope.app.dav.widget import TextDAVWidget, SequenceDAVWidget
from zope.app.dav.opaquenamespaces import DAVOpaqueNamespacesAdapter
from zope.app.dav.opaquenamespaces import IDAVOpaqueNamespaces
@@ -152,20 +148,25 @@
'PROPPATCH', proppatch.PROPPATCH)
ztapi.browserViewProviding(IText, TextDAVWidget, IDAVWidget)
ztapi.browserViewProviding(ISequence, SequenceDAVWidget, IDAVWidget)
- ztapi.provideAdapter(IAnnotatable, IAnnotations, AttributeAnnotations)
- ztapi.provideAdapter(IAnnotatable, IZopeDublinCore,
- ZDCAnnotatableAdapter)
- ztapi.provideAdapter(IAnnotatable, IDAVOpaqueNamespaces,
- DAVOpaqueNamespacesAdapter)
- ztapi.provideAdapter(IAnnotatable, ITestSchema, TestSchemaAdapter)
- sm = zapi.getGlobalSiteManager()
+
+ zope.component.provideAdapter(AttributeAnnotations, (IAnnotatable,))
+ zope.component.provideAdapter(ZDCAnnotatableAdapter, (IAnnotatable,),
+ IZopeDublinCore)
+ zope.component.provideAdapter(DAVOpaqueNamespacesAdapter,
+ (IAnnotatable,), IDAVOpaqueNamespaces)
+ zope.component.provideAdapter(TestSchemaAdapter, (IAnnotatable,),
+ ITestSchema)
+
directlyProvides(IDAVSchema, IDAVNamespace)
- sm.provideUtility(IDAVNamespace, IDAVSchema, 'DAV:')
+ zope.component.provideUtility(IDAVSchema, IDAVNamespace, 'DAV:')
+
directlyProvides(IZopeDublinCore, IDAVNamespace)
- sm.provideUtility(IDAVNamespace, IZopeDublinCore,
- 'http://www.purl.org/dc/1.1')
+ zope.component.provideUtility(IZopeDublinCore, IDAVNamespace,
+ 'http://www.purl.org/dc/1.1')
+
directlyProvides(ITestSchema, IDAVNamespace)
- sm.provideUtility(IDAVNamespace, ITestSchema, TestURI)
+ zope.component.provideUtility(ITestSchema, IDAVNamespace, TestURI)
+
self.db = DB()
self.conn = self.db.open()
root = self.conn.root()
@@ -234,7 +235,7 @@
def _checkProppatch(self, obj, ns=(), set=(), rm=(), extra='', expect=''):
request = _createRequest(namespaces=ns, set=set, remove=rm,
extra=extra)
- resource_url = zapi.absoluteURL(obj, request)
+ resource_url = absoluteURL(obj, request)
expect = '''<?xml version="1.0" encoding="utf-8"?>
<multistatus xmlns="DAV:"><response>
<href>%%(resource_url)s</href>
Modified: Zope3/trunk/src/zope/app/dav/tests/unitfixtures.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/tests/unitfixtures.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dav/tests/unitfixtures.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,19 +17,18 @@
"""
__docformat__ = 'restructuredtext'
+import zope.location
from persistent import Persistent
from zope.interface import implements
+from zope.annotation.interfaces import IAnnotatable
+from zope.filerepresentation.interfaces import IWriteFile
+from zope.filerepresentation.interfaces import IReadDirectory
-from zope.app.filerepresentation.interfaces import IWriteFile
-from zope.app.filerepresentation.interfaces import IReadDirectory
from zope.app.container.interfaces import IReadContainer
-from zope.app.annotation.interfaces import IAnnotatable
from zope.app.file.interfaces import IFile
-import zope.app.location
+class Folder(zope.location.Location, Persistent):
-class Folder(zope.app.location.Location, Persistent):
-
implements(IReadContainer, IReadDirectory)
def __init__(self, name, level=0, parent=None):
@@ -48,7 +47,7 @@
Folder('sub1', level=self.level+1, parent=self)))
return tuple(result)
-class File(zope.app.location.Location, Persistent):
+class File(zope.location.Location, Persistent):
implements(IWriteFile, IFile)
@@ -62,7 +61,7 @@
def write(self, data):
self.data = data
-class FooZPT(zope.app.location.Location, Persistent):
+class FooZPT(zope.location.Location, Persistent):
implements(IAnnotatable)
Modified: Zope3/trunk/src/zope/app/debug/debug.py
===================================================================
--- Zope3/trunk/src/zope/app/debug/debug.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/debug/debug.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,8 +20,8 @@
import base64, time
from StringIO import StringIO
from zope.publisher.publish import publish as _publish, debug_call
-from zope.publisher.browser import TestRequest
-from zope.app.publication.browser import BrowserPublication, setDefaultSkin
+from zope.publisher.browser import TestRequest, setDefaultSkin
+from zope.app.publication.browser import BrowserPublication
from zope.app.appsetup import config, database
class Debugger(object):
Modified: Zope3/trunk/src/zope/app/decorator.py
===================================================================
--- Zope3/trunk/src/zope/app/decorator.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/decorator.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,245 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Decorator support
-
-Decorators are proxies that are mostly transparent but that may provide
-additional features.
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-
-from zope.proxy import getProxiedObject, ProxyBase
-from zope.security.checker import selectChecker, CombinedChecker
-from zope.security.proxy import Proxy, getChecker
-from zope.interface.declarations import ObjectSpecificationDescriptor
-from zope.interface.declarations import getObjectSpecification
-from zope.interface.declarations import ObjectSpecification
-from zope.interface import providedBy
-
-class DecoratorSpecificationDescriptor(ObjectSpecificationDescriptor):
- """Support for interface declarations on decorators
-
- >>> from zope.interface import *
- >>> class I1(Interface):
- ... pass
- >>> class I2(Interface):
- ... pass
- >>> class I3(Interface):
- ... pass
- >>> class I4(Interface):
- ... pass
-
- >>> class D1(Decorator):
- ... implements(I1)
-
-
- >>> class D2(Decorator):
- ... implements(I2)
-
- >>> class X(object):
- ... implements(I3)
-
- >>> x = X()
- >>> directlyProvides(x, I4)
-
- Interfaces of X are ordered with the directly-provided interfaces first
-
- >>> [interface.getName() for interface in list(providedBy(x))]
- ['I4', 'I3']
-
- When we decorate objects, what order should the interfaces come
- in? One could argue that decorators are less specific, so they
- should come last.
-
- >>> [interface.getName() for interface in list(providedBy(D1(x)))]
- ['I4', 'I3', 'I1']
-
- >>> [interface.getName() for interface in list(providedBy(D2(D1(x))))]
- ['I4', 'I3', 'I1', 'I2']
- """
- def __get__(self, inst, cls=None):
- if inst is None:
- return getObjectSpecification(cls)
- else:
- provided = providedBy(getProxiedObject(inst))
-
- # Use type rather than __class__ because inst is a proxy and
- # will return the proxied object's class.
- cls = type(inst)
- return ObjectSpecification(provided, cls)
-
-
-class DecoratedSecurityCheckerDescriptor(object):
- """Descriptor for a Decorator that provides a decorated security checker.
-
- To illustrate, we'll create a class that will be proxied:
-
- >>> class Foo(object):
- ... a = 'a'
-
- and a class to proxy it that uses a decorated security checker:
-
- >>> class Wrapper(ProxyBase):
- ... b = 'b'
- ... __Security_checker__ = DecoratedSecurityCheckerDescriptor()
-
- Next we'll create and register a checker for `Foo`:
-
- >>> from zope.security.checker import NamesChecker, defineChecker
- >>> fooChecker = NamesChecker(['a'])
- >>> defineChecker(Foo, fooChecker)
-
- along with a checker for `Wrapper`:
-
- >>> wrapperChecker = NamesChecker(['b'])
- >>> defineChecker(Wrapper, wrapperChecker)
-
- Using `selectChecker()`, we can confirm that a `Foo` object uses
- `fooChecker`:
-
- >>> foo = Foo()
- >>> selectChecker(foo) is fooChecker
- True
- >>> fooChecker.check(foo, 'a')
- >>> fooChecker.check(foo, 'b') # doctest: +ELLIPSIS
- Traceback (most recent call last):
- ForbiddenAttribute: ('b', <zope.app.decorator.Foo object ...>)
-
- and that a `Wrapper` object uses `wrappeChecker`:
-
- >>> wrapper = Wrapper(foo)
- >>> selectChecker(wrapper) is wrapperChecker
- True
- >>> wrapperChecker.check(wrapper, 'b')
- >>> wrapperChecker.check(wrapper, 'a') # doctest: +ELLIPSIS
- Traceback (most recent call last):
- ForbiddenAttribute: ('a', <zope.app.decorator.Foo object ...>)
-
- (Note that the object description says `Foo` because the object is a
- proxy and generally looks and acts like the object it's proxying.)
-
- When we access wrapper's ``__Security_checker__`` attribute, we invoke
- the decorated security checker descriptor. The decorator's job is to make
- sure checkers from both objects are used when available. In this case,
- because both objects have checkers, we get a combined checker:
-
- >>> checker = wrapper.__Security_checker__
- >>> type(checker)
- <class 'zope.security.checker.CombinedChecker'>
- >>> checker.check(wrapper, 'a')
- >>> checker.check(wrapper, 'b')
-
- The decorator checker will work even with security proxied objects. To
- illustrate, we'll proxify `foo`:
-
- >>> from zope.security.proxy import ProxyFactory
- >>> secure_foo = ProxyFactory(foo)
- >>> secure_foo.a
- 'a'
- >>> secure_foo.b # doctest: +ELLIPSIS
- Traceback (most recent call last):
- ForbiddenAttribute: ('b', <zope.app.decorator.Foo object ...>)
-
- when we wrap the secured `foo`:
-
- >>> wrapper = Wrapper(secure_foo)
-
- we still get a combined checker:
-
- >>> checker = wrapper.__Security_checker__
- >>> type(checker)
- <class 'zope.security.checker.CombinedChecker'>
- >>> checker.check(wrapper, 'a')
- >>> checker.check(wrapper, 'b')
-
- The decorator checker has three other scenarios:
-
- - the wrapper has a checker but the proxied object doesn't
- - the proxied object has a checker but the wrapper doesn't
- - neither the wrapper nor the proxied object have checkers
-
- When the wrapper has a checker but the proxied object doesn't:
-
- >>> from zope.security.checker import NoProxy, _checkers
- >>> del _checkers[Foo]
- >>> defineChecker(Foo, NoProxy)
- >>> selectChecker(foo) is None
- True
- >>> selectChecker(wrapper) is wrapperChecker
- True
-
- the decorator uses only the wrapper checker:
-
- >>> wrapper = Wrapper(foo)
- >>> wrapper.__Security_checker__ is wrapperChecker
- True
-
- When the proxied object has a checker but the wrapper doesn't:
-
- >>> del _checkers[Wrapper]
- >>> defineChecker(Wrapper, NoProxy)
- >>> selectChecker(wrapper) is None
- True
- >>> del _checkers[Foo]
- >>> defineChecker(Foo, fooChecker)
- >>> selectChecker(foo) is fooChecker
- True
-
- the decorator uses only the proxied object checker:
-
- >>> wrapper.__Security_checker__ is fooChecker
- True
-
- Finally, if neither the wrapper not the proxied have checkers:
-
- >>> del _checkers[Foo]
- >>> defineChecker(Foo, NoProxy)
- >>> selectChecker(foo) is None
- True
- >>> selectChecker(wrapper) is None
- True
-
- the decorator doesn't have a checker:
-
- >>> wrapper.__Security_checker__ is None
- True
-
- """
- def __get__(self, inst, cls=None):
- if inst is None:
- return self
- else:
- proxied_object = getProxiedObject(inst)
- if type(proxied_object) is Proxy:
- checker = getChecker(proxied_object)
- else:
- checker = getattr(proxied_object, '__Security_checker__', None)
- if checker is None:
- checker = selectChecker(proxied_object)
- wrapper_checker = selectChecker(inst)
- if wrapper_checker is None:
- return checker
- elif checker is None:
- return wrapper_checker
- else:
- return CombinedChecker(wrapper_checker, checker)
-
-
-class Decorator(ProxyBase):
- """Decorator base class"""
-
- __providedBy__ = DecoratorSpecificationDescriptor()
- __Security_checker__ = DecoratedSecurityCheckerDescriptor()
-
+# This module has moved to zope.decorator
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.decorator',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/decorator.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.2
Modified: Zope3/trunk/src/zope/app/demo/hellopackage/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/demo/hellopackage/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/demo/hellopackage/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -31,7 +31,7 @@
-->
<class class=".hellomodule.HelloClass">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
<!--
Modified: Zope3/trunk/src/zope/app/demo/jobboard/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/jobboard/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/demo/jobboard/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,12 +17,11 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.app.publisher.browser import BrowserView
+from zope.publisher.browser import BrowserView
from zope.event import notify
-from zope.app.event.objectevent import ObjectModifiedEvent
+from zope.lifecycleevent import ObjectModifiedEvent
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-
from job import Job
class JobCreateView(BrowserView):
Modified: Zope3/trunk/src/zope/app/demo/jobboard/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/demo/jobboard/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/demo/jobboard/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -6,7 +6,7 @@
>
<class class="zope.app.demo.jobboard.job.JobList">
- <implements interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ <implements interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
<factory
id="zope.app.demo.jobboard.job.JobList"
Modified: Zope3/trunk/src/zope/app/demo/menu/menu.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/menu/menu.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/demo/menu/menu.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,7 +20,7 @@
from zope.app import zapi
from zope.app.component.hooks import getSite
-from zope.app.dublincore.interfaces import IZopeDublinCore
+from zope.dublincore.interfaces import IZopeDublinCore
from zope.app.publisher.interfaces.browser import IBrowserMenu
Modified: Zope3/trunk/src/zope/app/demo/passwdauth/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/passwdauth/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/demo/passwdauth/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,12 +22,12 @@
import os
from persistent import Persistent
+from zope.interface import implements
+from zope.location import locate
from zope.app.container.contained import Contained
-from zope.app.location import locate
from zope.app.pluggableauth import SimplePrincipal
from zope.app.pluggableauth.interfaces import ILoginPasswordPrincipalSource
from zope.app.security.interfaces import PrincipalLookupError
-from zope.interface import implements
from interfaces import IFileBasedPrincipalSource
class PasswdPrincipalSource(Contained, Persistent):
Modified: Zope3/trunk/src/zope/app/demo/skinpref/skin.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/skinpref/skin.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/demo/skinpref/skin.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,9 +19,9 @@
import zope.interface
from zope.publisher.interfaces.browser import IBrowserSkinType
+from zope.publisher.browser import applySkin as applySkinOnRequest
from zope.app.component.interfaces import ISite
from zope.app.preference.interfaces import IUserPreferences
-from zope.app.publisher.browser import applySkin as applySkinOnRequest
def applySkin(event):
# We only want to look for a new skin to set, if we entered a new site.
Modified: Zope3/trunk/src/zope/app/demo/widget/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/demo/widget/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/demo/widget/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -7,7 +7,7 @@
<class class="zope.app.demo.widget.app.DemoWidgetContainer">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
+ interface="zope.annotation.interfaces.IAttributeAnnotatable" />
<require permission="zope.View"
interface="zope.app.container.interfaces.IReadContainer" />
Modified: Zope3/trunk/src/zope/app/dependable/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/dependable/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dependable/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,11 +17,11 @@
"""
__docformat__ = 'restructuredtext'
-from interfaces import IDependable
-from zope.app.annotation.interfaces import IAnnotations
-from zope.app.traversing.api import getParent, canonicalPath, getPath
from zope.interface import implements
+from zope.traversing.api import getParent, canonicalPath, getPath
+from zope.annotation.interfaces import IAnnotations
+from zope.app.dependable.interfaces import IDependable
class PathSetAnnotation(object):
"""Abstract base class for annotations that are sets of paths.
Modified: Zope3/trunk/src/zope/app/dependable/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/dependable/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dependable/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -5,6 +5,6 @@
<adapter
factory="zope.app.dependable.Dependable"
provides="zope.app.dependable.interfaces.IDependable"
- for="zope.app.annotation.interfaces.IAnnotatable" />
+ for="zope.annotation.interfaces.IAnnotatable" />
</configure>
\ No newline at end of file
Modified: Zope3/trunk/src/zope/app/dependable/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/dependable/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dependable/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,7 +18,7 @@
__docformat__ = 'restructuredtext'
from zope.interface import Interface
-from zope.app.exception.interfaces import UserError
+from zope.exceptions.interfaces import UserError
class IDependable(Interface):
"""Objects that other objects depend on.
Modified: Zope3/trunk/src/zope/app/dependable/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/dependable/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dependable/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,7 +16,7 @@
$Id$
"""
from unittest import TestCase, TestSuite, main, makeSuite
-from zope.app.annotation.attribute import AttributeAnnotations
+from zope.annotation.attribute import AttributeAnnotations
from zope.app.testing.placelesssetup import PlacelessSetup
class C(object):
Modified: Zope3/trunk/src/zope/app/dtmlpage/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/dtmlpage/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dtmlpage/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -33,13 +33,13 @@
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
<adapter
for="zope.app.folder.interfaces.IFolder"
- provides="zope.app.filerepresentation.interfaces.IFileFactory"
+ provides="zope.filerepresentation.interfaces.IFileFactory"
name=".dtml"
factory=".dtmlpage.DTMLFactory"
permission="zope.ManageContent"
Modified: Zope3/trunk/src/zope/app/dtmlpage/dtmlpage.py
===================================================================
--- Zope3/trunk/src/zope/app/dtmlpage/dtmlpage.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dtmlpage/dtmlpage.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,12 +21,12 @@
from zope.documenttemplate.untrusted import UntrustedHTML
from zope.interface import implements
+from zope.annotation.interfaces import IAnnotatable
+from zope.filerepresentation.interfaces import IFileFactory
-from zope.app.annotation.interfaces import IAnnotatable
-from zope.app.filerepresentation.interfaces import IFileFactory
from zope.app.container.contained import Contained
+from zope.app.publication.interfaces import IFileContent
-from zope.app.publication.interfaces import IFileContent
from interfaces import IDTMLPage, IRenderDTMLPage
class DTMLPage(Persistent, Contained):
Modified: Zope3/trunk/src/zope/app/dtmlpage/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/dtmlpage/ftests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dtmlpage/ftests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -111,7 +111,7 @@
def test_suite():
- from zope.app.tests import functional
+ from zope.app.testing import functional
return unittest.TestSuite((
unittest.makeSuite(DTMLPageTest),
functional.FunctionalDocFileSuite('url.txt'),
Modified: Zope3/trunk/src/zope/app/dtmlpage/tests/test_dtmlpage.py
===================================================================
--- Zope3/trunk/src/zope/app/dtmlpage/tests/test_dtmlpage.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dtmlpage/tests/test_dtmlpage.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,10 +18,10 @@
import unittest
from zope.security.checker import NamesChecker, defineChecker
+from zope.traversing.adapters import Traverser, DefaultTraversable
+from zope.traversing.interfaces import ITraverser, ITraversable
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.traversing.adapters import Traverser, DefaultTraversable
-from zope.app.traversing.interfaces import ITraverser, ITraversable
from zope.app.testing import ztapi
from zope.app.container.contained import contained
from zope.app.dtmlpage.dtmlpage import DTMLPage
Deleted: Zope3/trunk/src/zope/app/dublincore/PACKAGE.cfg
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/PACKAGE.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dublincore/PACKAGE.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,5 +0,0 @@
-# The fssync sub-package is a separate component.
-
-<collection>
- fssync -
-</collection>
Modified: Zope3/trunk/src/zope/app/dublincore/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dublincore/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,2 +1,7 @@
-#
-# This file is necessary to make this directory a package.
+# This module has moved to zope.dublincore
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.dublincore',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/dublincore/__init__.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.2
Name: svn:keywords
+ Id
Modified: Zope3/trunk/src/zope/app/dublincore/annotatableadapter.py
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/annotatableadapter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dublincore/annotatableadapter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,120 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Dublin Core Annotatable Adapter
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from persistent.dict import PersistentDict
-
-from zope.app.annotation.interfaces import IAnnotations, IAnnotatable
-from zope.app.dublincore.zopedublincore import ZopeDublinCore
-from zope.app.dublincore.zopedublincore import DateProperty, ScalarProperty
-from zope.app.location import Location
-
-
-DCkey = "zope.app.dublincore.ZopeDublinCore"
-
-
-class ZDCAnnotatableAdapter(ZopeDublinCore, Location):
- """Adapt annotatable objects to Zope Dublin Core."""
-
- __used_for__ = IAnnotatable
-
- annotations = None
-
- def __init__(self, context):
- annotations = IAnnotations(context)
- dcdata = annotations.get(DCkey)
- if dcdata is None:
- self.annotations = annotations
- dcdata = ZDCAnnotationData()
-
- super(ZDCAnnotatableAdapter, self).__init__(dcdata)
-
- def _changed(self):
- if self.annotations is not None:
- self.annotations[DCkey] = self._mapping
- self.annotations = None
-
-
-class ZDCAnnotationData(PersistentDict):
- """Data for a Dublin Core annotation.
-
- A specialized class is used to allow an alternate fssync
- serialization to be registered. See the
- zope.app.dublincore.fssync package.
- """
-
-
-# Hybrid adapters.
-#
-# Adapter factories created using this support the Dublin Core using a
-# mixture of annotations and data on the context object.
-
-def partialAnnotatableAdapterFactory(direct_fields):
- if not direct_fields:
- raise ValueError("only use partialAnnotatableAdapterFactory()"
- " if at least one DC field is implemented directly")
- fieldmap = {}
- try:
- # is direct_fields a sequence or a mapping?
- direct_fields[0]
- except KeyError:
- # direct_fields: { dc_name: attribute_name }
- fieldmap.update(direct_fields)
- else:
- for attrname in direct_fields:
- fieldmap[attrname] = attrname
-
- class ZDCPartialAnnotatableAdapter(ZDCAnnotatableAdapter):
-
- def __init__(self, context):
- self.__context = context
- # can't use super() since this isn't a globally available class
- ZDCAnnotatableAdapter.__init__(self, context)
-
- for dcname, attrname in fieldmap.iteritems():
- oldprop = ZopeDublinCore.__dict__.get(dcname)
- if oldprop is None:
- raise ValueError("%r is not a valid DC field" % dcname)
- if (isinstance(oldprop, DateProperty)
- or not isinstance(oldprop, ScalarProperty)):
- raise ValueError("%r is not a supported DC field" % dcname)
- prop = DirectProperty(dcname, attrname)
- setattr(ZDCPartialAnnotatableAdapter, dcname, prop)
-
- return ZDCPartialAnnotatableAdapter
-
-
-class DirectProperty(object):
-
- def __init__(self, name, attrname):
- self.__name__ = name
- self.__attrname = attrname
-
- def __get__(self, inst, klass):
- if inst is None:
- return self
- context = inst._ZDCPartialAnnotatableAdapter__context
- return getattr(context, self.__attrname, u"")
-
- def __set__(self, inst, value):
- if not isinstance(value, unicode):
- raise TypeError("Element must be unicode")
- context = inst._ZDCPartialAnnotatableAdapter__context
- oldvalue = getattr(context, self.__attrname, None)
- if oldvalue != value:
- setattr(context, self.__attrname, value)
+# This module has moved to zope.dublincore.annotatableadapter
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.dublincore.annotatableadapter',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/dublincore/annotatableadapter.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.10
Deleted: Zope3/trunk/src/zope/app/dublincore/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dublincore/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,59 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope">
-
- <permission
- id="zope.app.dublincore.view"
- title="[zope.app.dublincore.view-permission]
- View Dublin-Core Meta Data "
- />
-
- <permission
- id="zope.app.dublincore.change"
- title="[zope.app.dublincore.change-permission]
- Change Dublin-Core Meta Data "
- />
-
- <adapter
- factory=".annotatableadapter.ZDCAnnotatableAdapter"
- provides="zope.app.dublincore.interfaces.IWriteZopeDublinCore"
- for="zope.app.annotation.interfaces.IAnnotatable"
- trusted="true"
- />
-
- <class class=".annotatableadapter.ZDCAnnotatableAdapter">
- <require
- permission="zope.app.dublincore.view"
- interface=".interfaces.IZopeDublinCore"
- />
- <require
- permission="zope.app.dublincore.change"
- interface=".interfaces.IWritableGeneralDublinCore"
- set_schema=".interfaces.IZopeDublinCore"
- />
- </class>
-
- <subscriber
- handler=".timeannotators.ModifiedAnnotator"
- for="zope.app.event.interfaces.IObjectModifiedEvent"
- />
-
- <subscriber
- handler=".timeannotators.CreatedAnnotator"
- for="zope.app.event.interfaces.IObjectCreatedEvent"
- />
-
- <subscriber
- handler=".creatorannotator.CreatorAnnotator"
- for="zope.app.event.interfaces.IObjectModifiedEvent"
- />
-
- <subscriber
- handler=".creatorannotator.CreatorAnnotator"
- for="zope.app.event.interfaces.IObjectCreatedEvent"
- />
-
-
- <!-- Include browser package -->
-
- <include package=".browser" />
-
-</configure>
Modified: Zope3/trunk/src/zope/app/dublincore/creatorannotator.py
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/creatorannotator.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dublincore/creatorannotator.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,42 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Object that takes care of annotating the dublin core creator field.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.security.management import queryInteraction
-from zope.security.proxy import removeSecurityProxy
-
-def CreatorAnnotator(event):
- """Update Dublin-Core creator property"""
- dc = IZopeDublinCore(event.object, None)
- # Principals that can create object do not necessarily have
- # 'zope.app.dublincore.change' permission. See issue 373.
- dc = removeSecurityProxy(dc)
- if dc is None:
- return
-
- # Try to find a principal for that one. If there
- # is no principal then we don't touch the list
- # of creators.
- interaction = queryInteraction()
- if interaction is not None:
- for participation in interaction.participations:
- principalid = participation.principal.id
- if not principalid in dc.creators:
- dc.creators = dc.creators + (unicode(principalid), )
-
+# This module has moved to zope.dublincore.creatorannotator
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.dublincore.creatorannotator',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/dublincore/creatorannotator.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.9
Modified: Zope3/trunk/src/zope/app/dublincore/dcsv.py
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/dcsv.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dublincore/dcsv.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,138 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Functions for working with Dublin Core Structured Values (DCSV) scheme.
-
-DCSV is specified in 'DCMI DCSV: A syntax for writing a list of
-labelled values in a text string', at:
-
-http://dublincore.org/documents/dcmi-dcsv/
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import re
-
-__all__ = "encode", "decode"
-
-try:
- basestring
-except NameError:
- # define basestring in Python 2.2.x:
- try:
- unicode
- except NameError:
- basestring = str
- else:
- basestring = str, unicode
-
-
-def encode(items):
- L = []
- for item in items:
- if isinstance(item, basestring):
- L.append(_encode_string(item, "values") + ";")
- else:
- k, v = item
- if not isinstance(v, basestring):
- raise TypeError("values must be strings; found %r" % v)
- v = _encode_string(v, "values")
- if k:
- if not isinstance(k, basestring):
- raise TypeError("labels must be strings; found %r" % k)
- k = _encode_string(k, "labels")
- s = "%s=%s;" % (k, v)
- else:
- s = v + ";"
- L.append(s)
- return " ".join(L)
-
-def _encode_string(s, what):
- if s.strip() != s:
- raise ValueError("%s may not include leading or trailing spaces: %r"
- % (what, s))
- return s.replace("\\", r"\\").replace(";", r"\;").replace("=", r"\=")
-
-
-def decode(text):
- items = []
- text = text.strip()
- while text:
- m = _find_interesting(text)
- if m:
- prefix, char = m.group(1, 2)
- prefix = _decode_string(prefix).rstrip()
- if char == ";":
- items.append(('', prefix))
- text = text[m.end():].lstrip()
- continue
- else: # char == "="
- text = text[m.end():].lstrip()
- # else we have a label
- m = _find_value(text)
- if m:
- value = m.group(1)
- text = text[m.end():].lstrip()
- else:
- value = text
- text = ''
- items.append((prefix, _decode_string(value)))
- else:
- items.append(('', _decode_string(text)))
- break
- return items
-
-_prefix = r"((?:[^;\\=]|\\.)*)"
-_find_interesting = re.compile(_prefix + "([;=])").match
-_find_value = re.compile(_prefix + ";").match
-
-def _decode_string(s):
- if "\\" not in s:
- return s.rstrip()
- r = ""
- while s:
- c1 = s[0]
- if c1 == "\\":
- c2 = s[1:2]
- if not c2:
- return r + c1
- r += c2
- s = s[2:]
- else:
- r += c1
- s = s[1:]
- return r.rstrip()
-
-
-def createMapping(items, allow_duplicates=False):
- mapping = {}
- for item in items:
- if isinstance(item, basestring):
- raise ValueError("can't create mapping with unlabelled data")
- k, v = item
- if not isinstance(k, basestring):
- raise TypeError("labels must be strings; found %r" % k)
- if not isinstance(v, basestring):
- raise TypeError("values must be strings; found %r" % v)
- if k in mapping:
- if allow_duplicates:
- mapping[k].append(v)
- else:
- raise ValueError("labels may not have more than one value")
- else:
- if allow_duplicates:
- mapping[k] = [v]
- else:
- mapping[k] = v
- return mapping
+# This module has moved to zope.dublincore.dcsv
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.dublincore.dcsv',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/dublincore/dcsv.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.3
Modified: Zope3/trunk/src/zope/app/dublincore/dcterms.py
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/dcterms.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dublincore/dcterms.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,192 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Support information for qualified Dublin Core Metadata.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.app.dublincore import dcsv
-
-# useful namespace URIs
-DC_NS = "http://purl.org/dc/elements/1.1/"
-DCTERMS_NS = "http://purl.org/dc/terms/"
-XSI_NS = "http://www.w3.org/2001/XMLSchema-instance"
-
-W3CDTF = "W3CDTF"
-
-
-def splitEncoding(name):
- if "." not in name:
- return name, None
- parts = name.split(".")
- if parts[-1] in encodings:
- if len(parts) == 2:
- return parts
- else:
- return ".".join(parts[:-1]), parts[-1]
- else:
- return name, None
-
-
-# The type validator function must raise an exception if the value
-# passed isn't valid for the type being check, other just return.
-
-_dcmitypes = {}
-for x in ("Collection Dataset Event Image InteractiveResource"
- " Service Software Sound Text PhysicalObject").split():
- _dcmitypes[x.lower()] = x
-del x
-
-def check_dcmitype(value):
- if value.lower() not in _dcmitypes:
- raise ValueError("%r not a valid DCMIType")
-
-def check_imt(value):
- pass
-
-def check_iso639_2(value):
- pass
-
-def check_rfc1766(value):
- pass
-
-def check_uri(value):
- pass
-
-def check_point(value):
- pass
-
-def check_iso3166(value):
- pass
-
-def check_box(value):
- pass
-
-def check_tgn(value):
- pass
-
-_period_fields = "name start end scheme".split()
-
-def check_period(value):
- # checks a Period in DCSV format; see:
- # http://dublincore.org/documents/dcmi-period/
- items = dcsv.decode(value)
- d = dcsv.createMapping(items)
- for k in d:
- if k not in _period_fields:
- raise ValueError("unknown field label %r" % k)
- if d.get("scheme", W3CDTF).upper() == W3CDTF:
- if "start" in d:
- check_w3cdtf(d["start"])
- if "end" in d:
- check_w3cdtf(d["end"])
-
-def check_w3cdtf(value):
- pass
-
-def check_rfc3066(value):
- pass
-
-encodings = {
- # name --> (allowed for, validator|None),
- "LCSH": (("Subject",), None),
- "MESH": (("Subject",), None),
- "DDC": (("Subject",), None),
- "LCC": (("Subject",), None),
- "UDC": (("Subject",), None),
- "DCMIType": (("Type",), check_dcmitype),
- "IMT": (("Format",), check_imt),
- "ISO639-2": (("Language",), check_iso639_2),
- "RFC1766": (("Language",), check_rfc1766),
- "URI": (("Identifier", "Relation", "Source",), check_uri),
- "Point": (("Coverage.Spatial",), check_point),
- "ISO3166": (("Coverage.Spatial",), check_iso3166),
- "Box": (("Coverage.Spatial",), check_box),
- "TGN": (("Coverage.Spatial",), check_tgn),
- "Period": (("Coverage.Temporal",), check_period),
- W3CDTF: (("Coverage.Temporal", "Date",), check_w3cdtf),
- "RFC3066": (("Language",), check_rfc3066),
- }
-
-
-name_to_element = {
- # unqualified DCMES 1.1
- "Title": ("dc:title", ""),
- "Creator": ("dc:creator", ""),
- "Subject": ("dc:subject", ""),
- "Description": ("dc:description", ""),
- "Publisher": ("dc:publisher", ""),
- "Contributor": ("dc:contributor", ""),
- "Date": ("dc:date", "dcterms:"+W3CDTF),
- "Type": ("dc:type", ""),
- "Format": ("dc:format", ""),
- "Identifier": ("dc:identifier", ""),
- "Source": ("dc:source", ""),
- "Language": ("dc:language", ""),
- "Relation": ("dc:relation", ""),
- "Coverage": ("dc:coverage", ""),
- "Rights": ("dc:rights", ""),
-
- # qualified DCMES 1.1 (directly handled by Zope)
- "Date.Created": ("dcterms:created", "dcterms:"+W3CDTF),
- "Date.Modified": ("dcterms:modified", "dcterms:"+W3CDTF),
-
- # qualified DCMES 1.1 (not used by Zope)
- "Audience": ("dcterms:audience", ""),
- "Audience.Education Level": ("dcterms:educationLevel", ""),
- "Audience.Mediator": ("dcterms:mediator", ""),
- "Coverage.Spatial": ("dcterms:spatial", ""),
- "Coverage.Temporal": ("dcterms:temporal", ""),
- "Date.Accepted": ("dcterms:accepted", "dcterms:"+W3CDTF),
- "Date.Available": ("dcterms:available", "dcterms:"+W3CDTF),
- "Date.Copyrighted": ("dcterms:copyrighted","dcterms:"+W3CDTF),
- "Date.Issued": ("dcterms:issued", "dcterms:"+W3CDTF),
- "Date.Submitted": ("dcterms:submitted", "dcterms:"+W3CDTF),
- "Date.Valid": ("dcterms:valid", "dcterms:"+W3CDTF),
- "Description.Abstract": ("dcterms:abstract", ""),
- "Description.Table Of Contents": ("dcterms:tableOfContents", ""),
- "Format": ("dc:format", ""),
- "Format.Extent": ("dcterms:extent", ""),
- "Format.Medium": ("dcterms:medium", ""),
- "Identifier.Bibliographic Citation": ("dcterms:bibliographicCitation", ""),
- "Relation.Is Version Of": ("dcterms:isVersionOf", ""),
- "Relation.Has Version": ("dcterms:hasVersion", ""),
- "Relation.Is Replaced By": ("dcterms:isReplacedBy", ""),
- "Relation.Replaces": ("dcterms:replaces", ""),
- "Relation.Is Required By": ("dcterms:isRequiredBy", ""),
- "Relation.Requires": ("dcterms:requires", ""),
- "Relation.Is Part Of": ("dcterms:isPartOf", ""),
- "Relation.Has Part": ("dcterms:hasPart", ""),
- "Relation.Is Referenced By": ("dcterms:isReferencedBy", ""),
- "Relation.References": ("dcterms:references", ""),
- "Relation.Is Format Of": ("dcterms:isFormatOf", ""),
- "Relation.Has Format": ("dcterms:hasFormat", ""),
- "Relation.Conforms To": ("dcterms:conformsTo", ""),
- "Rights.Access Rights": ("dcterms:accessRights", ""),
- "Title.Alternative": ("dcterms:alternative", ""),
- }
-
-_prefix_to_ns = {
- "dc": DC_NS,
- "dcterms": DCTERMS_NS,
- # "xsi": XSI_NS, dont' use this for element names, only attrs
- }
-
-element_to_name = {}
-for name, (qname, attrs) in name_to_element.iteritems():
- prefix, localname = qname.split(":")
- elem_name = _prefix_to_ns[prefix], localname
- element_to_name[elem_name] = name
- name_to_element[name] = (elem_name, attrs)
+# This module has moved to zope.dublincore.dcterms
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.dublincore.dcterms',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/dublincore/dcterms.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.5
Modified: Zope3/trunk/src/zope/app/dublincore/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dublincore/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,474 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Dublin Core interfaces
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.app.annotation.interfaces import IAnnotatable
-from zope.interface import Interface
-from zope.schema import Text, TextLine, Datetime, List
-
-class IDublinCoreElementItem(Interface):
- """A qualified dublin core element"""
-
- qualification = TextLine(
- title = u"Qualification",
- description = u"The element qualification"
- )
-
- value = Text(
- title = u"Value",
- description = u"The element value",
- )
-
-class IGeneralDublinCore(Interface):
- """Dublin-core data access interface
-
- The Dublin Core, http://dublincore.org/, is a meta data standard
- that specifies a set of standard data elements. It provides
- flexibility of interpretation of these elements by providing for
- element qualifiers that specialize the meaning of specific
- elements. For example, a date element might have a qualifier, like
- "creation" to indicate that the date is a creation date. In
- addition, any element may be repeated. For some elements, like
- subject, and contributor, this is obviously necessary, but for
- other elements, like title and description, allowing repetitions
- is not very useful and adds complexity.
-
- This interface provides methods for retrieving data in full
- generality, to be compliant with the Dublin Core standard.
- Other interfaces will provide more convenient access methods
- tailored to specific element usage patterns.
- """
-
- def getQualifiedTitles():
- """Return a sequence of Title IDublinCoreElementItem.
- """
-
- def getQualifiedCreators():
- """Return a sequence of Creator IDublinCoreElementItem.
- """
-
- def getQualifiedSubjects():
- """Return a sequence of Subject IDublinCoreElementItem.
- """
-
- def getQualifiedDescriptions():
- """Return a sequence of Description IDublinCoreElementItem.
- """
-
- def getQualifiedPublishers():
- """Return a sequence of Publisher IDublinCoreElementItem.
- """
-
- def getQualifiedContributors():
- """Return a sequence of Contributor IDublinCoreElementItem.
- """
-
- def getQualifiedDates():
- """Return a sequence of Date IDublinCoreElementItem.
- """
-
- def getQualifiedTypes():
- """Return a sequence of Type IDublinCoreElementItem.
- """
-
- def getQualifiedFormats():
- """Return a sequence of Format IDublinCoreElementItem.
- """
-
- def getQualifiedIdentifiers():
- """Return a sequence of Identifier IDublinCoreElementItem.
- """
-
- def getQualifiedSources():
- """Return a sequence of Source IDublinCoreElementItem.
- """
-
- def getQualifiedLanguages():
- """Return a sequence of Language IDublinCoreElementItem.
- """
-
- def getQualifiedRelations():
- """Return a sequence of Relation IDublinCoreElementItem.
- """
-
- def getQualifiedCoverages():
- """Return a sequence of Coverage IDublinCoreElementItem.
- """
-
- def getQualifiedRights():
- """Return a sequence of Rights IDublinCoreElementItem.
- """
-
-class IWritableGeneralDublinCore(Interface):
- """Provide write access to dublin core data
-
- This interface augments `IStandardDublinCore` with methods for
- writing elements.
- """
-
- def setQualifiedTitles(qualified_titles):
- """Set the qualified Title elements.
-
- The argument must be a sequence of `IDublinCoreElementItem`.
- """
-
- def setQualifiedCreators(qualified_creators):
- """Set the qualified Creator elements.
-
- The argument must be a sequence of Creator `IDublinCoreElementItem`.
- """
-
- def setQualifiedSubjects(qualified_subjects):
- """Set the qualified Subjects elements.
-
- The argument must be a sequence of Subject `IDublinCoreElementItem`.
- """
-
- def setQualifiedDescriptions(qualified_descriptions):
- """Set the qualified Descriptions elements.
-
- The argument must be a sequence of Description `IDublinCoreElementItem`.
- """
-
- def setQualifiedPublishers(qualified_publishers):
- """Set the qualified Publishers elements.
-
- The argument must be a sequence of Publisher `IDublinCoreElementItem`.
- """
-
- def setQualifiedContributors(qualified_contributors):
- """Set the qualified Contributors elements.
-
- The argument must be a sequence of Contributor `IDublinCoreElementItem`.
- """
-
- def setQualifiedDates(qualified_dates):
- """Set the qualified Dates elements.
-
- The argument must be a sequence of Date `IDublinCoreElementItem`.
- """
-
- def setQualifiedTypes(qualified_types):
- """Set the qualified Types elements.
-
- The argument must be a sequence of Type `IDublinCoreElementItem`.
- """
-
- def setQualifiedFormats(qualified_formats):
- """Set the qualified Formats elements.
-
- The argument must be a sequence of Format `IDublinCoreElementItem`.
- """
-
- def setQualifiedIdentifiers(qualified_identifiers):
- """Set the qualified Identifiers elements.
-
- The argument must be a sequence of Identifier `IDublinCoreElementItem`.
- """
-
- def setQualifiedSources(qualified_sources):
- """Set the qualified Sources elements.
-
- The argument must be a sequence of Source `IDublinCoreElementItem`.
- """
-
- def setQualifiedLanguages(qualified_languages):
- """Set the qualified Languages elements.
-
- The argument must be a sequence of Language `IDublinCoreElementItem`.
- """
-
- def setQualifiedRelations(qualified_relations):
- """Set the qualified Relations elements.
-
- The argument must be a sequence of Relation `IDublinCoreElementItem`.
- """
-
- def setQualifiedCoverages(qualified_coverages):
- """Set the qualified Coverages elements.
-
- The argument must be a sequence of Coverage `IDublinCoreElementItem`.
- """
-
- def setQualifiedRights(qualified_rights):
- """Set the qualified Rights elements.
-
- The argument must be a sequence of Rights `IDublinCoreElementItem`.
- """
-
-class IDCDescriptiveProperties(Interface):
- """Basic descriptive meta-data properties
- """
-
- title = TextLine(
- title = u'Title',
- description =
- u"The first unqualified Dublin Core 'Title' element value."
- )
-
- description = Text(
- title = u'Description',
- description =
- u"The first unqualified Dublin Core 'Description' element value.",
- )
-
-class IDCTimes(Interface):
- """Time properties
- """
-
- created = Datetime(
- title = u'Creation Date',
- description =
- u"The date and time that an object is created. "
- u"\nThis is normally set automatically."
- )
-
- modified = Datetime(
- title = u'Modification Date',
- description =
- u"The date and time that the object was last modified in a\n"
- u"meaningful way."
- )
-
-class IDCPublishing(Interface):
- """Publishing properties
- """
-
- effective = Datetime(
- title = u'Effective Date',
- description =
- u"The date and time that an object should be published. "
- )
-
-
- expires = Datetime(
- title = u'Expiration Date',
- description =
- u"The date and time that the object should become unpublished."
- )
-
-class IDCExtended(Interface):
- """Extended properties
-
- This is a mized bag of properties we want but that we probably haven't
- quite figured out yet.
- """
-
-
- creators = List(
- title = u'Creators',
- description = u"The unqualified Dublin Core 'Creator' element values",
- value_type = TextLine(),
- )
-
- subjects = List(
- title = u'Subjects',
- description = u"The unqualified Dublin Core 'Subject' element values",
- value_type = TextLine(),
- )
-
- publisher = Text(
- title = u'Publisher',
- description =
- u"The first unqualified Dublin Core 'Publisher' element value.",
- )
-
- contributors = List(
- title = u'Contributors',
- description =
- u"The unqualified Dublin Core 'Contributor' element values",
- value_type = TextLine(),
- )
-
-class ICMFDublinCore(Interface):
- """This interface duplicates the CMF dublin core interface.
- """
-
- def Title():
- """Return the resource title.
-
- The first unqualified Dublin Core `Title` element value is
- returned as a unicode string if an unqualified element is
- defined, otherwise, an empty unicode string is returned.
- """
-
- def Creator():
- """Return the resource creators.
-
- Return the full name(s) of the author(s) of the content
- object.
-
- The unqualified Dublin Core `Creator` element values are
- returned as a sequence of unicode strings.
- """
-
- def Subject():
- """Return the resource subjects.
-
- The unqualified Dublin Core `Subject` element values are
- returned as a sequence of unicode strings.
- """
-
- def Description():
- """Return the resource description
-
- Return a natural language description of this object.
-
- The first unqualified Dublin Core `Description` element value is
- returned as a unicode string if an unqualified element is
- defined, otherwise, an empty unicode string is returned.
- """
-
- def Publisher():
- """Dublin Core element - resource publisher
-
- Return full formal name of the entity or person responsible
- for publishing the resource.
-
- The first unqualified Dublin Core `Publisher` element value is
- returned as a unicode string if an unqualified element is
- defined, otherwise, an empty unicode string is returned.
- """
-
- def Contributors():
- """Return the resource contributors
-
- Return any additional collaborators.
-
- The unqualified Dublin Core `Contributor` element values are
- returned as a sequence of unicode strings.
- """
-
- def Date():
- """Return the default date
-
- The first unqualified Dublin Core `Date` element value is
- returned as a unicode string if an unqualified element is
- defined, otherwise, an empty unicode string is returned. The
- string is formatted 'YYYY-MM-DD H24:MN:SS TZ'.
- """
-
- def CreationDate():
- """Return the creation date.
-
- The value of the first Dublin Core `Date` element qualified by
- 'creation' is returned as a unicode string if a qualified
- element is defined, otherwise, an empty unicode string is
- returned. The string is formatted 'YYYY-MM-DD H24:MN:SS TZ'.
- """
-
- def EffectiveDate():
- """Return the effective date
-
- The value of the first Dublin Core `Date` element qualified by
- 'effective' is returned as a unicode string if a qualified
- element is defined, otherwise, an empty unicode string is
- returned. The string is formatted 'YYYY-MM-DD H24:MN:SS TZ'.
- """
-
- def ExpirationDate():
- """Date resource expires.
-
- The value of the first Dublin Core `Date` element qualified by
- 'expiration' is returned as a unicode string if a qualified
- element is defined, otherwise, an empty unicode string is
- returned. The string is formatted 'YYYY-MM-DD H24:MN:SS TZ'.
- """
-
- def ModificationDate():
- """Date resource last modified.
-
- The value of the first Dublin Core `Date` element qualified by
- 'modification' is returned as a unicode string if a qualified
- element is defined, otherwise, an empty unicode string is
- returned. The string is formatted 'YYYY-MM-DD H24:MN:SS TZ'.
- """
-
- def Type():
- """Return the resource type
-
- Return a human-readable type name for the resource.
-
- The first unqualified Dublin Core `Type` element value is
- returned as a unicode string if an unqualified element is
- defined, otherwise, an empty unicode string is returned.
- """
-
- def Format():
- """Return the resource format.
-
- Return the resource's MIME type (e.g., 'text/html',
- 'image/png', etc.).
-
- The first unqualified Dublin Core `Format` element value is
- returned as a unicode string if an unqualified element is
- defined, otherwise, an empty unicode string is returned.
- """
-
- def Identifier():
- """Return the URL of the resource.
-
- This value is computed. It is included in the output of
- qualifiedIdentifiers with the qualification 'url'.
- """
-
- def Language():
- """Return the resource language.
-
- Return the RFC language code (e.g., 'en-US', 'pt-BR')
- for the resource.
-
- The first unqualified Dublin Core `Language` element value is
- returned as a unicode string if an unqualified element is
- defined, otherwise, an empty unicode string is returned.
- """
-
- def Rights():
- """Return the resource rights.
-
- Return a string describing the intellectual property status,
- if any, of the resource. for the resource.
-
- The first unqualified Dublin Core `Rights` element value is
- returned as a unicode string if an unqualified element is
- defined, otherwise, an empty unicode string is returned.
- """
-
-class IZopeDublinCore(
- IGeneralDublinCore,
- ICMFDublinCore,
- IDCDescriptiveProperties,
- IDCTimes,
- IDCPublishing,
- IDCExtended,
- ):
- """Zope Dublin Core properties"""
-
-class IWriteZopeDublinCore(
- IZopeDublinCore,
- IWritableGeneralDublinCore,
- ):
- """Zope Dublin Core properties with generate update support"""
-
-
-class IZopeDublinCoreAnnotatable(IAnnotatable):
- """Objects that can be annotated with Zope Dublin-Core meta data
-
- This is a marker interface that indicates the intent to have
- Zope Dublin-Core meta data associated with an object.
- """
+# This module has moved to zope.dublincore.interfaces
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.dublincore.interfaces',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/dublincore/interfaces.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.3
Modified: Zope3/trunk/src/zope/app/dublincore/timeannotators.py
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/timeannotators.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dublincore/timeannotators.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,43 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Objects that take care of annotating dublin core meta data times
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from datetime import datetime
-import pytz
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.security.proxy import removeSecurityProxy
-
-
-def ModifiedAnnotator(event):
- dc = IZopeDublinCore(event.object, None)
- if dc is not None:
- # Principals that can modify objects do not necessary have permissions
- # to arbitrarily modify DC data, see issue 373
- dc = removeSecurityProxy(dc)
- dc.modified = datetime.now(pytz.utc)
-
-
-def CreatedAnnotator(event):
- dc = IZopeDublinCore(event.object, None)
- if dc is not None:
- # Principals that can create objects do not necessary have permissions
- # to arbitrarily modify DC data, see issue 373
- dc = removeSecurityProxy(dc)
- now = datetime.now(pytz.utc)
- dc.created = now
- dc.modified = now
+# This module has moved to zope.dublincore.timeannotators
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.dublincore.timeannotators',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/dublincore/timeannotators.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.8
Modified: Zope3/trunk/src/zope/app/dublincore/xmlmetadata.py
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/xmlmetadata.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dublincore/xmlmetadata.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,247 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Dublin Core XML data parser and writer
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import xml.sax
-import xml.sax.handler
-
-from cStringIO import StringIO
-from xml.sax.saxutils import escape, quoteattr
-
-from zope.app.dublincore import dcterms
-
-
-XSI_TYPE = (dcterms.XSI_NS, "type")
-
-dublin_core_namespaces = dcterms.DC_NS, dcterms.DCTERMS_NS
-
-
-DEFAULT_NAMESPACE_PREFIXES = {
- # uri: prefix,
- dcterms.DC_NS: "dc",
- dcterms.DCTERMS_NS: "dcterms",
- dcterms.XSI_NS: "xsi",
- }
-
-class NamespaceTracker(object):
- def __init__(self, mapping=None):
- self._mapping = {}
- self._used = {}
- if mapping:
- self._mapping.update(mapping)
- self._counter = 0
-
- def encode(self, (uri, localname)):
- if not uri:
- return localname
- if uri not in self._mapping:
- self._counter += 1
- prefix = "ns%d" % self._counter
- self._mapping[uri] = prefix
- self._used[prefix] = uri
- else:
- prefix = self._mapping[uri]
- if prefix not in self._used:
- self._used[prefix] = uri
- if prefix:
- return "%s:%s" % (prefix, localname)
- else:
- return localname
-
- def getPrefixMappings(self):
- return self._used.items()
-
-
-def dumpString(mapping):
- sio = StringIO()
- nsmap = NamespaceTracker(DEFAULT_NAMESPACE_PREFIXES)
- items = mapping.items()
- items.sort()
- prev = None
- for name, values in items:
- name, type = dcterms.splitEncoding(name)
- group = name.split(".", 1)[0]
- if prev != group:
- sio.write("\n")
- prev = group
- if name in dcterms.name_to_element:
- element, t = dcterms.name_to_element[name]
- qname = nsmap.encode(element)
- if not type:
- type = t
- if type:
- type = " %s=%s" % (nsmap.encode((dcterms.XSI_NS, "type")),
- quoteattr(type))
- for value in values:
- sio.write(" <%s%s>\n %s\n </%s>\n"
- % (qname, type, _encode_string(value), qname))
- else:
- raise RuntimeError("could not serialize %r metadata element"
- % name)
- content = sio.getvalue()
- sio = StringIO()
- sio.write("<?xml version='1.0' encoding='utf-8'?>\n"
- "<metadata")
- for prefix, uri in nsmap.getPrefixMappings():
- sio.write("\n xmlns:%s=%s" % (prefix, quoteattr(uri)))
- sio.write(">\n")
- sio.write(content)
- sio.write("</metadata>\n")
- return sio.getvalue()
-
-try:
- unicode
-except NameError:
- _encode_string = escape
-else:
- def _encode_string(s):
- if isinstance(s, unicode):
- s = s.encode('utf-8')
- return escape(s)
-
-
-def parse(source, error_handler=None):
- parser, ch = _setup_parser(error_handler)
- parser.parse(source)
- return ch.mapping
-
-def parseString(text, error_handler=None):
- parser, ch = _setup_parser(error_handler)
- parser.feed(text)
- parser.close()
- return ch.mapping
-
-def _setup_parser(error_handler):
- parser = xml.sax.make_parser()
- ch = DublinCoreHandler()
- parser.setFeature(xml.sax.handler.feature_namespaces, True)
- parser.setContentHandler(ch)
- if error_handler is not None:
- parser.setErrorHandler(error_handler)
- return parser, ch
-
-
-class PrefixManager(object):
- # We don't use this other than in the DublinCoreHandler, but it's
- # entirely general so we'll separate it out for now.
-
- """General handler for namespace prefixes.
-
- This should be used as a mix-in when creating a ContentHandler.
- """
-
- __prefix_map = None
-
- def startPrefixMapping(self, prefix, uri):
- if self.__prefix_map is None:
- self.__prefix_map = {}
- pm = self.__prefix_map
- pm.setdefault(prefix, []).append(uri)
-
- def endPrefixMapping(self, prefix):
- pm = self.__prefix_map
- uris = pm[prefix]
- del uris[-1]
- if not uris:
- del pm[prefix]
-
- def get_uri(self, prefix):
- pm = self.__prefix_map
- if pm is None:
- return None
- if prefix in pm:
- return pm[prefix][-1]
- else:
- return None
-
-
-class DublinCoreHandler(PrefixManager, xml.sax.handler.ContentHandler):
-
- def startDocument(self):
- self.mapping = {}
- self.stack = []
-
- def get_dc_container(self):
- name = None
- for (uri, localname), dcelem, validator in self.stack:
- if uri in dublin_core_namespaces:
- name = uri, localname
- if name in dcterms.element_to_name:
- # dcelem contains type info, so go back to the mapping
- return dcterms.element_to_name[name]
- else:
- return None
-
- def startElementNS(self, name, qname, attrs):
- self.buffer = u""
- # TODO: need convert element to metadata element name
- dcelem = validator = None
- if name in dcterms.element_to_name:
- dcelem = dcterms.element_to_name[name]
- type = attrs.get(XSI_TYPE)
- if type:
- if not dcelem:
- raise ValueError(
- "data type specified for unknown metadata element: %s"
- % qname)
- if ":" in type:
- prefix, t = type.split(":", 1)
- ns = self.get_uri(prefix)
- if ns != dcterms.DCTERMS_NS:
- raise ValueError("unknown data type namespace: %s" % t)
- type = t
- if type not in dcterms.encodings:
- raise ValueError("unknown data type: %r" % type)
- allowed_in, validator = dcterms.encodings[type]
- dcelem_split = dcelem.split(".")
- for elem in allowed_in:
- elem_split = elem.split(".")
- if dcelem_split[:len(elem_split)] == elem_split:
- break
- else:
- raise ValueError("%s values are not allowed for %r"
- % (type, dcelem))
- dcelem = "%s.%s" % (dcelem, type)
- if dcelem:
- cont = self.get_dc_container()
- if cont and cont != dcelem:
- prefix = cont + "."
- if not dcelem.startswith(prefix):
- raise ValueError("%s is not a valid refinement for %s"
- % (dcelem, cont))
- self.stack.append((name, dcelem, validator))
-
- def endElementNS(self, name, qname):
- startname, dcelem, validator = self.stack.pop()
- assert startname == name
- if self.buffer is None:
- return
- data = self.buffer.strip()
- self.buffer = None
- if not dcelem:
- return
- if validator is not None:
- validator(data)
- if dcelem in self.mapping:
- self.mapping[dcelem] += (data,)
- else:
- self.mapping[dcelem] = (data,)
-
- def characters(self, data):
- if self.buffer is not None:
- self.buffer += data
+# This module has moved to zope.dublincore.xmlmetadata
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.dublincore.xmlmetadata',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/dublincore/xmlmetadata.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.5
Modified: Zope3/trunk/src/zope/app/dublincore/zopedublincore.py
===================================================================
--- Zope3/trunk/src/zope/app/dublincore/zopedublincore.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/dublincore/zopedublincore.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,356 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Zope's Dublin Core Implementation
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from datetime import datetime
-
-from zope.interface import implements
-
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.datetimeutils import parseDatetimetz
-
-class SimpleProperty(object):
-
- def __init__(self, name):
- self.__name__ = name
-
-class ScalarProperty(SimpleProperty):
-
- def __get__(self, inst, klass):
- if inst is None:
- return self
- data = inst._mapping.get(self.__name__, ())
- if data:
- return data[0]
- else:
- return u''
-
- def __set__(self, inst, value):
- if not isinstance(value, unicode):
- raise TypeError("Element must be unicode")
- dict = inst._mapping
- __name__ = self.__name__
- inst._changed()
- dict[__name__] = (value, ) + dict.get(__name__, ())[1:]
-
-def _scalar_get(inst, name):
- data = inst._mapping.get(name, ())
- if data:
- return data[0]
- else:
- return u''
-
-class DateProperty(ScalarProperty):
-
- def __get__(self, inst, klass):
- if inst is None:
- return self
- data = inst._mapping.get(self.__name__, ())
- if data:
- return parseDatetimetz(data[0])
- else:
- return None
-
- def __set__(self, inst, value):
- if not isinstance(value, datetime):
- raise TypeError("Element must be %s", datetime)
-
- value = unicode(value.isoformat('T'), 'ascii')
-
- super(DateProperty, self).__set__(inst, value)
-
-
-class SequenceProperty(SimpleProperty):
-
- def __get__(self, inst, klass):
- if inst is None:
- return self
-
- return inst._mapping.get(self.__name__, ())
-
- def __set__(self, inst, value):
- value = tuple(value)
- for v in value:
- if not isinstance(v, unicode):
- raise TypeError("Elements must be unicode")
- inst._changed()
- inst._mapping[self.__name__] = value
-
-class ZopeDublinCore(object):
- """Zope Dublin Core Mixin
-
- Subclasses should define either `_changed()` or `_p_changed`.
-
- Just mix with `Persistence` to get a persistent version.
- """
-
- implements(IZopeDublinCore)
-
- def __init__(self, mapping=None):
- if mapping is None:
- mapping = {}
- self._mapping = mapping
-
- def _changed(self):
- self._p_changed = True
-
- title = ScalarProperty(u'Title')
-
- def Title(self):
- "See `IZopeDublinCore`"
- return self.title
-
- creators = SequenceProperty(u'Creator')
-
- def Creator(self):
- "See `IZopeDublinCore`"
- return self.creators
-
- subjects = SequenceProperty(u'Subject')
-
- def Subject(self):
- "See `IZopeDublinCore`"
- return self.subjects
-
- description = ScalarProperty(u'Description')
-
- def Description(self):
- "See `IZopeDublinCore`"
- return self.description
-
- publisher = ScalarProperty(u'Publisher')
-
- def Publisher(self):
- "See IZopeDublinCore"
- return self.publisher
-
- contributors = SequenceProperty(u'Contributor')
-
- def Contributors(self):
- "See `IZopeDublinCore`"
- return self.contributors
-
- def Date(self):
- "See IZopeDublinCore"
- return _scalar_get(self, u'Date')
-
- created = DateProperty(u'Date.Created')
-
- def CreationDate(self):
- "See `IZopeDublinCore`"
- return _scalar_get(self, u'Date.Created')
-
- effective = DateProperty(u'Date.Effective')
-
- def EffectiveDate(self):
- "See `IZopeDublinCore`"
- return _scalar_get(self, u'Date.Effective')
-
- expires = DateProperty(u'Date.Expires')
-
- def ExpirationDate(self):
- "See `IZopeDublinCore`"
- return _scalar_get(self, u'Date.Expires')
-
- modified = DateProperty(u'Date.Modified')
-
- def ModificationDate(self):
- "See `IZopeDublinCore`"
- return _scalar_get(self, u'Date.Modified')
-
- type = ScalarProperty(u'Type')
-
- def Type(self):
- "See `IZopeDublinCore`"
- return self.type
-
- format = ScalarProperty(u'Format')
-
- def Format(self):
- "See `IZopeDublinCore`"
- return self.format
-
- identifier = ScalarProperty(u'Identifier')
-
- def Identifier(self):
- "See `IZopeDublinCore`"
- return self.identifier
-
- language = ScalarProperty(u'Language')
-
- def Language(self):
- "See `IZopeDublinCore`"
- return self.language
-
- rights = ScalarProperty(u'Rights')
-
- def Rights(self):
- "See `IZopeDublinCore`"
- return self.rights
-
- def setQualifiedTitles(self, qualified_titles):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Title', qualified_titles)
-
- def setQualifiedCreators(self, qualified_creators):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Creator', qualified_creators)
-
- def setQualifiedSubjects(self, qualified_subjects):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Subject', qualified_subjects)
-
- def setQualifiedDescriptions(self, qualified_descriptions):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Description', qualified_descriptions)
-
- def setQualifiedPublishers(self, qualified_publishers):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Publisher', qualified_publishers)
-
- def setQualifiedContributors(self, qualified_contributors):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Contributor', qualified_contributors)
-
- def setQualifiedDates(self, qualified_dates):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Date', qualified_dates)
-
- def setQualifiedTypes(self, qualified_types):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Type', qualified_types)
-
- def setQualifiedFormats(self, qualified_formats):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Format', qualified_formats)
-
- def setQualifiedIdentifiers(self, qualified_identifiers):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Identifier', qualified_identifiers)
-
- def setQualifiedSources(self, qualified_sources):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Source', qualified_sources)
-
- def setQualifiedLanguages(self, qualified_languages):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Language', qualified_languages)
-
- def setQualifiedRelations(self, qualified_relations):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Relation', qualified_relations)
-
- def setQualifiedCoverages(self, qualified_coverages):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Coverage', qualified_coverages)
-
- def setQualifiedRights(self, qualified_rights):
- "See `IWritableDublinCore`"
- return _set_qualified(self, u'Rights', qualified_rights)
-
- def getQualifiedTitles(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Title')
-
- def getQualifiedCreators(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Creator')
-
- def getQualifiedSubjects(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Subject')
-
- def getQualifiedDescriptions(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Description')
-
- def getQualifiedPublishers(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Publisher')
-
- def getQualifiedContributors(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Contributor')
-
- def getQualifiedDates(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Date')
-
- def getQualifiedTypes(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Type')
-
- def getQualifiedFormats(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Format')
-
- def getQualifiedIdentifiers(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Identifier')
-
- def getQualifiedSources(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Source')
-
- def getQualifiedLanguages(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Language')
-
- def getQualifiedRelations(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Relation')
-
- def getQualifiedCoverages(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Coverage')
-
- def getQualifiedRights(self):
- "See `IStandardDublinCore`"
- return _get_qualified(self, u'Rights')
-
-
-def _set_qualified(self, name, qvalue):
- data = {}
- dict = self._mapping
-
- for qualification, value in qvalue:
- data[qualification] = data.get(qualification, ()) + (value, )
-
- self._changed()
- for qualification, values in data.iteritems():
- qname = qualification and (name + '.' + qualification) or name
- dict[qname] = values
-
-def _get_qualified(self, name):
- result = []
- for aname, avalue in self._mapping.iteritems():
-
- if aname == name:
- qualification = u''
- for value in avalue:
- result.append((qualification, value))
-
- elif aname.startswith(name):
- qualification = aname[len(name)+1:]
- for value in avalue:
- result.append((qualification, value))
-
- return tuple(result)
-
-
-__doc__ = ZopeDublinCore.__doc__ + __doc__
+# This module has moved to zope.dublincore.zopedublincore
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.dublincore.zopedublincore',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/dublincore/zopedublincore.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.6
Modified: Zope3/trunk/src/zope/app/error/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/error/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/error/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,31 +1 @@
-##############################################################################
-#
-# Copyright (c) 2006 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Error logging utility
-
-$Id$
-"""
-from zope.app.error.error import RootErrorReportingUtility
-from zope.app.error.error import ErrorReportingUtility
-from zope.app.error.error import globalErrorReportingUtility
-
-###############################################################################
-# BBB: 12/14/2004
-import sys
-sys.modules['zope.app.errorservice'] = sys.modules[__name__]
-
-RootErrorReportingService = RootErrorReportingUtility
-ErrorReportingService = ErrorReportingUtility
-globalErrorReportingService = globalErrorReportingUtility
-
-###############################################################################
+# import this
Modified: Zope3/trunk/src/zope/app/error/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/error/browser/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/error/browser/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,7 +15,7 @@
$Id$
"""
-from zope.app.publisher.browser import BrowserView
+from zope.publisher.browser import BrowserView
from zope.app import zapi
from zope.app.error.interfaces import IErrorReportingUtility
Modified: Zope3/trunk/src/zope/app/error/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/error/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/error/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -38,13 +38,6 @@
description="Error Reporting Utility for Logging Errors"
permission="zope.ManageServices" />
- <tool
- interface="..interfaces.IErrorReportingUtility"
- title="Error Reporting"
- description="Component to record all uncaught errors and exceptions."
- unique="true"
- />
-
<icon name="zmi_icon"
for="zope.app.error.interfaces.IErrorReportingUtility"
file="error.gif" />
Copied: Zope3/trunk/src/zope/app/event/README.txt (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/event/README.txt)
Modified: Zope3/trunk/src/zope/app/event/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/event/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/event/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,4 +17,11 @@
"""
__docformat__ = 'restructuredtext'
-from dispatching import publish
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "Event support has been moved to zope.component.event, life cycle events "
+ "to zope.lifecycleevent. This reference will be gone in Zope 3.5",
+ objectevent = 'zope.lifecycleevent',
+ interfaces = 'zope.lifecycleevent.interfaces',
+ dispatch = 'zope.component.event',
+ )
Modified: Zope3/trunk/src/zope/app/event/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/event/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/event/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,11 +1,12 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:event="http://namespaces.zope.org/event"
- >
+<configure xmlns="http://namespaces.zope.org/zope">
-<subscriber
- for="zope.app.event.interfaces.IObjectEvent"
- handler=".objectevent.objectEventNotify"
- />
+ <subscriber handler="zope.component.event.objectEventNotify" />
+ <configure package="zope.component.registry">
+ <subscriber handler=".dispatchUtilityRegistrationEvent" />
+ <subscriber handler=".dispatchAdapterRegistrationEvent" />
+ <subscriber handler=".dispatchSubscriptionAdapterRegistrationEvent" />
+ <subscriber handler=".dispatchHandlerRegistrationEvent" />
+ </configure>
+
</configure>
Copied: Zope3/trunk/src/zope/app/event/dispatch.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/event/dispatch.py)
Deleted: Zope3/trunk/src/zope/app/event/dispatching.py
===================================================================
--- Zope3/trunk/src/zope/app/event/dispatching.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/event/dispatching.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,74 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Implement zope-specific event dispatching, based on subscription adapters
-
-This package installs an event dispatcher that calls event handlers,
-registered as subscription adapters providing ``None``.
-
-So, to subscribe to an event, use a subscription adapter to ``None``:
-
- >>> from zope.app.testing.placelesssetup import setUp, tearDown
- >>> setUp()
-
- >>> class E1(object):
- ... pass
-
- >>> class E2(E1):
- ... pass
-
- >>> called = []
- >>> def handler1(event):
- ... called.append(1)
-
- >>> def handler2(event):
- ... called.append(2)
-
- >>> from zope.app.testing import ztapi
- >>> from zope.interface import implementedBy
- >>> ztapi.subscribe([implementedBy(E1)], None, handler1) # old way
- >>> ztapi.subscribe((E2,), None, handler2) # new way
-
- >>> from zope.event import notify
-
- >>> notify(E1())
- >>> called
- [1]
-
- >>> del called[:]
- >>> notify(E2())
- >>> called.sort()
- >>> called
- [1, 2]
-
- >>> tearDown()
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from warnings import warn
-from zope.component import subscribers
-import zope.event
-
-def dispatch(*event):
- # iterating over subscribers assures they get executed
- for ignored in subscribers(event, None):
- pass
-
-zope.event.subscribers.append(dispatch)
-
-def publish(context, event):
- warn("Use zope.event.notify rather than zope.app.event.publish",
- DeprecationWarning, 2)
- zope.event.notify(event)
Modified: Zope3/trunk/src/zope/app/event/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/event/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/event/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,80 +1,13 @@
-##############################################################################
-#
-# Copyright (c) 2002, 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Event-related interfaces
+# This module has moved to zope.lifecycleevent.interfaces
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.lifecycleevent.interfaces',
+ "Zope 3.5",
+ )
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.interface import Interface, Attribute
-
-
-class IObjectEvent(Interface):
- """An event related to an object.
-
- The object that generated this event is not necessarily the object
- refered to by location.
- """
-
- object = Attribute("The subject of the event.")
-
-
-class IObjectCreatedEvent(IObjectEvent):
- """An object has been created.
-
- The location will usually be ``None`` for this event."""
-
-
-class IObjectCopiedEvent(IObjectCreatedEvent):
- """An object has been copied"""
-
- original = Attribute("The original from which the copy was made")
-
-
-class IObjectModifiedEvent(IObjectEvent):
- """An object has been modified"""
-
-
-class IModificationDescription(Interface) :
- """ Marker interface for descriptions of object modifications.
-
- Can be used as a parameter of an IObjectModifiedEvent."""
-
-
-class IAttributes(IModificationDescription) :
- """ Describes the attributes of an interface.
-
- """
-
- interface = Attribute("The involved interface.")
- attributes = Attribute("A sequence of modified attributes.")
-
-
-class ISequence(IModificationDescription) :
- """ Describes the modified keys of a sequence-like interface.
-
- """
-
- interface = Attribute("The involved interface.")
- keys = Attribute("A sequence of modified keys.")
-
-
-# BBB: will go in Zope3.3
-
-class IObjectAnnotationsModifiedEvent(IObjectModifiedEvent):
- """An object's annotations have been modified"""
-
-
-class IObjectContentModifiedEvent(IObjectModifiedEvent):
- """An object's content has been modified"""
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "IObjectEvent has moved to zope.component.interfaces",
+ IObjectEvent = 'zope.component.interfaces:IObjectEvent',
+ )
Property changes on: Zope3/trunk/src/zope/app/event/interfaces.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.3
Modified: Zope3/trunk/src/zope/app/event/objectevent.py
===================================================================
--- Zope3/trunk/src/zope/app/event/objectevent.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/event/objectevent.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,250 +1,19 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""In Zope3 events are used by components to inform each other
-about relevant new objects and object modifications.
+# This module has moved to zope.lifecycleevent
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.lifecycleevent',
+ "Zope 3.5",
+ )
-To keep all subscribers up to date it is indispensable that the life cycle of
-an object is accompanied by various events.
-
- >>> class Sample(object) :
- ... "Test class"
-
- >>> obj = Sample()
- >>> notify(ObjectCreatedEvent(obj))
-
- >>> obj.modified = True
- >>> notify(ObjectModifiedEvent(obj))
-
-Zope3's Dublin Core Metadata for instance, rely on the bare
-ObjectCreatedEvent and ObjectModifiedEvent to record creation and modification
-times. Other event consumers like catalogs and caches may need more information
-to update themselves in an efficient manner. The necessary information can
-be provided as optional modification descriptions of the ObjectModifiedEvent.
-
-Some examples:
-
- >>> from zope.app.file import File
- >>> from zope.app.file.interfaces import IFile
- >>> file = File()
- >>> file.data = "123"
- >>> notify(ObjectModifiedEvent(obj, IFile))
-
-This says that we modified something via IFile. Note that an interface is an
-acceptable description. In fact, we might allow pretty much anything as a
-description and it depends on your needs what kind of descriptions
-you use.
-
-In the following we use an IAttributes description to describe in more detail
-which parts of an object where modified :
-
- >>> file.data = "456"
-
- >>> from zope.app.dublincore.interfaces import IZopeDublinCore
- >>> from zope.interface import directlyProvides
- >>> from zope.app.annotation.interfaces import IAttributeAnnotatable
- >>> directlyProvides(file, IAttributeAnnotatable)
-
- >>> IZopeDublinCore(file).title = u"New title"
- >>> IZopeDublinCore(file).title = u"New description"
- >>> event = ObjectModifiedEvent(obj, Attributes(IFile, 'data'),
- ... Attributes(IZopeDublinCore, 'title', 'description'),
- ... )
- >>> notify(event)
-
-This says we modified the file data and the DC title and description.
-
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.app.event.interfaces import IObjectEvent, IObjectCreatedEvent
-from zope.app.event.interfaces import IObjectModifiedEvent
-from zope.app.event.interfaces import IObjectCopiedEvent
-from zope.app.event.interfaces import IObjectAnnotationsModifiedEvent
-from zope.app.event.interfaces import IObjectContentModifiedEvent
-from zope.app.event.interfaces import IAttributes, ISequence
-from zope.interface import implements
-from zope.event import notify
-from zope.component import subscribers
-
-# BBB Backward Compatibility (Can go away in 3.3)
-import warnings
-
-
-_marker = object()
-
-
-class ObjectEvent(object):
- """Something has happened to an object"""
-
-
- implements(IObjectEvent)
-
- def __init__(self, object):
- self.object = object
-
-
-class ObjectCreatedEvent(ObjectEvent):
- """An object has been created"""
-
- implements(IObjectCreatedEvent)
-
-
-class Attributes(object) :
- """
- Describes modified attributes of an interface.
-
- >>> from zope.app.dublincore.interfaces import IZopeDublinCore
- >>> desc = Attributes(IZopeDublinCore, "title", "description")
- >>> desc.interface == IZopeDublinCore
- True
- >>> 'title' in desc.attributes
- True
-
- """
-
- implements(IAttributes)
-
- def __init__(self, interface, *attributes) :
- self.interface = interface
- self.attributes = attributes
-
-
-class Sequence(object) :
- """
- Describes modified keys of an interface.
-
- >>> from zope.app.container.interfaces import IContainer
- >>> desc = Sequence(IContainer, 'foo', 'bar')
- >>> desc.interface == IContainer
- True
- >>> desc.keys
- ('foo', 'bar')
-
- """
-
- implements(ISequence)
-
- def __init__(self, interface, *keys) :
- self.interface = interface
- self.keys = keys
-
-
-class ObjectModifiedEvent(ObjectEvent):
- """An object has been modified"""
-
- implements(IObjectModifiedEvent)
-
- def __init__(self, object, *descriptions) :
- """
- Init with a list of modification descriptions.
-
- >>> from zope.interface import implements, Interface, Attribute
- >>> class ISample(Interface) :
- ... field = Attribute("A test field")
- >>> class Sample(object) :
- ... implements(ISample)
-
- >>> obj = Sample()
- >>> obj.field = 42
- >>> notify(ObjectModifiedEvent(obj, Attributes(ISample, "field")))
-
- """
- super(ObjectModifiedEvent, self).__init__(object)
- self.descriptions = descriptions
-
-
-def modified(object, *descriptions):
- notify(ObjectModifiedEvent(object, *descriptions))
-
-
-class ObjectCopiedEvent(ObjectCreatedEvent):
- """An object has been copied"""
-
- implements(IObjectCopiedEvent)
-
- def __init__(self, object, original=None):
- super(ObjectCopiedEvent, self).__init__(object)
- self.original = original
- # BBB goes away in 3.3
- if original is None:
- warnings.warn(
- "%s with no original is deprecated and will no-longer "
- "be supported starting in Zope 3.3."
- % self.__class__.__name__,
- DeprecationWarning, stacklevel=2)
-
-
-def objectEventNotify(event):
- """Event subscriber to dispatch ObjectEvents to interested adapters."""
- adapters = subscribers((event.object, event), None)
- for adapter in adapters:
- pass # getting them does the work
-
-
-# BBB: Can go away in 3.3
-
-class ObjectAnnotationsModifiedEvent(ObjectModifiedEvent):
- """An object's annotations have been modified"""
-
- implements(IObjectAnnotationsModifiedEvent)
-
- def __init__(self, object, deprecated_use=True) :
- super(ObjectAnnotationsModifiedEvent, self).__init__(object)
- if deprecated_use :
- warnings.warn(
- "%s is deprecated and will no-longer be supported "
- "starting in Zope 3.3. Use ObjectModifiedEvent "
- "and modification descriptors instead."
- % self.__class__.__name__,
- DeprecationWarning)
-
-
-def annotationModified(object, deprecated_use=True):
- warnings.warn(
- "annotationModified is deprecated and will no-longer be "
- "supported starting in Zope 3.3. Use modified "
- "and modification descriptors instead."
- % self.__class__.__name__,
- DeprecationWarning)
-
- notify(ObjectAnnotationsModifiedEvent(object, deprecated_use=False))
-
-
-class ObjectContentModifiedEvent(ObjectModifiedEvent):
- """An object's content has been modified"""
-
- implements(IObjectContentModifiedEvent)
-
- def __init__(self, object, deprecated_use=True) :
- super(ObjectContentModifiedEvent, self).__init__(object)
- if deprecated_use :
- warnings.warn(
- "%s is deprecated and will no-longer be supported "
- "starting in Zope 3.3. Use ObjectModifiedEvent "
- "and modification descriptors instead."
- % self.__class__.__name__,
- DeprecationWarning)
-
-
-def contentModified(object, deprecated_use=True):
- warnings.warn(
- "contentModified is deprecated and will no-longer be "
- "supported starting in Zope 3.3. Use modified "
- "and modification descriptors instead."
- % self.__class__.__name__,
- DeprecationWarning)
-
- notify(ObjectContentModifiedEvent(object, deprecated_use=False))
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "It has moved to zope.component.interfaces. This reference will be "
+ "gone in Zope 3.5.",
+ ObjectEvent = 'zope.component.interfaces:ObjectEvent',
+ )
+zope.deferredimport.deprecated(
+ "It has moved to zope.component.event. This reference will be gone "
+ "in Zope 3.5",
+ objectEventNotify = 'zope.component.event:objectEventNotify',
+ )
Property changes on: Zope3/trunk/src/zope/app/event/objectevent.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.14
Modified: Zope3/trunk/src/zope/app/event/tests/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/event/tests/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/event/tests/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,2 +1,8 @@
-#
# This file is necessary to make this directory a package.
+
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "Its contents has moved into zope.component.testing. This reference "
+ "will be gone in Zope 3.5",
+ placelesssetup = 'zope.component.testing',
+ )
Modified: Zope3/trunk/src/zope/app/event/tests/placelesssetup.py
===================================================================
--- Zope3/trunk/src/zope/app/event/tests/placelesssetup.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/event/tests/placelesssetup.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,47 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Unit test logic for setting up and tearing down basic infrastructure
-
-$Id$
-"""
-
-from zope.app.event.interfaces import IObjectEvent
-from zope.app.event.objectevent import objectEventNotify
-from zope.app.testing import ztapi
-
-events = []
-
-def getEvents(event_type=None, filter=None):
- r = []
- for event in events:
- if event_type is not None and not event_type.providedBy(event):
- continue
- if filter is not None and not filter(event):
- continue
- r.append(event)
-
- return r
-
-def clearEvents():
- del events[:]
-
-class PlacelessSetup(object):
-
- def setUp(self):
- clearEvents()
- ztapi.subscribe([None], None, events.append)
- ztapi.subscribe([IObjectEvent], None, objectEventNotify)
-
-import zope.testing.cleanup
-zope.testing.cleanup.addCleanUp(clearEvents)
+# This module has moved to zope.component.eventtesting
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.component.eventtesting',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/event/tests/placelesssetup.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.16
Deleted: Zope3/trunk/src/zope/app/event/tests/test_dispatching.py
===================================================================
--- Zope3/trunk/src/zope/app/event/tests/test_dispatching.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/event/tests/test_dispatching.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,29 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test the event dispatching code
-
-$Id$
-"""
-import unittest
-from zope.testing.doctestunit import DocTestSuite
-
-
-def test_suite():
- return unittest.TestSuite((
- DocTestSuite('zope.app.event.dispatching'),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
-
Modified: Zope3/trunk/src/zope/app/event/tests/test_objectevent.py
===================================================================
--- Zope3/trunk/src/zope/app/event/tests/test_objectevent.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/event/tests/test_objectevent.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,54 +16,24 @@
$Id$
"""
import unittest
+import zope.component.event
from zope.testing import doctest
-from zope.app.annotation.interfaces import IAnnotations, IAnnotatable
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
-from zope.app.event.objectevent import ObjectModifiedEvent
-from zope.app.event.objectevent import ObjectAnnotationsModifiedEvent
-from zope.app.event.objectevent import ObjectContentModifiedEvent
-from zope.app.event import objectevent
from zope.app.container.contained import Contained, ObjectRemovedEvent
from zope.app.container.interfaces import IContained, IObjectRemovedEvent
-from zope.app.container.interfaces import IObjectEvent
from zope.app.container.sample import SampleContainer
from zope.app.testing.placelesssetup import setUp, tearDown
from zope.app.testing import ztapi
-
-class TestObjectModifiedEvent(unittest.TestCase):
+class TestObjectEventNotifications(unittest.TestCase):
- klass = ObjectModifiedEvent
- object = object()
-
def setUp(self):
- self.event = self.klass(self.object)
-
- def testGetObject(self):
- self.assertEqual(self.event.object, self.object)
-
-class TestObjectAnnotationsModifiedEvent(TestObjectModifiedEvent):
- klass = ObjectAnnotationsModifiedEvent
-
- def setUp(self):
- self.event = self.klass(self.object, deprecated_use=False)
-
-class TestObjectContentModifiedEvent(TestObjectModifiedEvent):
- klass = ObjectContentModifiedEvent
-
- def setUp(self):
- self.event = self.klass(self.object, deprecated_use=False)
-
-
-class TestObjectEventNotifications(unittest.TestCase):
- def setUp(self):
self.callbackTriggered = False
setUp()
+ def tearDown(self):
+ tearDown()
+
def testNotify(self):
events = []
@@ -74,7 +44,7 @@
item = Contained()
event = ObjectRemovedEvent(item)
- objectevent.objectEventNotify(event)
+ zope.component.event.objectEventNotify(event)
self.assertEqual([(item, event)], events)
def testNotifyNobody(self):
@@ -83,11 +53,11 @@
events = []
item = Contained()
evt = ObjectRemovedEvent(item)
- objectevent.objectEventNotify(evt)
+ zope.component.event.objectEventNotify(evt)
self.assertEqual([], events)
def testVeto(self):
- ztapi.subscribe([IObjectEvent], None, objectevent.objectEventNotify)
+ zope.component.provideHandler(zope.component.event.objectEventNotify)
container = SampleContainer()
item = Contained()
@@ -107,30 +77,9 @@
# del container['Fred'] will fire an ObjectRemovedEvent event.
self.assertRaises(Veto, container.__delitem__, 'Fred')
- def tearDown(self):
- tearDown()
-
-def setUpObjectEventDocTest(test) :
- setUp()
-
- ztapi.provideAdapter(IAttributeAnnotatable,
- IAnnotations, AttributeAnnotations)
- ztapi.provideAdapter(IAnnotatable,
- IZopeDublinCore, ZDCAnnotatableAdapter)
-
-def tearDownObjectEventDocTest(test) :
- tearDown()
-
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(TestObjectModifiedEvent),
- unittest.makeSuite(TestObjectAnnotationsModifiedEvent),
- unittest.makeSuite(TestObjectContentModifiedEvent),
unittest.makeSuite(TestObjectEventNotifications),
- doctest.DocTestSuite("zope.app.event.objectevent",
- setUp=setUpObjectEventDocTest,
- tearDown=tearDownObjectEventDocTest,
- optionflags=doctest.NORMALIZE_WHITESPACE),
))
if __name__=='__main__':
Modified: Zope3/trunk/src/zope/app/exception/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/exception/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -11,14 +11,6 @@
/>
<page
- for="zope.exceptions.INotFoundError"
- name="index.html"
- template="systemerror.pt"
- class="..systemerror.SystemErrorView"
- permission="zope.Public"
- />
-
- <page
for="zope.security.interfaces.IUnauthorized"
name="index.html"
permission="zope.Public"
@@ -28,7 +20,7 @@
<zope:adapter factory=".unauthorized.default_template" name="default" />
<page
- for="zope.app.exception.interfaces.IUserError"
+ for="zope.exceptions.interfaces.IUserError"
name="index.html"
permission="zope.Public"
template="user.pt"
Modified: Zope3/trunk/src/zope/app/exception/browser/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/ftests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/exception/browser/ftests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,9 +25,9 @@
raise ComponentLookupError()
-class TestNotFound(functional.BrowserTestCase):
+class TestComponentLookupError(functional.BrowserTestCase):
- def testNotFound(self):
+ def testComponentLookupError(self):
response = self.publish('/foobar', basic='mgr:mgrpw',
handle_errors=True)
self.assertEqual(response.getStatus(), 404)
@@ -38,7 +38,7 @@
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(TestNotFound),
+ unittest.makeSuite(TestComponentLookupError),
functional.FunctionalDocFileSuite('systemerror.txt'),
))
Modified: Zope3/trunk/src/zope/app/exception/browser/systemerror.txt
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/systemerror.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/exception/browser/systemerror.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -59,11 +59,11 @@
A system error occurred.
...
-Another way of getting a system error is the occurrence of an
-``INotFoundError``, such as ``ComponentLookupError``. I have registered a
-simple view in ``exception-ftesting.zcml`` that will raise a component lookup
-error. So if we call ``componentlookuperror.html``, we should get the error
-message:
+Another way of getting a system error is the occurrence of a system
+error, such as ``ComponentLookupError``. I have registered a simple
+view in ``exception-ftesting.zcml`` that will raise a component lookup
+error. So if we call ``componentlookuperror.html``, we should get the
+error message:
>>> print http(r"""
... GET /componentlookuperror.html HTTP/1.1
@@ -72,4 +72,3 @@
...
A system error occurred.
...
-
Modified: Zope3/trunk/src/zope/app/exception/browser/unauthorized.py
===================================================================
--- Zope3/trunk/src/zope/app/exception/browser/unauthorized.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/exception/browser/unauthorized.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,12 +17,13 @@
"""
__docformat__ = 'restructuredtext'
+from zope.publisher.browser import BrowserPage
+from zope.formlib import namedtemplate
+
from zope.app import zapi
-from zope.formlib import page
-from zope.formlib import namedtemplate
from zope.app.pagetemplate import ViewPageTemplateFile
-class Unauthorized(page.Page):
+class Unauthorized(BrowserPage):
def __call__(self):
# Set the error status to 403 (Forbidden) in the case when we don't
Modified: Zope3/trunk/src/zope/app/exception/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/exception/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/exception/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,17 +17,19 @@
from zope.interface import Interface, implements
-class IUserError(Interface):
- """User error exceptions
- """
+##############################################################################
+# BBB 2006/04/03 - to be removed after 12 months
-class UserError(Exception):
- """User errors
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "UserError has been moved to zope.exceptions.interfaces. This "
+ "reference will be removed in Zope 3.5.",
+ UserError = 'zope.exceptions.interfaces:UserError',
+ IUserError = 'zope.exceptions.interfaces:IUserError',
+ )
- These exceptions should generally be displayed to users unless
- they are handled.
- """
- implements(IUserError)
+#
+##############################################################################
class ISystemErrorView(Interface):
"""Error views that can classify their contexts as system errors
@@ -36,4 +38,3 @@
def isSystemError():
"""Return a boolean indicating whether the error is a system errror
"""
-
Modified: Zope3/trunk/src/zope/app/externaleditor/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/externaleditor/browser/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/externaleditor/browser/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,12 +15,13 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app import zapi
-from zope.app.publisher.browser import BrowserView
-from zope.app.filerepresentation.interfaces import IReadFile
+from zope.publisher.browser import BrowserView
+from zope.security.proxy import removeSecurityProxy
+from zope.filerepresentation.interfaces import IReadFile
+from zope.traversing.browser import absoluteURL
+
from zope.app.interface import queryType
from zope.app.content.interfaces import IContentType
-from zope.security.proxy import removeSecurityProxy
class ExternalEditor(BrowserView):
@@ -30,7 +31,7 @@
response = request.response
r = []
- url = zapi.absoluteURL(context, request)
+ url = absoluteURL(context, request)
r.append('url:%s' % url)
adapted = IReadFile(context)
Modified: Zope3/trunk/src/zope/app/externaleditor/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/externaleditor/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/externaleditor/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -29,11 +29,11 @@
site manager that a External Edit action should be available.
2. It needs to have an adapter for the interface
- ``zope.app.filerepresentation.interfaces.IReadFile``.
+ ``zope.filerepresentation.interfaces.IReadFile``.
3. It needs to have a ``PUT`` view which receive the content back from the
External Editor client and update the object, optimally using an
adapter to the interface
- ``zope.app.filerepresentation.interfaces.IWriteFile`` (but not
+ ``zope.filerepresentation.interfaces.IWriteFile`` (but not
necessarily).
"""
Modified: Zope3/trunk/src/zope/app/externaleditor/tests/test_external_edit.py
===================================================================
--- Zope3/trunk/src/zope/app/externaleditor/tests/test_external_edit.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/externaleditor/tests/test_external_edit.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,13 +18,13 @@
from zope.interface import implements, Interface, directlyProvides
from zope.publisher.browser import TestRequest
+from zope.filerepresentation.interfaces import IReadFile
from zope.app import zapi
from zope.app.component.testing import PlacefulSetup
from zope.app.testing import ztapi
from zope.app.container.contained import contained
from zope.app.content.interfaces import IContentType
-from zope.app.filerepresentation.interfaces import IReadFile
from zope.app.file.file import File, FileReadFile
from zope.app.externaleditor.interfaces import IExternallyEditable
Modified: Zope3/trunk/src/zope/app/file/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/app/file/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/file/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,8 +1,8 @@
persistent
transaction
zope.app
-zope.app.contenttypes
zope.app.onlinehelp
+zope.contenttype
zope.interface
zope.publisher
zope.schema
Modified: Zope3/trunk/src/zope/app/file/browser/file.py
===================================================================
--- Zope3/trunk/src/zope/app/file/browser/file.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/file/browser/file.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,19 +15,18 @@
$Id$
"""
-
from datetime import datetime
import zope.event
-
+from zope import lifecycleevent
+from zope.contenttype import guess_content_type
from zope.publisher import contenttype
from zope.schema import Text
-from zope.app import contenttypes
-from zope.app.event import objectevent
+from zope.exceptions.interfaces import UserError
+
from zope.app.file.file import File
from zope.app.file.interfaces import IFile
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.exception.interfaces import UserError
__docformat__ = 'restructuredtext'
@@ -59,7 +58,7 @@
contenttype = form.get("field.contentType")
if filename:
if not contenttype:
- contenttype = contenttypes.guess_content_type(filename)[0]
+ contenttype = guess_content_type(filename)[0]
if not form.get("add_input_name"):
form["add_input_name"] = filename
return self.update_object(form["field.data"], contenttype)
@@ -118,7 +117,7 @@
def update_object(self, data, contenttype):
f = File(data, contenttype)
- zope.event.notify(objectevent.ObjectCreatedEvent(f))
+ zope.event.notify(lifecycleevent.ObjectCreatedEvent(f))
self.context.add(f)
self.request.response.redirect(self.context.nextURL())
return ''
@@ -134,10 +133,6 @@
>>> sio = StringIO.StringIO("some data")
>>> sio.filename = 'abc.txt'
- >>> def eventLog(event):
- ... print 'ModifiedEvent:', event.descriptions[0].attributes
- >>> zope.event.subscribers.append(eventLog)
-
Before we instanciate the request, we need to make sure that the
``IUserPreferredLanguages`` adapter exists, so that the request's
locale exists. This is necessary because the ``update_object``
@@ -150,6 +145,12 @@
>>> ztapi.provideAdapter(IHTTPRequest, IUserPreferredLanguages,
... BrowserLanguages)
+ We install an event logger so we can see the events generated:
+
+ >>> def eventLog(event):
+ ... print 'ModifiedEvent:', event.descriptions[0].attributes
+ >>> zope.event.subscribers.append(eventLog)
+
Let's make sure we can use the uploaded file name if one isn't
specified by the user, and can use the content type when
specified.
@@ -206,14 +207,14 @@
def update_object(self, data, contenttype):
self.context.contentType = contenttype
- descriptor = objectevent.Attributes(IFile, "contentType")
+ descriptor = lifecycleevent.Attributes(IFile, "contentType")
# Update *only* if a new value is specified
if data:
self.context.data = data
descriptor.attributes += "data",
- event = objectevent.ObjectModifiedEvent(self.context, descriptor)
+ event = lifecycleevent.ObjectModifiedEvent(self.context, descriptor)
zope.event.notify(event)
formatter = self.request.locale.dates.getFormatter(
@@ -252,8 +253,7 @@
Converts between Unicode strings used in browser forms and 8-bit strings
stored internally.
- >>> from zope.app.publisher.browser import BrowserView
- >>> from zope.publisher.browser import TestRequest
+ >>> from zope.publisher.browser import BrowserView, TestRequest
>>> class FileEditView(FileEdit, BrowserView): pass
>>> view = FileEditView(File(), TestRequest())
>>> view.getData()
Modified: Zope3/trunk/src/zope/app/file/browser/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/file/browser/ftests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/file/browser/ftests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -302,7 +302,7 @@
self.checkForBrokenLinks(body, '/image/@@preview.html', 'mgr:mgrpw')
def test_suite():
- from zope.app.tests import functional
+ from zope.app.testing import functional
return unittest.TestSuite((
unittest.makeSuite(FileTest),
unittest.makeSuite(ImageTest),
Modified: Zope3/trunk/src/zope/app/file/browser/image.py
===================================================================
--- Zope3/trunk/src/zope/app/file/browser/image.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/file/browser/image.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,7 +17,7 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app.size.interfaces import ISized
+from zope.size.interfaces import ISized
from zope.app import zapi
class ImageData(object):
Modified: Zope3/trunk/src/zope/app/file/browser/tests/test_imagedata.py
===================================================================
--- Zope3/trunk/src/zope/app/file/browser/tests/test_imagedata.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/file/browser/tests/test_imagedata.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,7 +22,7 @@
from zope.interface import implements
from zope.app.file.image import Image
from zope.app.file.browser.image import ImageData
-from zope.app.traversing.browser.interfaces import IAbsoluteURL
+from zope.traversing.browser.interfaces import IAbsoluteURL
class FakeRequest(object):
pass
Modified: Zope3/trunk/src/zope/app/file/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/file/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/file/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -42,7 +42,7 @@
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
@@ -64,33 +64,33 @@
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
<adapter
factory=".image.ImageSized"
- provides="zope.app.size.interfaces.ISized"
+ provides="zope.size.interfaces.ISized"
for=".interfaces.IImage"
/>
<adapter
for=".interfaces.IFile"
- provides="zope.app.filerepresentation.interfaces.IReadFile"
+ provides="zope.filerepresentation.interfaces.IReadFile"
factory=".file.FileReadFile"
permission="zope.View"
/>
<adapter
for=".interfaces.IFile"
- provides="zope.app.filerepresentation.interfaces.IWriteFile"
+ provides="zope.filerepresentation.interfaces.IWriteFile"
factory=".file.FileWriteFile"
permission="zope.ManageContent"
/>
<adapter
for="zope.app.folder.interfaces.IFolder"
- provides="zope.app.filerepresentation.interfaces.IFileFactory"
+ provides="zope.filerepresentation.interfaces.IFileFactory"
factory=".image.FileFactory"
permission="zope.ManageContent"
/>
Modified: Zope3/trunk/src/zope/app/file/image.py
===================================================================
--- Zope3/trunk/src/zope/app/file/image.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/file/image.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,15 +21,14 @@
from cStringIO import StringIO
from zope.interface import implements
+from zope.size.interfaces import ISized
+from zope.size import byteDisplay
+from zope.contenttype import guess_content_type
-from zope.app.size.interfaces import ISized
-from zope.app.size import byteDisplay
-from zope.app.contenttypes import guess_content_type
from zope.app.i18n import ZopeMessageFactory as _
+from zope.app.file.file import File
+from zope.app.file.interfaces import IImage
-from file import File
-from interfaces import IImage
-
class Image(File):
implements(IImage)
Modified: Zope3/trunk/src/zope/app/file/tests/test_image.py
===================================================================
--- Zope3/trunk/src/zope/app/file/tests/test_image.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/file/tests/test_image.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -131,7 +131,7 @@
class TestSized(unittest.TestCase):
def testInterface(self):
- from zope.app.size.interfaces import ISized
+ from zope.size.interfaces import ISized
self.failUnless(ISized.implementedBy(ImageSized))
self.failUnless(verifyClass(ISized, ImageSized))
Modified: Zope3/trunk/src/zope/app/filerepresentation/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/filerepresentation/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/filerepresentation/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1 +1,7 @@
-# Import this.
+# This module has moved to zope.filerepresentation
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.filerepresentation',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/filerepresentation/__init__.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.1
Name: svn:keywords
+ Id
Modified: Zope3/trunk/src/zope/app/filerepresentation/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/filerepresentation/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/filerepresentation/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,144 +1,7 @@
-##############################################################################
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-##############################################################################
-"""File-system representation interfaces
-
-The interfaces defined here are used for file-system and
-file-system-like representations of objects, such as file-system
-synchronization, FTP, PUT, and WebDAV.
-
-There are three issues we need to deal with:
-
- File system representation
-
- Every object is either a directory or a file.
-
- Properties
-
- There are two kinds of proprties:
-
- - Data properties
-
- Data properties are handled directly by the object implementation.
-
- - Meta-data properties
-
- Meta data properties are handled via annotations.
-
- Completeness
-
- We must have a complete lossless data representation for file-system
- synchronization. This is achieved through serialization of:
-
- - All annotations (not just properties, and
-
- - Extra data.
-
- Strategies for common access mechanisms:
-
- FTP
-
- - For getting directory info (statish) information:
-
- - Use Zope DublinCore to get modification times
-
- - Show as readable if we can access a read method.
-
- - Show as writable if we can access a write method.
-
- FTP and WebDAV
-
- - Treat as a directory if there is an adapter to `IReadDirectory`.
- Treat as a file otherwise.
-
- - For creating objects:
-
- - Directories:
-
- Look for an `IDirectoryFactory` adapter.
-
- - Files
-
- First lookj for a `IFileFactory` adapter with a name that is
- the same as the extention (e.g. ".pt").
-
- Then look for an unnamed `IFileFactory` adapter.
-
-
- File-system synchronization
-
- Because this must be lossless, we will use class-based adapters
- for this, but we want to make it as easy as possible to use other
- adapters as well.
-
- For reading, there must be a class adapter to `IReadSync`. We will
- then apply rules similar to those above.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.interface import Interface
-from zope.app.container.interfaces import IReadContainer, IWriteContainer
-
-class IReadFile(Interface):
- """Provide read access to file data
- """
-
- def read():
- """Return the file data
- """
-
- def size():
- """Return the data length
- """
-
-class IWriteFile(Interface):
-
- def write(data):
- """Update the file data
- """
-
-# TODO: We will add ILargeReadFile and ILargeWriteFile to efficiently
-# handle large data.
-
-class IReadDirectory(IReadContainer):
- """Objects that should be treated as directories for reading
- """
-
-class IWriteDirectory(IWriteContainer):
- """Objects that should be treated as directories for writing
- """
-
-class IDirectoryFactory(Interface):
-
- def __call__(name):
- """Create a directory
-
- where a directory is an object with adapters to IReadDirectory
- and IWriteDirectory.
-
- """
-
-class IFileFactory(Interface):
-
- def __call__(name, content_type, data):
- """Create a file
-
- where a file is an object with adapters to `IReadFile`
- and `IWriteFile`.
-
- The file `name`, content `type`, and `data` are provided to help
- create the object.
- """
-
-# TODO: we will add additional interfaces for WebDAV and File-system
-# synchronization.
+# This module has moved to zope.filerepresentation.interfaces
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.filerepresentation.interfaces',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/filerepresentation/interfaces.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.1
Modified: Zope3/trunk/src/zope/app/folder/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/folder/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/folder/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -33,20 +33,20 @@
<adapter
for=".interfaces.IFolder"
- provides="zope.app.filerepresentation.interfaces.IDirectoryFactory"
+ provides="zope.filerepresentation.interfaces.IDirectoryFactory"
factory="zope.app.container.directory.Cloner"
permission="zope.ManageContent"
/>
<adapter
for=".interfaces.IFolder"
- provides="zope.app.filerepresentation.interfaces.IReadDirectory"
+ provides="zope.filerepresentation.interfaces.IReadDirectory"
factory=".filerepresentation.ReadDirectory"
permission="zope.View"
/>
<adapter
- provides="zope.app.location.interfaces.ISublocations"
+ provides="zope.location.interfaces.ISublocations"
for=".interfaces.IFolder"
factory=".folder.FolderSublocations"
/>
Modified: Zope3/trunk/src/zope/app/folder/folder.py
===================================================================
--- Zope3/trunk/src/zope/app/folder/folder.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/folder/folder.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -122,8 +122,8 @@
[]
>>> sm = Contained()
- >>> from zope.component.interfaces import ISiteManager
- >>> directlyProvides(sm, ISiteManager)
+ >>> from zope.component.interfaces import IComponentLookup
+ >>> directlyProvides(sm, IComponentLookup)
>>> folder.setSiteManager(sm)
>>> directlyProvides(folder, ISite)
>>> subs = list(FolderSublocations(folder).sublocations())
Modified: Zope3/trunk/src/zope/app/folder/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/folder/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/folder/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,10 +17,10 @@
"""
__docformat__ = 'restructuredtext'
+from zope.traversing.interfaces import IContainmentRoot
+from zope.annotation.interfaces import IAttributeAnnotatable
from zope.app.container.interfaces import IContainer
-from zope.app.traversing.interfaces import IContainmentRoot
from zope.app.component.interfaces import IPossibleSite
-from zope.app.annotation.interfaces import IAttributeAnnotatable
class IFolder(IContainer, IPossibleSite, IAttributeAnnotatable):
"""The standard Zope Folder object interface."""
Modified: Zope3/trunk/src/zope/app/folder/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/folder/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/folder/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,12 +18,12 @@
from unittest import TestCase, TestSuite, main, makeSuite
+import zope.component
from zope.testing.doctestunit import DocTestSuite
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter
-from zope.app.testing import ztapi
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.folder.interfaces import IFolder
-from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
from zope.app.component.testing import PlacefulSetup
from zope.app.component.tests.test_site import BaseTestSiteManagerContainer
from zope.app.container.tests.test_icontainer import BaseTestIContainer
@@ -51,7 +51,8 @@
def setUp(self):
PlacefulSetup.setUp(self)
PlacefulSetup.buildFolders(self)
- ztapi.provideAdapter(IFolder, IZopeDublinCore, ZDCAnnotatableAdapter)
+ zope.component.provideAdapter(ZDCAnnotatableAdapter, (IFolder,),
+ IZopeDublinCore)
def test_suite():
from zope.testing.doctestunit import DocTestSuite
Modified: Zope3/trunk/src/zope/app/form/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/form/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -26,7 +26,7 @@
deprecated('CustomSequenceWidgetFactory',
'Use CustomWidgetFactory instead. '
- 'The reference will be gone in Zope 3.3.')
+ 'The reference will be gone in Zope 3.4.')
class Widget(object):
"""Mixin class providing functionality common across widget types."""
@@ -120,7 +120,7 @@
return self._create(args)
-# BBB: Gone in 3.3 (does not satify IViewFactory)
+# BBB: Gone in 3.4 (does not satify IViewFactory)
class CustomSequenceWidgetFactory(CustomWidgetFactory):
"""Custom sequence widget factory."""
Modified: Zope3/trunk/src/zope/app/form/browser/add.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/add.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/add.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,22 +19,21 @@
import sys
-from zope.app import zapi
+import zope.component
from zope.component.interfaces import IFactory
from zope.event import notify
from zope.interface import Interface
+from zope.schema.interfaces import ValidationError
+from zope.security.checker import defineChecker, NamesChecker
+from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
+from zope.lifecycleevent import Attributes
-from zope.app.event.objectevent import ObjectCreatedEvent
-from zope.app.event.objectevent import ObjectModifiedEvent
-from zope.app.event.objectevent import Attributes
from zope.app.form.utility import setUpWidgets, getWidgetsData
from zope.app.i18n import ZopeMessageFactory as _
from zope.app.form.interfaces import IInputWidget, WidgetsError
from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.publisher.interfaces.browser import IDefaultBrowserLayer
-from zope.schema.interfaces import ValidationError
-from zope.security.checker import defineChecker, NamesChecker
from editview import EditView
from submit import Update
@@ -143,7 +142,7 @@
factory = self.__dict__.get('_factory_or_id', self._factory_or_id)
if type(factory) is str: # factory id
- return zapi.getUtility(IFactory, factory, self.context)
+ return zope.component.getUtility(IFactory, factory, self.context)
else:
return factory
@@ -181,5 +180,5 @@
if layer is None:
layer = IDefaultBrowserLayer
- s = zapi.getGlobalSiteManager()
- s.provideAdapter((for_, layer), Interface, name, class_)
+ s = zope.component.getGlobalSiteManager()
+ s.registerAdapter(class_, (for_, layer), Interface, name)
Modified: Zope3/trunk/src/zope/app/form/browser/editview.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/editview.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/editview.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,25 +20,23 @@
from datetime import datetime
import transaction
+import zope.component
from zope.interface import Interface
from zope.schema import getFieldNamesInOrder
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.publisher.browser import BrowserView
from zope.security.checker import defineChecker, NamesChecker
-
-from zope.app import zapi
from zope.event import notify
-from zope.app.event.objectevent import ObjectModifiedEvent
-from zope.app.event.objectevent import Attributes
+from zope.lifecycleevent import ObjectModifiedEvent
+from zope.lifecycleevent import Attributes
+
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.form.interfaces import WidgetsError
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
-from zope.app.publisher.browser import BrowserView
-
+from zope.app.form.interfaces import WidgetsError
from zope.app.form.utility import setUpEditWidgets, applyWidgetsChanges
from zope.app.form.browser.submit import Update
-
class EditView(BrowserView):
"""Simple edit-view base class
@@ -145,5 +143,5 @@
if layer is None:
layer = IDefaultBrowserLayer
- s = zapi.getGlobalSiteManager()
- s.provideAdapter((for_, layer), Interface, name, class_)
+ s = zope.component.getGlobalSiteManager()
+ s.registerAdapter(class_, (for_, layer), Interface, name)
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_booleanradiowidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_booleanradiowidget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_booleanradiowidget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,22 +16,17 @@
$Id: $
"""
import unittest
-from persistent import Persistent
import transaction
+from persistent import Persistent
-from support import *
-
-from zope.interface import Interface
-from zope.interface import implements
-
-from zope.schema import Bool
import zope.security.checker
+from zope.interface import Interface, implements
+from zope.schema import Bool
+from zope.traversing.api import traverse
-from zope.app.traversing.api import traverse
-
+from zope.app.form.browser.ftests.support import *
from zope.app.testing.functional import BrowserTestCase
-
class IFoo(Interface):
bar = Bool(title=u'Bar')
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_checkboxwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_checkboxwidget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_checkboxwidget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,22 +16,18 @@
$Id$
"""
import unittest
-from persistent import Persistent
import transaction
+from persistent import Persistent
-from zope.interface import Interface
-from zope.interface import implements
-
-from zope.schema import Bool
import zope.security.checker
-from zope.app.form.browser import CheckBoxWidget
+from zope.interface import Interface, implements
+from zope.schema import Bool
+from zope.traversing.api import traverse
-from support import *
-from zope.app.traversing.api import traverse
-
+from zope.app.form.browser import CheckBoxWidget
+from zope.app.form.browser.ftests.support import *
from zope.app.testing.functional import BrowserTestCase
-
class IBoolTest(Interface):
b1 = Bool(
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_datetimewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_datetimewidget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_datetimewidget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,23 +17,19 @@
"""
import unittest
import re
-from persistent import Persistent
import transaction
+from persistent import Persistent
from datetime import datetime
-from zope.app.datetimeutils import parseDatetimetz, tzinfo
-from zope.interface import Interface
-from zope.interface import implements
-
-from zope.schema import Datetime, Choice
import zope.security.checker
+from zope.datetime import parseDatetimetz, tzinfo
+from zope.interface import Interface, implements
+from zope.schema import Datetime, Choice
+from zope.traversing.api import traverse
-from support import *
-from zope.app.traversing.api import traverse
-
+from zope.app.form.browser.ftests.support import *
from zope.app.testing.functional import BrowserTestCase
-
class IDatetimeTest(Interface):
d2 = Datetime(
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_editview.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,21 +16,17 @@
$Id: test_checkboxwidget.py 26267 2004-07-08 23:06:19Z garrett $
"""
import unittest
-from persistent import Persistent
import transaction
+from persistent import Persistent
-from zope.interface import Interface
-from zope.interface import implements
-
-from zope.schema import TextLine
import zope.security.checker
+from zope.interface import Interface, implements
+from zope.schema import TextLine
+from zope.traversing.api import traverse
-from support import *
-from zope.app.traversing.api import traverse
-
+from zope.app.form.browser.ftests.support import *
from zope.app.testing.functional import BrowserTestCase
-
class IFoo(Interface):
optional_text = TextLine(required=False)
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_filewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_filewidget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_filewidget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,22 +16,18 @@
$Id$
"""
import unittest
+import transaction
from StringIO import StringIO
from persistent import Persistent
-import transaction
-from zope.interface import Interface
-from zope.interface import implements
-
+import zope.security.checker
+from zope.interface import Interface, implements
from zope.schema.interfaces import IField
from zope.schema import Field
-import zope.security.checker
+from zope.traversing.api import traverse
from zope.app.form.browser.textwidgets import FileWidget
-
-from support import *
-from zope.app.traversing.api import traverse
-
+from zope.app.form.browser.ftests.support import *
from zope.app.testing.functional import BrowserTestCase
from zope.app.form.interfaces import IInputWidget
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_floatwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_floatwidget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_floatwidget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,22 +16,17 @@
$Id$
"""
import unittest
-from persistent import Persistent
import transaction
+from persistent import Persistent
-from support import *
-
-from zope.interface import Interface
-from zope.interface import implements
-
-from zope.schema import Float, Choice
import zope.security.checker
+from zope.interface import Interface, implements
+from zope.traversing.api import traverse
-from zope.app.traversing.api import traverse
-
+from zope.schema import Float, Choice
+from zope.app.form.browser.ftests.support import *
from zope.app.testing.functional import BrowserTestCase
-
class IFloatTest(Interface):
f1 = Float(
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_intwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_intwidget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_intwidget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,22 +16,17 @@
$Id$
"""
import unittest
-from persistent import Persistent
import transaction
+from persistent import Persistent
-from support import *
-
-from zope.interface import Interface
-from zope.interface import implements
-
-from zope.schema import Int, Choice
import zope.security.checker
+from zope.interface import Interface, implements
+from zope.schema import Int, Choice
+from zope.traversing.api import traverse
-from zope.app.traversing.api import traverse
-
from zope.app.testing.functional import BrowserTestCase
+from zope.app.form.browser.ftests.support import *
-
class IIntTest(Interface):
i2 = Int(
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_textareawidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_textareawidget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_textareawidget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,21 +16,17 @@
$Id$
"""
import unittest
-from persistent import Persistent
import transaction
+from persistent import Persistent
-from zope.interface import Interface
-from zope.interface import implements
-
-from zope.schema import Text
import zope.security.checker
+from zope.interface import Interface, implements
+from zope.schema import Text
+from zope.traversing.api import traverse
-from support import *
-from zope.app.traversing.api import traverse
-
+from zope.app.form.browser.ftests.support import *
from zope.app.testing.functional import BrowserTestCase
-
class ITextTest(Interface):
s2 = Text(
Modified: Zope3/trunk/src/zope/app/form/browser/ftests/test_textwidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/ftests/test_textwidget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/ftests/test_textwidget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,19 +16,17 @@
$Id$
"""
import unittest
-from persistent import Persistent
import transaction
+from persistent import Persistent
+import zope.security.checker
from zope.interface import Interface, implements
from zope.schema import TextLine, Choice
-import zope.security.checker
+from zope.traversing.api import traverse
-from support import *
-from zope.app.traversing.api import traverse
-
+from zope.app.form.browser.ftests.support import *
from zope.app.testing.functional import BrowserTestCase
-
class ITextLineTest(Interface):
s2 = TextLine(
Modified: Zope3/trunk/src/zope/app/form/browser/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/metadirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/metadirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,8 +22,8 @@
from zope.configuration.fields import Tokens, Path, Bool, PythonIdentifier
from zope.configuration.fields import MessageID
from zope.schema import Text, TextLine, Id
-from zope.app.component.fields import LayerField
-from zope.app.security.fields import Permission
+from zope.security.zcml import Permission
+from zope.app.component.back35 import LayerField
from zope.app.publisher.browser.fields import MenuField
class ICommonInformation(Interface):
Modified: Zope3/trunk/src/zope/app/form/browser/schemadisplay.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/schemadisplay.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/schemadisplay.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,14 +17,13 @@
"""
__docformat__ = 'restructuredtext'
+import zope.component
from zope.interface import Interface
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.publisher.browser import BrowserView
from zope.schema import getFieldNamesInOrder
from zope.security.checker import defineChecker, NamesChecker
-from zope.app import zapi
-from zope.app.publisher.browser import BrowserView
-
from zope.app.form.utility import setUpDisplayWidgets
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
@@ -81,5 +80,5 @@
if layer is None:
layer = IDefaultBrowserLayer
- sm = zapi.getGlobalSiteManager()
- sm.provideAdapter((for_, layer), Interface, name, class_)
+ sm = zope.component.getGlobalSiteManager()
+ sm.registerAdapter(class_, (for_, layer), Interface, name)
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_add.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_add.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_add.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,8 +17,9 @@
"""
import unittest
+from zope.component import getMultiAdapter
from zope.component.interfaces import IFactory
-from zope.component.interfaces import ISiteManager
+from zope.component.interfaces import IComponentLookup
from zope.component.factory import Factory
from zope.interface import Interface, implements
from zope.publisher.browser import TestRequest
@@ -26,12 +27,11 @@
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.schema import TextLine, accessors
from zope.security.checker import CheckerPublic
+from zope.component.eventtesting import getEvents
+from zope.lifecycleevent.interfaces import IObjectCreatedEvent, IObjectModifiedEvent
-from zope.app import zapi
from zope.app.component.site import SiteManagerAdapter
from zope.app.container.interfaces import IAdding
-from zope.app.event.tests.placelesssetup import getEvents
-from zope.app.event.interfaces import IObjectCreatedEvent, IObjectModifiedEvent
from zope.app.form import CustomWidgetFactory
from zope.app.form.browser import TextWidget as Text
from zope.app.form.browser.add import AddViewFactory, AddView
@@ -258,7 +258,7 @@
(descriminator, callable, args, kw) = self._context.last_action
factory = AddViewFactory(*args)
request = TestRequest()
- view = zapi.getMultiAdapter((adding, request), name='addthis')
+ view = getMultiAdapter((adding, request), name='addthis')
content = view.create('a',0,abc='def')
self.failUnless(isinstance(content, C))
@@ -287,7 +287,7 @@
return "."
# register content factory for content factory id lookup
- ztapi.provideAdapter(None, ISiteManager, SiteManagerAdapter)
+ ztapi.provideAdapter(None, IComponentLookup, SiteManagerAdapter)
ztapi.provideUtility(IFactory, Factory(C), name='C')
adding = Adding(self)
@@ -295,7 +295,7 @@
(descriminator, callable, args, kw) = self._context.last_action
factory = AddViewFactory(*args)
request = TestRequest()
- view = zapi.getMultiAdapter((adding, request), name='addthis')
+ view = getMultiAdapter((adding, request), name='addthis')
content = view.create('a',0,abc='def')
self.failUnless(isinstance(content, C))
@@ -328,7 +328,7 @@
(descriminator, callable, args, kw) = self._context.last_action
factory = AddViewFactory(*args)
request = TestRequest()
- view = zapi.getMultiAdapter((adding, request), name='addthis')
+ view = getMultiAdapter((adding, request), name='addthis')
view.createAndAdd(SampleData.__dict__)
@@ -366,7 +366,7 @@
(descriminator, callable, args, kw) = self._context.last_action
factory = AddViewFactory(*args)
request = TestRequest()
- view = zapi.getMultiAdapter((adding, request), name='addthis')
+ view = getMultiAdapter((adding, request), name='addthis')
view.createAndAdd({'bar': 'bar'})
@@ -386,7 +386,7 @@
for (k, v) in dict(SampleData.__dict__).items()
]))
request.form[Update] = ''
- view = zapi.getMultiAdapter((adding, request), name='addthis')
+ view = getMultiAdapter((adding, request), name='addthis')
# Add hooks to V
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_datetimewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_datetimewidget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_datetimewidget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,7 +16,7 @@
$Id$
"""
import unittest, doctest
-from zope.app.datetimeutils import parseDatetimetz
+from zope.datetime import parseDatetimetz
from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
from zope.app.form.interfaces import IInputWidget
from zope.app.form.browser import DatetimeWidget
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_datewidget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_datewidget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_datewidget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,7 +16,7 @@
$Id$
"""
import unittest, doctest
-from zope.app.datetimeutils import parseDatetimetz
+from zope.datetime import parseDatetimetz
from zope.app.form.browser.tests.test_browserwidget import SimpleInputWidgetTest
from zope.app.form.interfaces import IInputWidget
from zope.app.form.browser import DateWidget
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_directives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,15 +19,15 @@
import unittest
from cStringIO import StringIO
-from zope.component.exceptions import ComponentLookupError
+from zope import component
+from zope.component.interfaces import ComponentLookupError
from zope.configuration.xmlconfig import xmlconfig, XMLConfig
-from zope.app.traversing.interfaces import TraversalError
+from zope.traversing.interfaces import TraversalError
from zope.interface import Interface, implements
from zope.publisher.browser import TestRequest
from zope.schema import TextLine, Int
from zope.security.proxy import ProxyFactory
-from zope.app import zapi
import zope.app.component
import zope.app.form.browser
import zope.app.publisher.browser
@@ -83,15 +83,14 @@
XMLConfig('meta.zcml', zope.app.publisher.browser)()
from zope.app.testing import ztapi
- from zope.app.traversing.adapters import DefaultTraversable
- from zope.app.traversing.interfaces import ITraversable
+ from zope.traversing.adapters import DefaultTraversable
+ from zope.traversing.interfaces import ITraversable
- ztapi.provideAdapter(None, ITraversable, DefaultTraversable)
-
+ component.provideAdapter(DefaultTraversable, (None,), ITraversable)
def testAddForm(self):
self.assertEqual(
- zapi.queryMultiAdapter((ob, request), name='add.html'),
+ component.queryMultiAdapter((ob, request), name='add.html'),
None)
xmlconfig(StringIO(template % ("""
<view
@@ -111,13 +110,13 @@
permission="zope.Public" />
""")))
- v = zapi.getMultiAdapter((ob, request), name='add.html')
+ v = component.getMultiAdapter((ob, request), name='add.html')
# expect to fail as standard macros are not configured
self.assertRaises(TraversalError, v)
def testEditForm(self):
self.assertEqual(
- zapi.queryMultiAdapter((ob, request), name='edit.html'),
+ component.queryMultiAdapter((ob, request), name='edit.html'),
None)
xmlconfig(StringIO(template % ("""
<view
@@ -137,13 +136,13 @@
permission="zope.Public" />
""")))
- v = zapi.getMultiAdapter((ob, request), name='edit.html')
+ v = component.getMultiAdapter((ob, request), name='edit.html')
# expect to fail as standard macros are not configured
self.assertRaises(TraversalError, v)
def testEditFormWithMenu(self):
self.assertEqual(
- zapi.queryMultiAdapter((ob, request), name='edit.html'),
+ component.queryMultiAdapter((ob, request), name='edit.html'),
None)
xmlconfig(StringIO(template % ('''
<browser:menu id="test_menu" title="Test menu"/>
@@ -166,13 +165,13 @@
/>
''')))
- v = zapi.queryMultiAdapter((ob, request), name='edit.html')
+ v = component.queryMultiAdapter((ob, request), name='edit.html')
# expect to fail as standard macros are not configured
self.assertRaises(TraversalError, v)
def testSchemaDisplay(self):
self.assertEqual(
- zapi.queryMultiAdapter((ob, request), name='view.html'),
+ component.queryMultiAdapter((ob, request), name='view.html'),
None)
xmlconfig(StringIO(template % ('''
<view
@@ -192,13 +191,13 @@
permission="zope.Public" />
''')))
- v = zapi.queryMultiAdapter((ob, request), name='view.html')
+ v = component.queryMultiAdapter((ob, request), name='view.html')
# expect to fail as standard macros are not configured
self.assertRaises(TraversalError, v)
def testAddFormWithWidget(self):
self.assertEqual(
- zapi.queryMultiAdapter((ob, request), name='add.html'),
+ component.queryMultiAdapter((ob, request), name='add.html'),
None)
xmlconfig(StringIO(template % ('''
<view
@@ -227,7 +226,7 @@
</browser:addform>
''')), )
- view = zapi.queryMultiAdapter((ob, request), name='add.html')
+ view = component.queryMultiAdapter((ob, request), name='add.html')
self.assert_(hasattr(view, 'text_widget'))
self.assert_(isinstance(view.text_widget, SomeWidget))
self.assertEqual(view.text_widget.extra, u'foo')
@@ -236,7 +235,7 @@
def testEditFormWithWidget(self):
self.assertEqual(
- zapi.queryMultiAdapter((ob, request), name='edit.html'),
+ component.queryMultiAdapter((ob, request), name='edit.html'),
None)
xmlconfig(StringIO(template % ('''
<view
@@ -265,7 +264,7 @@
</browser:editform>
''')), )
- view = zapi.queryMultiAdapter((ob, request), name='edit.html')
+ view = component.queryMultiAdapter((ob, request), name='edit.html')
self.assert_(hasattr(view, 'text_widget'))
self.assert_(isinstance(view.text_widget, SomeWidget))
self.assertEqual(view.text_widget.extra, u'foo')
@@ -273,7 +272,7 @@
def testSchemaDisplayWithWidget(self):
self.assertEqual(
- zapi.queryMultiAdapter((ob, request), name='view.html'),
+ component.queryMultiAdapter((ob, request), name='view.html'),
None)
xmlconfig(StringIO(template % ('''
<view
@@ -301,7 +300,7 @@
</browser:schemadisplay>
''')))
- view = zapi.queryMultiAdapter((ob, request), name='view.html')
+ view = component.queryMultiAdapter((ob, request), name='view.html')
self.assert_(hasattr(view, 'text_widget'))
self.assert_(isinstance(view.text_widget, SomeWidget))
self.assertEqual(view.text_widget.extra, u'foo')
Modified: Zope3/trunk/src/zope/app/form/browser/tests/test_editview.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/tests/test_editview.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/tests/test_editview.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,19 +21,18 @@
from zope.publisher.browser import TestRequest
from zope.schema import TextLine, accessors
from zope.schema.interfaces import ITextLine
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
+from zope.component.eventtesting import getEvents, clearEvents
+from zope.location.interfaces import ILocation
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.event.tests.placelesssetup import getEvents
from zope.app.form.browser import TextWidget
from zope.app.form.browser.editview import EditView
from zope.app.form.browser.submit import Update
-from zope.component.exceptions import ComponentLookupError
from zope.app.form.interfaces import IInputWidget
from zope.app.form.tests import utils
-from zope.app.location.interfaces import ILocation
class I(Interface):
foo = TextLine(title=u"Foo")
@@ -108,6 +107,7 @@
super(Test, self).setUp()
ztapi.browserViewProviding(ITextLine, TextWidget, IInputWidget)
ztapi.provideAdapter(IFoo, IBar, FooBarAdapter)
+ clearEvents()
def test_setPrefix_and_widgets(self):
v = EV(C(), TestRequest())
Modified: Zope3/trunk/src/zope/app/form/browser/textwidgets.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/textwidgets.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/textwidgets.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,13 +19,13 @@
from xml.sax import saxutils
from zope.interface import implements
+from zope.datetime import parseDatetimetz
+from zope.datetime import DateTimeError
from zope.app.form.interfaces import IInputWidget, ConversionError
from zope.app.form.browser.interfaces import ITextBrowserWidget
from zope.app.form.browser.widget import SimpleInputWidget, renderElement
from zope.app.form.browser.widget import DisplayWidget
-from zope.app.datetimeutils import parseDatetimetz
-from zope.app.datetimeutils import DateTimeError
from zope.app.i18n import ZopeMessageFactory as _
Modified: Zope3/trunk/src/zope/app/form/browser/widget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/widget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/widget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,11 +19,11 @@
from xml.sax.saxutils import quoteattr, escape
+from zope.component import getMultiAdapter
from zope.interface import implements
from zope.schema.interfaces import ValidationError
-from zope.app.publisher.browser import BrowserView
+from zope.publisher.browser import BrowserView
-from zope.app import zapi
from zope.app.form import Widget, InputWidget
from zope.app.form.interfaces import ConversionError
from zope.app.form.interfaces import InputErrors
@@ -101,8 +101,8 @@
def error(self):
if self._error:
- return zapi.getMultiAdapter((self._error, self.request),
- IWidgetInputErrorView).snippet()
+ return getMultiAdapter((self._error, self.request),
+ IWidgetInputErrorView).snippet()
return ""
def hidden(self):
Modified: Zope3/trunk/src/zope/app/form/browser/widgets.txt
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/widgets.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/browser/widgets.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -47,9 +47,9 @@
from zope.interface import Interface
from zope.schema import Object, Tuple, TextLine
from zope.schema.interfaces import ITextLine
- from zope.i18n import MessageIDFactory
+ from zope.i18nmessageid import MessageFactory
- _ = MessageIDFactory("poll")
+ _ = MessageFactory("poll")
class IPollOption(Interface):
label = TextLine(title=u'Label', min_length=1)
@@ -129,7 +129,7 @@
permission="zope.ManageContent" />
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
<require
Modified: Zope3/trunk/src/zope/app/form/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/form/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,7 +21,7 @@
from zope.component.interfaces import IView
from zope.interface import Attribute, Interface, implements
from zope.schema import Bool
-from zope.app.exception.interfaces import UserError
+from zope.exceptions.interfaces import UserError
class IWidgetInputError(Interface):
"""Placeholder for a snippet View"""
Modified: Zope3/trunk/src/zope/app/form/tests/test_utility.py
===================================================================
--- Zope3/trunk/src/zope/app/form/tests/test_utility.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/tests/test_utility.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,28 +17,22 @@
"""
import doctest
-from zope.interface import Interface, implements
-from zope.component.interfaces import IViewFactory
-from zope.component.exceptions import ComponentLookupError
-from zope.publisher.browser import TestRequest
import zope.security.checker
+from zope.interface import Interface, implements
+from zope.component.interfaces import IViewFactory, ComponentLookupError
+from zope.publisher.browser import TestRequest, BrowserView
from zope.security.interfaces import ForbiddenAttribute, Unauthorized
-import zope.security.checker
-
from zope.schema import Field, Int, accessors
from zope.schema.interfaces import IField, IInt
from zope.app.testing import ztapi, placelesssetup
-from zope.app.publisher.browser import BrowserView
from zope.app.form import Widget
from zope.app.form.interfaces import IWidget, IInputWidget, IDisplayWidget
from zope.app.form.interfaces import ConversionError, InputErrors, WidgetsError
-
from zope.app.form.utility import no_value, setUpWidget, setUpWidgets
from zope.app.form.utility import setUpEditWidgets, setUpDisplayWidgets
from zope.app.form.utility import getWidgetsData, viewHasInput
from zope.app.form.utility import applyWidgetsChanges
-
from zope.app.form.tests import utils
request = TestRequest()
@@ -538,7 +532,7 @@
>>> setUpWidgets(view, IContent, IWidget, 'prefix', True,
... initial={ "bar":"Bar" },
... context="Alt Context")
- view: <class 'zope.app.publisher.browser.BrowserView'>
+ view: <class 'zope.publisher.browser.BrowserView'>
name: foo
field: <class 'zope.app.form.tests.test_utility.Foo'>
viewType: <class 'zope.interface.interface.InterfaceClass'>
@@ -547,7 +541,7 @@
ignoreStickyValues: True
context: Alt Context
---
- view: <class 'zope.app.publisher.browser.BrowserView'>
+ view: <class 'zope.publisher.browser.BrowserView'>
name: bar
field: <class 'zope.app.form.tests.test_utility.Bar'>
viewType: <class 'zope.interface.interface.InterfaceClass'>
Modified: Zope3/trunk/src/zope/app/form/tests/test_widget.py
===================================================================
--- Zope3/trunk/src/zope/app/form/tests/test_widget.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/form/tests/test_widget.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -100,11 +100,11 @@
All widgets rely on a field and a request:
>>> from zope.schema import Field
- >>> from zope.component.tests.request import Request
>>> field = Field()
>>> from zope.interface import Interface
>>> class ITestRequest(Interface):
... pass
+ >>> from zope.app.component.tests.views import Request
>>> widget = TestInputWidget(field, Request(ITestRequest))
The default implementation of hasValidInput relies on
Modified: Zope3/trunk/src/zope/app/fssync/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/browser/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/fssync/browser/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,14 +23,13 @@
import tempfile
import transaction
-
-from zope.app.publisher.browser import BrowserView
-from zope.app.traversing.api import getName, getParent, getRoot
+from zope.traversing.api import getName, getParent, getRoot
from zope.fssync.snarf import Snarfer, Unsnarfer
-from zope.app.fssync import syncer
-from zope.app.fssync.committer import Committer, Checker
from zope.fssync.metadata import Metadata
+from zope.publisher.browser import BrowserView
+from zope.app.fssync import syncer
+from zope.app.fssync.committer import Committer, Checker
from zope.app.i18n import ZopeMessageFactory as _
def snarf_dir(response, dirname):
Modified: Zope3/trunk/src/zope/app/fssync/committer.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/committer.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/fssync/committer.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,23 +19,21 @@
import os
+import zope.component
+from zope.event import notify
from zope.configuration.name import resolve
from zope.fssync import fsutil
from zope.fssync.metadata import Metadata
from zope.fssync.server.interfaces import IObjectDirectory, IObjectFile
from zope.proxy import removeAllProxies
from zope.xmlpickle import fromxml
+from zope.traversing.api import traverseName, getName
+from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
+from zope.filerepresentation.interfaces import IFileFactory
+from zope.filerepresentation.interfaces import IDirectoryFactory
-from zope.app import zapi
from zope.app.fssync import fspickle
from zope.app.container.interfaces import IContainer
-from zope.app.container.interfaces import IContainer
-from zope.app.traversing.api import traverseName, getName
-from zope.app.filerepresentation.interfaces import IFileFactory
-from zope.app.filerepresentation.interfaces import IDirectoryFactory
-from zope.event import notify
-from zope.app.event.objectevent import ObjectCreatedEvent
-from zope.app.event.objectevent import ObjectModifiedEvent
from zope.app.container.contained import contained
class SynchronizationError(Exception):
@@ -395,7 +393,7 @@
else:
iface = IFileFactory
- factory = zapi.queryAdapter(location, iface, suffix)
+ factory = zope.component.queryAdapter(location, iface, suffix)
if factory is None:
factory = iface(location, None)
Modified: Zope3/trunk/src/zope/app/fssync/fspickle.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/fspickle.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/fssync/fspickle.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,7 +25,7 @@
`loads()` function. The name of the outermost object is not stored in
the pickle unless it is stored in the object.
->>> from zope.app.location.tests import TLocation
+>>> from zope.location.tests import TLocation
>>> root = TLocation()
>>> zope.interface.directlyProvides(root, IContainmentRoot)
>>> o1 = DataLocation('o1', root, 12)
@@ -64,20 +64,16 @@
__docformat__ = 'restructuredtext'
import cPickle
-
from cStringIO import StringIO
import zope.interface
+from zope import location
+from zope.location.interfaces import ILocation
+from zope.location.traversing import LocationPhysicallyLocatable
+from zope.location.tests import TLocation
+from zope.traversing.interfaces import IContainmentRoot
+from zope.traversing.interfaces import ITraverser
-from zope.app import location
-from zope.app import zapi
-from zope.app.location.interfaces import ILocation
-from zope.app.location.traversing import LocationPhysicallyLocatable
-from zope.app.location.tests import TLocation
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.app.traversing.interfaces import ITraverser
-
-
PARENT_MARKER = ".."
# We're not ready to use protocol 2 yet; this can be changed when
@@ -111,7 +107,7 @@
class ParentPersistentIdGenerator(object):
"""
- >>> from zope.app.location.tests import TLocation
+ >>> from zope.location.tests import TLocation
>>> root = TLocation()
>>> zope.interface.directlyProvides(root, IContainmentRoot)
>>> o1 = TLocation(); o1.__parent__ = root; o1.__name__ = 'o1'
Modified: Zope3/trunk/src/zope/app/fssync/fsregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/fsregistry.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/fssync/fsregistry.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,21 +19,12 @@
"""
__docformat__ = 'restructuredtext'
-import zope.deprecation
-
from zope.exceptions import DuplicationError
from zope.interface import implements
from zope.app.fssync.interfaces import IGlobalFSSyncUtility
from zope.app.fssync.interfaces import IFactoryNotFoundError
-# BBB Backward Compatibility (Can go away in 3.3)
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError
-zope.deprecation.__show__.on()
-
-class FactoryNotFoundError(NotFoundError):
- # BBB : NotFoundError inheritance
- # Backward Compatibility (Can go away in 3.3)
+class FactoryNotFoundError(LookupError):
implements(IFactoryNotFoundError)
class FSRegistry(object):
Modified: Zope3/trunk/src/zope/app/fssync/syncer.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/syncer.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/fssync/syncer.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,13 +18,11 @@
__docformat__ = 'restructuredtext'
from zope.app import zapi
+from zope.traversing.api import getPath
+from zope.annotation.interfaces import IAnnotations
from zope.fssync.server.syncer import Syncer
+from zope.app.fssync.interfaces import IGlobalFSSyncUtility
-from zope.app.annotation.interfaces import IAnnotations
-from zope.app.traversing.api import getPath
-
-from interfaces import IGlobalFSSyncUtility
-
def getObjectId(obj):
return str(getPath(obj))
Modified: Zope3/trunk/src/zope/app/fssync/tests/test_committer.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/tests/test_committer.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/fssync/tests/test_committer.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,30 +20,28 @@
import tempfile
import unittest
-from zope.app import zapi
-from zope.app.testing import ztapi
-from zope.app.traversing.interfaces import TraversalError
-from zope.interface import implements
-
+import zope.component
+import zope.interface
+from zope.traversing.interfaces import TraversalError, IContainmentRoot
+from zope.traversing.interfaces import ITraversable, ITraverser
from zope.xmlpickle import loads, dumps
+from zope.location import Location
+from zope.filerepresentation.interfaces import IFileFactory
+from zope.filerepresentation.interfaces import IDirectoryFactory
+
from zope.fssync import fsutil
from zope.fssync.server.entryadapter import DefaultFileAdpater
from zope.fssync.tests.mockmetadata import MockMetadata
from zope.fssync.tests.tempfiles import TempFiles
-
from zope.fssync.server.entryadapter import DirectoryAdapter
+
+from zope.app.testing import ztapi
from zope.app.container.interfaces import IContainer
-from zope.app.filerepresentation.interfaces import IFileFactory
-from zope.app.filerepresentation.interfaces import IDirectoryFactory
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.app.traversing.interfaces import ITraversable, ITraverser
-from zope.app.location import Location
from zope.app.testing.placelesssetup import PlacelessSetup
from zope.app.fssync import committer, syncer # The module
from zope.app.fssync.committer import Checker, Committer, SynchronizationError
from zope.app.fssync.fsregistry import provideSynchronizer, fsRegistry
-from zope.app.fssync.interfaces import IGlobalFSSyncUtility
class Sample(object):
@@ -51,9 +49,8 @@
class PretendContainer(Location):
+ zope.interface.implements(IContainer, ITraversable, ITraverser)
- implements(IContainer, ITraversable, ITraverser)
-
def __init__(self):
self.holding = {}
@@ -95,10 +92,9 @@
PCname = PretendContainer.__module__ + "." + PretendContainer.__name__
class PretendRootContainer(PretendContainer):
+ zope.interface.implements(IContainmentRoot)
- implements(IContainmentRoot)
-
class DictAdapter(DefaultFileAdpater):
def setBody(self, body):
@@ -122,8 +118,7 @@
super(TestBase, self).setUp()
# Set up FSRegistryUtility
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(IGlobalFSSyncUtility, fsRegistry)
+ zope.component.provideUtility(fsRegistry)
provideSynchronizer(None, DefaultFileAdpater)
# Set up temporary name administration
@@ -136,11 +131,15 @@
PlacelessSetup.tearDown(self)
+ at zope.component.adapter(IContainer)
+ at zope.interface.implementer(IFileFactory)
def file_factory_maker(container):
def file_factory(name, content_type, data):
return loads(data)
return file_factory
+ at zope.component.adapter(IContainer)
+ at zope.interface.implementer(IDirectoryFactory)
def directory_factory_maker(container):
def directory_factory(name):
return PretendContainer()
@@ -213,7 +212,7 @@
self.name = name
self.value = value
class TestRoot(object):
- implements(IContainmentRoot, ITraverser)
+ zope.interface.implements(IContainmentRoot, ITraverser)
def traverse(self, *args):
pass
fspath = tempfile.mktemp()
@@ -260,7 +259,7 @@
self.assertEqual(container.items(), [("foo", ["hello", "world"])])
def test_create_object_ifilefactory(self):
- ztapi.provideAdapter(IContainer, IFileFactory, file_factory_maker)
+ zope.component.provideAdapter(file_factory_maker)
container = PretendContainer()
entry = {"flag": "added"}
data = ["hello", "world"]
@@ -270,8 +269,7 @@
self.assertEqual(container.holding, {"foo": ["hello", "world"]})
def test_create_object_idirectoryfactory(self):
- ztapi.provideAdapter(IContainer, IDirectoryFactory,
- directory_factory_maker)
+ zope.component.provideAdapter(directory_factory_maker)
container = PretendContainer()
entry = {"flag": "added"}
tfn = os.path.join(self.tempdir(), "foo")
@@ -289,9 +287,8 @@
# Set up environment
provideSynchronizer(PretendContainer, DirectoryAdapter)
provideSynchronizer(dict, DictAdapter)
- ztapi.provideAdapter(IContainer, IFileFactory, file_factory_maker)
- ztapi.provideAdapter(IContainer, IDirectoryFactory,
- directory_factory_maker)
+ zope.component.provideAdapter(file_factory_maker)
+ zope.component.provideAdapter(directory_factory_maker)
# Set up fixed part of object tree
self.parent = PretendContainer()
Modified: Zope3/trunk/src/zope/app/fssync/tests/test_fspickle.py
===================================================================
--- Zope3/trunk/src/zope/app/fssync/tests/test_fspickle.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/fssync/tests/test_fspickle.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,15 +16,13 @@
$Id$
"""
import unittest
+from zope.testing.doctestunit import DocTestSuite
+from zope.interface import directlyProvides
+from zope.traversing.interfaces import IContainmentRoot
+from zope.location.tests import TLocation
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.app.location.tests import TLocation
from zope.app.fssync import fspickle
-from zope.interface import directlyProvides
-from zope.testing.doctestunit import DocTestSuite
-
-
class PersistentLoaderTestCase(unittest.TestCase):
def setUp(self):
Modified: Zope3/trunk/src/zope/app/ftp/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/ftp/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/ftp/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,5 +22,5 @@
The view, in turn, uses adapters for the `IReadFile`, `IWriteFile`,
`IReadDirectory`, `IWriteDirectory`, `IFileFactory`, and
- `IDirectoryFactory`, defined in `zope.app.filerepresentation.interfaces`.
+ `IDirectoryFactory`, defined in `zope.filerepresentation.interfaces`.
Modified: Zope3/trunk/src/zope/app/ftp/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/ftp/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/ftp/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,20 +23,18 @@
from zope.publisher.interfaces.ftp import IFTPPublisher
from zope.security.proxy import removeSecurityProxy
from zope.security.checker import canAccess
-
-from zope.app.filerepresentation.interfaces import IReadFile, IWriteFile
-from zope.app.filerepresentation.interfaces import IReadDirectory
-from zope.app.filerepresentation.interfaces import IWriteDirectory
-from zope.app.filerepresentation.interfaces import IFileFactory
-from zope.app.filerepresentation.interfaces import IDirectoryFactory
-
from zope.event import notify
-from zope.app.event.objectevent import ObjectCreatedEvent
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.copypastemove.interfaces import IContainerItemRenamer
+from zope.lifecycleevent import ObjectCreatedEvent
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.filerepresentation.interfaces import IReadFile, IWriteFile
+from zope.filerepresentation.interfaces import IReadDirectory
+from zope.filerepresentation.interfaces import IWriteDirectory
+from zope.filerepresentation.interfaces import IFileFactory
+from zope.filerepresentation.interfaces import IDirectoryFactory
+from zope.copypastemove.interfaces import IContainerItemRenamer
+
from zope.app.container.interfaces import IContainer
-
class FTPView(object):
implements(IFTPPublisher)
Modified: Zope3/trunk/src/zope/app/ftp/tests/test_ftpview.py
===================================================================
--- Zope3/trunk/src/zope/app/ftp/tests/test_ftpview.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/ftp/tests/test_ftpview.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,19 +21,19 @@
from zope.interface import implements
from zope.security.checker import defineChecker, NamesChecker
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.filerepresentation.interfaces import IReadFile, IWriteFile
+from zope.filerepresentation.interfaces import IReadDirectory
+from zope.filerepresentation.interfaces import IWriteDirectory
+from zope.filerepresentation.interfaces import IFileFactory
+from zope.filerepresentation.interfaces import IDirectoryFactory
+from zope.copypastemove.interfaces import IObjectMover
+from zope.copypastemove.interfaces import IContainerItemRenamer
+from zope.copypastemove import ContainerItemRenamer
from zope.app.testing import ztapi
-from zope.app.filerepresentation.interfaces import IReadFile, IWriteFile
-from zope.app.filerepresentation.interfaces import IReadDirectory
-from zope.app.filerepresentation.interfaces import IWriteDirectory
-from zope.app.filerepresentation.interfaces import IFileFactory
-from zope.app.filerepresentation.interfaces import IDirectoryFactory
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.ftp import FTPView
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.copypastemove.interfaces import IObjectMover
-from zope.app.copypastemove.interfaces import IContainerItemRenamer
-from zope.app.copypastemove import ContainerItemRenamer
from zope.app.container.contained import setitem, Contained
from zope.app.container.interfaces import IContainer
Modified: Zope3/trunk/src/zope/app/homefolder/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/homefolder/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/homefolder/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -201,10 +201,10 @@
(2) Or alternatively via the path adapter:
- >>> from zope.app.traversing.interfaces import IPathAdapter
- >>> from zope.app import zapi
- >>> zapi.getAdapter(principal, IPathAdapter,
- ... "homefolder") is baseFolder['stephan']
+ >>> import zope.component
+ >>> from zope.traversing.interfaces import IPathAdapter
+ >>> zope.component.getAdapter(principal, IPathAdapter,
+ ... "homefolder") is baseFolder['stephan']
True
As you can see, the path adapter just returns the homefolder. This way we can
Modified: Zope3/trunk/src/zope/app/homefolder/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/homefolder/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/homefolder/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -13,12 +13,14 @@
##############################################################################
"""Home Folder related views.
-$Id:$
+$Id$
"""
__docformat__ = "reStructuredText"
import zope.schema
from zope.schema.vocabulary import SimpleVocabulary
from zope.security.proxy import removeSecurityProxy
+from zope.traversing.interfaces import TraversalError
+from zope.dottedname.resolve import resolve
from zope.app import zapi
from zope.app.form.browser import TextWidget, MultiSelectWidget
@@ -27,11 +29,7 @@
from zope.app.form.interfaces import ConversionError
from zope.app.security.vocabulary import PrincipalSource
-from zope.app.traversing.interfaces import TraversalError
-from zope.dottedname.resolve import resolve
-
-
class PathWidget(TextWidget):
def _toFieldValue(self, input):
Modified: Zope3/trunk/src/zope/app/homefolder/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/homefolder/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/homefolder/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -12,7 +12,7 @@
<adapter
for="zope.security.interfaces.IPrincipal"
- provides="zope.app.traversing.interfaces.IPathAdapter"
+ provides="zope.traversing.interfaces.IPathAdapter"
factory=".homefolder.getHomeFolder"
name="homefolder" />
@@ -80,12 +80,6 @@
menu="zmi_views" title="Assignments"
/>
- <browser:tool
- interface=".interfaces.IHomeFolderManager"
- title="Home Folder Manager"
- description="A Principal Home Folder Manager"
- />
-
<!-- Registering documentation with API doc -->
<configure
xmlns:apidoc="http://namespaces.zope.org/apidoc"
Modified: Zope3/trunk/src/zope/app/homefolder/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/homefolder/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/homefolder/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,15 +20,15 @@
import unittest
from zope.interface import classImplements
from zope.security.interfaces import IPrincipal
+from zope.traversing.interfaces import IPathAdapter
from zope.testing import doctest
+from zope.annotation.interfaces import IAnnotatable
+from zope.annotation.interfaces import IAttributeAnnotatable
+
from zope.app.testing import placelesssetup, setup, ztapi
-
-from zope.app.annotation.interfaces import IAnnotatable
-from zope.app.annotation.interfaces import IAttributeAnnotatable
from zope.app.file import File
from zope.app.securitypolicy.interfaces import IPrincipalRoleManager
from zope.app.securitypolicy.principalrole import AnnotationPrincipalRoleManager
-from zope.app.traversing.interfaces import IPathAdapter
from zope.app.homefolder.homefolder import HomeFolder, getHomeFolder
from zope.app.homefolder.interfaces import IHomeFolder
Modified: Zope3/trunk/src/zope/app/http/delete.py
===================================================================
--- Zope3/trunk/src/zope/app/http/delete.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/http/delete.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,7 +15,7 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app.filerepresentation.interfaces import IWriteDirectory
+from zope.filerepresentation.interfaces import IWriteDirectory
from zope.app.publication.http import MethodNotAllowed
Modified: Zope3/trunk/src/zope/app/http/exception/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/http/exception/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/http/exception/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -28,23 +28,7 @@
name="index.html"
/>
-<!-- BBB : can be removed in 3.3 -->
<view
- for="zope.exceptions.INotFoundError"
- type="zope.publisher.interfaces.http.IHTTPRequest"
- name="index.html"
- permission="zope.Public"
- factory=".notfound.NotFound"
- />
-
-<defaultView
- for="zope.exceptions.INotFoundError"
- type="zope.publisher.interfaces.http.IHTTPRequest"
- name="index.html"
- />
-<!-- END BBB : can be removed in 3.3 -->
-
-<view
for="zope.app.publication.http.IMethodNotAllowed"
factory="zope.app.http.exception.methodnotallowed.MethodNotAllowedView"
name="index.html"
Modified: Zope3/trunk/src/zope/app/http/put.py
===================================================================
--- Zope3/trunk/src/zope/app/http/put.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/http/put.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,13 +16,14 @@
__docformat__ = 'restructuredtext'
from zope.component import queryAdapter
-from zope.app.http.interfaces import INullResource
-from zope.app.filerepresentation.interfaces import IWriteFile
-from zope.app.filerepresentation.interfaces import IWriteDirectory, IFileFactory
from zope.event import notify
-from zope.app.event.objectevent import ObjectCreatedEvent
+from zope.lifecycleevent import ObjectCreatedEvent
from zope.interface import implements
+from zope.filerepresentation.interfaces import IWriteFile
+from zope.filerepresentation.interfaces import IWriteDirectory, IFileFactory
+from zope.app.http.interfaces import INullResource
+
class NullResource(object):
"""Object representing objects to be created by a `PUT`.
"""
Modified: Zope3/trunk/src/zope/app/http/tests/test_delete.py
===================================================================
--- Zope3/trunk/src/zope/app/http/tests/test_delete.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/http/tests/test_delete.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,15 +16,16 @@
$Id$
"""
from unittest import TestCase, TestSuite, makeSuite
+
+from zope.interface import implements
+from zope.publisher.browser import TestRequest
+from zope.filerepresentation.interfaces import IWriteDirectory, IFileFactory
+
import zope.app.http.delete
-from zope.publisher.browser import TestRequest
-from zope.app.filerepresentation.interfaces import IWriteDirectory, IFileFactory
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.interface import implements
from zope.app.container.contained import contained
from zope.app.publication.http import MethodNotAllowed
-
class UnwritableContainer(object):
pass
Modified: Zope3/trunk/src/zope/app/http/tests/test_put.py
===================================================================
--- Zope3/trunk/src/zope/app/http/tests/test_put.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/http/tests/test_put.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,12 +17,14 @@
"""
from unittest import TestCase, TestSuite, makeSuite
from StringIO import StringIO
+
+from zope.interface import implements
+from zope.publisher.browser import TestRequest
+from zope.filerepresentation.interfaces import IWriteFile
+from zope.filerepresentation.interfaces import IWriteDirectory, IFileFactory
+
import zope.app.http.put
-from zope.publisher.browser import TestRequest
-from zope.app.filerepresentation.interfaces import IWriteFile
-from zope.app.filerepresentation.interfaces import IWriteDirectory, IFileFactory
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.interface import implements
class File(object):
Modified: Zope3/trunk/src/zope/app/i18n/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/i18n/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18n/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,19 +17,6 @@
"""
__docformat__ = 'restructuredtext'
-# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.i18nmessageid import MessageIDFactory, MessageFactory
-zope.deprecation.__show__.on()
-
-# import one of these as _ to create i18n messages in the zope domain
-ZopeMessageIDFactory = MessageIDFactory('zope')
+# import this as _ to create i18n messages in the zope domain
+from zope.i18nmessageid import MessageFactory
ZopeMessageFactory = MessageFactory('zope')
-
-zope.deprecation.deprecated('ZopeMessageIDFactory',
- 'Mutable i18n messages ("message ids") have been '
- 'deprecated in favour of immutable ones and will '
- 'be removed in Zope 3.3. Please use '
- 'ZopeMessageFactory instead of '
- 'ZopeMessageIDFactory.')
Modified: Zope3/trunk/src/zope/app/i18n/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/i18n/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18n/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -2,13 +2,6 @@
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser">
- <tool
- interface="zope.i18n.interfaces.ITranslationDomain"
- title="Translation Domains"
- description="Translation Domains allow you to localize your software by
- providing message translations."
- />
-
<pages
permission="zope.ManageServices"
for="zope.i18n.interfaces.ITranslationDomain"
Modified: Zope3/trunk/src/zope/app/i18n/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/i18n/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18n/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -13,7 +13,7 @@
/>
<class class="zope.publisher.http.HTTPRequest">
- <implements interface="zope.app.annotation.IAttributeAnnotatable" />
+ <implements interface="zope.annotation.IAttributeAnnotatable" />
</class>
<!-- Setup charset negotiation -->
@@ -42,13 +42,13 @@
<subscriber
for=".interfaces.ILocalTranslationDomain
- ..component.interfaces.registration.IRegistrationActivatedEvent"
+ zope.component.interfaces.IRegistered"
handler=".translationdomain.setDomainOnActivation"
/>
<subscriber
for=".interfaces.ILocalTranslationDomain
- ..component.interfaces.registration.IRegistrationDeactivatedEvent"
+ zope.component.interfaces.IUnregistered"
handler=".translationdomain.unsetDomainOnDeactivation"
/>
@@ -56,7 +56,7 @@
<class class=".messagecatalog.MessageCatalog">
<factory id="zope.app.MessageCatalog" />
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
+ interface="zope.annotation.interfaces.IAttributeAnnotatable" />
<require permission="zope.View"
interface="zope.i18n.interfaces.IMessageCatalog" />
@@ -78,7 +78,7 @@
provides="zope.i18n.interfaces.IMessageImportFilter"
/>
- <include file="locales.zcml" />
+ <include package="zope.i18n.locales" />
<include package=".xmlrpc" />
<include package=".browser" />
Deleted: Zope3/trunk/src/zope/app/i18n/locales.zcml
===================================================================
--- Zope3/trunk/src/zope/app/i18n/locales.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18n/locales.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,57 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope">
-
- <class class="zope.i18n.format.NumberFormat">
- <allow interface="zope.i18n.interfaces.INumberFormat" />
- </class>
-
- <class class="zope.i18n.format.DateTimeFormat">
- <allow interface="zope.i18n.interfaces.IDateTimeFormat" />
- </class>
-
-
- <class class="zope.i18n.locales.LocaleIdentity">
- <allow interface="zope.i18n.interfaces.locales.ILocaleIdentity" />
- </class>
-
- <class class="zope.i18n.locales.LocaleVersion">
- <allow interface="zope.i18n.interfaces.locales.ILocaleVersion" />
- </class>
-
- <class class="zope.i18n.locales.LocaleDisplayNames">
- <allow interface="zope.i18n.interfaces.locales.ILocaleDisplayNames" />
- </class>
-
- <class class="zope.i18n.locales.LocaleTimeZone">
- <allow interface="zope.i18n.interfaces.locales.ILocaleTimeZone" />
- </class>
-
- <class class="zope.i18n.locales.LocaleFormat">
- <allow interface="zope.i18n.interfaces.locales.ILocaleFormat" />
- </class>
-
- <class class="zope.i18n.locales.LocaleFormatLength">
- <allow interface="zope.i18n.interfaces.locales.ILocaleFormatLength" />
- </class>
-
- <class class="zope.i18n.locales.LocaleCalendar">
- <allow interface="zope.i18n.interfaces.locales.ILocaleCalendar" />
- </class>
-
- <class class="zope.i18n.locales.LocaleDates">
- <allow interface="zope.i18n.interfaces.locales.ILocaleDates" />
- </class>
-
- <class class="zope.i18n.locales.LocaleCurrency">
- <allow interface="zope.i18n.interfaces.locales.ILocaleCurrency" />
- </class>
-
- <class class="zope.i18n.locales.LocaleNumbers">
- <allow interface="zope.i18n.interfaces.locales.ILocaleNumbers" />
- </class>
-
- <class class="zope.i18n.locales.Locale">
- <allow interface="zope.i18n.interfaces.locales.ILocale" />
- </class>
-
-</configure>
\ No newline at end of file
Deleted: Zope3/trunk/src/zope/app/i18n/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/i18n/meta.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18n/meta.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,16 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:meta="http://namespaces.zope.org/meta"
- >
-
- <meta:directives namespace="http://namespaces.zope.org/i18n">
-
- <meta:directive
- name="registerTranslations"
- schema=".metadirectives.IRegisterTranslationsDirective"
- handler=".metaconfigure.registerTranslations"
- />
-
- </meta:directives>
-
-</configure>
Deleted: Zope3/trunk/src/zope/app/i18n/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/i18n/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18n/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,57 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""This module handles the 'i18n' namespace directives.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import os
-
-from zope.app.component.metaconfigure import utility
-from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
-from zope.i18n.testmessagecatalog import TestMessageCatalog
-from zope.i18n.translationdomain import TranslationDomain
-from zope.i18n.interfaces import ITranslationDomain
-
-
-def registerTranslations(_context, directory):
- path = os.path.normpath(directory)
- domains = {}
-
- # Gettext has the domain-specific catalogs inside the language directory,
- # which is exactly the opposite as we need it. So create a dictionary that
- # reverses the nesting.
- for language in os.listdir(path):
- lc_messages_path = os.path.join(path, language, 'LC_MESSAGES')
- if os.path.isdir(lc_messages_path):
- for domain_file in os.listdir(lc_messages_path):
- if domain_file.endswith('.mo'):
- domain_path = os.path.join(lc_messages_path, domain_file)
- domain = domain_file[:-3]
- if not domain in domains:
- domains[domain] = {}
- domains[domain][language] = domain_path
-
- # Now create TranslationDomain objects and add them as utilities
- for name, langs in domains.items():
- domain = TranslationDomain(name)
-
- for lang, file in langs.items():
- domain.addCatalog(GettextMessageCatalog(lang, name, file))
-
- # make sure we have a TEST catalog for each domain:
- domain.addCatalog(TestMessageCatalog(name))
-
- utility(_context, ITranslationDomain, domain, name=name)
Modified: Zope3/trunk/src/zope/app/i18n/tests/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/i18n/tests/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18n/tests/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,2 +1,9 @@
-#
# This file is necessary to make this directory a package.
+
+# BBB 2006/04/19 -- to be removed after 12 months
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "Its contents has moved into zope.i18n.testing. This reference "
+ "will be gone in Zope 3.5",
+ placelesssetup = 'zope.i18n.testing',
+ )
Modified: Zope3/trunk/src/zope/app/i18n/tests/placelesssetup.py
===================================================================
--- Zope3/trunk/src/zope/app/i18n/tests/placelesssetup.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18n/tests/placelesssetup.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,30 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Unit test logic for setting up and tearing down basic infrastructure
-
-$Id$
-"""
-from zope.app.testing import ztapi
-from zope.i18n.interfaces import IUserPreferredCharsets
-from zope.i18n.interfaces import IUserPreferredLanguages
-from zope.publisher.browser import BrowserLanguages
-from zope.publisher.http import HTTPCharsets, IHTTPRequest
-
-class PlacelessSetup(object):
-
- def setUp(self):
- ztapi.provideAdapter(IHTTPRequest, IUserPreferredCharsets,
- HTTPCharsets)
- ztapi.provideAdapter(IHTTPRequest, IUserPreferredLanguages,
- BrowserLanguages)
+# This module has moved to zope.i18n.testing
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.i18n.testing',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/i18n/tests/placelesssetup.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.5
Modified: Zope3/trunk/src/zope/app/i18n/tests/test_translationdomain.py
===================================================================
--- Zope3/trunk/src/zope/app/i18n/tests/test_translationdomain.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18n/tests/test_translationdomain.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -27,15 +27,14 @@
from zope.interface import implements, classImplements
from zope.interface.verify import verifyObject
from zope.testing.doctestunit import DocTestSuite
+from zope.annotation.interfaces import IAttributeAnnotatable
from zope.app import zapi
-from zope.app.annotation.interfaces import IAttributeAnnotatable
from zope.app.i18n.interfaces import ISyncTranslationDomain
from zope.app.i18n.messagecatalog import MessageCatalog
from zope.app.i18n.translationdomain import TranslationDomain
from zope.app.component.testing import PlacefulSetup
from zope.app.testing import setup, ztapi
-from zope.app.component.interfaces import ILocalUtility
class Environment(object):
@@ -187,7 +186,7 @@
def setUp(self):
- classImplements(TranslationDomain, ILocalUtility, IAttributeAnnotatable)
+ classImplements(TranslationDomain, IAttributeAnnotatable)
self.sm = PlacefulSetup.setUp(self, site=True)
TestITranslationDomain.setUp(self)
Deleted: Zope3/trunk/src/zope/app/i18n/tests/testi18ndirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/i18n/tests/testi18ndirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18n/tests/testi18ndirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,62 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test the gts ZCML namespace directives.
-
-$Id$
-"""
-import os
-import unittest
-
-from zope.component.tests.placelesssetup import PlacelessSetup
-from zope.configuration import xmlconfig
-
-from zope.app import zapi
-from zope.i18n.interfaces import ITranslationDomain
-import zope.app.i18n
-import zope.i18n.tests
-
-template = """<configure
- xmlns='http://namespaces.zope.org/zope'
- xmlns:i18n='http://namespaces.zope.org/i18n'>
- %s
- </configure>"""
-
-
-class DirectivesTest(PlacelessSetup, unittest.TestCase):
-
- def setUp(self):
- super(DirectivesTest, self).setUp()
- self.context = xmlconfig.file('meta.zcml', zope.app.i18n)
-
- def testRegisterTranslations(self):
- eq = self.assertEqual
- eq(zapi.queryUtility(ITranslationDomain), None)
- xmlconfig.string(
- template % '''
- <configure package="zope.i18n.tests">
- <i18n:registerTranslations directory="./locale" />
- </configure>
- ''', self.context)
- path = os.path.join(os.path.dirname(zope.i18n.tests.__file__),
- 'locale', 'en',
- 'LC_MESSAGES', 'zope-i18n.mo')
- util = zapi.getUtility(ITranslationDomain, 'zope-i18n')
- eq(util._catalogs, {'test': ['test'], 'en': [unicode(path)]})
-
-
-def test_suite():
- return unittest.makeSuite(DirectivesTest)
-
-if __name__ == '__main__':
- unittest.TextTestRunner().run(test_suite())
Modified: Zope3/trunk/src/zope/app/i18n/translationdomain.py
===================================================================
--- Zope3/trunk/src/zope/app/i18n/translationdomain.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18n/translationdomain.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,21 +19,20 @@
import re
from BTrees.OOBTree import OOBTree
-from zope.interface import implements
-from zope.app import zapi
-from zope.app.container.btree import BTreeContainer
-from zope.app.i18n.interfaces import ILocalTranslationDomain
+import zope.component
+from zope.interface import implements
from zope.i18n import interpolate
from zope.i18n.negotiator import negotiator
from zope.i18n.interfaces import INegotiator, ITranslationDomain
from zope.i18n.simpletranslationdomain import SimpleTranslationDomain
+
+from zope.app.container.btree import BTreeContainer
+from zope.app.i18n.interfaces import ILocalTranslationDomain
from zope.app.container.contained import Contained
-from zope.app.component.site import UtilityRegistration
from zope.app.component import queryNextUtility
class TranslationDomain(BTreeContainer, SimpleTranslationDomain, Contained):
-
implements(ILocalTranslationDomain)
def __init__(self):
@@ -68,7 +67,7 @@
if target_language is None and context is not None:
avail_langs = self.getAvailableLanguages()
# Let's negotiate the language to translate to. :)
- negotiator = zapi.getUtility(INegotiator, context=self)
+ negotiator = zope.component.getUtility(INegotiator, context=self)
target_language = negotiator.getLanguage(avail_langs, context)
# Get the translation. Default is the source text itself.
@@ -166,8 +165,8 @@
def addLanguage(self, language):
'See `IWriteTranslationDomain`'
- catalog = zapi.createObject(u'zope.app.MessageCatalog',
- language)
+ catalog = zope.component.createObject(u'zope.app.MessageCatalog',
+ language)
self[language] = catalog
@@ -221,9 +220,6 @@
fmsg['mod_time'])
-# BBB: Backward compatibility. 12/09/2004
-DomainRegistration = UtilityRegistration
-
def setDomainOnActivation(domain, event):
"""Set the permission id upon registration activation.
@@ -239,8 +235,8 @@
>>> domain1.domain
'<domain not activated>'
- >>> from zope.app.component import registration
- >>> event = registration.RegistrationActivatedEvent(
+ >>> import zope.component.interfaces
+ >>> event = zope.component.interfaces.Registered(
... Registration(domain1, 'domain1'))
Now we pass the event into this function, and the id of the domain should
@@ -267,8 +263,8 @@
>>> domain1 = TranslationDomain()
>>> domain1.domain = 'domain1'
- >>> from zope.app.component import registration
- >>> event = registration.RegistrationDeactivatedEvent(
+ >>> import zope.component.interfaces
+ >>> event = zope.component.interfaces.Unregistered(
... Registration(domain1, 'domain1'))
Now we pass the event into this function, and the id of the role should be
Modified: Zope3/trunk/src/zope/app/i18nfile/browser/i18nimage.py
===================================================================
--- Zope3/trunk/src/zope/app/i18nfile/browser/i18nimage.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18nfile/browser/i18nimage.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,10 +20,10 @@
from urllib import quote
from zope.i18n.negotiator import negotiator
+from zope.size import ISized
from zope.app.i18n import ZopeMessageFactory as _
from zope.app.file.browser.image import ImageData
-from zope.app.size import ISized
class I18nImageEdit(object):
Modified: Zope3/trunk/src/zope/app/i18nfile/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/i18nfile/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/i18nfile/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -41,7 +41,7 @@
attributes="setDefaultLanguage removeLanguage setData"
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
@@ -69,7 +69,7 @@
attributes="setDefaultLanguage removeLanguage setData"
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
Modified: Zope3/trunk/src/zope/app/interface/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/interface/vocabulary.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/interface/vocabulary.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,8 +20,8 @@
from zope.interface import classProvides, providedBy
from zope.security.proxy import removeSecurityProxy
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
-from zope.app.component.interface import interfaceToName
-from zope.app.schema.interfaces import IVocabularyFactory
+from zope.schema.interfaces import IVocabularyFactory
+from zope.component.interface import interfaceToName
class ObjectInterfacesVocabulary(SimpleVocabulary):
Modified: Zope3/trunk/src/zope/app/intid/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/intid/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/intid/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -28,11 +28,11 @@
from zope.event import notify
from zope.interface import implements
from zope.security.proxy import removeSecurityProxy
+from zope.location.interfaces import ILocation
from zope.app import zapi
from zope.app.container.contained import Contained
from zope.app.keyreference.interfaces import IKeyReference, NotYet
-from zope.app.location.interfaces import ILocation
from zope.app.intid.interfaces import IIntIds
from zope.app.intid.interfaces import IntIdRemovedEvent
Modified: Zope3/trunk/src/zope/app/intid/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/intid/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/intid/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -2,13 +2,6 @@
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser">
- <tool
- interface="zope.app.intid.interfaces.IIntIds"
- title="Unique Id Tool"
- description="Unique Ids Tools are used to provide system-wide unique ids
- for documents."
- />
-
<addMenuItem
title="Unique Id Utility"
description="A utility that provides unique ids to objects"
Modified: Zope3/trunk/src/zope/app/intid/browser/tracking.txt
===================================================================
--- Zope3/trunk/src/zope/app/intid/browser/tracking.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/intid/browser/tracking.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -34,31 +34,17 @@
...
... 1
... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
- ... Content-Disposition: form-data; name="field.status"
+ ... Content-Disposition: form-data; name="field.comment"
...
- ... Active
- ... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
- ... Content-Disposition: form-data; name="field.status-empty-marker"
...
- ... 1
... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
- ... Content-Disposition: form-data; name="field.permission"
+ ... Content-Disposition: form-data; name="field.actions.register"
...
- ...
- ... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
- ... Content-Disposition: form-data; name="field.permission-empty-marker"
- ...
- ... 1
- ... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ
- ... Content-Disposition: form-data; name="UPDATE_SUBMIT"
- ...
- ... Add
+ ... Register
... ------------CedQTrEQIEPbgfYhvcITAhQi2aJdgu3tYfJ0WYQmkpLQTt6OTOpd5GJ--
... """)
HTTP/1.1 303 See Other
...
- Location: @@SelectedManagementView.html
- ...
Now, we'll add a few folders:
Modified: Zope3/trunk/src/zope/app/intid/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/intid/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/intid/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -6,7 +6,7 @@
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
<require
@@ -27,13 +27,13 @@
<subscriber
handler=".removeIntIdSubscriber"
- for="zope.app.location.interfaces.ILocation
+ for="zope.location.interfaces.ILocation
zope.app.container.interfaces.IObjectRemovedEvent"
/>
<subscriber
handler=".addIntIdSubscriber"
- for="zope.app.location.interfaces.ILocation
+ for="zope.location.interfaces.ILocation
zope.app.container.interfaces.IObjectAddedEvent"
/>
Modified: Zope3/trunk/src/zope/app/intid/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/intid/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/intid/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,10 +23,10 @@
from zope.interface import implements
from zope.interface.verify import verifyObject
+from zope.location.interfaces import ILocation
from zope.app.testing import setup, ztapi
from zope.app import zapi
-from zope.app.location.interfaces import ILocation
from zope.app.component.hooks import setSite
from zope.app.intid.interfaces import IIntIds
Modified: Zope3/trunk/src/zope/app/introspector/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/introspector/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/introspector/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,9 +23,8 @@
from zope.interface.interfaces import IInterface
from zope.interface.interface import InterfaceClass
from zope.security.proxy import removeSecurityProxy
+from zope.component.interface import searchInterface, getInterface
-from zope.app import zapi
-from zope.app.component.interface import searchInterface, getInterface
from zope.app.introspector.interfaces import IIntrospector
##############################################################################
Modified: Zope3/trunk/src/zope/app/introspector/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/introspector/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/introspector/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,17 +17,15 @@
"""
__docformat__ = 'restructuredtext'
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
from zope.interface import directlyProvides, directlyProvidedBy
from zope.proxy import removeAllProxies
+from zope.publisher.browser import BrowserView
+from zope.component.interface import getInterface
from zope.app import zapi
-from zope.app.component.interface import getInterface
from zope.app.introspector.interfaces import IIntrospector
-from zope.app.publisher.browser import BrowserView
-
-
class IntrospectorView(BrowserView):
def getIntrospector(self):
Modified: Zope3/trunk/src/zope/app/introspector/tests/test_introspector.py
===================================================================
--- Zope3/trunk/src/zope/app/introspector/tests/test_introspector.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/introspector/tests/test_introspector.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,14 +18,17 @@
import zope.deprecation
from unittest import TestCase, TestSuite, main, makeSuite
+
+from zope.interface import Interface, Attribute, implements, directlyProvides
+from zope.interface.verify import verifyObject
+from zope.component.interface import provideInterface
+
+from zope.app.testing import placelesssetup
+
zope.deprecation.__show__.off()
from zope.app.introspector import Introspector
from zope.app.introspector.interfaces import IIntrospector
zope.deprecation.__show__.on()
-from zope.interface import Interface, Attribute, implements, directlyProvides
-from zope.interface.verify import verifyObject
-from zope.app.component.interface import provideInterface
-from zope.app.testing import placelesssetup
class ITestClass(Interface):
def drool():
Modified: Zope3/trunk/src/zope/app/introspector/tests/test_introspectorview.py
===================================================================
--- Zope3/trunk/src/zope/app/introspector/tests/test_introspectorview.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/introspector/tests/test_introspectorview.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,12 +19,14 @@
import zope.deprecation
-from zope.app.component.testing import PlacefulSetup
from zope.publisher.browser import TestRequest
from zope.interface import Interface, directlyProvidedBy
from zope.interface import directlyProvides, implements
-from zope.app.component.interface import provideInterface
+from zope.component.interface import provideInterface
+
+from zope.app.component.testing import PlacefulSetup
from zope.app.testing import ztapi, setup
+
zope.deprecation.__show__.off()
from zope.app.introspector.interfaces import IIntrospector
from zope.app.introspector import Introspector
Modified: Zope3/trunk/src/zope/app/keyreference/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/keyreference/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/keyreference/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,8 +17,9 @@
"""
import zope.interface
from zope.schema import DottedName
+from zope.i18nmessageid import MessageFactory
-from zope.app.i18n import ZopeMessageFactory as _
+_ = MessageFactory('zope')
class NotYet(Exception):
Modified: Zope3/trunk/src/zope/app/locales/extract.py
===================================================================
--- Zope3/trunk/src/zope/app/locales/extract.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/locales/extract.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,15 +25,10 @@
import traceback
from pygettext import safe_eval, normalize, make_escapes
-from interfaces import IPOTEntry, IPOTMaker, ITokenEater
from zope.interface import implements
+from zope.i18nmessageid import Message
+from zope.app.locales.interfaces import IPOTEntry, IPOTMaker, ITokenEater
-# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.i18nmessageid import MessageID, Message
-zope.deprecation.__show__.on()
-
DEFAULT_CHARSET = 'UTF-8'
DEFAULT_ENCODING = '8bit'
@@ -117,10 +112,8 @@
def write(self, file):
if self.comments:
file.write(self.comments)
- if (isinstance(self.msgid, MessageID) and
- self.msgid != self.msgid.default) or (
- isinstance(self.msgid, Message) and
- self.msgid.default is not None):
+ if (isinstance(self.msgid, Message) and
+ self.msgid.default is not None):
default = self.msgid.default.strip()
lines = normalize(default).split("\n")
lines[0] = "#. Default: %s\n" % lines[0]
Modified: Zope3/trunk/src/zope/app/location/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/location/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/location/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,22 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Locations
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.app.location.location import Location, locate, LocationIterator
-from zope.app.location.location import inside, LocationProxy
-from zope.app.location.interfaces import ILocation
+# This module has moved to zope.location
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.location',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/location/__init__.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.8
Deleted: Zope3/trunk/src/zope/app/location/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/location/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/location/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,12 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- i18n_domain="zope"
- >
-
- <adapter
- for="zope.app.location.interfaces.ILocation"
- provides="zope.app.traversing.interfaces.IPhysicallyLocatable"
- factory="zope.app.location.traversing.LocationPhysicallyLocatable"
- />
-
-</configure>
Modified: Zope3/trunk/src/zope/app/location/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/location/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/location/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,44 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Location framework interfaces
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.interface import Interface, Attribute
-from zope import schema
-
-
-class ILocation(Interface):
- """Objects that have a structural location"""
-
- __parent__ = Attribute("The parent in the location hierarchy")
-
- __name__ = schema.TextLine(
- title=u"The name within the parent",
- description=u"Traverse the parent with this name to get the object.",
- required=False,
- default=None)
-
-
-class ISublocations(Interface):
- """Provide access to sublocations."""
-
- def sublocations():
- """Return sublocations
-
- An iterable of objects whose __parent__ is the object
- providing the interface is returned.
- """
+# This module has moved to zope.location.interfaces
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.location.interfaces',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/location/interfaces.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.2
Modified: Zope3/trunk/src/zope/app/location/location.py
===================================================================
--- Zope3/trunk/src/zope/app/location/location.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/location/location.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,177 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Location support
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import zope.interface
-from zope.app.location.interfaces import ILocation
-from zope.proxy import ProxyBase, getProxiedObject
-from zope.app.decorator import DecoratorSpecificationDescriptor
-from zope.app.decorator import DecoratedSecurityCheckerDescriptor
-
-class Location(object):
- """Stupid mix-in that defines `__parent__` and `__name__` attributes
-
- Usage within an Object field:
-
- >>> from zope.interface import implements, Interface
- >>> from zope.schema import Object
- >>> from zope.schema.fieldproperty import FieldProperty
- >>> from zope.app.location.interfaces import ILocation
- >>> from zope.app.location.location import Location
-
- >>> class IA(Interface):
- ... location = Object(schema=ILocation, required=False, default=None)
- >>> class A(object):
- ... implements(IA)
- ... location = FieldProperty(IA['location'])
-
- >>> a = A()
- >>> a.location = Location()
-
- >>> loc = Location(); loc.__name__ = u'foo'
- >>> a.location = loc
-
- >>> loc = Location(); loc.__name__ = None
- >>> a.location = loc
-
- >>> loc = Location(); loc.__name__ = 'foo'
- >>> a.location = loc
- Traceback (most recent call last):
- ...
- WrongContainedType: [foo <type 'unicode'>]
-
- """
-
- zope.interface.implements(ILocation)
-
- __parent__ = __name__ = None
-
-def locate(object, parent, name=None):
- """Locate an object in another
-
- This method should only be called from trusted code, because it
- sets attributes that are normally unsettable.
- """
-
- object.__parent__ = parent
- object.__name__ = name
-
-def LocationIterator(object):
- while object is not None:
- yield object
- object = getattr(object, '__parent__', None)
-
-def inside(l1, l2):
- """Is l1 inside l2
-
- L1 is inside l2 if l2 is an ancestor of l1.
-
- >>> o1 = Location()
- >>> o2 = Location(); o2.__parent__ = o1
- >>> o3 = Location(); o3.__parent__ = o2
- >>> o4 = Location(); o4.__parent__ = o3
-
- >>> inside(o1, o1)
- 1
- >>> inside(o2, o1)
- 1
- >>> inside(o3, o1)
- 1
- >>> inside(o4, o1)
- 1
-
- >>> inside(o1, o4)
- 0
-
- >>> inside(o1, None)
- 0
-
- """
-
- while l1 is not None:
- if l1 is l2:
- return True
- l1 = l1.__parent__
-
- return False
-
-class ClassAndInstanceDescr(object):
-
- def __init__(self, *args):
- self.funcs = args
-
- def __get__(self, inst, cls):
- if inst is None:
- return self.funcs[1](cls)
- return self.funcs[0](inst)
-
-class LocationProxy(ProxyBase):
- __doc__ = """Location-object proxy
-
- This is a non-picklable proxy that can be put around objects that
- don't implement `ILocation`.
-
- >>> l = [1, 2, 3]
- >>> p = LocationProxy(l, "Dad", "p")
- >>> p
- [1, 2, 3]
- >>> p.__parent__
- 'Dad'
- >>> p.__name__
- 'p'
-
- >>> import pickle
- >>> p2 = pickle.dumps(p)
- Traceback (most recent call last):
- ...
- TypeError: Not picklable
-
- Proxies should get their doc strings from the object they proxy:
-
- >>> p.__doc__ == l.__doc__
- True
-
- """
-
- zope.interface.implements(ILocation)
-
- __slots__ = '__parent__', '__name__'
- __safe_for_unpickling__ = True
-
- def __new__(self, ob, container=None, name=None):
- return ProxyBase.__new__(self, ob)
-
- def __init__(self, ob, container=None, name=None):
- ProxyBase.__init__(self, ob)
- self.__parent__ = container
- self.__name__ = name
-
- def __reduce__(self, proto=None):
- raise TypeError("Not picklable")
-
-
- __doc__ = ClassAndInstanceDescr(
- lambda inst: getProxiedObject(inst).__doc__,
- lambda cls, __doc__ = __doc__: __doc__,
- )
-
- __reduce_ex__ = __reduce__
-
- __providedBy__ = DecoratorSpecificationDescriptor()
-
- __Security_checker__ = DecoratedSecurityCheckerDescriptor()
+# This module has moved to zope.location.location
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.location.location',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/location/location.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.8
Modified: Zope3/trunk/src/zope/app/location/pickling.py
===================================================================
--- Zope3/trunk/src/zope/app/location/pickling.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/location/pickling.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,235 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Location copying/pickling support
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.app.location.interfaces import ILocation
-from zope.app.location.location import Location, inside
-from zope.app.location.traversing import LocationPhysicallyLocatable
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.app.traversing.interfaces import ITraverser
-import cPickle
-import tempfile
-import zope.interface
-
-def locationCopy(loc):
- r"""Return a copy of an object, and anything in it
-
- If object in the location refer to objects outside of the
- location, then the copies of the objects in the location refer to
- the same outside objects.
-
- For example, suppose we have an object (location) hierarchy like this::
-
- o1
- / \
- o2 o3
- | |
- o4 o5
-
- >>> o1 = Location()
- >>> o1.o2 = Location(); o1.o2.__parent__ = o1
- >>> o1.o3 = Location(); o1.o3.__parent__ = o1
- >>> o1.o2.o4 = Location(); o1.o2.o4.__parent__ = o1.o2
- >>> o1.o3.o5 = Location(); o1.o3.o5.__parent__ = o1.o3
-
- In addition, o3 has a non-location reference to o4.
-
- >>> o1.o3.o4 = o1.o2.o4
-
- When we copy o3, we should get a copy of o3 and o5, with
- references to o1 and o4.
-
- >>> c3 = locationCopy(o1.o3)
- >>> c3 is o1.o3
- 0
- >>> c3.__parent__ is o1
- 1
- >>> c3.o5 is o1.o3.o5
- 0
- >>> c3.o5.__parent__ is c3
- 1
- >>> c3.o4 is o1.o2.o4
- 1
-
- """
- tmp = tempfile.TemporaryFile()
- persistent = CopyPersistent(loc)
-
- # Pickle the object to a temporary file
- pickler = cPickle.Pickler(tmp, 2)
- pickler.persistent_id = persistent.id
- pickler.dump(loc)
-
- # Now load it back
- tmp.seek(0)
- unpickler = cPickle.Unpickler(tmp)
- unpickler.persistent_load = persistent.load
-
- return unpickler.load()
-
-
-class CopyPersistent(object):
- """Persistence hooks for copying locations
-
- See `locationCopy` above.
-
- We get initialized with an initial location:
-
- >>> o1 = Location()
- >>> persistent = CopyPersistent(o1)
-
- We provide an `id` function that returns None when given a non-location:
-
- >>> persistent.id(42)
-
- Or when given a location that is inside the initial location:
-
- >>> persistent.id(o1)
- >>> o2 = Location(); o2.__parent__ = o1
- >>> persistent.id(o2)
-
- But, if we get a location outside the original location, we assign
- it an `id` and return the `id`:
-
- >>> o3 = Location()
- >>> id3 = persistent.id(o3)
- >>> id3 is None
- 0
- >>> o4 = Location()
- >>> id4 = persistent.id(o4)
- >>> id4 is None
- 0
- >>> id4 is id3
- 0
-
- If we ask for the `id` of an outside location more than once, we
- always get the same `id` back:
-
- >> persistent.id(o4) == id4
- 1
-
- We also provide a load function that returns the objects for which
- we were given ids:
-
- >>> persistent.load(id3) is o3
- 1
- >>> persistent.load(id4) is o4
- 1
-
- """
-
- def __init__(self, location):
- self.location = location
- self.pids_by_id = {}
- self.others_by_pid = {}
- self.load = self.others_by_pid.get
-
- def id(self, object):
- if ILocation.providedBy(object):
- if not inside(object, self.location):
- if id(object) in self.pids_by_id:
- return self.pids_by_id[id(object)]
- pid = len(self.others_by_pid)
-
- # The following is needed to overcome a bug
- # in pickle.py. The pickle checks the boolean value
- # of the id, rather than whether it is None.
- pid += 1
-
- self.pids_by_id[id(object)] = pid
- self.others_by_pid[pid] = object
- return pid
-
- return None
-
-
-class PathPersistent(object):
- """Persistence hooks for pickling locations
-
- See `locationCopy` above.
-
- Unlike copy persistent, we use paths for ids of outside locations
- so that we can separate pickling and unpickling in time. We have
- to compute paths and traverse objects to load paths, but paths can
- be stored for later use, unlike the ids used by `CopyPersistent`.
-
- We require outside locations that can be adapted to `ITraversable`.
- To simplify the example, we'll use a simple traversable location
- defined in `zope.app.location.tests`, `TLocation`.
-
- Normally, general adapters are used to make objects traversable.
-
- We get initialized with an initial location:
-
- >>> o1 = Location()
- >>> persistent = PathPersistent(o1)
-
- We provide an id function that returns None when given a non-location:
-
- >>> persistent.id(42)
-
- Or when given a location that is inside the initial location:
-
- >>> persistent.id(o1)
- >>> o2 = Location(); o2.__parent__ = o1
- >>> persistent.id(o2)
-
- But, if we get a location outside the original location, we return it's
- path. To compute it's path, it must be rooted:
-
- >>> from zope.app.location.tests import TLocation
- >>> root = TLocation()
- >>> zope.interface.directlyProvides(root, IContainmentRoot)
- >>> o3 = TLocation(); o3.__name__ = 'o3'
- >>> o3.__parent__ = root; root.o3 = o3
- >>> persistent.id(o3)
- u'/o3'
-
- >>> o4 = TLocation(); o4.__name__ = 'o4'
- >>> o4.__parent__ = o3; o3.o4 = o4
- >>> persistent.id(o4)
- u'/o3/o4'
-
-
- We also provide a load function that returns objects by traversing
- given paths. It has to find the root based on the object given to
- the constructor. Therefore, that object must also be rooted:
-
- >>> o1.__parent__ = root
- >>> persistent.load(u'/o3') is o3
- 1
- >>> persistent.load(u'/o3/o4') is o4
- 1
-
- """
-
- def __init__(self, location):
- self.location = location
-
- def id(self, object):
- if ILocation.providedBy(object):
- if not inside(object, self.location):
- return LocationPhysicallyLocatable(object).getPath()
-
- return None
-
- def load(self, path):
- if path[:1] != u'/':
- raise ValueError("ZPersistent paths must be absolute", path)
- root = LocationPhysicallyLocatable(self.location).getRoot()
- return ITraverser(root).traverse(path[1:])
+# This module has moved to zope.location.pickling
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.location.pickling',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/location/pickling.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.8
Deleted: Zope3/trunk/src/zope/app/location/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/location/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/location/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,47 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Location support tests
-
-$Id$
-"""
-import unittest
-from zope.testing.doctestunit import DocTestSuite
-from zope.app.location.location import Location
-import zope.interface
-from zope.app.traversing.interfaces import ITraverser
-
-class TLocation(Location):
- """Simple traversable location used in examples."""
-
- zope.interface.implements(ITraverser)
-
- def traverse(self, path, default=None, request=None):
- o = self
- for name in path.split(u'/'):
- o = getattr(o, name)
- return o
-
-def test_suite():
- return unittest.TestSuite((
- DocTestSuite('zope.app.location.location'),
- DocTestSuite('zope.app.location.traversing'),
- DocTestSuite('zope.app.location.pickling'),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
-
-
-
-
Modified: Zope3/trunk/src/zope/app/location/traversing.py
===================================================================
--- Zope3/trunk/src/zope/app/location/traversing.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/location/traversing.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,175 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Classes to support implenting IContained
-
-$Id$
-"""
-import zope.interface
-from zope.app.traversing.interfaces import IPhysicallyLocatable
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.app.traversing.interfaces import ITraverser
-from zope.app.component.interfaces import ISite
-from zope.app.traversing.api import getParents
-from zope.app.location.location import Location
-
-
-class LocationPhysicallyLocatable(object):
- """Provide location information for location objects
- """
-
- zope.interface.implements(IPhysicallyLocatable)
-
- def __init__(self, context):
- self.context = context
-
- def getRoot(self):
- """Get the root location for a location.
-
- See IPhysicallyLocatable
-
- The root location is a location that contains the given
- location and that implements IContainmentRoot.
-
- >>> root = Location()
- >>> zope.interface.directlyProvides(root, IContainmentRoot)
- >>> LocationPhysicallyLocatable(root).getRoot() is root
- 1
-
- >>> o1 = Location(); o1.__parent__ = root
- >>> LocationPhysicallyLocatable(o1).getRoot() is root
- 1
-
- >>> o2 = Location(); o2.__parent__ = o1
- >>> LocationPhysicallyLocatable(o2).getRoot() is root
- 1
-
- We'll get a TypeError if we try to get the location fo a
- rootless object:
-
- >>> o1.__parent__ = None
- >>> LocationPhysicallyLocatable(o1).getRoot()
- Traceback (most recent call last):
- ...
- TypeError: Not enough context to determine location root
- >>> LocationPhysicallyLocatable(o2).getRoot()
- Traceback (most recent call last):
- ...
- TypeError: Not enough context to determine location root
-
- If we screw up and create a location cycle, it will be caught:
-
- >>> o1.__parent__ = o2
- >>> LocationPhysicallyLocatable(o1).getRoot()
- Traceback (most recent call last):
- ...
- TypeError: Maximum location depth exceeded, """ \
- """probably due to a a location cycle.
- """
- context = self.context
- max = 9999
- while context is not None:
- if IContainmentRoot.providedBy(context):
- return context
- context = context.__parent__
- max -= 1
- if max < 1:
- raise TypeError("Maximum location depth exceeded, "
- "probably due to a a location cycle.")
-
- raise TypeError("Not enough context to determine location root")
-
- def getPath(self):
- """Get the path of a location.
-
- See IPhysicallyLocatable
-
- This is an "absolute path", rooted at a root object.
-
- >>> root = Location()
- >>> zope.interface.directlyProvides(root, IContainmentRoot)
- >>> LocationPhysicallyLocatable(root).getPath()
- u'/'
-
- >>> o1 = Location(); o1.__parent__ = root; o1.__name__ = 'o1'
- >>> LocationPhysicallyLocatable(o1).getPath()
- u'/o1'
-
- >>> o2 = Location(); o2.__parent__ = o1; o2.__name__ = u'o2'
- >>> LocationPhysicallyLocatable(o2).getPath()
- u'/o1/o2'
-
- It is an error to get the path of a rootless location:
-
- >>> o1.__parent__ = None
- >>> LocationPhysicallyLocatable(o1).getPath()
- Traceback (most recent call last):
- ...
- TypeError: Not enough context to determine location root
-
- >>> LocationPhysicallyLocatable(o2).getPath()
- Traceback (most recent call last):
- ...
- TypeError: Not enough context to determine location root
-
- If we screw up and create a location cycle, it will be caught:
-
- >>> o1.__parent__ = o2
- >>> LocationPhysicallyLocatable(o1).getPath()
- Traceback (most recent call last):
- ...
- TypeError: Maximum location depth exceeded, """ \
- """probably due to a a location cycle.
-
- """
-
- path = []
- context = self.context
- max = 9999
- while context is not None:
- if IContainmentRoot.providedBy(context):
- if path:
- path.append('')
- path.reverse()
- return u'/'.join(path)
- else:
- return u'/'
- path.append(context.__name__)
- context = context.__parent__
- max -= 1
- if max < 1:
- raise TypeError("Maximum location depth exceeded, "
- "probably due to a a location cycle.")
-
- raise TypeError("Not enough context to determine location root")
-
- def getName(self):
- """Get a location name
-
- See IPhysicallyLocatable.
-
- >>> o1 = Location(); o1.__name__ = 'o1'
- >>> LocationPhysicallyLocatable(o1).getName()
- 'o1'
-
- """
- return self.context.__name__
-
- def getNearestSite(self):
- """return the nearest site, see IPhysicallyLocatable"""
- if ISite.providedBy(self.context):
- return self.context
- for parent in getParents(self.context):
- if ISite.providedBy(parent):
- return parent
- return self.getRoot()
+# This module has moved to zope.location.traversing
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.location.traversing',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/location/traversing.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.8
Modified: Zope3/trunk/src/zope/app/locking/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/locking/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/locking/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -376,9 +376,8 @@
that makes sense::
>>> from zope.component import getAdapter
+ >>> from zope.traversing.interfaces import IPathAdapter
- >>> from zope.app.traversing.interfaces import IPathAdapter
-
>>> ns = getAdapter(42, IPathAdapter, "locking")
>>> ns.lockable
False
Modified: Zope3/trunk/src/zope/app/locking/adapter.py
===================================================================
--- Zope3/trunk/src/zope/app/locking/adapter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/locking/adapter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -124,10 +124,8 @@
return '<Locking adapter for %s>' % repr(self.context)
class LockingPathAdapter(object):
+ interface.implements(zope.traversing.interfaces.IPathAdapter)
- interface.implements(
- zope.app.traversing.interfaces.IPathAdapter)
-
def __init__(self, target):
self._locking = LockingAdapterFactory(target)
self.lockable = self._locking is not None
Modified: Zope3/trunk/src/zope/app/locking/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/locking/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/locking/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -47,7 +47,7 @@
<class class=".storage.Sized">
<require
permission="zope.Public"
- interface="zope.app.size.interfaces.ISized"
+ interface="zope.size.interfaces.ISized"
/>
</class>
Modified: Zope3/trunk/src/zope/app/locking/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/locking/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/locking/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,9 +18,8 @@
"""
from zope import interface, schema
-from zope.app.event.interfaces import IObjectEvent
+from zope.component.interfaces import ObjectEvent, IObjectEvent
from zope.interface.common.mapping import IMapping
-from zope.app.event.objectevent import ObjectEvent
from zope.app.i18n import ZopeMessageFactory as _
class ILockable(interface.Interface):
Modified: Zope3/trunk/src/zope/app/locking/storage.py
===================================================================
--- Zope3/trunk/src/zope/app/locking/storage.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/locking/storage.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,12 +25,12 @@
from BTrees.IOBTree import IOBTree
from zope import component, interface
+from zope.size.interfaces import ISized
from zope.app.keyreference.interfaces import IKeyReference
from zope.app.locking import interfaces
# for backwards compatibility:
from zope.app.locking.interfaces import ILockStorage
-from zope.app.size.interfaces import ISized
from zope.app.i18n import ZopeMessageFactory as _
Modified: Zope3/trunk/src/zope/app/locking/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/locking/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/locking/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,14 +16,16 @@
$Id:$
"""
-
import sys, unittest, time
-from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.component.testing import PlacelessSetup
import zope.event
from zope.testing import doctest
from transaction import abort
from zope.interface import Interface
+from zope.traversing.interfaces import IPathAdapter
+from zope.security.testing import Principal, Participation
+
from zope.app.testing import ztapi
from zope.app.file.file import File
from zope.app.folder.folder import Folder
@@ -31,11 +33,8 @@
from zope.app.locking.adapter import LockingAdapterFactory
from zope.app.locking.adapter import LockingPathAdapter
from zope.app.locking.storage import ILockStorage, PersistentLockStorage
-from zope.app.traversing.interfaces import IPathAdapter
from zope.app.keyreference.interfaces import IKeyReference
-from zope.security.testing import Principal, Participation
-
class FakeModule:
def __init__(self, dict):
self.__dict = dict
@@ -66,6 +65,9 @@
def __cmp__(self, other):
return cmp(id(self.object), id(other.object))
+def maybeFakeKeyReference(ob):
+ if not isinstance(ob, int):
+ return FakeKeyReference(ob)
class TestLockStorage(unittest.TestCase):
@@ -136,7 +138,7 @@
dict['__name__'] = name
sys.modules[name] = FakeModule(dict)
- ztapi.provideAdapter(Interface, IKeyReference, FakeKeyReference)
+ ztapi.provideAdapter(Interface, IKeyReference, maybeFakeKeyReference)
ztapi.provideAdapter(Interface, ILockable, LockingAdapterFactory)
ztapi.provideAdapter(None, IPathAdapter, LockingPathAdapter,
"locking")
Deleted: Zope3/trunk/src/zope/app/mail/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/app/mail/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,7 +0,0 @@
-transaction
-zope.app
-zope.component
-zope.configuration
-zope.interface
-zope.schema
-zope.security
Deleted: Zope3/trunk/src/zope/app/mail/SETUP.cfg
===================================================================
--- Zope3/trunk/src/zope/app/mail/SETUP.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/SETUP.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,5 +0,0 @@
-# Tell zpkg how to install the ZCML slugs.
-
-<data-files zopeskel/etc/package-includes>
- mail-*.zcml
-</data-files>
Modified: Zope3/trunk/src/zope/app/mail/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1 +1,7 @@
-# make this directory a package
+# This module has moved to zope.sendmail
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.sendmail',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/mail/__init__.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.2
Name: svn:keywords
+ Id
Deleted: Zope3/trunk/src/zope/app/mail/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/mail/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,31 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:mail="http://namespaces.zope.org/mail"
- i18n_domain="zope"
- >
-
- <permission
- id="zope.SendMail"
- title="[send-mail-permission]
- Send out mail with arbitrary from and to addresses"
- />
-
- <mail:smtpMailer name="smtp" hostname="localhost" port="25" />
-
- <!--
- To send mail, uncomment the following directive and be sure to
- create the queue directory.
-
- <mail:queuedDelivery permission="zope.SendMail"
- queuePath="./queue"
- mailer="smtp" />
- -->
-
- <interface interface="zope.app.mail.interfaces.IMailDelivery" />
-
- <utility
- component=".vocabulary.MailDeliveryNames"
- name="Mail Delivery Names"
- />
-
-</configure>
Modified: Zope3/trunk/src/zope/app/mail/delivery.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/delivery.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/delivery.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,226 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Mail Delivery utility implementation
-
-This module contains various implementations of `MailDeliverys`.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import rfc822
-import threading
-import logging
-import atexit
-import time
-from os import unlink, getpid
-from cStringIO import StringIO
-from random import randrange
-from time import strftime
-from socket import gethostname
-
-from zope.interface import implements
-from zope.app.mail.interfaces import IDirectMailDelivery, IQueuedMailDelivery
-from zope.app.mail.maildir import Maildir
-from transaction.interfaces import IDataManager
-import transaction
-
-
-class MailDataManager(object):
- implements(IDataManager)
-
- def __init__(self, callable, args=(), onAbort=None):
- self.callable = callable
- self.args = args
- self.onAbort = onAbort
- # Use the default thread transaction manager.
- self.transaction_manager = transaction.manager
-
- def commit(self, transaction):
- pass
-
- def abort(self, transaction):
- if self.onAbort:
- self.onAbort()
-
- def sortKey(self):
- return id(self)
-
- # No subtransaction support.
- def abort_sub(self, transaction):
- pass
-
- commit_sub = abort_sub
-
- def beforeCompletion(self, transaction):
- pass
-
- afterCompletion = beforeCompletion
-
- def tpc_begin(self, transaction, subtransaction=False):
- assert not subtransaction
-
- def tpc_vote(self, transaction):
- pass
-
- def tpc_finish(self, transaction):
- self.callable(*self.args)
-
- tpc_abort = abort
-
-
-class AbstractMailDelivery(object):
-
- def newMessageId(self):
- """Generates a new message ID according to RFC 2822 rules"""
- randmax = 0x7fffffff
- left_part = '%s.%d.%d' % (strftime('%Y%m%d%H%M%S'),
- getpid(),
- randrange(0, randmax))
- return "%s@%s" % (left_part, gethostname())
-
- def send(self, fromaddr, toaddrs, message):
- parser = rfc822.Message(StringIO(message))
- messageid = parser.getheader('Message-Id')
- if messageid:
- if not messageid.startswith('<') or not messageid.endswith('>'):
- raise ValueError('Malformed Message-Id header')
- messageid = messageid[1:-1]
- else:
- messageid = self.newMessageId()
- message = 'Message-Id: <%s>\n%s' % (messageid, message)
- transaction.get().join(
- self.createDataManager(fromaddr, toaddrs, message))
- return messageid
-
-
-class DirectMailDelivery(AbstractMailDelivery):
- __doc__ = IDirectMailDelivery.__doc__
-
- implements(IDirectMailDelivery)
-
- def __init__(self, mailer):
- self.mailer = mailer
-
- def createDataManager(self, fromaddr, toaddrs, message):
- return MailDataManager(self.mailer.send,
- args=(fromaddr, toaddrs, message))
-
-
-class QueuedMailDelivery(AbstractMailDelivery):
- __doc__ = IQueuedMailDelivery.__doc__
-
- implements(IQueuedMailDelivery)
-
- def __init__(self, queuePath):
- self._queuePath = queuePath
-
- queuePath = property(lambda self: self._queuePath)
-
- def createDataManager(self, fromaddr, toaddrs, message):
- maildir = Maildir(self.queuePath, True)
- msg = maildir.newMessage()
- msg.write('X-Zope-From: %s\n' % fromaddr)
- msg.write('X-Zope-To: %s\n' % ", ".join(toaddrs))
- msg.write(message)
- return MailDataManager(msg.commit, onAbort=msg.abort)
-
-
-class QueueProcessorThread(threading.Thread):
- """This thread is started at configuration time from the
- `mail:queuedDelivery` directive handler.
- """
-
- log = logging.getLogger("QueueProcessorThread")
- __stopped = False
-
- def __init__(self):
- threading.Thread.__init__(self)
-
- def setMaildir(self, maildir):
- """Set the maildir.
-
- This method is used just to provide a `maildir` stubs ."""
- self.maildir = maildir
-
- def setQueuePath(self, path):
- self.maildir = Maildir(path, True)
-
- def setMailer(self, mailer):
- self.mailer = mailer
-
- def _parseMessage(self, message):
- """Extract fromaddr and toaddrs from the first two lines of
- the `message`.
-
- Returns a fromaddr string, a toaddrs tuple and the message
- string.
- """
-
- fromaddr = ""
- toaddrs = ()
- rest = ""
-
- try:
- first, second, rest = message.split('\n', 2)
- except ValueError:
- return fromaddr, toaddrs, message
-
- if first.startswith("X-Zope-From: "):
- i = len("X-Zope-From: ")
- fromaddr = first[i:]
-
- if second.startswith("X-Zope-To: "):
- i = len("X-Zope-To: ")
- toaddrs = tuple(second[i:].split(", "))
-
- return fromaddr, toaddrs, rest
-
- def run(self, forever=True):
- atexit.register(self.stop)
- while not self.__stopped:
- for filename in self.maildir:
- fromaddr = ''
- toaddrs = ()
- try:
- file = open(filename)
- message = file.read()
- file.close()
- fromaddr, toaddrs, message = self._parseMessage(message)
- self.mailer.send(fromaddr, toaddrs, message)
- unlink(filename)
- # TODO: maybe log the Message-Id of the message sent
- self.log.info("Mail from %s to %s sent.",
- fromaddr, ", ".join(toaddrs))
- # Blanket except because we don't want
- # this thread to ever die
- except:
- if fromaddr != '' or toaddrs != ():
- self.log.error(
- "Error while sending mail from %s to %s.",
- fromaddr, ", ".join(toaddrs), exc_info=True)
- else:
- self.log.error(
- "Error while sending mail : %s ",
- filename, exc_info=True)
- else:
- if forever:
- time.sleep(3)
-
- # A testing plug
- if not forever:
- break
-
- def stop(self):
- self.__stopped = True
+# This module has moved to zope.sendmail.delivery
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.sendmail.delivery',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/mail/delivery.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.1
Modified: Zope3/trunk/src/zope/app/mail/event.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/event.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/event.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,41 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Collection of possible Mail Events.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.interface import implements
-
-from zope.app.mail.interfaces import IMailSentEvent, IMailErrorEvent
-
-
-class MailSentEvent(object):
- __doc__ = IMailSentEvent.__doc__
-
- implements(IMailSentEvent)
-
- def __init__(self, messageId):
- self.messageId = messageId
-
-
-class MailErrorEvent(object):
- __doc__ = IMailErrorEvent.__doc__
-
- implements(IMailErrorEvent)
-
- def __init__(self, messageId, errorMessage):
- self.messageId = messageId
- self.errorMessage = errorMessage
+# This module has moved to zope.sendmail.event
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.sendmail.event',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/mail/event.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.4
Modified: Zope3/trunk/src/zope/app/mail/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,262 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Mailer interfaces
-
-Email sending from Zope 3 applications works as follows:
-
-- A Zope 3 application locates a mail delivery utility (`IMailDelivery`) and
- feeds a message to it. It gets back a unique message ID so it can keep
- track of the message by subscribing to `IMailEvent` events.
-
-- The utility registers with the transaction system to make sure the
- message is only sent when the transaction commits successfully. (Among
- other things this avoids duplicate messages on `ConflictErrors`.)
-
-- If the delivery utility is a `IQueuedMailDelivery`, it puts the message into
- a queue (a Maildir mailbox in the file system). A separate process or thread
- (`IMailQueueProcessor`) watches the queue and delivers messages
- asynchronously. Since the queue is located in the file system, it survives
- Zope restarts or crashes and the mail is not lost. The queue processor
- can implement batching to keep the server load low.
-
-- If the delivery utility is a `IDirectMailDelivery`, it delivers messages
- synchronously during the transaction commit. This is not a very good idea,
- as it makes the user wait. Note that transaction commits must not fail,
- but that is not a problem, because mail delivery problems dispatch an
- event instead of raising an exception.
-
- However, there is a problem -- sending events causes unknown code to be
- executed during the transaction commit phase. There should be a way to
- start a new transaction for event processing after this one is commited.
-
-- An `IMailQueueProcessor` or `IDirectMailDelivery` actually delivers the
- messages by using a mailer (`IMailer`) component that encapsulates the
- delivery process. There currently is only one mailer:
-
- - `ISMTPMailer` sends all messages to a relay host using SMTP
-
-- If mail delivery succeeds, an `IMailSentEvent` is dispatched by the mailer.
- If mail delivery fails, no exceptions are raised, but an `IMailErrorEvent` is
- dispatched by the mailer.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.interface import Interface, Attribute
-from zope.schema import Object, TextLine, Int, Password, BytesLine
-
-from zope.app.i18n import ZopeMessageFactory as _
-
-
-class IMailDelivery(Interface):
- """A mail delivery utility allows someone to send an email to a group of
- people."""
-
- def send(fromaddr, toaddrs, message):
- """Send an email message.
-
- `fromaddr` is the sender address (byte string),
-
- `toaddrs` is a sequence of recipient addresses (byte strings).
-
- `message` is a byte string that contains both headers and body
- formatted according to RFC 2822. If it does not contain a Message-Id
- header, it will be generated and added automatically.
-
- Returns the message ID.
-
- You can subscribe to `IMailEvent` events for notification about
- problems or successful delivery.
-
- Messages are actually sent during transaction commit.
- """
-
-
-class IDirectMailDelivery(IMailDelivery):
- """A mail delivery utility that delivers messages synchronously during
- transaction commit.
-
- Not useful for production use, but simpler to set up and use.
- """
-
- mailer = Attribute("IMailer that is used for message delivery")
-
-
-class IQueuedMailDelivery(IMailDelivery):
- """A mail delivery utility that puts all messages into a queue in the
- filesystem.
-
- Messages will be delivered asynchronously by a separate component.
- """
-
- queuePath = TextLine(
- title=_(u"Queue path"),
- description=_(u"Pathname of the directory used to queue mail."))
-
-
-class IMailQueueProcessor(Interface):
- """A mail queue processor that delivers queueud messages asynchronously.
- """
-
- queuePath = TextLine(
- title=_(u"Queue Path"),
- description=_(u"Pathname of the directory used to queue mail."))
-
- pollingInterval = Int(
- title=_(u"Polling Interval"),
- description=_(u"How often the queue is checked for new messages"
- " (in milliseconds)"),
- default=5000)
-
- mailer = Attribute("IMailer that is used for message delivery")
-
-
-class IMailer(Interface):
- """Mailer handles synchronous mail delivery."""
-
- def send(fromaddr, toaddrs, message):
- """Send an email message.
-
- `fromaddr` is the sender address (unicode string),
-
- `toaddrs` is a sequence of recipient addresses (unicode strings).
-
- `message` contains both headers and body formatted according to RFC
- 2822. It should contain at least Date, From, To, and Message-Id
- headers.
-
- Messages are sent immediatelly.
-
- Dispatches an `IMailSentEvent` on successful delivery, otherwise an
- `IMailErrorEvent`.
- """
-
-
-class ISMTPMailer(IMailer):
- """A mailer that delivers mail to a relay host via SMTP."""
-
- hostname = TextLine(
- title=_(u"Hostname"),
- description=_(u"Name of server to be used as SMTP server."))
-
- port = Int(
- title=_(u"Port"),
- description=_(u"Port of SMTP service"),
- default=25)
-
- username = TextLine(
- title=_(u"Username"),
- description=_(u"Username used for optional SMTP authentication."))
-
- password = Password(
- title=_(u"Password"),
- description=_(u"Password used for optional SMTP authentication."))
-
-
-class IMailEvent(Interface):
- """Generic mail event."""
-
- messageId = Attribute("Message id according to RFC 2822")
-
-
-class IMailSentEvent(IMailEvent):
- """Event that is fired when a message is succesfully sent.
-
- This does not mean that all the recipients have received it, it only
- means that the message left this system successfully. It is possible
- that a bounce message will arrive later from some remote mail server.
- """
-
-
-class IMailErrorEvent(IMailEvent):
- """Event that is fired when a message cannot be delivered."""
-
- errorMessage = Attribute("Error message")
-
-
-
-class IMaildirFactory(Interface):
-
- def __call__(dirname, create=False):
- """Opens a `Maildir` folder at a given filesystem path.
-
- If `create` is ``True``, the folder will be created when it does not
- exist. If `create` is ``False`` and the folder does not exist, an
- exception (``OSError``) will be raised.
-
- If path points to a file or an existing directory that is not a
- valid `Maildir` folder, an exception is raised regardless of the
- `create` argument.
- """
-
-
-class IMaildir(Interface):
- """Read/write access to `Maildir` folders.
-
- See http://www.qmail.org/man/man5/maildir.html for detailed format
- description.
- """
-
- def __iter__():
- """Returns an iterator over the pathnames of messages in this folder.
- """
-
- def newMessage():
- """Creates a new message in the `maildir`.
-
- Returns a file-like object for a new file in the ``tmp`` subdirectory
- of the `Maildir`. After writing message contents to it, call the
- ``commit()`` or ``abort()`` method on it.
-
- The returned object implements `IMaildirMessageWriter`.
- """
-
-
-class IMaildirMessageWriter(Interface):
- """A file-like object to a new message in a `Maildir`."""
-
- def write(str):
- """Writes a string to the file.
-
- There is no return value. Due to buffering, the string may not actually
- show up in the file until the ``commit()`` method is called.
- """
-
- def writelines(sequence):
- """Writes a sequence of strings to the file.
-
- The sequence can be any iterable object producing strings, typically a
- list of strings. There is no return value. ``writelines`` does not add
- any line separators.
- """
-
- def commit():
- """Commits the new message using the `Maildir` protocol.
-
- First, the message file is flushed, closed, then it is moved from
- ``tmp`` into ``new`` subdirectory of the maildir.
-
- Calling ``commit()`` more than once is allowed.
- """
-
- def abort():
- """Aborts the new message.
-
- The message file is closed and removed from the ``tmp`` subdirectory
- of the `maildir`.
-
- Calling ``abort()`` more than once is allowed.
- """
-
+# This module has moved to zope.sendmail.interfaces
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.sendmail.interfaces',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/mail/interfaces.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.1
Deleted: Zope3/trunk/src/zope/app/mail/mail-configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/mail/mail-configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/mail-configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1 +0,0 @@
-<include package="zope.app.mail"/>
Deleted: Zope3/trunk/src/zope/app/mail/mail-meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/mail/mail-meta.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/mail-meta.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1 +0,0 @@
-<include package="zope.app.mail" file="meta.zcml"/>
Modified: Zope3/trunk/src/zope/app/mail/maildir.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/maildir.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/maildir.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,145 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Read/write access to `Maildir` folders.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import os
-import socket
-import time
-import random
-
-from zope.interface import implements, classProvides
-
-from zope.app.mail.interfaces import \
- IMaildirFactory, IMaildir, IMaildirMessageWriter
-
-
-class Maildir(object):
- """See `zope.app.interfaces.mail.IMaildir`"""
-
- classProvides(IMaildirFactory)
- implements(IMaildir)
-
- def __init__(self, path, create=False):
- "See `zope.app.interfaces.mail.IMaildirFactory`"
- self.path = path
-
- def access(path):
- return os.access(path, os.F_OK)
-
- subdir_cur = os.path.join(path, 'cur')
- subdir_new = os.path.join(path, 'new')
- subdir_tmp = os.path.join(path, 'tmp')
-
- if create and not access(path):
- os.mkdir(path)
- os.mkdir(subdir_cur)
- os.mkdir(subdir_new)
- os.mkdir(subdir_tmp)
- maildir = True
- else:
- maildir = (os.path.isdir(subdir_cur) and os.path.isdir(subdir_new)
- and os.path.isdir(subdir_tmp))
- if not maildir:
- raise ValueError('%s is not a Maildir folder' % path)
-
- def __iter__(self):
- "See `zope.app.interfaces.mail.IMaildir`"
- join = os.path.join
- subdir_cur = join(self.path, 'cur')
- subdir_new = join(self.path, 'new')
- # http://www.qmail.org/man/man5/maildir.html says:
- # "It is a good idea for readers to skip all filenames in new
- # and cur starting with a dot. Other than this, readers
- # should not attempt to parse filenames."
- new_messages = [join(subdir_new, x) for x in os.listdir(subdir_new)
- if not x.startswith('.')]
- cur_messages = [join(subdir_cur, x) for x in os.listdir(subdir_cur)
- if not x.startswith('.')]
- return iter(new_messages + cur_messages)
-
- def newMessage(self):
- "See `zope.app.interfaces.mail.IMaildir`"
- # NOTE: http://www.qmail.org/man/man5/maildir.html says, that the first
- # step of the delivery process should be a chdir. Chdirs and
- # threading do not mix. Is that chdir really necessary?
- join = os.path.join
- subdir_tmp = join(self.path, 'tmp')
- subdir_new = join(self.path, 'new')
- pid = os.getpid()
- host = socket.gethostname()
- randmax = 0x7fffffff
- counter = 0
- while True:
- timestamp = int(time.time())
- unique = '%d.%d.%s.%d' % (timestamp, pid, host,
- random.randrange(randmax))
- filename = join(subdir_tmp, unique)
- try:
- fd = os.open(filename, os.O_CREAT|os.O_EXCL|os.O_WRONLY, 0600)
- except OSError:
- # File exists
- counter += 1
- if counter >= 1000:
- raise RuntimeError("Failed to create unique file name"
- " in %s, are we under a DoS attack?"
- % subdir_tmp)
- # NOTE: maildir.html (see above) says I should sleep for 2
- time.sleep(0.1)
- else:
- break
- return MaildirMessageWriter(os.fdopen(fd, 'w'), filename,
- join(subdir_new, unique))
-
-
-class MaildirMessageWriter(object):
- """See `zope.app.interfaces.mail.IMaildirMessageWriter`"""
-
- implements(IMaildirMessageWriter)
-
- def __init__(self, fd, filename, new_filename):
- self._filename = filename
- self._new_filename = new_filename
- self._fd = fd
- self._closed = False
- self._aborted = False
-
- def write(self, data):
- self._fd.write(data)
-
- def writelines(self, lines):
- self._fd.writelines(lines)
-
- def commit(self):
- if self._closed and self._aborted:
- raise RuntimeError('Cannot commit, message already aborted')
- elif not self._closed:
- self._closed = True
- self._aborted = False
- self._fd.close()
- os.rename(self._filename, self._new_filename)
- # NOTE: the same maildir.html says it should be a link, followed by
- # unlink. But Win32 does not necessarily have hardlinks!
-
- def abort(self):
- if not self._closed:
- self._closed = True
- self._aborted = True
- self._fd.close()
- os.unlink(self._filename)
-
- # should there be a __del__ that does abort()?
+# This module has moved to zope.sendmail.maildir
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.sendmail.maildir',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/mail/maildir.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.4
Modified: Zope3/trunk/src/zope/app/mail/mailer.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/mailer.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/mailer.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,46 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-
-"""These are classes which abstract different channels an email
-message could be sent out by.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from smtplib import SMTP
-
-from zope.interface import implements
-from zope.app.mail.interfaces import ISMTPMailer
-
-
-class SMTPMailer(object):
-
- implements(ISMTPMailer)
-
- smtp = SMTP
-
- def __init__(self, hostname='localhost', port=25,
- username=None, password=None):
- self.hostname = hostname
- self.port = port
- self.username = username
- self.password = password
-
- def send(self, fromaddr, toaddrs, message):
- connection = self.smtp(self.hostname, str(self.port))
- if self.username is not None and self.password is not None:
- connection.login(self.username, self.password)
- connection.sendmail(fromaddr, toaddrs, message)
- connection.quit()
+# This module has moved to zope.sendmail.mailer
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.sendmail.mailer',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/mail/mailer.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.6
Deleted: Zope3/trunk/src/zope/app/mail/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/mail/meta.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/meta.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,23 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:meta="http://namespaces.zope.org/meta">
-
- <meta:directive
- namespace="http://namespaces.zope.org/mail"
- name="queuedDelivery"
- schema=".metadirectives.IQueuedDeliveryDirective"
- handler=".metaconfigure.queuedDelivery" />
-
- <meta:directive
- namespace="http://namespaces.zope.org/mail"
- name="directDelivery"
- schema=".metadirectives.IDirectDeliveryDirective"
- handler=".metaconfigure.directDelivery" />
-
- <meta:directive
- namespace="http://namespaces.zope.org/mail"
- name="smtpMailer"
- schema=".metadirectives.ISMTPMailerDirective"
- handler=".metaconfigure.smtpMailer" />
-
-</configure>
Deleted: Zope3/trunk/src/zope/app/mail/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,89 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""mail ZCML Namespace handler
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.configuration.exceptions import ConfigurationError
-
-from zope.security.checker import InterfaceChecker, CheckerPublic
-
-from zope.app import zapi
-from zope.app.component.metaconfigure import handler, proxify, PublicPermission
-from zope.app.mail.delivery import QueuedMailDelivery, DirectMailDelivery
-from zope.app.mail.delivery import QueueProcessorThread
-from zope.app.mail.interfaces import IMailer, IMailDelivery
-from zope.app.mail.mailer import SMTPMailer
-
-
-def _assertPermission(permission, interfaces, component):
- if permission is not None:
- if permission == PublicPermission:
- permission = CheckerPublic
- checker = InterfaceChecker(interfaces, permission)
-
- return proxify(component, checker)
-
-
-def queuedDelivery(_context, permission, queuePath, mailer, name="Mail"):
-
- def createQueuedDelivery():
- delivery = QueuedMailDelivery(queuePath)
- delivery = _assertPermission(permission, IMailDelivery, delivery)
-
- handler('provideUtility', IMailDelivery, delivery, name)
-
- mailerObject = zapi.queryUtility(IMailer, mailer)
- if mailerObject is None:
- raise ConfigurationError("Mailer %r is not defined" %mailer)
-
- thread = QueueProcessorThread()
- thread.setMailer(mailerObject)
- thread.setQueuePath(queuePath)
- thread.start()
-
- _context.action(
- discriminator = ('delivery', name),
- callable = createQueuedDelivery,
- args = () )
-
-
-def directDelivery(_context, permission, mailer, name="Mail"):
-
- def createDirectDelivery():
- mailerObject = zapi.queryUtility(IMailer, mailer)
- if mailerObject is None:
- raise ConfigurationError("Mailer %r is not defined" %mailer)
-
- delivery = DirectMailDelivery(mailerObject)
- delivery = _assertPermission(permission, IMailDelivery, delivery)
-
- handler('provideUtility', IMailDelivery, delivery, name)
-
- _context.action(
- discriminator = ('utility', IMailDelivery, name),
- callable = createDirectDelivery,
- args = () )
-
-
-def smtpMailer(_context, name, hostname="localhost", port="25",
- username=None, password=None):
- _context.action(
- discriminator = ('utility', IMailer, name),
- callable = handler,
- args = ('provideUtility',
- IMailer, SMTPMailer(hostname, port, username, password), name)
- )
Deleted: Zope3/trunk/src/zope/app/mail/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/metadirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/metadirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,95 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""'mail' ZCML Namespaces Schemas
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.configuration.fields import Path
-from zope.interface import Interface
-from zope.schema import TextLine, ASCII, BytesLine, Int
-from zope.app.security.fields import Permission
-
-
-class IDeliveryDirective(Interface):
- """This abstract directive describes a generic mail delivery utility
- registration."""
-
- name = TextLine(
- title=u"Name",
- description=u'Specifies the Delivery name of the mail utility. '\
- u'The default is "Mail".',
- default=u"Mail",
- required=False)
-
- permission = Permission(
- title=u"Permission",
- description=u"Defines the permission needed to use this service.",
- required=True)
-
- mailer = TextLine(
- title=u"Mailer",
- description=u"Defines the mailer to be used for sending mail.",
- required=True)
-
-
-class IQueuedDeliveryDirective(IDeliveryDirective):
- """This directive creates and registers a global queued mail utility. It
- should be only called once during startup."""
-
- queuePath = Path(
- title=u"Queue Path",
- description=u"Defines the path for the queue directory.",
- required=True)
-
-
-class IDirectDeliveryDirective(IDeliveryDirective):
- """This directive creates and registers a global direct mail utility. It
- should be only called once during startup."""
-
-
-class IMailerDirective(Interface):
- """A generic directive registering a mailer for the mail utility."""
-
- name = TextLine(
- title=u"Name",
- description=u"Name of the Mailer.",
- required=True)
-
-
-class ISMTPMailerDirective(IMailerDirective):
- """Registers a new SMTP mailer."""
-
- hostname = BytesLine(
- title=u"Hostname",
- description=u"Hostname of the SMTP host.",
- default="localhost",
- required=False)
-
- port = Int(
- title=u"Port",
- description=u"Port of the SMTP server.",
- default=25,
- required=False)
-
- username = TextLine(
- title=u"Username",
- description=u"A username for SMTP AUTH.",
- required=False)
-
- password = TextLine(
- title=u"Password",
- description=u"A password for SMTP AUTH.",
- required=False)
Modified: Zope3/trunk/src/zope/app/mail/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/mail/vocabulary.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/mail/vocabulary.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,25 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2006 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Mail vocabularies
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.interface import classProvides
-from zope.app.schema.interfaces import IVocabularyFactory
-from zope.app.component.vocabulary import UtilityVocabulary
-
-class MailDeliveryNames(UtilityVocabulary):
- classProvides(IVocabularyFactory)
+# This module has moved to zope.sendmail.vocabulary
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.sendmail.vocabulary',
+ "Zope 3.5",
+ )
Modified: Zope3/trunk/src/zope/app/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/meta.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/meta.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -8,7 +8,7 @@
<include package="zope.app.publisher" file="meta.zcml" />
<include package="zope.app.security" file="meta.zcml" />
<include package="zope.app.form.browser" file="meta.zcml" />
-<include package="zope.app.i18n" file="meta.zcml" />
+<include package="zope.i18n" file="meta.zcml" />
<include package="zope.app.pagetemplate" file="meta.zcml" />
<include package="zope.app.schema" file="meta.zcml" />
<include package="zope.app.container.browser" file="meta.zcml" />
Modified: Zope3/trunk/src/zope/app/module/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/module/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/module/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -113,7 +113,7 @@
>>> ZopeModuleRegistry.findModule('mymodule') is module
True
>>> ZopeModuleRegistry.modules()
- ['mymodule']
+ [u'mymodule']
Additionally, the package provides two API functions that look up a module in
the registry and then in `sys.modules`:
@@ -149,4 +149,4 @@
>>> zope.app.module.uninstallPersistentModuleImporter(event)
>>> __builtin__.__import__
- <built-in function __import__>
\ No newline at end of file
+ <built-in function __import__>
Modified: Zope3/trunk/src/zope/app/module/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/module/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/module/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -8,19 +8,13 @@
/>
</localUtility>
- <subscriber
- for="..component.interfaces.registration.IRegistrationActivatedEvent"
- handler=".manager.setNameOnActivation"
- />
+ <subscriber handler=".manager.setNameOnActivation" />
- <subscriber
- for="..component.interfaces.registration.IRegistrationDeactivatedEvent"
- handler=".manager.unsetNameOnDeactivation"
- />
+ <subscriber handler=".manager.unsetNameOnDeactivation" />
<adapter
for="zope.app.component.interfaces.ISiteManagementFolder"
- provides="zope.app.filerepresentation.interfaces.IFileFactory"
+ provides="zope.filerepresentation.interfaces.IFileFactory"
name=".py"
factory=".manager.ModuleFactory"
permission="zope.ManageContent"
Modified: Zope3/trunk/src/zope/app/module/manager.py
===================================================================
--- Zope3/trunk/src/zope/app/module/manager.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/module/manager.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,9 +19,10 @@
import persistent
import zodbcode.module
import zope.interface
+import zope.component
+from zope.filerepresentation.interfaces import IFileFactory
from zope.app.container.contained import Contained
-from zope.app.filerepresentation.interfaces import IFileFactory
from zope.app.module.interfaces import IModuleManager
from zope.app.module import ZopeModuleRegistry
@@ -63,7 +64,13 @@
# See zope.app.module.interfaces.IModuleManager
source = property(_getSource, _setSource)
+ def _setName(self, name):
+ self.__dict__['name'] = name
+ self._recompile = True
+ name = property(lambda self: self.__dict__['name'], _setName)
+
+
class ModuleFactory(object):
"""Special factory for creating module managers in site managment
folders."""
@@ -81,17 +88,14 @@
m.execute()
return m
-
-def setNameOnActivation(event):
+ at zope.component.adapter(IModuleManager,
+ zope.component.interfaces.IRegistered)
+def setNameOnActivation(manager, event):
"""Set the module name upon registration activation."""
- module = event.object.component
- if isinstance(module, ModuleManager):
- module.name = event.object.name
- module._recompile = True
+ manager.name = event.object.name
-def unsetNameOnDeactivation(event):
+ at zope.component.adapter(IModuleManager,
+ zope.component.interfaces.IUnregistered)
+def unsetNameOnDeactivation(manager, event):
"""Unset the permission id up registration deactivation."""
- module = event.object.component
- if isinstance(module, ModuleManager):
- module.name = None
- module._recompile = True
+ manager.name = None
Modified: Zope3/trunk/src/zope/app/module/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/module/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/module/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,19 +18,15 @@
__docformat__ = "reStructuredText"
import unittest
+import zope.component
from zope.testing import doctest
-from zope.app.component import interfaces
from zope.app.module import manager
-from zope.app.testing import setup, ztapi
+from zope.app.testing import setup
def setUp(test):
setup.placefulSetUp()
- ztapi.subscribe(
- (interfaces.registration.IRegistrationActivatedEvent,), None,
- manager.setNameOnActivation)
- ztapi.subscribe(
- (interfaces.registration.IRegistrationDeactivatedEvent,), None,
- manager.unsetNameOnDeactivation)
+ zope.component.provideHandler(manager.setNameOnActivation)
+ zope.component.provideHandler(manager.unsetNameOnDeactivation)
def tearDown(test):
setup.placefulTearDown()
Modified: Zope3/trunk/src/zope/app/onlinehelp/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/app/onlinehelp/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/onlinehelp/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,10 +1,10 @@
persistent
zope.app
zope.app.file
-zope.app.contenttypes
zope.app.renderer
zope.app.i18n
zope.configuration
+zope.contenttype
zope.interface
zope.proxy
zope.schema
Modified: Zope3/trunk/src/zope/app/onlinehelp/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/onlinehelp/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/onlinehelp/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -61,7 +61,7 @@
>>> import os
>>> from tests.test_onlinehelp import testdir
>>> from tests.test_onlinehelp import I1, Dummy1, Dummy2
- >>> from zope.app.tests import ztapi
+ >>> from zope.app.testing import ztapi
>>> from zope.component.interfaces import IFactory
>>> from zope.component.factory import Factory
>>> from zope.app.onlinehelp.onlinehelptopic import OnlineHelpTopic
Modified: Zope3/trunk/src/zope/app/onlinehelp/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/onlinehelp/browser/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/onlinehelp/browser/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,11 +18,11 @@
__docformat__ = 'restructuredtext'
from zope.security.proxy import removeSecurityProxy
+from zope.publisher.browser import BrowserView
+from zope.publisher.interfaces.browser import IBrowserView
from zope.app import zapi
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.app.publisher.browser import BrowserView
-from zope.app.publisher.interfaces.browser import IBrowserView
from zope.app.onlinehelp.interfaces import IOnlineHelpTopic, IOnlineHelp
from zope.app.onlinehelp import getTopicFor
Modified: Zope3/trunk/src/zope/app/onlinehelp/browser/tree.py
===================================================================
--- Zope3/trunk/src/zope/app/onlinehelp/browser/tree.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/onlinehelp/browser/tree.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,13 +18,11 @@
__docformat__ = 'restructuredtext'
from zope.i18n import translate
+from zope.publisher.browser import BrowserView
from zope.app import zapi
-from zope.app.publisher.browser import BrowserView
-
from zope.app.onlinehelp.interfaces import IOnlineHelp
-
class OnlineHelpTopicTreeView(BrowserView):
"""Online help topic tree view."""
Modified: Zope3/trunk/src/zope/app/onlinehelp/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/onlinehelp/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/onlinehelp/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -66,14 +66,14 @@
<view
name="help"
type="*"
- provides="zope.app.traversing.interfaces.ITraversable"
+ provides="zope.traversing.interfaces.ITraversable"
for="*"
factory=".helpNamespace"
/>
<adapter
name="help"
- provides="zope.app.traversing.interfaces.ITraversable"
+ provides="zope.traversing.interfaces.ITraversable"
for="*"
factory=".helpNamespace"
/>
Modified: Zope3/trunk/src/zope/app/onlinehelp/onlinehelp.py
===================================================================
--- Zope3/trunk/src/zope/app/onlinehelp/onlinehelp.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/onlinehelp/onlinehelp.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -24,16 +24,16 @@
from zope.interface import implements
from zope.configuration.exceptions import ConfigurationError
+from zope.traversing.interfaces import IContainmentRoot
from zope.app import zapi
-from zope.app.traversing.interfaces import IContainmentRoot
from zope.app.onlinehelp.interfaces import IOnlineHelp, IOnlineHelpTopic
from zope.app.onlinehelp.onlinehelptopic import OnlineHelpTopic
class OnlineHelp(OnlineHelpTopic):
"""
>>> import os
- >>> from zope.app.tests import ztapi
+ >>> from zope import component
>>> from zope.component.interfaces import IFactory
>>> from zope.component.factory import Factory
>>> from zope.app.onlinehelp.tests.test_onlinehelp import testdir
@@ -47,7 +47,7 @@
First do the interface verifying tests.
>>> from zope.interface.verify import verifyObject
- >>> from zope.app.traversing.interfaces import IContainmentRoot
+ >>> from zope.traversing.interfaces import IContainmentRoot
>>> verifyObject(IOnlineHelp, onlinehelp)
True
>>> verifyObject(IContainmentRoot, onlinehelp)
@@ -63,10 +63,10 @@
>>> rest = Factory(RESTOnlineHelpTopic)
>>> stx = Factory(STXOnlineHelpTopic)
>>> zpt = Factory(ZPTOnlineHelpTopic)
- >>> ztapi.provideUtility(IFactory, default, 'onlinehelp.topic.default')
- >>> ztapi.provideUtility(IFactory, rest, 'onlinehelp.topic.rest')
- >>> ztapi.provideUtility(IFactory, stx, 'onlinehelp.topic.stx')
- >>> ztapi.provideUtility(IFactory, zpt, 'onlinehelp.topic.zpt')
+ >>> component.provideUtility(default, IFactory, 'onlinehelp.topic.default')
+ >>> component.provideUtility(rest, IFactory, 'onlinehelp.topic.rest')
+ >>> component.provideUtility(stx, IFactory, 'onlinehelp.topic.stx')
+ >>> component.provideUtility(zpt, IFactory, 'onlinehelp.topic.zpt')
>>> path = os.path.join(testdir(), 'help2.txt')
>>> onlinehelp.registerHelpTopic('', 'help2', 'Help 2',
... path, I1, 'view.html')
@@ -153,5 +153,5 @@
#utils = zapi.getService(Utilities)
#utils.provideUtility(IOnlineHelpTopic, topic, topic.getTopicPath())
- zapi.getGlobalSiteManager().provideUtility(
- IOnlineHelpTopic, topic, topic.getTopicPath())
+ zapi.getGlobalSiteManager().registerUtility(
+ topic, IOnlineHelpTopic, topic.getTopicPath())
Modified: Zope3/trunk/src/zope/app/onlinehelp/onlinehelptopic.py
===================================================================
--- Zope3/trunk/src/zope/app/onlinehelp/onlinehelptopic.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/onlinehelp/onlinehelptopic.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,9 +23,9 @@
from persistent import Persistent
from zope.interface import implements
from zope.configuration.exceptions import ConfigurationError
+from zope.contenttype import guess_content_type
from zope.app.container.sample import SampleContainer
-from zope.app.contenttypes import guess_content_type
from zope.app.file.image import getImageInfo
from zope.app.onlinehelp.interfaces import IOnlineHelpTopic
@@ -389,8 +389,7 @@
r"""Represents a page template based Help Topic which has other
filename extension than `.pt`.
- >>> from zope.publisher.browser import TestRequest
- >>> from zope.app.publisher.browser import BrowserView
+ >>> from zope.publisher.browser import TestRequest, BrowserView
>>> from zope.app.pagetemplate.viewpagetemplatefile import \
... ViewPageTemplateFile
>>> from zope.app.onlinehelp.tests.test_onlinehelp import testdir
@@ -469,11 +468,11 @@
import sys
-from zope.app.publisher.browser import BrowserView
+from zope.interface import implements
+from zope.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPublisher
-from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.publisher.interfaces import NotFound
-from zope.interface import implements
+from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
class simple(BrowserView):
Modified: Zope3/trunk/src/zope/app/onlinehelp/tests/test_helpdirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/onlinehelp/tests/test_helpdirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/onlinehelp/tests/test_helpdirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,27 +17,27 @@
"""
import unittest
-import zope.app.component
-import zope.app.security
-import zope.app.onlinehelp
-
from zope.interface import Interface
from zope.configuration import xmlconfig
from zope.configuration.xmlconfig import XMLConfig
from zope.component.interfaces import IFactory
from zope.component.factory import Factory
-from zope.app.traversing.interfaces import IPhysicallyLocatable
-from zope.app.traversing.interfaces import ITraverser, ITraversable
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.traversing.interfaces import ITraverser, ITraversable
+from zope.traversing.adapters import Traverser, DefaultTraversable
+from zope.location.traversing import LocationPhysicallyLocatable
+from zope.security.interfaces import IPermission
+from zope.security.permission import Permission
+
+import zope.app.component
+import zope.app.security
+import zope.app.onlinehelp
from zope.app.onlinehelp import tests
from zope.app.onlinehelp import globalhelp
from zope.app.onlinehelp.onlinehelptopic import OnlineHelpTopic
from zope.app.onlinehelp.onlinehelptopic import RESTOnlineHelpTopic
from zope.app.onlinehelp.onlinehelptopic import STXOnlineHelpTopic
from zope.app.onlinehelp.onlinehelptopic import ZPTOnlineHelpTopic
-from zope.app.security.interfaces import IPermission
-from zope.app.security.permission import Permission
-from zope.app.location.traversing import LocationPhysicallyLocatable
-from zope.app.traversing.adapters import Traverser, DefaultTraversable
from zope.app.testing import ztapi, placelesssetup
Modified: Zope3/trunk/src/zope/app/onlinehelp/tests/test_onlinehelp.py
===================================================================
--- Zope3/trunk/src/zope/app/onlinehelp/tests/test_onlinehelp.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/onlinehelp/tests/test_onlinehelp.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,11 +20,12 @@
from zope.interface import Interface, implements
from zope.testing.doctestunit import DocTestSuite
+from zope.traversing.interfaces import ITraversable, ITraverser
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.traversing.adapters import Traverser, DefaultTraversable
+from zope.location.traversing import LocationPhysicallyLocatable
+
from zope.app.testing import ztapi, placelesssetup
-from zope.app.traversing.interfaces import ITraversable, IPhysicallyLocatable,\
- ITraverser
-from zope.app.traversing.adapters import Traverser, DefaultTraversable
-from zope.app.location.traversing import LocationPhysicallyLocatable
class I1(Interface):
pass
Modified: Zope3/trunk/src/zope/app/onlinehelp/tests/test_treeview.py
===================================================================
--- Zope3/trunk/src/zope/app/onlinehelp/tests/test_treeview.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/onlinehelp/tests/test_treeview.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,10 +19,10 @@
from unittest import TestCase, TestLoader, TextTestRunner
+from zope import component
from zope.pagetemplate.tests.util import check_xml
from zope.publisher.browser import TestRequest
-from zope.app.site.tests.placefulsetup import PlacefulSetup
-from zope.app.tests import ztapi
+from zope.app.component.testing import PlacefulSetup
from zope.app.onlinehelp.tests import util
from zope.app.onlinehelp.interfaces import IOnlineHelp, IOnlineHelpTopic
from zope.app.onlinehelp.onlinehelp import OnlineHelp
@@ -41,7 +41,7 @@
PlacefulSetup.setUp(self, site=True)
path = os.path.join(testdir(), 'help.txt')
self.onlinehelp = OnlineHelp('Help', path)
- ztapi.provideUtility(IOnlineHelp, self.onlinehelp, "OnlineHelp")
+ component.provideUtility(self.onlinehelp, IOnlineHelp, "OnlineHelp")
def test_onlinehelp(self):
view = OnlineHelpTopicTreeView
Modified: Zope3/trunk/src/zope/app/pagetemplate/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pagetemplate/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -6,14 +6,14 @@
<adapter
for="*"
- provides="zope.app.traversing.interfaces.IPathAdapter"
+ provides="zope.traversing.interfaces.IPathAdapter"
factory=".talesapi.ZopeTalesAPI"
name="zope"
/>
<adapter
for="*"
- provides="zope.app.traversing.interfaces.IPathAdapter"
+ provides="zope.traversing.interfaces.IPathAdapter"
factory=".urlquote.URLQuote"
name="url"/>
@@ -44,4 +44,11 @@
<allow attributes="__call__" />
</class>
+ <adapter
+ for="zope.app.pagetemplate.viewpagetemplatefile.BoundPageTemplate
+ zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.publisher.interfaces.browser.IBrowserPublisher"
+ factory="zope.app.publication.traversers.NoTraverser"
+ />
+
</configure>
Modified: Zope3/trunk/src/zope/app/pagetemplate/engine.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/engine.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pagetemplate/engine.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,24 +21,23 @@
import sys
+from zope import component
from zope.interface import implements
+from zope.component.interfaces import ComponentLookupError
+from zope.traversing.interfaces import IPathAdapter, ITraversable
+from zope.traversing.interfaces import TraversalError
+from zope.traversing.adapters import Traverser, traversePathElement
+from zope.security.untrustedpython import rcompile
+from zope.security.proxy import ProxyFactory
+from zope.security.untrustedpython.builtins import SafeBuiltins
+from zope.i18n import translate
from zope.tales.expressions import PathExpr, StringExpr, NotExpr, DeferExpr
from zope.tales.expressions import SimpleModuleImporter
from zope.tales.pythonexpr import PythonExpr
from zope.tales.tales import ExpressionEngine, Context
-from zope.component.exceptions import ComponentLookupError
-from zope.app.traversing.interfaces import TraversalError
-from zope.security.untrustedpython import rcompile
-from zope.security.proxy import ProxyFactory
-from zope.security.untrustedpython.builtins import SafeBuiltins
-from zope.i18n import translate
-
-from zope.app import zapi
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.traversing.adapters import Traverser, traversePathElement
-from zope.app.traversing.interfaces import IPathAdapter, ITraversable
class InlineCodeError(Exception):
pass
@@ -126,7 +125,7 @@
# TODO This is only needed when self.evaluateInlineCode is true,
# so should only be needed for zope.app.pythonpage.
from zope.app.interpreter.interfaces import IInterpreter
- interpreter = zapi.queryUtility(IInterpreter, lang)
+ interpreter = component.queryUtility(IInterpreter, lang)
if interpreter is None:
error = _('No interpreter named "${lang_name}" was found.',
mapping={'lang_name': lang})
@@ -196,7 +195,7 @@
if namespace is None:
def namespace(object):
try:
- return zapi.getAdapter(object, IPathAdapter, name)
+ return component.getAdapter(object, IPathAdapter, name)
except ComponentLookupError:
raise KeyError(name)
Modified: Zope3/trunk/src/zope/app/pagetemplate/simpleviewclass.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/simpleviewclass.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pagetemplate/simpleviewclass.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,11 +18,11 @@
__docformat__ = 'restructuredtext'
import sys
-from zope.app.publisher.browser import BrowserView
+from zope.interface import implements
+from zope.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPublisher
+from zope.publisher.interfaces import NotFound
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.publisher.interfaces import NotFound
-from zope.interface import implements
class simple(BrowserView):
Modified: Zope3/trunk/src/zope/app/pagetemplate/talesapi.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/talesapi.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pagetemplate/talesapi.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,16 +17,15 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app.dublincore.interfaces import IDCDescriptiveProperties
-from zope.app.dublincore.interfaces import IDCTimes
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.size.interfaces import ISized
-from zope.app import zapi
from zope.interface import implements
+from zope.size.interfaces import ISized
from zope.security.interfaces import Unauthorized
from zope.tales.interfaces import ITALESFunctionNamespace
+from zope.dublincore.interfaces import IDCDescriptiveProperties
+from zope.dublincore.interfaces import IDCTimes
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.traversing.api import getName
-
class ZopeTalesAPI(object):
implements(IDCTimes, IDCDescriptiveProperties, ITALESFunctionNamespace)
@@ -66,13 +65,13 @@
modified = property(modified)
def name(self):
- return zapi.name(self.context)
+ return getName(self.context)
def title_or_name(self):
try:
- return getattr(self, 'title', '') or zapi.name(self.context)
+ return getattr(self, 'title', '') or getName(self.context)
except Unauthorized:
- return zapi.name(self.context)
+ return getName(self.context)
def size(self):
a = ISized(self.context, None)
Modified: Zope3/trunk/src/zope/app/pagetemplate/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/tests/test_directives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pagetemplate/tests/test_directives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,14 +20,13 @@
from zope.configuration.xmlconfig import xmlconfig, XMLConfig
from zope.interface import Interface, implements
-from zope.app.testing import ztapi
+from zope.traversing.interfaces import ITraversable
import zope.app.pagetemplate
+from zope.app.testing import ztapi
+from zope.app.testing.placelesssetup import PlacelessSetup
from zope.app.pagetemplate.engine import Engine
-from zope.app.traversing.interfaces import ITraversable
-from zope.app.testing.placelesssetup import PlacelessSetup
-
template = """<configure
xmlns='http://namespaces.zope.org/zope'
xmlns:tales='http://namespaces.zope.org/tales'>
Modified: Zope3/trunk/src/zope/app/pagetemplate/tests/test_talesapi.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/tests/test_talesapi.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pagetemplate/tests/test_talesapi.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,12 +15,13 @@
$Id$
"""
+from datetime import datetime
from zope.testing.doctestunit import DocTestSuite
from zope.interface import implements
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.size.interfaces import ISized
-from zope.app.traversing.interfaces import IPhysicallyLocatable
-from datetime import datetime
+from zope.size.interfaces import ISized
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.dublincore.interfaces import IZopeDublinCore
+
from zope.app.pagetemplate.talesapi import ZopeTalesAPI
class TestObject(object):
Modified: Zope3/trunk/src/zope/app/pagetemplate/urlquote.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/urlquote.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pagetemplate/urlquote.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,7 +19,7 @@
import urllib
from zope.interface import implements
-from zope.app.traversing.interfaces import IPathAdapter
+from zope.traversing.interfaces import IPathAdapter
class URLQuote(object):
r"""An adapter for URL quoting.
Modified: Zope3/trunk/src/zope/app/pluggableauth/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/pluggableauth/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pluggableauth/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -32,6 +32,8 @@
from zope.interface import implements
from zope.component.interfaces import IViewFactory
from zope.deprecation import deprecated
+from zope.traversing.api import getPath
+from zope.location import locate
from zope.app import zapi
from zope.app.component import queryNextUtility
@@ -42,10 +44,8 @@
from zope.app.container.constraints import ContainerTypesConstraint
from zope.app.container.contained import Contained, setitem, uncontained
from zope.app.container.ordered import OrderedContainer
-from zope.app.location import locate
from zope.app.security.interfaces import ILoginPassword, IAuthentication
from zope.app.security.interfaces import PrincipalLookupError
-from zope.app.traversing.api import getPath
from interfaces import IUserSchemafied, IPluggableAuthentication
from interfaces import IPrincipalSource, ILoginPasswordPrincipalSource
@@ -203,7 +203,7 @@
Define a stub for `PluggableAuthentication`
- >>> from zope.app.traversing.interfaces import IPhysicallyLocatable
+ >>> from zope.traversing.interfaces import IPhysicallyLocatable
>>> class PluggableAuthStub(object):
... implements(IPhysicallyLocatable)
... def __init__(self, earmark=None):
Modified: Zope3/trunk/src/zope/app/pluggableauth/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/pluggableauth/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pluggableauth/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -10,20 +10,6 @@
permission="zope.ManageSite"
interface=".interfaces.IPluggableAuthentication"
/>
-<!--
- <allow
- interface="zope.app.container.interfaces.IReadContainer"
- />
-
- <require
- permission="zope.ManageSite"
- interface="zope.app.container.interfaces.IWriteContainer"
- />
--->
- <require
- permission="zope.ManageSite"
- interface="zope.app.site.interfaces.ISimpleService"
- />
</localUtility>
<subscriber
Modified: Zope3/trunk/src/zope/app/pluggableauth/tests/test_pluggableauth.py
===================================================================
--- Zope3/trunk/src/zope/app/pluggableauth/tests/test_pluggableauth.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pluggableauth/tests/test_pluggableauth.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,8 +21,9 @@
from zope.app import zapi
from zope.app.testing import ztapi, setup
-import zope.app.site.tests as placefulsetup
+from zope.app.component.testing import PlacefulSetup
+
from zope.app.security.interfaces import PrincipalLookupError
from zope.publisher.interfaces.http import IHTTPCredentials
@@ -43,10 +44,10 @@
import base64
-class Setup(placefulsetup.PlacefulSetup, TestCase):
+class Setup(PlacefulSetup, TestCase):
def setUp(self):
- sm = placefulsetup.PlacefulSetup.setUp(self, site=True)
+ sm = PlacefulSetup.setUp(self, site=True)
ztapi.provideAdapter(IHTTPCredentials, ILoginPassword, BasicAuthAdapter)
ztapi.browserView(IPrincipalSource, "login",
Modified: Zope3/trunk/src/zope/app/preference/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/preference/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/preference/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -404,7 +404,7 @@
This function is also commonly registered as an adapter,
- >>> from zope.app.location.interfaces import ILocation
+ >>> from zope.location.interfaces import ILocation
>>> ztapi.provideAdapter(ILocation, interfaces.IUserPreferences,
... UserPreferences)
@@ -425,9 +425,9 @@
register all necessary traversal components and the special `preferences`
namespace:
- >>> import zope.app.traversing.interfaces
+ >>> import zope.traversing.interfaces
>>> ztapi.provideAdapter(None,
- ... zope.app.traversing.interfaces.ITraversable,
+ ... zope.traversing.interfaces.ITraversable,
... preference.preferencesNamespace,
... 'preferences')
Modified: Zope3/trunk/src/zope/app/preference/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/preference/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/preference/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -9,19 +9,19 @@
name="preferences"
for="*"
type="*"
- provides="zope.app.traversing.interfaces.ITraversable"
+ provides="zope.traversing.interfaces.ITraversable"
factory=".preference.preferencesNamespace"
/>
<adapter
name="preferences"
for="*"
- provides="zope.app.traversing.interfaces.ITraversable"
+ provides="zope.traversing.interfaces.ITraversable"
factory=".preference.preferencesNamespace"
/>
<adapter
- for="zope.app.location.interfaces.ILocation"
+ for="zope.location.interfaces.ILocation"
provides=".interfaces.IUserPreferences"
factory=".preference.UserPreferences"
/>
@@ -74,16 +74,6 @@
permission="zope.ManageSite"
/>
- <browser:tool
- interface=".interfaces.IDefaultPreferenceProvider"
- title="Default User Preferences Provider"
- description="
- This component lets you define the local default user
- preferences. The values of this provider are used, if the
- user has not made a selection yet."
- unique="true"
- />
-
<!-- Preferences-specific macros -->
<browser:page
for="*"
Modified: Zope3/trunk/src/zope/app/preference/default.py
===================================================================
--- Zope3/trunk/src/zope/app/preference/default.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/preference/default.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,17 +20,15 @@
from BTrees.OOBTree import OOBTree
import zope.interface
+import zope.component
from zope.security.checker import defineChecker
+from zope.traversing.interfaces import IContainmentRoot
+from zope.location import locate
-from zope.app import component
-from zope.app import zapi
+import zope.app.component
from zope.app.container.contained import Contained
-from zope.app.location import locate
-from zope.app.traversing.interfaces import IContainmentRoot
-
from zope.app.preference import preference, interfaces
-
class DefaultPreferenceProvider(persistent.Persistent, Contained):
zope.interface.implements(interfaces.IDefaultPreferenceProvider)
@@ -38,7 +36,7 @@
self.data = OOBTree()
def getDefaultPreferenceGroup(self, id=''):
- group = zapi.getUtility(interfaces.IPreferenceGroup, name=id)
+ group = zope.component.getUtility(interfaces.IPreferenceGroup, name=id)
group = group.__bind__(self)
default = DefaultPreferenceGroup(group, self)
zope.interface.alsoProvides(default, IContainmentRoot)
@@ -92,7 +90,7 @@
# There is currently no local entry, so let's go to the next
# provider and lookup the group and value there.
- nextProvider = component.queryNextUtility(
+ nextProvider = zope.app.component.queryNextUtility(
self.provider, interfaces.IDefaultPreferenceProvider)
# No more providers found, so return the schema's default
Modified: Zope3/trunk/src/zope/app/preference/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/preference/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/preference/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,11 +20,10 @@
import zope.interface
import zope.schema
from zope.configuration.fields import MessageID
+from zope.location.interfaces import ILocation
from zope.app.container.interfaces import IReadContainer
-from zope.app.location.interfaces import ILocation
-
class IPreferenceGroup(ILocation):
"""A group of preferences.
Modified: Zope3/trunk/src/zope/app/preference/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/preference/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/preference/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,7 +16,7 @@
$Id: metaconfigure.py 26889 2004-08-04 04:00:36Z pruggera $
"""
__docformat__ = 'restructuredtext'
-from zope.app.component.metaconfigure import utility
+from zope.component.zcml import utility
from zope.app.preference.interfaces import IPreferenceGroup
from zope.app.preference.preference import PreferenceGroup
Modified: Zope3/trunk/src/zope/app/preference/preference.py
===================================================================
--- Zope3/trunk/src/zope/app/preference/preference.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/preference/preference.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,14 +22,14 @@
from zope.schema import getFields
from zope.security.checker import CheckerPublic, Checker, defineChecker
from zope.security.management import getInteraction
+from zope.traversing.interfaces import IContainmentRoot
+from zope.location import LocationProxy, locate, Location
import zope.app.component.hooks
from zope.app import zapi
from zope.app.container.contained import Contained
from zope.app.container.interfaces import IReadContainer
-from zope.app.location import LocationProxy, locate, Location
from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility
-from zope.app.traversing.interfaces import IContainmentRoot
from zope.app.preference.interfaces import IPreferenceGroup
from zope.app.preference.interfaces import IPreferenceCategory
Modified: Zope3/trunk/src/zope/app/principalannotation/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/principalannotation/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/principalannotation/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,12 +22,12 @@
from persistent import Persistent
from persistent.dict import PersistentDict
from BTrees.OOBTree import OOBTree
+import zope.security.interfaces
from zope import interface, component
-import zope.security.interfaces
+from zope.location import Location
+from zope.annotation.interfaces import IAnnotations
-from zope.app.annotation.interfaces import IAnnotations
from zope.app.container.contained import Contained
-from zope.app.location import Location
from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility
from zope.app.component import queryNextUtility
Modified: Zope3/trunk/src/zope/app/principalannotation/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/principalannotation/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/principalannotation/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,13 +21,6 @@
title="Principal Annotation Utility"
description="Stores Annotations for Principals" />
- <browser:tool
- interface=".interfaces.IPrincipalAnnotationUtility"
- title="Principal Annotations"
- description="Stores annotations for any principal."
- unique="true"
- />
-
<subscriber
for="zope.app.appsetup.IDatabaseOpenedEvent"
handler=".bootstrap.bootStrapSubscriber"
Modified: Zope3/trunk/src/zope/app/principalannotation/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/principalannotation/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/principalannotation/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,16 +20,15 @@
import zope.component
from zope.interface import implements
-from zope.app import zapi
-from zope.app.annotation.interfaces import IAnnotations
+from zope.annotation.interfaces import IAnnotations
+from zope.security.interfaces import IPrincipal
+
from zope.app.principalannotation import PrincipalAnnotationUtility
-from zope.app.security.interfaces import IPrincipal
from zope.app.component.testing import PlacefulSetup
-from zope.app.testing import ztapi, setup
+from zope.app.testing import setup
from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility
class Principal(object):
-
implements(IPrincipal)
def __init__(self, id):
Modified: Zope3/trunk/src/zope/app/publication/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,19 +20,27 @@
"""
__docformat__ = 'restructuredtext'
-from zope.interface import providedBy
-from zope.interface import directlyProvides
-
+from zope.component import queryMultiAdapter
from zope.publisher.interfaces.browser import IBrowserPublisher
-from zope.publisher.interfaces.browser import IDefaultSkin
-from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.security.checker import ProxyFactory
-from zope.app import zapi
from zope.app.publication.publicationtraverse \
import PublicationTraverser as PublicationTraverser_
from zope.app.publication.http import BaseHTTPPublication
-from zope.security.checker import ProxyFactory
+##############################################################################
+# BBB 2006/04/03 - to be removed after 12 months
+
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "setDefaultSkin has been moved to zope.publisher.browser. This "
+ "reference will be removed in Zope 3.5.",
+ setDefaultSkin = 'zope.publisher.browser:setDefaultSkin',
+ )
+
+#
+##############################################################################
+
class PublicationTraverser(PublicationTraverser_):
def traverseRelativeURL(self, request, ob, path):
@@ -57,7 +65,7 @@
# ob is already proxied, so the result of calling a method will be
return ob.browserDefault(request)
else:
- adapter = zapi.queryMultiAdapter((ob, request), IBrowserPublisher)
+ adapter = queryMultiAdapter((ob, request), IBrowserPublisher)
if adapter is not None:
ob, path = adapter.browserDefault(request)
ob = ProxyFactory(ob)
@@ -79,72 +87,3 @@
def __call__(self):
return self.__pub
-
-def setDefaultSkin(request):
- """Sets the default skin for the request.
-
- The default skin is a marker interface that can be registered as an
- adapter that provides IDefaultSkin for the request type.
-
- If a default skin is not available, the default layer
- (IDefaultBrowserLayer) is used.
-
- To illustrate, we'll first use setDefaultSkin without a registered
- IDefaultSkin adapter:
-
- >>> from zope.publisher.interfaces.browser import IBrowserRequest
- >>> from zope.interface import implements
- >>> class Request(object):
- ... implements(IBrowserRequest)
-
- >>> request = Request()
- >>> IDefaultBrowserLayer.providedBy(request)
- False
-
- >>> setDefaultSkin(request)
- >>> IDefaultBrowserLayer.providedBy(request)
- True
-
- When we register a default layer, however:
-
- >>> from zope.interface import Interface
- >>> class IMySkin(Interface):
- ... pass
- >>> from zope.app.testing import ztapi
- >>> ztapi.provideAdapter(IBrowserRequest, IDefaultSkin, IMySkin)
-
- setDefaultSkin uses the layer instead of IDefaultBrowserLayer.providedBy:
-
- >>> request = Request()
- >>> IMySkin.providedBy(request)
- False
- >>> IDefaultSkin.providedBy(request)
- False
-
- >>> setDefaultSkin(request)
-
- >>> IMySkin.providedBy(request)
- True
- >>> IDefaultBrowserLayer.providedBy(request)
- False
-
- Any interfaces that are directly provided by the request coming into this
- method are replaced by the applied layer/skin interface:
-
- >>> request = Request()
- >>> class IFoo(Interface):
- ... pass
- >>> directlyProvides(request, IFoo)
- >>> IFoo.providedBy(request)
- True
- >>> setDefaultSkin(request)
- >>> IFoo.providedBy(request)
- False
-
- """
- adapters = zapi.getSiteManager().adapters
- skin = adapters.lookup((providedBy(request),), IDefaultSkin, '')
- if skin is not None:
- directlyProvides(request, skin)
- else:
- directlyProvides(request, IDefaultBrowserLayer)
Modified: Zope3/trunk/src/zope/app/publication/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/publication/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -3,6 +3,21 @@
xmlns:browser="http://namespaces.zope.org/browser"
>
+ <view
+ for="zope.interface.Interface"
+ type="zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.publisher.interfaces.browser.IBrowserPublisher"
+ factory="zope.app.publication.traversers.SimpleComponentTraverser"
+ permission="zope.Public"
+ allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
+ />
+
+ <adapter
+ for="types.MethodType zope.publisher.interfaces.browser.IBrowserRequest"
+ provides="zope.publisher.interfaces.browser.IBrowserPublisher"
+ factory="zope.app.publication.traversers.NoTraverser"
+ />
+
<browser:view
for="zope.app.publication.interfaces.IFileContent"
provides="zope.publisher.interfaces.browser.IBrowserPublisher"
Modified: Zope3/trunk/src/zope/app/publication/httpfactory.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/httpfactory.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/httpfactory.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,9 +20,9 @@
from zope import interface
from zope.publisher.interfaces.browser import IBrowserRequest
+from zope.publisher.browser import setDefaultSkin
from zope.app.publication import interfaces
-from zope.app.publication.browser import setDefaultSkin
from zope.app.publication.requestpublicationregistry import factoryRegistry
Modified: Zope3/trunk/src/zope/app/publication/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,7 +18,7 @@
__docformat__ = 'restructuredtext'
from zope import interface
-import zope.app.event.interfaces
+import zope.component.interfaces
class IPublicationRequestFactory(interface.Interface):
"""Publication request factory"""
@@ -29,7 +29,7 @@
A request is created and configured with a publication object.
"""
-class IBeforeTraverseEvent(zope.app.event.interfaces.IObjectEvent):
+class IBeforeTraverseEvent(zope.component.interfaces.IObjectEvent):
"""An event which gets sent on publication traverse"""
request = interface.Attribute("The current request")
Modified: Zope3/trunk/src/zope/app/publication/publicationtraverse.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/publicationtraverse.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/publicationtraverse.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,13 +18,12 @@
__docformat__ = 'restructuredtext'
from types import StringTypes
+from zope.component import queryMultiAdapter
from zope.publisher.interfaces import NotFound
from zope.security.checker import ProxyFactory
-
-from zope.app import zapi
-from zope.app.traversing.namespace import namespaceLookup
-from zope.app.traversing.namespace import nsParse
-from zope.app.traversing.interfaces import TraversalError
+from zope.traversing.namespace import namespaceLookup
+from zope.traversing.namespace import nsParse
+from zope.traversing.interfaces import TraversalError
from zope.publisher.interfaces import IPublishTraverse
class DuplicateNamespaces(Exception):
@@ -56,8 +55,8 @@
ob2 = ob.publishTraverse(request, nm)
else:
# self is marker
- adapter = zapi.queryMultiAdapter((ob, request), IPublishTraverse,
- default=self)
+ adapter = queryMultiAdapter((ob, request), IPublishTraverse,
+ default=self)
if adapter is not self:
ob2 = adapter.publishTraverse(request, nm)
else:
Modified: Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,17 +16,15 @@
$Id: test_browserpublication.py 38357 2005-09-07 20:14:34Z srichter $
"""
import unittest
-from zope.testing import doctest
-from zope.app.testing import placelesssetup, ztapi
+from zope.app.testing import ztapi
from StringIO import StringIO
from zope.security.interfaces import ForbiddenAttribute
from zope.interface import Interface, implements
from zope.publisher.publish import publish
-from zope.publisher.browser import TestRequest
-from zope.app.publisher.browser import BrowserView
+from zope.publisher.browser import TestRequest, BrowserView
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.proxy import getProxiedObject
@@ -316,10 +314,6 @@
unittest.makeSuite(BrowserPublicationTests, 'test'),
unittest.makeSuite(BrowserDefaultTests, 'test'),
unittest.makeSuite(HTTPPublicationRequestFactoryTests, 'test'),
- doctest.DocTestSuite('zope.app.publication.browser',
- setUp=placelesssetup.setUp,
- tearDown=placelesssetup.tearDown),
-
))
Modified: Zope3/trunk/src/zope/app/publication/tests/test_httpfactory.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_httpfactory.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/tests/test_httpfactory.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,7 +23,7 @@
from zope.publisher.browser import BrowserRequest
from zope.publisher.http import HTTPRequest
from zope.publisher.xmlrpc import XMLRPCRequest
-from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.component.testing import PlacelessSetup
from zope.app.publication.httpfactory import HTTPPublicationRequestFactory
from zope.app.publication.browser import BrowserPublication
Modified: Zope3/trunk/src/zope/app/publication/tests/test_requestpublicationfactories.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_requestpublicationfactories.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/tests/test_requestpublicationfactories.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,7 +23,7 @@
from zope.publisher.browser import BrowserRequest
from zope.publisher.http import HTTPRequest
from zope.publisher.xmlrpc import XMLRPCRequest
-from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.component.testing import PlacelessSetup
from zope.app.publication.httpfactory import HTTPPublicationRequestFactory
from zope.app.publication.browser import BrowserPublication
Modified: Zope3/trunk/src/zope/app/publication/tests/test_requestpublicationregistry.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_requestpublicationregistry.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/tests/test_requestpublicationregistry.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,7 +21,7 @@
from zope import component, interface
from zope.interface.verify import verifyClass
-from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.component.testing import PlacelessSetup
from zope.configuration.exceptions import ConfigurationError
from zope.app.publication import interfaces
Modified: Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/tests/test_simplecomponenttraverser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,9 +16,8 @@
$Id$
"""
import unittest
-from zope.component.tests.request import Request
from zope.publisher.interfaces import NotFound
-from zope.interface import Interface
+from zope.interface import Interface, directlyProvides
from zope.app.publication.traversers import SimpleComponentTraverser
from zope.app.testing.placelesssetup import PlacelessSetup
@@ -37,7 +36,11 @@
return getattr(self, name, default)
-class Request(Request):
+class Request(object):
+
+ def __init__(self, type):
+ directlyProvides(self, type)
+
def getEffectiveURL(self):
return ''
Modified: Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/tests/test_zopepublication.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -24,29 +24,29 @@
from ZODB.DemoStorage import DemoStorage
import transaction
+import zope.component
from zope.interface.verify import verifyClass
from zope.interface import implements, classImplements, implementedBy
from zope.i18n.interfaces import IUserPreferredCharsets
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
from zope.publisher.base import TestPublication, TestRequest
from zope.publisher.http import IHTTPRequest, HTTPCharsets
from zope.publisher.interfaces import IRequest, IPublishTraverse
from zope.security import simplepolicies
from zope.security.management import setSecurityPolicy, queryInteraction
from zope.security.management import endInteraction
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.location.interfaces import ILocation
-from zope.app import zapi
from zope.app.testing.placelesssetup import PlacelessSetup
from zope.app.testing import setup, ztapi
from zope.app.error.interfaces import IErrorReportingUtility
-from zope.app.location.interfaces import ILocation
-from zope.app.traversing.interfaces import IPhysicallyLocatable
from zope.app.security.principalregistry import principalRegistry
from zope.app.security.interfaces import IUnauthenticatedPrincipal, IPrincipal
from zope.app.publication.zopepublication import ZopePublication
from zope.app.folder import Folder, rootFolder
-from zope.app.location import Location
+from zope.location import Location
from zope.app.security.interfaces import IAuthenticationUtility
class Principal(object):
@@ -125,7 +125,7 @@
connection.close()
self.app = app
- from zope.app.traversing.namespace import view, resource, etc
+ from zope.traversing.namespace import view, resource, etc
ztapi.provideNamespaceHandler('view', view)
ztapi.provideNamespaceHandler('resource', resource)
ztapi.provideNamespaceHandler('etc', etc)
@@ -378,8 +378,7 @@
def testAbortTransactionWithErrorReportingUtility(self):
# provide our fake error reporting utility
- sm = zapi.getGlobalSiteManager()
- sm.provideUtility(IErrorReportingUtility, ErrorReportingUtility())
+ zope.component.provideUtility(ErrorReportingUtility())
class FooError(Exception):
pass
@@ -397,7 +396,7 @@
self.assertEqual(last_txn_info, new_txn_info)
# instead, we expect a message in our logging utility
- error_log = zapi.getUtility(IErrorReportingUtility)
+ error_log = zope.component.getUtility(IErrorReportingUtility)
self.assertEqual(len(error_log.exceptions), 1)
error_info, request = error_log.exceptions[0]
self.assertEqual(error_info[0], FooError)
@@ -467,10 +466,10 @@
def testTransactionAnnotation(self):
from zope.interface import directlyProvides
- from zope.app.location.traversing import LocationPhysicallyLocatable
- from zope.app.location.interfaces import ILocation
- from zope.app.traversing.interfaces import IPhysicallyLocatable
- from zope.app.traversing.interfaces import IContainmentRoot
+ from zope.location.traversing import LocationPhysicallyLocatable
+ from zope.location.interfaces import ILocation
+ from zope.traversing.interfaces import IPhysicallyLocatable
+ from zope.traversing.interfaces import IContainmentRoot
ztapi.provideAdapter(ILocation, IPhysicallyLocatable,
LocationPhysicallyLocatable)
Modified: Zope3/trunk/src/zope/app/publication/traversers.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/traversers.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/traversers.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -67,6 +67,9 @@
return view, path
+def NoTraverser(ob, request):
+ return None
+
class TestTraverser(object):
"""Bobo-style traverser, mostly useful for testing"""
implements(IBrowserPublisher)
@@ -77,7 +80,7 @@
def browserDefault(self, request):
ob = self.context
- if providedBy(ob):
+ if list(providedBy(ob)):
view_name = zapi.getDefaultViewName(ob, request)
return ob, (("@@%s" % view_name),)
Modified: Zope3/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/zopepublication.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publication/zopepublication.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -33,13 +33,14 @@
from zope.security.management import newInteraction, endInteraction
from zope.security.checker import ProxyFactory
from zope.security.proxy import removeSecurityProxy
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.location import LocationProxy
from zope.app import zapi
from zope.app.applicationcontrol.applicationcontrol \
import applicationControllerRoot
from zope.app.error.interfaces import IErrorReportingUtility
from zope.app.exception.interfaces import ISystemErrorView
-from zope.app.location import LocationProxy
from zope.app.publication.interfaces import BeforeTraverseEvent
from zope.app.publication.interfaces import EndRequestEvent
from zope.app.publication.publicationtraverse import PublicationTraverse
@@ -47,7 +48,6 @@
from zope.app.security.interfaces import IUnauthenticatedPrincipal
from zope.app.security.interfaces import IAuthentication
from zope.app.component.interfaces import ISite
-from zope.app.traversing.interfaces import IPhysicallyLocatable
class Cleanup(object):
Modified: Zope3/trunk/src/zope/app/publisher/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/app/publisher/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1 +1 @@
-zope.app.contenttypes
+zope.contenttype
Modified: Zope3/trunk/src/zope/app/publisher/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,49 +19,25 @@
from zope.component import getSiteManager
import zope.interface
-from zope.interface import implements, directlyProvidedBy, directlyProvides
+from zope.interface import implements
from zope.publisher.browser import BrowserLanguages
from zope.i18n.interfaces import IUserPreferredLanguages
from zope.i18n.interfaces import IModifiableUserPreferredLanguages
-from zope.app.location import Location
-from zope.app.publisher.interfaces.browser import IBrowserView
-from zope.publisher.interfaces.browser import IBrowserSkinType
+##############################################################################
+# BBB 2006/04/03 - to be removed after 12 months
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "It has been moved to zope.publisher.browser. This reference will "
+ "be removed in Zope 3.5.",
+ BrowserView = 'zope.publisher.browser:BrowserView',
+ applySkin = 'zope.publisher.browser:applySkin',
+ )
-key = "zope.app.publisher.browser.IUserPreferredLanguages"
+#
+##############################################################################
-class BrowserView(Location):
- """Browser View.
-
- >>> view = BrowserView("context", "request")
- >>> view.context
- 'context'
- >>> view.request
- 'request'
-
- >>> view.__parent__
- 'context'
- >>> view.__parent__ = "parent"
- >>> view.__parent__
- 'parent'
- """
-
- implements(IBrowserView)
-
- def __init__(self, context, request):
- self.context = context
- self.request = request
-
- def __getParent(self):
- return getattr(self, '_parent', self.context)
-
- def __setParent(self, parent):
- self._parent = parent
-
- __parent__ = property(__getParent, __setParent)
-
-
class IDefaultViewNameAPI(zope.interface.Interface):
def getDefaultViewName(object, request, context=None):
@@ -101,45 +77,13 @@
map(zope.interface.providedBy, (object, request)), IDefaultViewName)
return name or default
-def applySkin(request, skin):
- """Change the presentation skin for this request.
-
- >>> import pprint
- >>> from zope.interface import Interface, providedBy
- >>> class SkinA(Interface): pass
- >>> directlyProvides(SkinA, IBrowserSkinType)
- >>> class SkinB(Interface): pass
- >>> directlyProvides(SkinB, IBrowserSkinType)
- >>> class IRequest(Interface): pass
-
- >>> class Request(object):
- ... implements(IRequest)
-
- >>> req = Request()
-
- >>> applySkin(req, SkinA)
- >>> pprint.pprint(list(providedBy(req).interfaces()))
- [<InterfaceClass zope.app.publisher.browser.SkinA>,
- <InterfaceClass zope.app.publisher.browser.IRequest>]
-
- >>> applySkin(req, SkinB)
- >>> pprint.pprint(list(providedBy(req).interfaces()))
- [<InterfaceClass zope.app.publisher.browser.SkinB>,
- <InterfaceClass zope.app.publisher.browser.IRequest>]
- """
- # Remove all existing skin declarations (commonly the default skin).
- ifaces = [iface
- for iface in directlyProvidedBy(request)
- if not IBrowserSkinType.providedBy(iface)]
- # Add the new skin.
- ifaces.append(skin)
- directlyProvides(request, *ifaces)
-
class NotCompatibleAdapterError(Exception):
"""Adapter not compatible with
zope.i18n.interfaces.IModifiableBrowserLanguages has been used.
"""
+key = "zope.app.publisher.browser.IUserPreferredLanguages"
+
class CacheableBrowserLanguages(BrowserLanguages):
implements(IUserPreferredLanguages)
Modified: Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -29,7 +29,7 @@
from zope.interface import implements
from zope.publisher.interfaces import NotFound
from zope.security.proxy import Proxy
-from zope.app.publisher.browser import BrowserView
+from zope.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.app.publisher.browser.resource import Resource
Modified: Zope3/trunk/src/zope/app/publisher/browser/fields.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/fields.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/fields.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,7 +18,7 @@
__docformat__ = 'restructuredtext'
import zope.schema
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
from zope.configuration.exceptions import ConfigurationError
from zope.configuration.fields import GlobalObject
from zope.interface.interfaces import IInterface
Modified: Zope3/trunk/src/zope/app/publisher/browser/fileresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/fileresource.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/fileresource.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,20 +17,16 @@
"""
import time
-
+from zope.security.proxy import Proxy
+from zope.interface import implements
+from zope.datetime import time as timeFromDateTimeString
from zope.publisher.interfaces import NotFound
-
-from zope.app.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPublisher
+from zope.publisher.browser import BrowserView
from zope.app.publisher.fileresource import File, Image
from zope.app.publisher.browser.resource import Resource
-from zope.app.datetimeutils import time as timeFromDateTimeString
-from zope.security.proxy import Proxy
-
-from zope.interface import implements
-
class FileResource(BrowserView, Resource):
implements(IBrowserPublisher)
Modified: Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/i18nresourcemeta.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,14 +21,12 @@
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.security.proxy import Proxy
from zope.security.checker import CheckerPublic, Checker
+from zope.component.zcml import handler
-from zope.app import zapi
-from zope.app.component.metaconfigure import handler
from zope.app.publisher.fileresource import File, Image
+from zope.app.publisher.browser.i18nfileresource import I18nFileResourceFactory
-from i18nfileresource import I18nFileResourceFactory
-
class I18nResource(object):
type = IBrowserRequest
@@ -104,8 +102,8 @@
self._context.action(
discriminator = ('i18n-resource', self.name, self.type, self.layer),
callable = handler,
- args = ('provideAdapter',
- (self.layer,), Interface, self.name, factory,
+ args = ('registerAdapter',
+ factory, (self.layer,), Interface, self.name,
self._context.info)
)
Modified: Zope3/trunk/src/zope/app/publisher/browser/icon.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/icon.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/icon.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,12 +21,11 @@
from zope.interface import Interface
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.configuration.exceptions import ConfigurationError
+from zope.traversing.namespace import getResource
+from zope.component.interface import provideInterface
+from zope.component.zcml import handler
-from zope.app import zapi
-from zope.app.component.interface import provideInterface
-from zope.app.component.metaconfigure import handler
from zope.app.publisher.browser import metaconfigure
-from zope.app.traversing.namespace import getResource
IName = re.compile('I[A-Z][a-z]')
@@ -95,8 +94,8 @@
_context.action(
discriminator = ('view', name, vfactory, layer),
callable = handler,
- args = ('provideAdapter',
- (for_, layer), Interface, name, vfactory, _context.info)
+ args = ('registerAdapter',
+ vfactory, (for_, layer), Interface, name, _context.info)
)
_context.action(
Modified: Zope3/trunk/src/zope/app/publisher/browser/managementviewselector.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/managementviewselector.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/managementviewselector.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,9 +17,7 @@
"""
from zope.interface import implements
from zope.publisher.interfaces.browser import IBrowserPublisher
-
-from zope.app import zapi
-from zope.app.publisher.browser import BrowserView
+from zope.publisher.browser import BrowserView
from zope.app.publisher.browser.menu import getFirstMenuItem
class ManagementViewSelector(BrowserView):
Modified: Zope3/trunk/src/zope/app/publisher/browser/menu.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/menu.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/menu.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,16 +18,15 @@
__docformat__ = "reStructuredText"
import sys
-from zope.interface import Interface, implements
-from zope.interface import providedBy
+import zope.component
+from zope.interface import Interface, implements, providedBy
from zope.security import checkPermission, canAccess
from zope.security.interfaces import Unauthorized, Forbidden
from zope.security.proxy import removeSecurityProxy
+from zope.publisher.browser import BrowserView
-from zope.app import zapi
from zope.app.pagetemplate.engine import Engine
from zope.app.publication.browser import PublicationTraverser
-from zope.app.publisher.browser import BrowserView
from zope.app.publisher.interfaces.browser import IMenuAccessView
from zope.app.publisher.interfaces.browser import IBrowserMenu
from zope.app.publisher.interfaces.browser import IBrowserMenuItem
@@ -44,13 +43,13 @@
self.description = description
def getMenuItemType(self):
- return zapi.getUtility(IMenuItemType, self.id)
+ return zope.component.getUtility(IMenuItemType, self.id)
def getMenuItems(self, object, request):
"""Return menu item entries in a TAL-friendly form."""
result = []
- for name, item in zapi.getAdapters((object, request),
- self.getMenuItemType()):
+ for name, item in zope.component.getAdapters((object, request),
+ self.getMenuItemType()):
if item.available():
result.append(item)
@@ -173,7 +172,7 @@
def getMenu(id, object, request):
"""Return menu item entries in a TAL-friendly form."""
- menu = zapi.getUtility(IBrowserMenu, id)
+ menu = zope.component.getUtility(IBrowserMenu, id)
return menu.getMenuItems(object, request)
Modified: Zope3/trunk/src/zope/app/publisher/browser/menu.txt
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/menu.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/menu.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -117,9 +117,9 @@
item itself, or (2) the filter returns ``False``, in which case the menu
item should also not be shown.
+ >>> from zope.security.interfaces import IPermission
+ >>> from zope.security.permission import Permission
>>> from zope.app.testing import ztapi
- >>> from zope.app.security.interfaces import IPermission
- >>> from zope.app.security.permission import Permission
>>> perm = Permission('perm', 'Permission')
>>> ztapi.provideUtility(IPermission, perm, 'perm')
Modified: Zope3/trunk/src/zope/app/publisher/browser/menumeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/menumeta.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/menumeta.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,29 +15,26 @@
$Id$
"""
+import zope.component
from zope.configuration.exceptions import ConfigurationError
from zope.interface.interface import InterfaceClass
from zope.interface import Interface
+from zope.publisher.interfaces.browser import IBrowserRequest
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.security.checker import InterfaceChecker, CheckerPublic
+from zope.component.interface import provideInterface
+from zope.component.zcml import adapter, proxify, utility
-from zope.app import zapi
-from zope.app.component.interface import provideInterface
-from zope.app.component.metaconfigure import adapter, proxify
-from zope.app.component.metaconfigure import utility
+from zope.app.component.contentdirective import ClassDirective
from zope.app.pagetemplate.engine import Engine
+from zope.app.container.interfaces import IAdding
from zope.app.publisher.browser.menu import BrowserMenu
from zope.app.publisher.browser.menu import BrowserMenuItem, BrowserSubMenuItem
from zope.app.publisher.interfaces.browser import IBrowserMenu
from zope.app.publisher.interfaces.browser import IBrowserMenuItem
from zope.app.publisher.interfaces.browser import IMenuItemType
-
-from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.app.container.interfaces import IAdding
-from zope.app.component.contentdirective import ClassDirective
from zope.app.publisher.interfaces.browser import AddMenu
-
# Create special modules that contain all menu item types
from types import ModuleType as module
import sys
@@ -208,7 +205,7 @@
" is optional but can\'t be empty"
)
- gsm = zapi.getGlobalSiteManager()
+ gsm = zope.component.getGlobalSiteManager()
if gsm.adapters.lookup((for_, layer),
Interface, view_name) is None:
raise ConfigurationError(
@@ -240,7 +237,7 @@
if menu is not None:
if isinstance(menu, (str, unicode)):
- menu = zapi.getUtility(IMenuItemType, menu)
+ menu = zope.component.getUtility(IMenuItemType, menu)
if menu is None:
raise ValueError("Missing menu id '%s'" % menu)
Modified: Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,6 +17,8 @@
"""
import warnings
from zope.component.interfaces import IDefaultViewName
+from zope.component.interface import provideInterface
+from zope.component.zcml import handler
from zope.configuration.exceptions import ConfigurationError
from zope.interface import directlyProvides
from zope.interface.interface import InterfaceClass
@@ -24,14 +26,12 @@
from zope.publisher.interfaces.browser import IBrowserSkinType
from zope.app import zapi, layers, skins
-from zope.app.component.metaconfigure import handler
# referred to through ZCML
from zope.app.publisher.browser.resourcemeta import resource
from zope.app.publisher.browser.resourcemeta import resourceDirectory
from zope.app.publisher.browser.i18nresourcemeta import I18nResource
from zope.app.publisher.browser.viewmeta import view
-from zope.app.component.interface import provideInterface
# BBB 2006/02/18, to be removed after 12 months
import zope.deprecation
@@ -214,7 +214,8 @@
"""Provides a new skin.
First, let's ignore the warnigns:
- >>> warnings.filterwarnings('ignore', category=DeprecationWarning)
+ >>> showwarning = warnings.showwarning
+ >>> warnings.showwarning = lambda *a, **k: None
>>> import pprint
>>> class Info(object):
@@ -283,7 +284,7 @@
ConfigurationError: You must specify the 'name' or 'interface' attribute.
Enabling the warnings again:
- >>> warnings.resetwarnings()
+ >>> warnings.showwarning = showwarning
"""
if name is None and interface is None:
raise ConfigurationError(
@@ -371,8 +372,8 @@
True
"""
skin = zapi.getUtility(IBrowserSkinType, name)
- handler('provideAdapter',
- (IBrowserRequest,), IDefaultSkin, '', skin, info),
+ handler('registerAdapter',
+ skin, (IBrowserRequest,), IDefaultSkin, '', info),
def defaultSkin(_context, name):
@@ -387,8 +388,8 @@
_context.action(
discriminator = ('defaultViewName', for_, layer, name),
callable = handler,
- args = ('provideAdapter',
- (for_, layer), IDefaultViewName, '', name, _context.info)
+ args = ('registerAdapter',
+ name, (for_, layer), IDefaultViewName, '', _context.info)
)
if for_ is not None:
Modified: Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/metadirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,11 +21,11 @@
from zope.configuration.fields import GlobalObject, GlobalInterface
from zope.configuration.fields import Tokens, Path, PythonIdentifier, MessageID
from zope.schema import TextLine, Text, Id, Int, Bool
+from zope.security.zcml import Permission
from zope.app.component.metadirectives import IBasicViewInformation
-from zope.app.component.fields import LayerField
+from zope.app.component.back35 import LayerField
from zope.app.publisher.browser.fields import MenuField
-from zope.app.security.fields import Permission
#
# browser views
Modified: Zope3/trunk/src/zope/app/publisher/browser/pagetemplateresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/pagetemplateresource.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/pagetemplateresource.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,9 +17,9 @@
"""
from zope.interface import implements
+from zope.security.proxy import Proxy
from zope.publisher.interfaces import NotFound
-from zope.security.proxy import Proxy
-from zope.app.publisher.browser import BrowserView
+from zope.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.app.publisher.pagetemplateresource import PageTemplate
Modified: Zope3/trunk/src/zope/app/publisher/browser/resource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/resource.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/resource.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,15 +15,14 @@
$Id$
"""
+from zope.component import getMultiAdapter
from zope.component.interfaces import IResource
from zope.interface import implements
+from zope.traversing.browser.interfaces import IAbsoluteURL
+from zope.location import Location
-from zope.app import zapi
from zope.app.component.hooks import getSite
-from zope.app.location import Location
-from zope.app.traversing.browser.interfaces import IAbsoluteURL
-
class Resource(Location):
implements(IResource)
@@ -36,5 +35,5 @@
name = name[12:]
site = getSite()
- url = str(zapi.getMultiAdapter((site, self.request), IAbsoluteURL))
+ url = str(getMultiAdapter((site, self.request), IAbsoluteURL))
return "%s/@@/%s" % (url, name)
Modified: Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/resourcemeta.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,9 +22,9 @@
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.security.checker import CheckerPublic, NamesChecker
+from zope.component.zcml import handler
from zope.app import zapi
-from zope.app.component.metaconfigure import handler
from fileresource import FileResourceFactory, ImageResourceFactory
from pagetemplateresource import PageTemplateResourceFactory
@@ -77,8 +77,8 @@
_context.action(
discriminator = ('resource', name, IBrowserRequest, layer),
callable = handler,
- args = ('provideAdapter',
- (layer,), Interface, name, factory, _context.info),
+ args = ('registerAdapter',
+ factory, (layer,), Interface, name, _context.info),
)
def resourceDirectory(_context, name, directory, layer=IDefaultBrowserLayer,
@@ -98,6 +98,6 @@
_context.action(
discriminator = ('resource', name, IBrowserRequest, layer),
callable = handler,
- args = ('provideAdapter',
- (layer,), Interface, name, factory, _context.info),
+ args = ('registerAdapter',
+ factory, (layer,), Interface, name, _context.info),
)
Modified: Zope3/trunk/src/zope/app/publisher/browser/resources.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/resources.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/resources.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,14 +15,13 @@
$Id$
"""
-from zope.app.publisher.browser import BrowserView
+import zope.component
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.publisher.interfaces import NotFound
+from zope.publisher.browser import BrowserView
from zope.interface import implements
+from zope.location import locate
-from zope.app import zapi
-from zope.app.location import locate
-
class Resources(BrowserView):
"""Provide a URL-accessible resource namespace
"""
@@ -32,11 +31,11 @@
def publishTraverse(self, request, name):
'''See interface IBrowserPublisher'''
- resource = zapi.queryAdapter(request, name=name)
+ resource = zope.component.queryAdapter(request, name=name)
if resource is None:
raise NotFound(self, name)
- sm = zapi.getSiteManager()
+ sm = zope.component.getSiteManager()
locate(resource, sm, name)
return resource
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/support.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/support.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/support.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,19 +15,18 @@
$Id$
"""
+import zope.component
from zope.interface import implements
+from zope.traversing.interfaces import IContainmentRoot
-from zope.app import zapi
from zope.app.component.hooks import setSite
from zope.app.component.interfaces import ISite
-from zope.app.traversing.interfaces import IContainmentRoot
-
class Site:
implements(ISite, IContainmentRoot)
def getSiteManager(self):
- return zapi.getGlobalSiteManager()
+ return zope.component.getGlobalSiteManager()
site = Site()
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_addMenuItem.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_addMenuItem.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_addMenuItem.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,9 +21,9 @@
<InterfaceClass zope.component.interfaces.IFactory>,
'BrowserAdd__zope.app.publisher.browser.tests.test_addMenuItem.X'),
<function handler>,
- ('provideUtility',
+ ('registerUtility',
+ <Factory for <class 'zope.app.publisher.browser.tests.test_addMenuItem.X'>>,
<InterfaceClass zope.component.interfaces.IFactory>,
- <Factory for <class 'zope.app.publisher.browser.tests.test_addMenuItem.X'>>,
'BrowserAdd__zope.app.publisher.browser.tests.test_addMenuItem.X')),
(None,
<function provideInterface>,
@@ -35,12 +35,12 @@
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.container.interfaces.IAdding>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'')),
(None,
<function provideInterface>,
@@ -59,7 +59,7 @@
"""
import unittest
-from zope.testing.doctestunit import DocTestSuite
+from zope.testing.doctest import DocTestSuite
import re
import pprint
import cStringIO
@@ -110,12 +110,12 @@
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.container.interfaces.IAdding>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'')),
(None,
<function provideInterface>,
@@ -149,12 +149,12 @@
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.container.interfaces.IAdding>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'')),
(None,
<function provideInterface>,
@@ -182,9 +182,9 @@
<InterfaceClass zope.component.interfaces.IFactory>,
'BrowserAdd__zope.app.publisher.browser.tests.test_addMenuItem.X'),
<function handler>,
- ('provideUtility',
+ ('registerUtility',
+ <Factory for <class 'zope.app.publisher.browser.tests.test_addMenuItem.X'>>,
<InterfaceClass zope.component.interfaces.IFactory>,
- <Factory for <class 'zope.app.publisher.browser.tests.test_addMenuItem.X'>>,
'BrowserAdd__zope.app.publisher.browser.tests.test_addMenuItem.X')),
(None,
<function provideInterface>,
@@ -201,12 +201,12 @@
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.container.interfaces.IAdding>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'')),
(None,
<function provideInterface>,
@@ -239,12 +239,12 @@
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.publisher.browser.tests.test_addMenuItem.IX>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'')),
(None,
<function provideInterface>,
@@ -273,12 +273,12 @@
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.container.interfaces.IAdding>,
<InterfaceClass zope.app.publisher.browser.tests.test_addMenuItem.ILayerStub>),
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'')),
(None,
<function provideInterface>,
@@ -311,12 +311,12 @@
<class 'zope.app.publisher.browser.tests.test_addMenuItem.MenuStub'>,
'Add an X'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.publisher.browser.tests.test_addMenuItem.IX>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<class 'zope.app.publisher.browser.tests.test_addMenuItem.MenuStub'>,
'Add an X',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'')),
(None,
<function provideInterface>,
@@ -346,12 +346,12 @@
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X'),
<function handler>,
- ('provideAdapter',
+ ('registerAdapter',
+ <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
(<InterfaceClass zope.app.container.interfaces.IAdding>,
<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
<InterfaceClass zope.app.publisher.interfaces.browser.AddMenu>,
'Add an X',
- <zope.app.publisher.browser.menumeta.MenuItemFactory object>,
'')),
(None,
<function provideInterface>,
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_browserlanguages.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_browserlanguages.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_browserlanguages.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,16 +17,15 @@
"""
import unittest
+import zope.component
from zope.interface import directlyProvides
from zope.publisher.browser import BrowserLanguages
from zope.publisher.tests.test_browserlanguages import TestRequest
from zope.publisher.tests.test_browserlanguages import BrowserLanguagesTest
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.annotation.attribute import AttributeAnnotations
-from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.annotation import IAttributeAnnotatable, IAnnotations
-from zope.app.annotation.attribute import AttributeAnnotations
-
from zope.app.publisher.browser import CacheableBrowserLanguages
from zope.app.publisher.browser import ModifiableBrowserLanguages
from zope.app.publisher.browser import NotCompatibleAdapterError
@@ -36,8 +35,7 @@
def setUp(self):
super(CacheableBrowserLanguagesTests, self).setUp()
- ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,
- AttributeAnnotations)
+ zope.component.provideAdapter(AttributeAnnotations)
def factory(self, request):
directlyProvides(request, IAttributeAnnotatable)
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_directives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -30,7 +30,11 @@
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.publisher.interfaces.browser import IBrowserSkinType, IDefaultSkin
from zope.security.proxy import removeSecurityProxy, ProxyFactory
+from zope.security.permission import Permission
+from zope.security.interfaces import IPermission
from zope.testing.doctestunit import DocTestSuite
+from zope.traversing.adapters import DefaultTraversable
+from zope.traversing.interfaces import ITraversable
import zope.app.publisher.browser
from zope.app import zapi
@@ -39,13 +43,8 @@
from zope.app.publisher.browser.i18nfileresource import I18nFileResource
from zope.app.publisher.browser.menu import getFirstMenuItem
from zope.app.publisher.interfaces.browser import IMenuItemType
-from zope.app.security.permission import Permission
-from zope.app.security.interfaces import IPermission
from zope.app.testing import placelesssetup, ztapi
-from zope.app.traversing.adapters import DefaultTraversable
-from zope.app.traversing.interfaces import ITraversable
-
tests_path = os.path.join(
os.path.dirname(zope.app.publisher.browser.__file__),
'tests')
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_icondirective.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_icondirective.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_icondirective.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -26,6 +26,7 @@
from zope.security.checker import ProxyFactory, CheckerPublic
from zope.security.interfaces import Forbidden
from zope.security.proxy import removeSecurityProxy
+from zope.traversing.interfaces import IContainmentRoot
import zope.app.publisher.browser
from zope.app import zapi
@@ -33,7 +34,6 @@
from zope.app.component.interfaces import ISite
from zope.app.publisher.browser.tests import support
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.traversing.interfaces import IContainmentRoot
template = """<configure
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_pagetemplateresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_pagetemplateresource.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_pagetemplateresource.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,16 +18,16 @@
import os
from unittest import TestCase, main, makeSuite
+import zope.component
from zope.publisher.interfaces import NotFound
-from zope.app.testing import ztapi
from zope.security.checker import NamesChecker
from zope.publisher.browser import TestRequest
+from zope.traversing.interfaces import ITraversable
+from zope.traversing.adapters import DefaultTraversable
from zope.app.testing.placelesssetup import PlacelessSetup
from zope.app.publisher.browser.pagetemplateresource import \
PageTemplateResourceFactory
-from zope.app.traversing.interfaces import ITraversable
-from zope.app.traversing.adapters import DefaultTraversable
import zope.app.publisher.browser.tests as p
test_directory = os.path.dirname(p.__file__)
@@ -40,7 +40,7 @@
def setUp(self):
super(Test, self).setUp()
- ztapi.provideAdapter(None, ITraversable, DefaultTraversable)
+ zope.component.provideAdapter(DefaultTraversable, (None,), ITraversable)
def testNoTraversal(self):
path = os.path.join(test_directory, 'testfiles', 'test.pt')
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_resources.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_resources.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_resources.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,16 +16,16 @@
$Id$
"""
from unittest import TestCase, main, makeSuite
-from zope.app.testing import ztapi
-from zope.app.testing.placelesssetup import PlacelessSetup
from zope.i18n.interfaces import IUserPreferredCharsets
-
from zope.publisher.http import IHTTPRequest
from zope.publisher.http import HTTPCharsets
from zope.publisher.browser import TestRequest
-from zope.app.publisher.interfaces.browser import IBrowserView
+from zope.publisher.interfaces.browser import IBrowserView
+from zope.app.testing import ztapi
+from zope.app.testing.placelesssetup import PlacelessSetup
+
class Test(PlacelessSetup, TestCase):
def setUp(self):
Modified: Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/viewmeta.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,26 +17,23 @@
"""
import os
-from zope.component.exceptions import ComponentLookupError
-from zope.component.interfaces import IDefaultViewName
+from zope.component import queryMultiAdapter
+from zope.component.interfaces import ComponentLookupError, IDefaultViewName
+from zope.component.interface import provideInterface
+from zope.component.zcml import handler
from zope.interface import implements, classImplements, Interface
from zope.publisher.interfaces import NotFound
-from zope.security.checker import CheckerPublic, Checker
-from zope.security.checker import defineChecker
+from zope.security.checker import CheckerPublic, Checker, defineChecker
from zope.configuration.exceptions import ConfigurationError
-from zope.app.component.interface import provideInterface
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.publisher.interfaces.browser import IBrowserPublisher
-from zope.app import zapi
-from zope.app.component.metaconfigure import handler
+from zope.publisher.browser import BrowserView
+
from zope.app.pagetemplate.simpleviewclass import SimpleViewClass
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.app.publisher.browser import BrowserView
from zope.app.publisher.browser.menumeta import menuItemDirective
-
-
# There are three cases we want to suport:
#
# Named view without pages (single-page view)
@@ -93,19 +90,6 @@
allowed_interface=None, allowed_attributes=None,
attribute='__call__', menu=None, title=None,
):
-
- # BBB: Goes away in 3.3.
- # Handle old default layer code. Code that reused the page directive will
- # send a string.
- if layer == 'default':
- import warnings
- warnings.warn(
- 'Strings as layer names are not supported anymore. In the case '
- 'of the `default` layer, please use the `IDefaultBrowserLayer` '
- 'instead. This support goes away in Zope 3.3.',
- DeprecationWarning, 2)
- layer = IDefaultBrowserLayer
-
_handle_menu(_context, menu, title, [for_], name, permission, layer)
required = {}
@@ -174,8 +158,8 @@
_context.action(
discriminator = ('view', for_, name, IBrowserRequest, layer),
callable = handler,
- args = ('provideAdapter',
- (for_, layer), Interface, name, new_class, _context.info),
+ args = ('registerAdapter',
+ new_class, (for_, layer), Interface, name, _context.info),
)
@@ -284,7 +268,7 @@
if name in pages:
return getattr(self, pages[name])
- view = zapi.queryMultiAdapter((self, request), name=name)
+ view = queryMultiAdapter((self, request), name=name)
if view is not None:
return view
@@ -297,7 +281,7 @@
if name in pages:
return getattr(self, pages[name])
- view = zapi.queryMultiAdapter((self, request), name=name)
+ view = queryMultiAdapter((self, request), name=name)
if view is not None:
return view
@@ -351,8 +335,8 @@
_context.action(
discriminator = ('view', (for_, layer), name, self.provides),
callable = handler,
- args = ('provideAdapter',
- (for_, layer), self.provides, name, newclass,
+ args = ('registerAdapter',
+ newclass, (for_, layer), self.provides, name,
_context.info),
)
Modified: Zope3/trunk/src/zope/app/publisher/browser/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/vocabulary.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/browser/vocabulary.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,8 +17,8 @@
"""
from zope.interface import classProvides
from zope.publisher.interfaces.browser import IBrowserSkinType
+from zope.schema.interfaces import IVocabularyFactory
from zope.app.component.vocabulary import UtilityVocabulary
-from zope.app.schema.interfaces import IVocabularyFactory
class BrowserSkinsVocabulary(UtilityVocabulary):
classProvides(IVocabularyFactory)
Modified: Zope3/trunk/src/zope/app/publisher/fieldconverters.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/fieldconverters.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/fieldconverters.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,13 +18,13 @@
from datetime import datetime
from zope.publisher.browser import registerTypeConverter
-from zope.app.datetimeutils import parse as parseDateTime
+from zope.datetime import parse as parseDateTime
def field2date_via_datetimeutils(v):
"""Converter for request fields marshalled as ':date'.
o TODO: Uses the non-localized and non-tzinfo-aware 'parseDateTime'
- utility from zope.app.datetimeutils; a better alternative
+ utility from zope.datetime; a better alternative
would be more I18N / L10N aware, perhaps even adapting to
the expressed preferences of the user.
"""
Modified: Zope3/trunk/src/zope/app/publisher/fileresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/fileresource.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/fileresource.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,11 +17,10 @@
"""
import os
import posixpath
-
from time import time
-from zope.app.contenttypes import guess_content_type
-from zope.app.datetimeutils import rfc1123_date
+from zope.contenttype import guess_content_type
+from zope.datetime import rfc1123_date
class File(object):
Modified: Zope3/trunk/src/zope/app/publisher/interfaces/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/interfaces/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/interfaces/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,16 +15,23 @@
$Id$
"""
-from zope.component.interfaces import IView
from zope.app.i18n import ZopeMessageFactory as _
from zope.interface import Interface, directlyProvides
from zope.interface.interfaces import IInterface
from zope.schema import TextLine, Text, Choice, URI, Int, InterfaceField
+##############################################################################
+# BBB 2006/04/03 - to be removed after 12 months
-class IBrowserView(IView):
- """Browser View"""
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "IBrowserView has been moved to zope.publisher.interfaces.browser. "
+ "This reference will be removed in Zope 3.5.",
+ IBrowserView = 'zope.publisher.interfaces.browser:IBrowserView',
+ )
+#
+##############################################################################
class IMenuItemType(IInterface):
"""Menu item type
Modified: Zope3/trunk/src/zope/app/publisher/xmlrpc/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/publisher/xmlrpc/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/xmlrpc/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -144,7 +144,7 @@
particulat, it has an adapter that simply traverses to attributes.
If an XML-RPC view isn't going to be public, then it also has to
-implement 'zope.app.location.ILocation' so that security grants can be
+implement 'zope.location.ILocation' so that security grants can be
acquired for it, at least with Zope's default security policy. The
`MethodPublisher` class does that too.
Modified: Zope3/trunk/src/zope/app/publisher/xmlrpc/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/xmlrpc/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/xmlrpc/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,9 +18,9 @@
$Id$
"""
import zope.interface
-import zope.app.location
+import zope.location
+import zope.publisher.interfaces.xmlrpc
import zope.app.publisher.interfaces.xmlrpc
-import zope.publisher.interfaces.xmlrpc
class XMLRPCView(object):
"""A base XML-RPC view that can be used as mix-in for XML-RPC views."""
@@ -35,7 +35,7 @@
"""
# Need to test new __parent__ attribute
-class MethodPublisher(XMLRPCView, zope.app.location.Location):
+class MethodPublisher(XMLRPCView, zope.location.Location):
"""Base class for very simple XML-RPC views that publish methods
This class is meant to be more of an example than a standard base class.
Modified: Zope3/trunk/src/zope/app/publisher/xmlrpc/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/xmlrpc/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/xmlrpc/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,10 +20,9 @@
from zope.security.checker import CheckerPublic, Checker
from zope.configuration.exceptions import ConfigurationError
from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
+from zope.component.interface import provideInterface
+from zope.component.zcml import handler
-from zope.app import zapi
-from zope.app.component.interface import provideInterface
-from zope.app.component.metaconfigure import handler
from zope.app.publisher.xmlrpc import MethodPublisher
def view(_context, for_=None, interface=None, methods=None,
@@ -78,8 +77,8 @@
_context.action(
discriminator = ('view', for_, name, IXMLRPCRequest),
callable = handler,
- args = ('provideAdapter',
- (for_, IXMLRPCRequest), Interface, name, class_,
+ args = ('registerAdapter',
+ class_, (for_, IXMLRPCRequest), Interface, name,
_context.info)
)
else:
@@ -96,8 +95,8 @@
_context.action(
discriminator = ('view', for_, name, IXMLRPCRequest),
callable = handler,
- args = ('provideAdapter',
- (for_, IXMLRPCRequest), Interface, name, new_class,
+ args = ('registerAdapter',
+ new_class, (for_, IXMLRPCRequest), Interface, name,
_context.info)
)
Modified: Zope3/trunk/src/zope/app/publisher/xmlrpc/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/xmlrpc/metadirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/xmlrpc/metadirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,9 +18,8 @@
import zope.configuration.fields
import zope.interface
import zope.schema
+import zope.security.zcml
-import zope.app.security.fields
-
class IViewDirective(zope.interface.Interface):
"""View Directive for XML-RPC methods."""
@@ -51,7 +50,7 @@
required=False
)
- permission = zope.app.security.fields.Permission(
+ permission = zope.security.zcml.Permission(
title=u"Permission",
description=u"""The permission needed to use the view.
Modified: Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/test_directives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/test_directives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,12 +19,9 @@
from zope.configuration import xmlconfig
from zope.configuration.exceptions import ConfigurationError
-from zope.app.component.tests.views import IC, V1
+from zope.app.component.tests.views import Request, IC, V1
from zope.app.testing.placelesssetup import PlacelessSetup
from zope.security.proxy import ProxyFactory
-
-from zope.component.tests.request import Request
-
from zope.publisher.interfaces.xmlrpc import IXMLRPCRequest
from zope.app import zapi
Modified: Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/xmlrpc_error.zcml
===================================================================
--- Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/xmlrpc_error.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/publisher/xmlrpc/tests/xmlrpc_error.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -6,8 +6,8 @@
<xmlrpc:view
name="test"
- factory="zope.component.tests.views.V1"
- for="zope.component.tests.views.IC"
+ factory="zope.app.component.tests.views.V1"
+ for="zope.app.component.tests.views.IC"
methods="action index"
permission="zope.Public" />
Modified: Zope3/trunk/src/zope/app/pythonpage/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/pythonpage/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pythonpage/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,7 +23,7 @@
set_attributes="source contentType"
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
Modified: Zope3/trunk/src/zope/app/pythonpage/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/pythonpage/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/pythonpage/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,19 +16,20 @@
$Id$
"""
import unittest
-from zope.app import zapi
+
+import zope.component
+from zope.interface import implements
+from zope.testing.doctestunit import DocTestSuite
+from zope.traversing.interfaces import IContainmentRoot
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.traversing.adapters import RootPhysicallyLocatable
+from zope.location.traversing import LocationPhysicallyLocatable
+
from zope.app.container.contained import Contained
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.app.traversing.interfaces import IPhysicallyLocatable
from zope.app.interpreter.interfaces import IInterpreter
from zope.app.interpreter.python import PythonInterpreter
-from zope.app.location.traversing import LocationPhysicallyLocatable
from zope.app.testing import placelesssetup, ztapi
-from zope.app.traversing.adapters import RootPhysicallyLocatable
-from zope.interface import implements
-from zope.testing.doctestunit import DocTestSuite
-
class Root(Contained):
implements(IContainmentRoot)
@@ -37,8 +38,8 @@
def setUp(test):
placelesssetup.setUp()
- sm = zapi.getGlobalSiteManager()
- sm.provideUtility(IInterpreter, PythonInterpreter, 'text/server-python')
+ sm = zope.component.getGlobalSiteManager()
+ sm.registerUtility(PythonInterpreter, IInterpreter, 'text/server-python')
ztapi.provideAdapter(None, IPhysicallyLocatable,
LocationPhysicallyLocatable)
Deleted: Zope3/trunk/src/zope/app/rdb/SETUP.cfg
===================================================================
--- Zope3/trunk/src/zope/app/rdb/SETUP.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/SETUP.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,5 +0,0 @@
-# Tell zpkg how to install the ZCML slugs.
-
-<data-files zopeskel/etc/package-includes>
- rdb-*.zcml
-</data-files>
Modified: Zope3/trunk/src/zope/app/rdb/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/rdb/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,483 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Zope RDBMS Transaction Integration.
-
-Provides a proxy for interaction between the zope transaction
-framework and the db-api connection. Databases which want to support
-sub transactions need to implement their own proxy.
-
-$Id$
-"""
-import re
-import time, random, thread
-from urllib import unquote_plus
-
-from persistent import Persistent
-
-import transaction
-from transaction.interfaces import IDataManager
-
-from zope.security.checker import NamesChecker
-
-from zope.interface import implements
-from zope.app.container.contained import Contained
-from zope.app.rdb.interfaces import DatabaseException, DatabaseAdapterError
-from zope.app.rdb.interfaces import IResultSet
-from zope.app.rdb.interfaces import IZopeConnection, IZopeCursor
-from zope.app.rdb.interfaces import IManageableZopeDatabaseAdapter
-from zope.thread import local
-
-
-DEFAULT_ENCODING = "utf-8"
-
-def sqlquote(x):
- r"""
- Escape data suitable for inclusion in generated ANSI SQL92 code for
- cases where bound variables are not suitable.
-
- >>> sqlquote("Hi")
- "'Hi'"
- >>> sqlquote("It's mine")
- "'It''s mine'"
- >>> sqlquote("\\'")
- "'\\\\'''"
- >>> sqlquote(u"\\'")
- u"'\\\\'''"
- >>> sqlquote(32)
- 32
- >>> sqlquote(None)
- 'NULL'
- """
- if isinstance(x, (str, unicode)):
- x = "'%s'" % x.replace('\\', '\\\\').replace("'", "''")
- elif isinstance(x, (int, long, float)):
- pass
- elif x is None:
- x = 'NULL'
- else:
- raise TypeError('do not know how to handle type %s' % type(x))
- return x
-
-
-class ResultSet(list):
- """Database Result Set.
-
- Currently we don't do lazy instantation of rows.
- """
-
- implements(IResultSet)
- __slots__ = ('columns',)
-
- def __init__(self, columns, rows):
- self.columns = tuple(columns)
- row_class = RowClassFactory(columns)
- super(ResultSet, self).__init__(map(row_class, rows))
-
- __safe_for_unpickling__ = True
-
- def __reduce__(self):
- cols = self.columns
- return (ResultSet,
- (cols, [[getattr(row, col) for col in cols] for row in self])
- )
-
- def __cmp__(self, other):
- if not isinstance(other, ResultSet):
- return super(ResultSet, self).__cmp__(other)
- c = cmp(self.columns, other.columns)
- if c:
- return c
- for row, other_row in zip(self, other):
- c = cmp(row, other_row)
- if c:
- return c
- return cmp(len(self), len(other))
-
-
-class ZopeDatabaseAdapter(Persistent, Contained):
-
- implements(IManageableZopeDatabaseAdapter)
-
- # We need to store our connections in a thread local to ensure that
- # different threads do not accidently use the same connection. This
- # is important when instantiating database adapters using
- # rdb:provideConnection as the same ZopeDatabaseAdapter instance will
- # be used by all threads.
- _connections = local()
-
- def __init__(self, dsn):
- self.setDSN(dsn)
- self._unique_id = '%s.%s.%s' % (
- time.time(), random.random(), thread.get_ident()
- )
-
- def _get_v_connection(self):
- """We used to store the ZopeConnection in a volatile attribute.
- However this was not always thread safe.
- """
- return getattr(ZopeDatabaseAdapter._connections, self._unique_id, None)
-
- def _set_v_connection(self, value):
- setattr(ZopeDatabaseAdapter._connections, self._unique_id, value)
-
- _v_connection = property(_get_v_connection, _set_v_connection)
-
- def _connection_factory(self):
- """This method should be overwritten by all subclasses"""
- conn_info = parseDSN(self.dsn)
-
- def setDSN(self, dsn):
- assert dsn.startswith('dbi://'), "The DSN has to start with 'dbi://'"
- self.dsn = dsn
-
- def getDSN(self):
- return self.dsn
-
- def connect(self):
- if not self.isConnected():
- try:
- self._v_connection = ZopeConnection(
- self._connection_factory(), self)
- except DatabaseException:
- raise
- # Note: I added the general Exception, since the DA can return
- # implementation-specific errors. But we really want to catch all
- # issues at this point, so that we can convert it to a
- # DatabaseException.
- except Exception, error:
- raise DatabaseException(str(error))
-
- def disconnect(self):
- if self.isConnected():
- self._v_connection.close()
- self._v_connection = None
-
- def isConnected(self):
- return self._v_connection is not None
-
- def __call__(self):
- self.connect()
- return self._v_connection
-
- # Pessimistic defaults
- paramstyle = 'pyformat'
- threadsafety = 0
- encoding = DEFAULT_ENCODING
-
- def setEncoding(self, encoding):
- # Check the encoding
- "".decode(encoding)
- self.encoding = encoding
-
- def getEncoding(self):
- return self.encoding
-
- def getConverter(self, type):
- 'See IDBITypeInfo'
- return identity
-
-def identity(x):
- return x
-
-_dsnFormat = re.compile(
- r"dbi://"
- r"(((?P<username>.*?)(:(?P<password>.*?))?)?"
- r"(@(?P<host>.*?)(:(?P<port>.*?))?)?/)?"
- r"(?P<dbname>.*?)(;(?P<raw_params>.*))?"
- r"$"
+# This module has moved to zope.rdb
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.rdb',
+ "Zope 3.5",
)
-
-_paramsFormat = re.compile(r"([^=]+)=([^;]*);?")
-
-def parseDSN(dsn):
- """Parses a database connection string.
-
- We could have the following cases:
-
- dbi://dbname
- dbi://dbname;param1=value...
- dbi://user/dbname
- dbi://user:passwd/dbname
- dbi://user:passwd/dbname;param1=value...
- dbi://user@host/dbname
- dbi://user:passwd@host/dbname
- dbi://user:passwd@host:port/dbname
- dbi://user:passwd@host:port/dbname;param1=value...
-
- Any values that might contain characters special for URIs need to be
- quoted as it would be returned by `urllib.quote_plus`.
-
- Return value is a mapping with the following keys:
-
- username username (if given) or an empty string
- password password (if given) or an empty string
- host host (if given) or an empty string
- port port (if given) or an empty string
- dbname database name
- parameters a mapping of additional parameters to their values
- """
-
- if not isinstance(dsn, (str, unicode)):
- raise ValueError('The dsn is not a string. It is a %r' % type(dsn))
-
- match = _dsnFormat.match(dsn)
- if match is None:
- raise ValueError('Invalid DSN; must start with "dbi://": %r' % dsn)
-
- result = match.groupdict("")
- raw_params = result.pop("raw_params")
-
- for key, value in result.items():
- result[key] = unquote_plus(value)
-
- params = _paramsFormat.findall(raw_params)
- result["parameters"] = dict([(unquote_plus(key), unquote_plus(value))
- for key, value in params])
-
- return result
-
-
-class ZopeCursor(object):
- implements(IZopeCursor)
-
- def __init__(self, cursor, connection):
- self.cursor = cursor
- self.connection = connection
-
- def execute(self, operation, parameters=None):
- """Executes an operation, registering the underlying
- connection with the transaction system. """
- operation, parameters = self._prepareOperation(operation, parameters)
- self.connection.registerForTxn()
- if parameters is None:
- return self.cursor.execute(operation)
- return self.cursor.execute(operation, parameters)
-
- def executemany(self, operation, parameters):
- """Executes an operation, registering the underlying
- connection with the transaction system. """
- operation, parameters = self._prepareOperation(operation, parameters)
- # If executemany() is not defined pass parameters
- # to execute() as defined by DB API v.1
- method = getattr(self.cursor, "executemany", self.cursor.execute)
- self.connection.registerForTxn()
- return method(operation, parameters)
-
- def _prepareOperation(self, operation, parameters):
- encoding = self.connection.getTypeInfo().getEncoding()
- if isinstance(operation, unicode):
- operation = operation.encode(encoding)
- parameters = self._prepareParameters(parameters, encoding)
- return operation, parameters
-
- def _prepareParameters(self, parameters, encoding):
- if isinstance(parameters, list):
- for i, v in enumerate(parameters):
- if isinstance(v, unicode):
- parameters[i] = v.encode(encoding)
- else:
- parameters[i] = self._prepareParameters(v, encoding)
- elif isinstance(parameters, tuple):
- parameters = list(parameters)
- for i, v in enumerate(parameters):
- if isinstance(v, unicode):
- parameters[i] = v.encode(encoding)
- parameters = tuple(parameters)
- elif isinstance(parameters, dict):
- for k, v in parameters.items():
- if isinstance(v, unicode):
- parameters[k] = v.encode(encoding)
- return parameters
-
- def __getattr__(self, key):
- return getattr(self.cursor, key)
-
- def fetchone(self):
- results = self.cursor.fetchone()
- if results is None:
- return None
- return self._convertTypes([results])[0]
-
- def fetchmany(self, *args, **kw):
- results = self.cursor.fetchmany(*args, **kw)
- return self._convertTypes(results)
-
- def fetchall(self):
- results = self.cursor.fetchall()
- return self._convertTypes(results)
-
- def _convertTypes(self, results):
- "Perform type conversion on query results"
- getConverter = self.connection.getTypeInfo().getConverter
- converters = [getConverter(col_info[1])
- for col_info in self.cursor.description]
-## A possible optimization -- need benchmarks to check if it is worth it
-## if [x for x in converters if x is not ZopeDatabaseAdapter.identity]:
-## return results # optimize away
-
- def convertRow(row):
- return map(lambda converter, value: converter(value),
- converters, row)
-
- return map(convertRow, results)
-
-class ZopeConnection(object):
-
- implements(IZopeConnection)
-
- def __init__(self, conn, typeinfo):
- self.conn = conn
- self._txn_registered = False
- self._type_info = typeinfo
-
- def __getattr__(self, key):
- # The IDBIConnection interface is hereby implemented
- return getattr(self.conn, key)
-
- def cursor(self):
- 'See IZopeConnection'
- return ZopeCursor(self.conn.cursor(), self)
-
- def registerForTxn(self):
- 'See IZopeConnection'
- if not self._txn_registered:
- tm = ZopeDBTransactionManager(self)
- transaction.get().join(tm)
- self._txn_registered = True
-
- def commit(self):
- 'See IDBIConnection'
- self._txn_registered = False
- self.conn.commit()
-
- def rollback(self):
- 'See IDBIConnection'
- self._txn_registered = False
- self.conn.rollback()
-
- def getTypeInfo(self):
- 'See IDBITypeInfoProvider'
- return self._type_info
-
-
-def queryForResults(conn, query):
- """Convenience function to quickly execute a query."""
-
- cursor = conn.cursor()
-
- try:
- cursor.execute(query)
- except Exception, error:
- # Just catch the exception, so that we can convert it to a database
- # exception.
- raise DatabaseException(str(error))
-
- if cursor.description is not None:
- columns = [c[0] for c in cursor.description]
- results = cursor.fetchall()
- else:
- # Handle the case that the query was not a SELECT
- columns = []
- results = []
-
- return ResultSet(columns, results)
-
-
-class ZopeDBTransactionManager(object):
-
- implements(IDataManager)
-
- def __init__(self, dbconn):
- self._dbconn = dbconn
- self.transaction_manager = transaction.manager
-
- def prepare(self, txn):
- pass
-
- def tpc_begin(self, txn):
- pass
-
- def tpc_vote(self, txn):
- pass
-
- def tpc_finish(self, txn):
- pass
-
- def tpc_abort(self, txn):
- pass
-
- def abort(self, txn):
- self._dbconn.rollback()
-
- def commit(self, txn):
- self._dbconn.commit()
-
- def sortKey(self):
- """
- ZODB uses a global sort order to prevent deadlock when it commits
- transactions involving multiple resource managers. The resource
- manager must define a sortKey() method that provides a global ordering
- for resource managers.
-
- (excerpt from transaction/notes.txt)
- """
- return 'rdb' + str(id(self))
-
-class Row(object):
- """Represents a row in a ResultSet"""
-
- def __init__(self, data):
- for k, v in zip(self.__slots__, data):
- setattr(self, k, v)
-
- def __str__(self):
- return "row class %s" % str(self.__slots__)
-
- def __cmp__(self, other):
- if not isinstance(other, Row):
- return super(Row, self).__cmp__(other)
- c = cmp(self.__slots__, other.__slots__)
- if c:
- return c
- for column in self.__slots__:
- c = cmp(getattr(self, column), getattr(other, column))
- if c:
- return c
- return 0
-
-class InstanceOnlyDescriptor(object):
- __marker = object()
- def __init__(self, value=__marker):
- if value is not self.__marker:
- self.value = value
-
- def __get__(self, inst, cls=None):
- if inst is None:
- raise AttributeError
- return self.value
-
- def __set__(self, inst, value):
- self.value = value
-
- def __delete__(self, inst):
- del self.value
-
-def RowClassFactory(columns):
- """Creates a Row object"""
- klass_namespace = {}
- klass_namespace['__Security_checker__'] = InstanceOnlyDescriptor(
- NamesChecker(columns))
- klass_namespace['__slots__'] = tuple(columns)
-
- return type('GeneratedRowClass', (Row,), klass_namespace)
Property changes on: Zope3/trunk/src/zope/app/rdb/__init__.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.24
Copied: Zope3/trunk/src/zope/app/rdb/browser.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/rdb/browser.py)
Deleted: Zope3/trunk/src/zope/app/rdb/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/rdb/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,59 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- i18n_domain="zope"
- >
-
- <permission
- id="zope.app.rdb.Use"
- title="[zope.app.rdb.Use] Use Database Connections"
- />
-
- <class class="zope.app.rdb.ZopeConnection">
- <require
- permission="zope.ManageContent"
- interface="zope.app.rdb.interfaces.IZopeConnection"
- />
- </class>
-
- <class class="zope.app.rdb.ZopeCursor">
- <require
- permission="zope.ManageContent"
- interface="zope.app.rdb.interfaces.IZopeCursor"
- />
- </class>
-
- <class class="zope.app.rdb.Row">
- <require
- permission="zope.ManageContent"
- attributes="__getattr__"
- />
- </class>
-
- <localUtility class="zope.app.rdb.ZopeDatabaseAdapter">
-
- <require
- permission="zope.app.rdb.Use"
- interface="zope.app.rdb.interfaces.IZopeDatabaseAdapter" />
-
- </localUtility>
-
- <class class="zope.app.rdb.ResultSet">
- <!-- require zope.View for all list methods -->
- <require
- permission="zope.View"
- attributes="__getitem__ __getslice__ __len__ __iter__ __contains__
- index count __str__ __add__ __radd__" />
-
- <!-- Also require zope.View on the columns attribute, which is
- specified in IResultSet -->
- <require
- permission="zope.View"
- attributes="columns"
- />
- </class>
-
- <include file="gadflyda.zcml" />
-
- <include package=".browser" />
-
-</configure>
Deleted: Zope3/trunk/src/zope/app/rdb/gadfly-meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/rdb/gadfly-meta.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/gadfly-meta.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,11 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:meta="http://namespaces.zope.org/meta">
-
- <meta:directive
- namespace="http://namespaces.zope.org/rdb"
- name="gadflyRoot"
- schema=".gadflymeta.IGadflyRoot"
- handler=".gadflymeta.gadflyRootHandler" />
-
-</configure>
Copied: Zope3/trunk/src/zope/app/rdb/gadfly.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/rdb/gadfly.py)
Deleted: Zope3/trunk/src/zope/app/rdb/gadflyda.py
===================================================================
--- Zope3/trunk/src/zope/app/rdb/gadflyda.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/gadflyda.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,101 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Gadfly Database Adapter (batteries included)
-
-$Id$
-"""
-import gadfly
-import os
-
-from zope.app.rdb import ZopeDatabaseAdapter, parseDSN
-from zope.app.rdb import DatabaseException, DatabaseAdapterError
-from zope.app.rdb import ZopeConnection, ZopeCursor
-
-GadflyError = DatabaseAdapterError
-
-
-class GadflyAdapterCursor(ZopeCursor):
-
- def executemany(self, operation, parameters):
- command = operation.split(None, 1)[0].lower()
- if command not in ("insert", "update", "delete"):
- raise DatabaseAdapterError(
- "executemany() is not applicable for %r" % operation)
-
- operation, parameters = self._prepareOperation(operation, parameters)
- self.connection.registerForTxn()
- if command == "insert":
- self.execute(operation, parameters)
- else:
- for param in parameters:
- self.execute(operation, param)
-
-class GadflyAdapterConnection(ZopeConnection):
-
- def cursor(self):
- return GadflyAdapterCursor(self.conn.cursor(), self)
-
-class GadflyAdapter(ZopeDatabaseAdapter):
- """A Gadfly adapter for Zope3"""
-
- # The registerable object needs to have a container
- __name__ = __parent__ = None
- _v_connection = None
- paramstyle = 'qmark'
-
- def _connection_factory(self):
- """Create a Gadfly DBI connection based on the DSN.
-
- Only local (filesystem-based) Gadfly connections are supported
- at this moment."""
-
- conn_info = parseDSN(self.dsn)
- if conn_info['host'] != '' or conn_info['username'] != '' or \
- conn_info['port'] != '' or conn_info['password'] != '':
- raise DatabaseAdapterError(
- "DSN for GadflyDA must be of the form "
- "dbi://dbname or dbi://dbname;dir=directory."
- )
-
- connection = conn_info['dbname']
- dir = os.path.join(getGadflyRoot(),
- conn_info['parameters'].get('dir', connection))
-
- if not os.path.isdir(dir):
- raise DatabaseAdapterError('Not a directory ' + dir)
-
- if not os.path.exists(os.path.join(dir, connection + ".gfd")):
- db = gadfly.gadfly()
- db.startup(connection, dir)
- else:
- db = gadfly.gadfly(connection, dir)
-
- return db
-
- def connect(self):
- if not self.isConnected():
- try:
- self._v_connection = GadflyAdapterConnection(
- self._connection_factory(), self)
- except gadfly.error, error:
- raise DatabaseException(str(error))
-
-_gadflyRoot = 'gadfly'
-
-def setGadflyRoot(path='gadfly'):
- global _gadflyRoot
- _gadflyRoot = path
-
-def getGadflyRoot():
- return _gadflyRoot
Deleted: Zope3/trunk/src/zope/app/rdb/gadflyda.zcml
===================================================================
--- Zope3/trunk/src/zope/app/rdb/gadflyda.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/gadflyda.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,24 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope">
-
- <class class="zope.app.rdb.gadflyda.GadflyAdapter">
- <factory
- title="Gadfly Database Adapter" />
- <require
- permission="zope.app.rdb.Use"
- interface="zope.app.rdb.interfaces.IZopeDatabaseAdapter" />
- <require
- permission="zope.ManageServices"
- interface="zope.app.rdb.interfaces.IZopeDatabaseAdapterManagement" />
- </class>
-
- <class class="zope.app.rdb.gadflyda.GadflyAdapterCursor">
- <allow
- interface="zope.app.rdb.interfaces.IZopeCursor" />
- </class>
-
- <class class="zope.app.rdb.gadflyda.GadflyAdapterConnection">
- <allow
- interface="zope.app.rdb.interfaces.IZopeConnection" />
- </class>
-
-</configure>
Deleted: Zope3/trunk/src/zope/app/rdb/gadflymeta.py
===================================================================
--- Zope3/trunk/src/zope/app/rdb/gadflymeta.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/gadflymeta.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,38 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""'gadflyRoot' Directive Handler
-
-$Id: metaconfigure.py 25177 2004-06-02 13:17:31Z jim $
-"""
-from zope.configuration.fields import Path
-from zope.interface import Interface
-
-from zope.app import zapi
-from zope.app.rdb.gadflyda import setGadflyRoot
-
-class IGadflyRoot(Interface):
- """This directive creates a globale connection to an RDBMS."""
-
- path = Path(
- title=u"Path of Gadfly Root",
- description=u"Specifies the path of the gadfly root relative to the"
- u"packge.",
- required=True)
-
-
-def gadflyRootHandler(_context, path):
- _context.action(
- discriminator = ('gadflyRoot',),
- callable = setGadflyRoot,
- args = (path,) )
Modified: Zope3/trunk/src/zope/app/rdb/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/rdb/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,333 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Relational Database Adapter interfaces.
-
-$Id$
-"""
-from zope.interface import Interface
-from zope.interface import Attribute
-from zope.schema import TextLine
-from zope.app.i18n import ZopeMessageFactory as _
-
-
-class IDBITypeInfoProvider(Interface):
- """This object can get the Type Info for a particular DBI
- implementation."""
-
- def getTypeInfo():
- """Return an IDBITypeInfo object."""
-
-class IDBITypeInfo(Interface):
- """Database adapter specific information"""
-
- paramstyle = Attribute("""
- String constant stating the type of parameter marker formatting
- expected by the interface. Possible values are [2]:
-
- 'qmark' = Question mark style, e.g. '...WHERE name=?'
- 'numeric' = Numeric, positional style, e.g. '...WHERE name=:1'
- 'named' = Named style, e.g. '...WHERE name=:name'
- 'format' = ANSI C printf format codes, e.g. '...WHERE name=%s'
- 'pyformat' = Python extended format codes, e.g. '...WHERE name=%(name)s'
- """)
-
- threadsafety = Attribute("""
- Integer constant stating the level of thread safety the interface
- supports. Possible values are:
-
- 0 = Threads may not share the module.
- 1 = Threads may share the module, but not connections.
- 2 = Threads may share the module and connections.
- 3 = Threads may share the module, connections and cursors.
-
- Sharing in the above context means that two threads may use a resource
- without wrapping it using a mutex semaphore to implement resource
- locking. Note that you cannot always make external resources thread
- safe by managing access using a mutex: the resource may rely on global
- variables or other external sources that are beyond your control.
- """)
-
- encoding = TextLine(
- title=_("Database encoding"),
- description=_("Encoding of the database content"),
- default=u"utf-8",
- required=False
- )
-
- def getEncoding():
- """Get the database encoding."""
-
- def setEncoding(encoding):
- """Set the database encoding."""
-
- def getConverter(type):
- """Return a converter function for field type matching key"""
-
-class IResultSet(Interface):
- """Holds results, and allows iteration."""
-
- columns = Attribute("""A list of the column names of the returned result
- set.""")
-
- def __getitem__(index):
- """Return a brain row for index."""
-
-
-class DatabaseException(Exception):
- """Generic Database Error"""
-
- def __init__(self, message):
- self.message = message
-
- def __str__(self):
- return self.message
-
-class DatabaseAdapterError(DatabaseException):
- pass
-
-arraysize = 1 # default constant, symbolic
-
-class IDBICursor(Interface):
- """DB API ICursor interface"""
-
- description = Attribute("""This read-only attribute is a sequence of
- 7-item sequences. Each of these sequences contains information
- describing one result column: (name, type_code, display_size,
- internal_size, precision, scale, null_ok). This attribute will be None
- for operations that do not return rows or if the cursor has not had an
- operation invoked via the executeZZZ() method yet.
-
- The type_code can be interpreted by comparing it to the Type Objects
- specified in the section below. """)
-
- arraysize = Attribute("""This read/write attribute specifies the number of
- rows to fetch at a time with fetchmany(). It defaults to 1 meaning to
- fetch a single row at a time.
-
- Implementations must observe this value with respect to the
- fetchmany() method, but are free to interact with the database a
- single row at a time. It may also be used in the implementation of
- executemany().
- """)
-
- def close():
- """Close the cursor now (rather than whenever __del__ is called). The
- cursor will be unusable from this point forward; an Error (or
- subclass) exception will be raised if any operation is attempted with
- the cursor.
- """
-
- def execute(operation, parameters=None):
- """Prepare and execute a database operation (query or
- command). Parameters may be provided as sequence or mapping and will
- be bound to variables in the operation. Variables are specified in a
- database-specific notation (see the module's paramstyle attribute for
- details). [5]
-
- A reference to the operation will be retained by the cursor. If the
- same operation object is passed in again, then the cursor can optimize
- its behavior. This is most effective for algorithms where the same
- operation is used, but different parameters are bound to it (many
- times).
-
- For maximum efficiency when reusing an operation, it is best to use
- the setinputsizes() method to specify the parameter types and sizes
- ahead of time. It is legal for a parameter to not match the predefined
- information; the implementation should compensate, possibly with a
- loss of efficiency.
-
- The parameters may also be specified as list of tuples to e.g. insert
- multiple rows in a single operation, but this kind of usage is
- depreciated: executemany() should be used instead.
-
- Return values are not defined.
- """
-
- def executemany(operation, seq_of_parameters):
- """Prepare a database operation (query or command) and then execute it
- against all parameter sequences or mappings found in the sequence
- seq_of_parameters.
-
- Modules are free to implement this method using multiple calls to the
- execute() method or by using array operations to have the database
- process the sequence as a whole in one call.
-
- The same comments as for execute() also apply accordingly to this
- method.
-
- Return values are not defined.
- """
-
- def fetchone():
- """Fetch the next row of a query result set, returning a single
- sequence, or None when no more data is available. [6]
-
- An Error (or subclass) exception is raised if the previous call to
- executeZZZ() did not produce any result set or no call was issued yet.
- """
-
- def fetchmany(size=arraysize):
- """Fetch the next set of rows of a query result, returning a sequence
- of sequences (e.g. a list of tuples). An empty sequence is returned
- when no more rows are available.
-
- The number of rows to fetch per call is specified by the parameter. If
- it is not given, the cursor's arraysize determines the number of rows
- to be fetched. The method should try to fetch as many rows as
- indicated by the size parameter. If this is not possible due to the
- specified number of rows not being available, fewer rows may be
- returned.
-
- An Error (or subclass) exception is raised if the previous call to
- executeZZZ() did not produce any result set or no call was issued yet.
-
- Note there are performance considerations involved with the size
- parameter. For optimal performance, it is usually best to use the
- arraysize attribute. If the size parameter is used, then it is best
- for it to retain the same value from one fetchmany() call to the next.
- """
-
- def fetchall():
- """Fetch all (remaining) rows of a query result, returning them as a
- sequence of sequences (e.g. a list of tuples). Note that the cursor's
- arraysize attribute can affect the performance of this operation.
-
- An Error (or subclass) exception is raised if the previous call to
- executeZZZ() did not produce any result set or no call was issued yet.
- """
-
-class IDBIConnection(Interface):
- """A DB-API based Interface """
-
- def cursor():
- """Return a new IDBICursor Object using the connection.
-
- If the database does not provide a direct cursor concept, the module
- will have to emulate cursors using other means to the extent needed by
- this specification. """
-
- def commit():
- """Commit any pending transaction to the database. Note that if the
- database supports an auto-commit feature, this must be initially off.
- An interface method may be provided to turn it back on.
-
- Database modules that do not support transactions should implement
- this method with void functionality.
- """
-
- def rollback():
- """In case a database does provide transactions this method causes the
- database to roll back to the start of any pending transaction. Closing
- a connection without committing the changes first will cause an
- implicit rollback to be performed. """
-
- def close():
- """Close the connection now (rather than whenever __del__ is
- called). The connection will be unusable from this point forward; an
- Error (or subclass) exception will be raised if any operation is
- attempted with the connection. The same applies to all cursor objects
- trying to use the connection. """
-
-class ISQLCommand(Interface):
- """Static SQL commands."""
-
- connectionName = Attribute("""The name of the database connection
- to use in getConnection """)
-
- def getConnection():
- """Get the database connection."""
-
- def __call__():
- """Execute an sql query and return a result object if appropriate"""
-
-class IZopeDatabaseAdapter(IDBITypeInfo):
- """Interface for persistent object that returns
- volatile IZopeConnections."""
-
- def isConnected():
- """Check whether the Zope Connection is actually connected to the
- database."""
-
- def __call__():
- """Return an IZopeConnection object"""
-
-class IZopeDatabaseAdapterManagement(Interface):
-
- def setDSN(dsn):
- """Set the DSN for the Adapter instance"""
-
- def getDSN():
- """Get the DSN of the Adapter instance"""
-
- dsn = TextLine(
- title=_("DSN"),
- description=_(
- "Specify the DSN (Data Source Name) of the database. "
- "Examples include:\n"
- "\n"
- "dbi://dbname\n"
- "dbi://dbname;param1=value...\n"
- "dbi://user:passwd/dbname\n"
- "dbi://user:passwd/dbname;param1=value...\n"
- "dbi://user:passwd@host:port/dbname\n"
- "dbi://user:passwd@host:port/dbname;param1=value...\n"
- "\n"
- "All values should be properly URL-encoded."),
- default=u"dbi://dbname",
- required=True)
-
- def connect():
- """Connect to the specified database."""
-
- def disconnect():
- """Disconnect from the database."""
-
-class IManageableZopeDatabaseAdapter(IZopeDatabaseAdapter,
- IZopeDatabaseAdapterManagement):
- """Database adapters with management functions
- """
-
-class IZopeConnection(IDBIConnection, IDBITypeInfoProvider):
-
- # An implementation of this object will be exposed to the
- # user. Therefore the Zope connection represents a connection in
- # the Zope sense, meaning that the object might not be actually
- # connected to a real relational database.
-
- def cursor():
- """Return an IZopeCursor object."""
-
- def registerForTxn():
- """Join the current transaction.
-
- This method should only be inovoked by the Zope/DB transaction
- manager.
- """
-
-class IZopeCursor(IDBICursor):
- """An IDBICursor that integrates with Zope's transactions"""
-
- def execute(operation, parameters=None):
- """Executes an operation, registering the underlying connection with
- the transaction system.
-
- See IDBICursor for more detailed execute information.
- """
-
- def executemany(operation, seq_of_parameters):
- """Executes an operation, registering the underlying connection with
- the transaction system.
-
- See IDBICursor for more detailed executemany information.
- """
+# This module has moved to zope.rdb.interfaces
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.rdb.interfaces',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/rdb/interfaces.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.1
Deleted: Zope3/trunk/src/zope/app/rdb/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/rdb/meta.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/meta.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,13 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:meta="http://namespaces.zope.org/meta">
-
- <meta:directive
- namespace="http://namespaces.zope.org/rdb"
- name="provideConnection"
- schema=".metadirectives.IProvideConnectionDirective"
- handler=".metaconfigure.connectionhandler" />
-
- <include file="gadfly-meta.zcml" />
-
-</configure>
Deleted: Zope3/trunk/src/zope/app/rdb/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/rdb/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,39 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""'rdb' ZCML Namespace Directive Handler
-
-$Id$
-"""
-from zope.app import zapi
-from zope.app.rdb.interfaces import IZopeDatabaseAdapter
-
-
-def connectionhandler(_context, name, component, dsn):
- connection = component(dsn)
- _context.action(
- discriminator = ('provideConnection', name),
- callable = provideConnection,
- args = (name, connection) )
-
-def provideConnection(name, connection):
- """ Registers a database connection
-
- Uses the global site manager for registering the connection
- """
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(IZopeDatabaseAdapter, connection, name)
-
-
-
-
Deleted: Zope3/trunk/src/zope/app/rdb/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/rdb/metadirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/metadirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,42 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""'rdb' ZCML Namespace Directives
-
-$Id$
-"""
-from zope.configuration.fields import GlobalObject
-from zope.interface import Interface
-from zope.schema import TextLine
-
-class IProvideConnectionDirective(Interface):
- """This directive creates a globale connection to an RDBMS."""
-
- name = TextLine(
- title=u"Name",
- description=u"This is the name the connection will be known as.",
- required=True)
-
- component = GlobalObject(
- title=u"Component",
- description=u"Specifies the component that provides the connection. "
- "This component handles one particular RDBMS.",
- required=True)
-
- dsn = TextLine(
- title=u"DSN",
- description=u"The DSN contains all the connection information. The"\
- u"syntax looks as follows: \n" \
- u"dbi://username:password@host:port/dbname;param1=value...",
- default=u"dbi://localhost/testdb",
- required=True)
Deleted: Zope3/trunk/src/zope/app/rdb/rdb-configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/rdb/rdb-configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/rdb-configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1 +0,0 @@
-<include package="zope.app.rdb"/>
Deleted: Zope3/trunk/src/zope/app/rdb/rdb-meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/rdb/rdb-meta.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rdb/rdb-meta.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1 +0,0 @@
-<include package="zope.app.rdb" file="meta.zcml"/>
Modified: Zope3/trunk/src/zope/app/recorder/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/recorder/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/recorder/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,15 +23,17 @@
import urllib
import datetime
from cStringIO import StringIO
+
from zope.interface import Interface
from zope.schema import Text
+from zope.publisher.browser import BrowserView
+from zope.publisher.interfaces import NotFound
+
from zope.app.form.utility import setUpWidgets, getWidgetsData
from zope.app.form.interfaces import IInputWidget, WidgetsError
-from zope.app.publisher.browser import BrowserView
from zope.app import recorder
from zope.app.testing import dochttp
from zope.app.i18n import ZopeMessageFactory as _
-from zope.publisher.interfaces import NotFound
class IRecorderSessionsFilterForm(Interface):
Modified: Zope3/trunk/src/zope/app/recorder/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/recorder/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/recorder/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,9 +23,8 @@
import unittest
import transaction
from zope.testing import doctest
-from zope.publisher.browser import TestRequest
+from zope.publisher.browser import TestRequest, BrowserView
from zope.app.testing import setup, ztapi
-from zope.app.publisher.browser import BrowserView
def doctest_RecordingProtocol():
@@ -614,10 +613,10 @@
ztapi.browserViewProviding(IText, TextAreaWidget, IInputWidget)
# ++view++ namespace
- from zope.app.traversing.interfaces import ITraversable
- import zope.app.traversing.namespace
+ from zope.traversing.interfaces import ITraversable
+ import zope.traversing.namespace
ztapi.provideView(None, None, ITraversable, 'view',
- zope.app.traversing.namespace.view)
+ zope.traversing.namespace.view)
# Macros
from zope.app.basicskin.standardmacros import StandardMacros
Modified: Zope3/trunk/src/zope/app/renderer/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/renderer/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/renderer/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,7 +17,7 @@
"""
from zope.component.interfaces import IFactory
from zope.interface import implements, directlyProvides, Declaration
-from zope.app.publisher.browser import BrowserView
+from zope.publisher.browser import BrowserView
from interfaces import ISource, IHTMLRenderer
Modified: Zope3/trunk/src/zope/app/renderer/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/renderer/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/renderer/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -7,7 +7,7 @@
<utility
component=".vocabulary.SourceTypeVocabulary"
- provides="zope.app.schema.interfaces.IVocabularyFactory"
+ provides="zope.schema.interfaces.IVocabularyFactory"
name="SourceTypes"
/>
Modified: Zope3/trunk/src/zope/app/renderer/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/renderer/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/renderer/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,8 +18,7 @@
# BBB 2006/02/24, to be removed after 12 months
import warnings
-from zope.app import zapi
-from zope.app.component.metaconfigure import handler
+from zope.component.zcml import handler
from zope.configuration.fields import GlobalInterface, GlobalObject
from zope.interface import Interface
Modified: Zope3/trunk/src/zope/app/renderer/plaintext.py
===================================================================
--- Zope3/trunk/src/zope/app/renderer/plaintext.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/renderer/plaintext.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,8 +16,8 @@
$Id$
"""
from zope.interface import implements
+from zope.publisher.browser import BrowserView
-from zope.app.publisher.browser import BrowserView
from zope.app.i18n import ZopeMessageFactory as _
from zope.app.renderer.interfaces import ISource, IHTMLRenderer
from zope.app.renderer import SourceFactory
Modified: Zope3/trunk/src/zope/app/renderer/rest.py
===================================================================
--- Zope3/trunk/src/zope/app/renderer/rest.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/renderer/rest.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,7 +21,8 @@
from docutils.writers.html4css1 import Writer
from zope.interface import implements
-from zope.app.publisher.browser import BrowserView
+from zope.publisher.browser import BrowserView
+
from zope.app.i18n import ZopeMessageFactory as _
from zope.app.renderer.interfaces import ISource, IHTMLRenderer
from zope.app.renderer import SourceFactory
Modified: Zope3/trunk/src/zope/app/renderer/stx.py
===================================================================
--- Zope3/trunk/src/zope/app/renderer/stx.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/renderer/stx.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,8 +20,8 @@
from zope.interface import implements
from zope.structuredtext.document import Document
from zope.structuredtext.html import HTML
+from zope.publisher.browser import BrowserView
-from zope.app.publisher.browser import BrowserView
from zope.app.i18n import ZopeMessageFactory as _
from zope.app.renderer.interfaces import ISource, IHTMLRenderer
from zope.app.renderer import SourceFactory
Modified: Zope3/trunk/src/zope/app/renderer/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/renderer/vocabulary.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/renderer/vocabulary.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,16 +15,15 @@
$Id$
"""
+import zope.component
from zope.interface import alsoProvides
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
-
-from zope.app import zapi
+from zope.schema.interfaces import IVocabularyFactory
from zope.app.renderer.interfaces import ISource
-from zope.app.schema.interfaces import IVocabularyFactory
def SourceTypeVocabulary(context):
return SimpleVocabulary(
[SimpleTerm(name, title=factory.title) for name, factory in
- zapi.getFactoriesFor(ISource)])
+ zope.component.getFactoriesFor(ISource)])
alsoProvides(SourceTypeVocabulary, IVocabularyFactory)
Modified: Zope3/trunk/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rotterdam/tests/test_xmlnavigationviews.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,9 +23,9 @@
from zope.publisher.browser import TestRequest
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.publisher.interfaces import NotFound
+from zope.traversing.api import traverse
from zope.app.testing import ztapi
-from zope.app.traversing.api import traverse
from zope.app.container.interfaces import IReadContainer
from zope.app.component.site import LocalSiteManager
from zope.app.component.testing import PlacefulSetup
Modified: Zope3/trunk/src/zope/app/rotterdam/xmlobject.py
===================================================================
--- Zope3/trunk/src/zope/app/rotterdam/xmlobject.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/rotterdam/xmlobject.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,15 +22,13 @@
from zope.proxy import sameProxiedObjects
from zope.security.interfaces import Unauthorized, Forbidden
from zope.i18n import translate
+from zope.traversing.api import getParents, getParent, traverse
+from zope.publisher.browser import BrowserView
from zope.app import zapi
-from zope.app.publisher.browser import BrowserView
from zope.app.container.interfaces import IReadContainer
-from zope.app.traversing.api import getParents, getParent, traverse
-
from zope.app.i18n import ZopeMessageFactory as _
-
titleTemplate = _('Contains $${num} item(s)')
loadingMsg = _('Loading...')
Modified: Zope3/trunk/src/zope/app/schema/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/browser/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schema/browser/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,16 +15,15 @@
$Id$
"""
-from zope.app import zapi
+from zope.schema import getFieldNamesInOrder, getFieldsInOrder
+from zope.publisher.browser import BrowserView
+
from zope.app.form.browser.editview import EditView
from zope.app.form.utility import setUpEditWidgets
from zope.app.i18n import ZopeMessageFactory as _
from zope.app.schema.interfaces import IMutableSchema
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.app.publisher.browser import BrowserView
-from zope.schema import getFieldNamesInOrder, getFieldsInOrder
-
_msg_anErrorOccurred = _("An error occurred")
class EditSchema(BrowserView):
Modified: Zope3/trunk/src/zope/app/schema/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/schema/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schema/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -2,12 +2,6 @@
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser">
- <tool
- interface="zope.app.schema.interfaces.ISchemaUtility"
- title="Persistent, Local Schemas"
- description="These are schemas that live in the ZODB and are modifiable."
- />
-
<menu
id="add_schema_field"
title="Menu of Fields to be added to a schema." />
@@ -57,7 +51,7 @@
<zope:adapter
factory=".traversal.SchemaFieldTraversable"
- provides="zope.app.traversing.interfaces.ITraversable"
+ provides="zope.traversing.interfaces.ITraversable"
for="zope.app.schema.interfaces.IMutableSchema" />
</zope:configure>
Modified: Zope3/trunk/src/zope/app/schema/browser/traversal.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/browser/traversal.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schema/browser/traversal.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,12 +16,12 @@
from zope.interface import implements
from zope.publisher.interfaces.browser import IBrowserPublisher
from zope.publisher.interfaces import NotFound
+from zope.traversing.interfaces import TraversalError, ITraversable
+from zope.traversing.namespace import UnexpectedParameters
+from zope.location.interfaces import ILocation
from zope.app import zapi
-from zope.app.location.interfaces import ILocation
from zope.app.schema.interfaces import IMutableSchema
-from zope.app.traversing.interfaces import TraversalError, ITraversable
-from zope.app.traversing.namespace import UnexpectedParameters
_marker = object()
Modified: Zope3/trunk/src/zope/app/schema/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/schema/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schema/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,12 +17,8 @@
</localUtility>
- <class class=".schema.SchemaRegistration">
- <require
- permission="zope.ManageServices"
- interface="zope.app.component.interfaces.IUtilityRegistration"
- set_schema="zope.app.component.interfaces.IUtilityRegistration" />
- </class>
+ <subscriber handler=".schema.schemaUtilityRegistered" />
+ <subscriber handler=".schema.schemaUtilityUnregistered" />
<include file="fields.zcml" />
<include package=".browser" />
Modified: Zope3/trunk/src/zope/app/schema/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schema/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,13 +19,6 @@
from zope.interface.interfaces import IInterface
from zope.app.container.interfaces import IAdding
-class IVocabularyFactory(Interface):
- """Can create vocabularies."""
-
- def __call__(self, context):
- """The context provides a location that the vocabulary can make use
- of."""
-
class ISchemaUtility(Interface):
pass
Modified: Zope3/trunk/src/zope/app/schema/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schema/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,8 +17,8 @@
"""
import warnings
from zope.interface import directlyProvides
-from zope.app.schema.interfaces import IVocabularyFactory
-from zope.app.component.metaconfigure import utility
+from zope.schema.interfaces import IVocabularyFactory
+from zope.component.zcml import utility
class FactoryKeywordPasser(object):
"""Helper that passes additional keywords to the actual factory."""
@@ -42,7 +42,7 @@
"removed in Zope 3.5. Use the 'utility' directive instead to "
"register the class as a named utility:\n"
' <utility\n'
- ' provides="zope.app.schema.interfaces.IVocabularyFactory"\n'
+ ' provides="zope.schema.interfaces.IVocabularyFactory"\n'
' component="%s"\n'
' name="%s"\n'
' />' % (dottedname, name),
Modified: Zope3/trunk/src/zope/app/schema/schema.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/schema.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schema/schema.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,13 +20,13 @@
from persistent import Persistent
from persistent.dict import PersistentDict
from zope.interface import Interface, implements
+import zope.component.interfaces
from zope.security.proxy import removeSecurityProxy
from zope.proxy import removeAllProxies
from zope.app import zapi
from zope.app.container.browser.adding import Adding
from zope.app.interface import PersistentInterfaceClass
-from zope.app.component.site import UtilityRegistration
from zope.app.container.contained import Contained, setitem, uncontained
from zope.interface.interface import Attribute, Method, fromFunction
@@ -266,18 +266,21 @@
def nextURL(self):
"""See zope.app.container.interfaces.IAdding"""
- return zapi.absoluteURL(self.context, self.request)+'/@@editschema.html'
+ return zapi.absoluteURL(self.context,
+ self.request,
+ )+'/@@editschema.html'
-class SchemaRegistration(UtilityRegistration):
- """Schema Registration
+ at zope.component.adapter(
+ ISchemaUtility,
+ zope.component.interfaces.IRegistered,
+ )
+def schemaUtilityRegistered(schema, event):
+ schema.setName(event.object.name)
- We have a custom registration here, since we want active registrations to
- set the name of the schema.
- """
-
- def activated(self):
- self.component.setName(self.name)
-
- def deactivated(self):
- self.component.setName('<schema not activated>')
+ at zope.component.adapter(
+ ISchemaUtility,
+ zope.component.interfaces.IUnregistered,
+ )
+def schemaUtilityUnregistered(schema, event):
+ schema.setName('<schema not activated>')
Modified: Zope3/trunk/src/zope/app/schema/tests/test_fieldfactory.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/tests/test_fieldfactory.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schema/tests/test_fieldfactory.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,8 +20,7 @@
import zope.app.schema
from zope.app import zapi
-from zope.component.exceptions import ComponentLookupError
-from zope.component.interfaces import IFactory
+from zope.component.interfaces import ComponentLookupError, IFactory
from zope.app.testing.placelesssetup import PlacelessSetup
from zope.schema.interfaces import IField, IText
from zope.interface import Interface
Modified: Zope3/trunk/src/zope/app/schema/tests/test_interfaceutility.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/tests/test_interfaceutility.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schema/tests/test_interfaceutility.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,52 +16,33 @@
$Id$
"""
import unittest
+import zope.component
from zope.interface import Interface, implements
from zope.interface.interface import InterfaceClass
from zope.interface.interfaces import IInterface
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
+from zope.component.interface import getInterface, searchInterface
+from zope.traversing.api import traverse
-from zope.app import zapi
-from zope.app.component.interfaces import ILocalUtility
-from zope.app.component.site import UtilityRegistration
from zope.app.component.testing import PlacefulSetup
-from zope.app.component.interface import getInterface, searchInterface
-from zope.app.component.interfaces.registration import ActiveStatus
-from zope.app.component.interfaces.registration import InactiveStatus
-from zope.app.component.interfaces.registration import IRegistered
from zope.app.container.contained import Contained
from zope.app.dependable.interfaces import IDependable
from zope.app.testing import setup
-from zope.app.traversing.api import traverse
class IBaz(Interface): pass
class Baz(object):
- # We implement IRegistered and IDependable directly to
+ # We implement IDependable directly to
# depend as little as possible on other infrastructure.
- implements(IBaz, ILocalUtility, IRegistered, IDependable)
+ implements(IBaz, IDependable)
def __init__(self, name):
self.name = name
- self._usages = []
self._dependents = []
def foo(self):
return 'foo ' + self.name
- def addUsage(self, location):
- "See zope.app.registration.interfaces.IRegistered"
- if location not in self._usages:
- self._usages.append(location)
-
- def removeUsage(self, location):
- "See zope.app.registration.interfaces.IRegistered"
- self._usages.remove(location)
-
- def usages(self):
- "See zope.app.registration.interfaces.IRegistered"
- return self._usages
-
def addDependent(self, location):
"See zope.app.dependable.interfaces.IDependable"
if location not in self._dependents:
@@ -89,10 +70,10 @@
sm = PlacefulSetup.setUp(self, site=True)
def test_getLocalInterface_delegates_to_globalUtility(self):
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(IInterface, Bar("blob"), name="blob")
- gsm.provideUtility(IBaz, Baz("global baz"))
- gsm.provideUtility(IInterface, Foo("global bob"), name="bob")
+ gsm = zope.component.getGlobalSiteManager()
+ gsm.registerUtility(Bar("blob"), IInterface, name="blob")
+ gsm.registerUtility(Baz("global baz"), IBaz)
+ gsm.registerUtility(Foo("global bob"), IInterface, name="bob")
self.assertEqual(getInterface(None, "bob").__class__, Foo)
self.assertEqual(getInterface(None, "blob").__class__, Bar)
@@ -102,10 +83,10 @@
baz = Baz("global baz")
foo = Foo("global bob")
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(IInterface, foo, name="bob")
- gsm.provideUtility(IInterface, bar)
- gsm.provideUtility(IBaz, baz)
+ gsm = zope.component.getGlobalSiteManager()
+ gsm.registerUtility(foo, IInterface, name="bob")
+ gsm.registerUtility(bar, IInterface)
+ gsm.registerUtility(baz, IBaz)
ifaces = searchInterface(None)
self.assert_(len(ifaces), 2)
@@ -126,28 +107,24 @@
bar = Bar("global")
baz = Baz("global baz")
foo = Foo("global bob")
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(IInterface, foo, name="bob")
- gsm.provideUtility(ILocalUtility, bar)
- gsm.provideUtility(IBaz, baz)
+ gsm = zope.component.getGlobalSiteManager()
+ gsm.registerUtility(foo, IInterface, name="bob")
+ gsm.registerUtility(baz, IBaz)
+
iface_utilities = gsm.getUtilitiesFor(IInterface)
ifaces = [iface for (name, iface) in iface_utilities]
self.assertEqual(ifaces, [(foo)])
- iface_utilities = gsm.getUtilitiesFor(ILocalUtility)
- ifaces = [iface for (name, iface) in iface_utilities]
- self.assertEqual(ifaces, [(bar)])
-
iface_utilities = gsm.getUtilitiesFor(IBaz)
ifaces = [iface for (name, iface) in iface_utilities]
self.assertEqual(ifaces, [(baz)])
def test_getLocalInterface_raisesComponentLookupError(self):
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(IInterface, Foo("global"))
- gsm.provideUtility(IBaz, Baz("global baz"))
- gsm.provideUtility(IInterface, Foo("global bob"), name="bob")
+ gsm = zope.component.getGlobalSiteManager()
+ gsm.registerUtility(Foo("global"), Interface)
+ gsm.registerUtility(Baz("global baz"), IBaz)
+ gsm.registerUtility(Foo("global bob"), IInterface, name="bob")
self.assertRaises(ComponentLookupError,
getInterface, None, "bobesponja")
@@ -156,10 +133,10 @@
foo = Foo("global bob")
bar = Bar("global")
baz = Baz("global baz")
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(IInterface, bar)
- gsm.provideUtility(IBaz, baz)
- gsm.provideUtility(IInterface, foo, name="bob")
+ gsm = zope.component.getGlobalSiteManager()
+ gsm.registerUtility(foo, IInterface, name="bob")
+ gsm.registerUtility(bar, IInterface)
+ gsm.registerUtility(baz, IBaz)
self.assertEqual(searchInterface(None, search_string="bob"),
[foo])
@@ -169,20 +146,21 @@
foo = Foo("global bob")
bar = Bar("global")
baz = Baz("global baz")
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(IInterface, bar)
- gsm.provideUtility(IBaz, baz)
- gsm.provideUtility(IInterface, foo, name="bob")
+ gsm = zope.component.getGlobalSiteManager()
+ gsm.registerUtility(foo, IInterface, name="bob")
+ gsm.registerUtility(bar, IInterface)
+ gsm.registerUtility(baz, IBaz)
self.assertEqual(searchInterface(None, search_string="bob"),
[foo])
def test_query_get_Utility_delegates_to_global(self):
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(IInterface, Foo("global"))
- gsm.provideUtility(IInterface, Foo("global bob"), name="bob")
+ zope.component.provideUtility(Foo("global"), IInterface)
+ zope.component.provideUtility(Foo("global bob"), IInterface,
+ name="bob")
- sm = zapi.getSiteManager(self.rootFolder)
+ gsm = zope.component.getGlobalSiteManager()
+ sm = zope.component.getSiteManager(self.rootFolder)
self.assert_(gsm != sm)
# If queryUtility works on the site manager, getUtility in zapi must
@@ -192,29 +170,22 @@
"foo global bob")
def test_local_utilities(self):
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(IInterface, Foo("global"))
- gsm.provideUtility(IInterface, Foo("global bob"), name="bob")
+ gsm = zope.component.getGlobalSiteManager()
+ gsm.registerUtility(Foo("global"), IInterface)
+ gsm.registerUtility(Foo("global bob"), IInterface, name="bob")
- sm = zapi.getSiteManager(self.rootFolder)
+ sm = zope.component.getSiteManager(self.rootFolder)
default = traverse(self.rootFolder, "++etc++site/default")
default['foo'] = Foo("local")
foo = default['foo']
- cm = default.registrationManager
for name in ('', 'bob'):
- registration = UtilityRegistration(name, IInterface, foo)
- cname = cm.addRegistration(registration)
- registration = traverse(cm, cname)
-
gout = name and "foo global "+name or "foo global"
self.assertEqual(sm.queryUtility(IInterface, name).foo(), gout)
-
- registration.status = ActiveStatus
+ sm.registerUtility(foo, IInterface, name)
self.assertEqual(
sm.queryUtility(IInterface, name).foo(), "foo local")
-
- registration.status = InactiveStatus
+ sm.unregisterUtility(foo, IInterface, name)
self.assertEqual(sm.queryUtility(IInterface, name).foo(), gout)
Modified: Zope3/trunk/src/zope/app/schema/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/vocabulary.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schema/vocabulary.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,12 +15,12 @@
$Id$
"""
-from zope.app import zapi
+import zope.component
from zope.interface import Interface, implements
from zope.schema.interfaces import IVocabularyRegistry
from zope.schema import vocabulary
from zope.testing import cleanup
-from zope.app.schema.interfaces import IVocabularyFactory
+from zope.schema.interfaces import IVocabularyFactory
class ZopeVocabularyRegistry(object):
"""IVocabularyRegistry that supports global and local utilities."""
@@ -30,7 +30,7 @@
def get(self, context, name):
"""See zope.schema.interfaces.IVocabularyRegistry"""
- factory = zapi.getUtility(IVocabularyFactory, name)
+ factory = zope.component.getUtility(IVocabularyFactory, name)
return factory(context)
def _clear():
@@ -43,6 +43,5 @@
vocabulary._clear()
vocabulary.setVocabularyRegistry(ZopeVocabularyRegistry())
-
_clear()
cleanup.addCleanUp(_clear)
Modified: Zope3/trunk/src/zope/app/schemacontent/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/schemacontent/browser/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schemacontent/browser/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -24,7 +24,7 @@
from zope.app.form.interfaces import IInputWidget
from zope.app.schemacontent.interfaces import IContentComponentDefinition
from zope.app.schemacontent.content import ContentComponentInstance
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
from zope.interface import implements
from zope.publisher.interfaces import IPublishTraverse
from zope.schema import getFieldsInOrder, Choice
Modified: Zope3/trunk/src/zope/app/schemacontent/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/schemacontent/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schemacontent/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -2,13 +2,6 @@
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser">
- <tool
- interface="zope.app.schemacontent.interfaces.IContentComponentDefinition"
- title="Content Component Definition"
- description="Content Component Definitions are used to declare
- schema-based content objects."
- />
-
<!-- Content Component Definition -->
<!-- Menu entry for "Add Utility" menu -->
Modified: Zope3/trunk/src/zope/app/schemacontent/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/schemacontent/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schemacontent/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,21 +19,16 @@
</localUtility>
- <class class=".content.ContentComponentDefinitionRegistration">
- <require
- permission="zope.ManageServices"
- interface="zope.app.component.interfaces.IUtilityRegistration"
- set_schema="zope.app.component.interfaces.IUtilityRegistration"
- />
- </class>
-
<!-- Content Component Instance -->
<class class=".content.ContentComponentInstance">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
+ interface="zope.annotation.interfaces.IAttributeAnnotatable" />
</class>
+ <subscriber handler=".content.registeredContentComponent" />
+ <subscriber handler=".content.unregisteredContentComponent" />
+
<include package=".browser" />
</configure>
Modified: Zope3/trunk/src/zope/app/schemacontent/content.py
===================================================================
--- Zope3/trunk/src/zope/app/schemacontent/content.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schemacontent/content.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,10 +15,13 @@
$Id$
"""
+
+from zope import component
+import zope.component.interfaces
+
from persistent import Persistent
from persistent.dict import PersistentDict
from zope.app.container.contained import Contained
-from zope.app.component.site import UtilityRegistration
from zope.interface import directlyProvides, implements
from zope.schema import getFields
from zope.security.checker import CheckerPublic, Checker, defineChecker
@@ -26,7 +29,21 @@
from interfaces import IContentComponentDefinition
from interfaces import IContentComponentInstance
+ at component.adapter(
+ IContentComponentDefinition,
+ zope.component.interfaces.IRegistered,
+ )
+def registeredContentComponent(component, event):
+ component.name = event.object.name
+ at component.adapter(
+ IContentComponentDefinition,
+ zope.component.interfaces.IUnregistered,
+ )
+def unregisteredContentComponent(component, event):
+ component.name = None
+
+
class ContentComponentDefinition(Persistent, Contained):
implements(IContentComponentDefinition)
@@ -38,16 +55,6 @@
self.permissions = PersistentDict()
-class ContentComponentDefinitionRegistration(UtilityRegistration):
- """Content Component Registration"""
-
- def activated(self):
- self.component.name = self.name
-
- def deactivated(self):
- self.component.name = None
-
-
class ContentComponentInstance(Persistent):
implements(IContentComponentInstance)
Modified: Zope3/trunk/src/zope/app/schemacontent/tests/test_content.py
===================================================================
--- Zope3/trunk/src/zope/app/schemacontent/tests/test_content.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/schemacontent/tests/test_content.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,18 +16,20 @@
$Id$
"""
import unittest
+from zope.testing import doctest
+from zope.app.testing import placelesssetup
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
from zope.interface import Interface, classImplements
from zope.schema import Int, TextLine, Text
+from zope.annotation.interfaces import IAttributeAnnotatable
from zope.app import zapi
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.component.interfaces import ILocalUtility
from zope.app.container.interfaces import IAdding
-from zope.app.schemacontent.content import \
- ContentComponentDefinition, ContentComponentDefinitionRegistration, \
- ContentComponentInstance
+from zope.app.schemacontent.content import ContentComponentDefinition
+from zope.app.schemacontent.content import ContentComponentInstance
+from zope.app.schemacontent.content import registeredContentComponent
+from zope.app.schemacontent.content import unregisteredContentComponent
from zope.app.schemacontent.interfaces import IContentComponentDefinition
from zope.app.testing import setup, ztapi
@@ -36,43 +38,6 @@
title = TextLine(title=u"title", default=u'Title goes here.')
description = Text(title=u"desription")
-
-class ContentComponentDefinitionRegistrationTests(unittest.TestCase):
-
- __name__ = __parent__ = None
-
- def setUp(self):
- setup.placefulSetUp()
- self.rootFolder = setup.buildSampleFolderTree()
-
- mgr = setup.createSiteManager(self.rootFolder)
-
- # Setup Definition
- classImplements(ContentComponentDefinition, ILocalUtility)
- classImplements(ContentComponentDefinition, IAttributeAnnotatable)
- default = zapi.traverse(mgr, 'default')
- default['TestDoc'] = ContentComponentDefinition()
-
- # Setup Definition Registration
- path = "%s/default/%s" % (zapi.getPath(mgr), 'TestDoc')
- reg = ContentComponentDefinitionRegistration(
- 'TestDoc', IContentComponentDefinition, default['TestDoc'])
- key = default.registrationManager.addRegistration(reg)
- self.reg = zapi.traverse(default.registrationManager, key)
-
- def tearDown(self):
- setup.placefulTearDown()
-
- def test_activated(self):
- self.reg.activated()
- self.assertEqual(self.reg.component.name, 'TestDoc')
-
- def test_deactivated(self):
- self.test_activated()
- self.reg.deactivated()
- self.assertEqual(self.reg.component.name, None)
-
-
class ContentComponentInstanceTests(unittest.TestCase):
def test_getattr(self):
@@ -97,10 +62,39 @@
self.assertEqual(doc.getSchema().__class__, IDocument.__class__)
self.assertEqual(doc.getSchema().__dict__, IDocument.__dict__)
+def test_subscribers():
+ """
+There seems to be a desire for ContentComponentDefinitions to know the
+name they are registered under. The registeredContentComponent and
+unregisteredContentComponent subscribers set or clear a definition's
+name when the definition is registered or unregistered.
+
+ >>> import zope.component.interfaces
+ >>> class FauxRegistration:
+ ... name = u'bob'
+ >>> definition = ContentComponentDefinition()
+ >>> registeredContentComponent(
+ ... definition,
+ ... zope.component.interfaces.Registered(FauxRegistration)
+ ... )
+ >>> definition.name
+ u'bob'
+ >>> unregisteredContentComponent(
+ ... definition,
+ ... zope.component.interfaces.Unregistered(FauxRegistration)
+ ... )
+ >>> print definition.name
+ None
+
+"""
+
def test_suite():
return unittest.TestSuite((
- unittest.makeSuite(ContentComponentDefinitionRegistrationTests),
unittest.makeSuite(ContentComponentInstanceTests),
+ doctest.DocTestSuite(
+ setUp=placelesssetup.setUp,
+ tearDown=placelesssetup.tearDown,
+ ),
))
if __name__ == '__main__':
Modified: Zope3/trunk/src/zope/app/security/_protections.py
===================================================================
--- Zope3/trunk/src/zope/app/security/_protections.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/_protections.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,30 +17,19 @@
"""
def protect():
- from zope.security.checker import NoProxy
-
- # BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3
- import zope.deprecation
- zope.deprecation.__show__.off()
- from zope.i18nmessageid import MessageID, Message
- zope.deprecation.__show__.on()
-
# Add message id types to the basic types, so their setting cannot be
# overridden, once set. `protect()` was not guranteed to run after
# zope.security.checker._clear, so that sometimes the proxies were not set.
# This is not the ideal solution, but it is effective.
- # Make sure the message id gets never proxied
- # TODO because MessageIDs are mutable, this is a security hole. This hole
- # is one of the primary reasons for the development of the Message
- # replacement. See zope/i18nmessageid/messages.txt.
- zope.security.checker.BasicTypes[MessageID] = NoProxy
- # this, however, is not a security hole, because Messages are immutable.
+ # Make sure the message id gets never proxied. This is not a
+ # security hole because Messages are immutable.
+ import zope.security.checker
+ from zope.security.checker import NoProxy
+ from zope.i18nmessageid import Message
zope.security.checker.BasicTypes[Message] = NoProxy
# add __parent__ and __name__ to always available names
- import zope.security.checker
for name in ['__name__', '__parent__']:
if name not in zope.security.checker._available_by_default:
zope.security.checker._available_by_default.append(name)
-
Modified: Zope3/trunk/src/zope/app/security/adapter.py
===================================================================
--- Zope3/trunk/src/zope/app/security/adapter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/adapter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,135 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Support for taking security into account in adaptation
-
-$Id$
-"""
-
-from zope.security.checker import ProxyFactory
-from zope.security.proxy import removeSecurityProxy
-from zope.app.location import ILocation, Location, LocationProxy
-
-
-def assertLocation(adapter, parent):
- """Assert locatable adapters.
-
- This function asserts that the adapter get location-proxied if
- it doesn't provide ILocation itself. Further more the returned
- locatable adapter get its parent set if its __parent__ attribute
- is currently None.
-
- see adapter.txt
- """
- # handle none-locatable adapters (A)
- if not ILocation.providedBy(adapter):
- locatable = LocationProxy(adapter)
- locatable.__parent__ = parent
- return locatable
-
- # handle locatable, parentless adapters (B)
- if adapter.__parent__ is None:
- adapter.__parent__ = parent
- return adapter
-
- # handle locatable, parentful adapters (C)
- else:
- return adapter
-
-
-class LocatingTrustedAdapterFactory(object):
- """Adapt an adapter factory to provide trusted and (locatable) adapters.
-
- Trusted adapters always adapt unproxied objects. If asked to
- adapt any proxied objects, it will unproxy them and then
- security-proxy the resulting adapter (S) unless the objects where not
- security-proxied before (N).
-
- Further locating trusted adapters provide a location for protected
- adapters only (S). If such a protected adapter itself does not provide
- ILocation it is wrapped within a location proxy and it parent will
- be set. If the adapter does provide ILocation and it's __parent__ is None,
- we set the __parent__ to the adapter's context:
-
- see adapter.txt
- """
- def __init__(self, factory):
- self.factory = factory
- self.__name__ = factory.__name__
- self.__module__ = factory.__module__
-
- # protected methods
- def _customizeProtected(self, adapter, context):
- return assertLocation(adapter, context)
-
- def _customizeUnprotected(self, adapter, context):
- if (ILocation.providedBy(adapter)
- and adapter.__parent__ is None):
- adapter.__parent__ = context
- return adapter
-
- def __call__(self, *args):
- for arg in args:
- if removeSecurityProxy(arg) is not arg:
- args = map(removeSecurityProxy, args)
- adapter = self.factory(*args)
- adapter = self._customizeProtected(adapter, args[0])
- return ProxyFactory(adapter)
-
- adapter = self.factory(*args)
- adapter = self._customizeUnprotected(adapter, args[0])
- return adapter
-
-
-# BBB, entire class gone in 3.2
-class TrustedAdapterFactory(LocatingTrustedAdapterFactory):
- """Adapt an adapter factory to provide trusted adapters.
-
- Trusted adapters always adapt unproxied objects. If asked to
- adapt any proxied objects, it will unproxy them and then
- security-proxy the resulting adapter unless the objects where not
- security-proxied before.
-
- If the adapter does provide ILocation and it's __parent__ is None,
- we set the __parent__ to the adapter's context.
- """
-
- # do not location-proxy the adapter
- def _customizeProtected(self, adapter, context):
- return self._customizeUnprotected(adapter, context)
-
-
-class LocatingUntrustedAdapterFactory(object):
- """Adapt an adapter factory to provide locatable untrusted adapters
-
- Untrusted adapters always adapt proxied objects. If any permission
- other than zope.Public is required, untrusted adapters need a location
- in order that the local authentication mechanism can be inovked
- correctly.
-
- If the adapter does not provide ILocation, we location proxy it and
- set the parent. If the adapter does provide ILocation and
- it's __parent__ is None, we set the __parent__ to the adapter's
- context only:
-
- see adapter.txt
- """
-
- def __init__(self, factory):
- self.factory = factory
- self.__name__ = factory.__name__
- self.__module__ = factory.__module__
-
- def __call__(self, *args):
- adapter = self.factory(*args)
- return assertLocation(adapter, args[0])
+# This module has moved to zope.security.adapter
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.security.adapter',
+ "Zope 3.5",
+ )
Modified: Zope3/trunk/src/zope/app/security/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/security/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,13 +17,6 @@
factory="zope.app.security.browser.principalterms.PrincipalTerms"
/>
- <browser:tool
- interface="..interfaces.IAuthentication"
- title="Authentication"
- description="Authenticates Principals."
- unique="true"
- />
-
<browser:page
name="failsafelogin.html"
for="*"
@@ -58,12 +51,6 @@
permission="zope.Public"
/>
- <browser:tool
- interface="..interfaces.IPermission"
- title="Permission"
- description="Security Permission"
- />
-
<browser:addform
name="AddPermission.html"
schema="..interfaces.IPermission"
Modified: Zope3/trunk/src/zope/app/security/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/security/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -32,28 +32,28 @@
id="zope.app.security.Permission"
/>
<allow
- interface=".interfaces.IPermission"
+ interface="zope.security.interfaces.IPermission"
/>
<require
permission="zope.Security"
- set_schema=".interfaces.IPermission"
+ set_schema="zope.security.interfaces.IPermission"
/>
</localUtility>
<subscriber
for="zope.security.interfaces.IPermission
- ..component.interfaces.registration.IRegistrationActivatedEvent"
+ zope.component.interfaces.IRegistered"
handler=".permission.setIdOnActivation"
/>
<subscriber
for="zope.security.interfaces.IPermission
- ..component.interfaces.registration.IRegistrationDeactivatedEvent"
+ zope.component.interfaces.IUnregistered"
handler=".permission.unsetIdOnDeactivation"
/>
- <class class=".permission.Permission">
- <allow interface=".interfaces.IPermission" />
+ <class class="zope.security.permission.Permission">
+ <allow interface="zope.security.interfaces.IPermission" />
</class>
<class class=".principalregistry.Principal">
Modified: Zope3/trunk/src/zope/app/security/fields.py
===================================================================
--- Zope3/trunk/src/zope/app/security/fields.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/fields.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,82 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Security related configuration fields.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-from zope import schema
-from zope.interface import implements
-from zope.schema.interfaces import IFromUnicode
-from zope.app.security.permission import checkPermission
-
-class Permission(schema.Id):
- r"""This field describes a permission.
-
- Let's look at an example:
-
- >>> class FauxContext(object):
- ... permission_mapping = {'zope.ManageCode':'zope.private'}
- ... _actions = []
- ... def action(self, **kws):
- ... self._actions.append(kws)
- >>> context = FauxContext()
- >>> field = Permission().bind(context)
-
- Let's test the fromUnicode method:
-
- >>> field.fromUnicode(u'zope.foo')
- 'zope.foo'
- >>> field.fromUnicode(u'zope.ManageCode')
- 'zope.private'
-
- Now let's see whether validation works alright
-
- >>> field._validate('zope.ManageCode')
- >>> context._actions[0]['args']
- (None, 'zope.foo')
- >>> field._validate('3 foo')
- Traceback (most recent call last):
- ...
- InvalidId: 3 foo
-
- zope.Public is always valid
- >>> field._validate('zope.Public')
- """
- implements(IFromUnicode)
-
- def fromUnicode(self, u):
- u = super(Permission, self).fromUnicode(u)
-
- map = getattr(self.context, 'permission_mapping', {})
- return map.get(u, u)
-
- def _validate(self, value):
- super(Permission, self)._validate(value)
-
- if value != 'zope.Public':
- self.context.action(
- discriminator = None,
- callable = checkPermission,
- args = (None, value),
-
- # Delay execution till end. This is an
- # optimization. We don't want to intersperse utility
- # lookup, done when checking permissions, with utility
- # definitions. Utility lookup is expensive after
- # utility definition, as extensive caches have to be
- # rebuilt.
- order=9999999,
- )
-
+# This module has moved to zope.security.zcml
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.security.zcml',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/security/fields.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.2
Modified: Zope3/trunk/src/zope/app/security/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/security/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,20 +15,12 @@
$Id$
"""
-
-import zope.deprecation
-
from zope.interface import Interface
from zope.schema import Text, TextLine
from zope.security.interfaces import IPrincipal, IPermission, IGroup
from zope.schema.interfaces import ISource
-# BBB : Can move away in 3.3
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError
-zope.deprecation.__show__.on()
-
-class PrincipalLookupError(NotFoundError):
+class PrincipalLookupError(LookupError):
"""A prncipal could not be found for a principal id
"""
Modified: Zope3/trunk/src/zope/app/security/meta.zcml
===================================================================
--- Zope3/trunk/src/zope/app/security/meta.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/meta.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -2,11 +2,7 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:meta="http://namespaces.zope.org/meta">
- <meta:directive
- namespace="http://namespaces.zope.org/zope"
- name="permission"
- schema=".metadirectives.IDefinePermissionDirective"
- handler=".metaconfigure.definePermission" />
+ <include package="zope.security" file="meta.zcml" />
<meta:directive
namespace="http://namespaces.zope.org/zope"
@@ -38,13 +34,6 @@
schema=".metadirectives.IDefineEverybodyGroupDirective"
handler=".metaconfigure.everybodyGroup" />
- <meta:directive
- name="securityPolicy"
- namespace="http://namespaces.zope.org/zope"
- schema=".metadirectives.ISecurityPolicyDirective"
- handler=".metaconfigure.securityPolicy"
- />
-
<meta:groupingDirective
name="module"
namespace="http://namespaces.zope.org/zope"
@@ -63,10 +52,4 @@
schema=".metadirectives.IRequire"
handler=".metaconfigure.require" />
- <meta:directive
- name="redefinePermission"
- namespace="http://namespaces.zope.org/meta"
- schema=".metadirectives.IRedefinePermission"
- handler=".metaconfigure.redefinePermission" />
-
</configure>
Modified: Zope3/trunk/src/zope/app/security/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/security/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,29 +15,15 @@
$Id$
"""
-
from zope import component
+from zope.component.zcml import utility
from zope.security.checker import moduleChecker, Checker, defineChecker
from zope.security.checker import CheckerPublic
-from zope.security.management import setSecurityPolicy
-from zope.security.interfaces import IPermission
-from zope.app.component.metaconfigure import utility
-
-from zope.app.security.permission import Permission
from zope.app.security import principalregistry
from zope.app.security import interfaces
-def securityPolicy(_context, component):
-
- _context.action(
- discriminator = 'defaultPolicy',
- callable = setSecurityPolicy,
- args = (component,) )
-
-
-
def protectModule(module, name, permission):
"""Set up a module checker to require a permission to access a name
@@ -91,12 +77,6 @@
args = (context.module, name, permission),
)
-
-def definePermission(_context, id, title, description=''):
- permission = Permission(id, title, description)
- utility(_context, IPermission, permission, name=id)
-
-
def _principal():
group = component.queryUtility(interfaces.IAuthenticatedGroup)
if group is not None:
@@ -202,13 +182,3 @@
callable = principalregistry.principalRegistry.registerGroup,
args = (principal, ),
)
-
-
-def redefinePermission(_context, from_, to):
- _context = _context.context
-
- # check if context has any permission mappings yet
- if not hasattr(_context, 'permission_mapping'):
- _context.permission_mapping={}
-
- _context.permission_mapping[from_] = to
Modified: Zope3/trunk/src/zope/app/security/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/security/metadirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/metadirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,20 +17,22 @@
"""
from zope.interface import Interface
from zope.configuration.fields import GlobalObject, GlobalInterface
-from zope.configuration.fields import Tokens, PythonIdentifier, MessageID
+from zope.configuration.fields import Tokens, PythonIdentifier
from zope.schema import InterfaceField, Id, TextLine
-from fields import Permission
+from zope.security.zcml import Permission
+##############################################################################
+# BBB 2006/04/03 -- to be removed after 12 months
-class ISecurityPolicyDirective(Interface):
- """Defines the security policy that will be used for Zope."""
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "It has been renamed to zope.security.zcml.IPermissionDirective. "
+ "This reference will be gone in Zope 3.5",
+ IBaseDefineDirective = 'zope.security.zcml:IPermissionDirective'
+ )
- component = GlobalObject(
- title=u"Component",
- description=u"Pointer to the object that will handle the security.",
- required=True)
+##############################################################################
-
class IModule(Interface):
"""Group security declarations about a module"""
@@ -75,29 +77,6 @@
title=u"Permission ID",
description=u"The id of the permission to require.")
-
-class IBaseDefineDirective(Interface):
- """Define a new security object."""
-
- id = Id(
- title=u"Id",
- description=u"Id as which this object will be known and used.",
- required=True)
-
- title = MessageID(
- title=u"Title",
- description=u"Provides a title for the object.",
- required=True)
-
- description = MessageID(
- title=u"Description",
- description=u"Provides a description for the object.",
- required=False)
-
-
-class IDefinePermissionDirective(IBaseDefineDirective):
- """Define a new permission."""
-
class IBasePrincipalDirective(Interface):
"""Base interface for principal definition directives."""
@@ -147,16 +126,3 @@
class IDefineEverybodyGroupDirective(IBasePrincipalDirective):
"""Define the everybody group."""
-
-class IRedefinePermission(Interface):
- """Define a permission to replace another permission."""
-
- from_ = Permission(
- title=u"Original permission",
- description=u"Original permission id to redefine.",
- required=True)
-
- to = Permission(
- title=u"Substituted permission",
- description=u"Substituted permission id.",
- required=True)
Modified: Zope3/trunk/src/zope/app/security/permission.py
===================================================================
--- Zope3/trunk/src/zope/app/security/permission.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/permission.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,23 +17,23 @@
"""
from persistent import Persistent
from zope.interface import implements
-from zope.schema.interfaces import ValidationError
-from zope.security.checker import CheckerPublic
-from zope.app import zapi
-from zope.app.location import Location
-from zope.app.security.interfaces import IPermission
+from zope.location import Location
+from zope.security.interfaces import IPermission
from zope.app.i18n import ZopeMessageFactory as _
NULL_ID = _('<permission not activated>')
-class Permission(object):
- implements(IPermission)
+##############################################################################
+# BBB 2006/04/03 -- to be removed after 12 months
- def __init__(self, id, title="", description=""):
- self.id = id
- self.title = title
- self.description = description
+import zope.deferredimport
+zope.deferredimport.deprecatedFrom(
+ "It has been moved to zope.security.permission. This reference "
+ "will be gone in Zope 3.5", 'zope.security.permission',
+ 'Permission', 'checkPermission', 'allPermissions'
+ )
+##############################################################################
class LocalPermission(Persistent, Location):
implements(IPermission)
@@ -58,9 +58,9 @@
>>> perm1 = LocalPermission('Permission 1', 'A first permission')
>>> perm1.id
u'<permission not activated>'
-
- >>> from zope.app.component import registration
- >>> event = registration.RegistrationActivatedEvent(
+
+ >>> import zope.component.interfaces
+ >>> event = zope.component.interfaces.Registered(
... Registration(perm1, 'perm1'))
Now we pass the event into this function, and the id of the permission
@@ -87,8 +87,8 @@
>>> perm1 = LocalPermission('Permission 1', 'A first permission')
>>> perm1.id = 'perm1'
- >>> from zope.app.component import registration
- >>> event = registration.RegistrationDeactivatedEvent(
+ >>> import zope.component.interfaces
+ >>> event = zope.component.interfaces.Unregistered(
... Registration(perm1, 'perm1'))
Now we pass the event into this function, and the id of the permission
@@ -99,47 +99,3 @@
u'<permission not activated>'
"""
permission.id = NULL_ID
-
-
-def checkPermission(context, permission_id):
- """Check whether a given permission exists in the provided context.
-
- >>> from zope.app.testing.placelesssetup import setUp, tearDown
- >>> setUp()
-
- >>> from zope.app.testing.ztapi import provideUtility
- >>> provideUtility(IPermission, Permission('x'), 'x')
-
- >>> checkPermission(None, 'x')
- >>> checkPermission(None, 'y')
- Traceback (most recent call last):
- ...
- ValueError: ('Undefined permission id', 'y')
-
- >>> tearDown()
- """
- if permission_id is CheckerPublic:
- return
- if not zapi.queryUtility(IPermission, permission_id, context=context):
- raise ValueError("Undefined permission id", permission_id)
-
-def allPermissions(context=None):
- """Get the ids of all defined permissions
-
- >>> from zope.app.testing.placelesssetup import setUp, tearDown
- >>> setUp()
-
- >>> from zope.app.testing.ztapi import provideUtility
- >>> provideUtility(IPermission, Permission('x'), 'x')
- >>> provideUtility(IPermission, Permission('y'), 'y')
-
- >>> ids = list(allPermissions(None))
- >>> ids.sort()
- >>> ids
- [u'x', u'y']
-
- >>> tearDown()
- """
- for id, permission in zapi.getUtilitiesFor(IPermission, context):
- if id != u'zope.Public':
- yield id
Modified: Zope3/trunk/src/zope/app/security/principal.py
===================================================================
--- Zope3/trunk/src/zope/app/security/principal.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/principal.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,36 +15,16 @@
$Id$
"""
-
-import zope.deprecation
-
-from zope.app import zapi
+from zope.component import getUtility
from zope.app.security.interfaces import PrincipalLookupError
from zope.app.security.interfaces import IAuthentication
-# BBB Backward Compatibility (Can go away in 3.3)
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError
-zope.deprecation.__show__.on()
-
-import warnings
-
def checkPrincipal(context, principal_id):
-
- auth = zapi.getUtility(IAuthentication, context=context)
+ auth = getUtility(IAuthentication, context=context)
try:
if auth.getPrincipal(principal_id):
return
except PrincipalLookupError:
pass
- except NotFoundError: # BBB Backward Compatibility
- warnings.warn(
- "A %s instance raised a NotFoundError in "
- "getPrincipals. Raising NotFoundError in this "
- "method is deprecated and will no-longer be supported "
- "staring in Zope 3.3. PrincipalLookupError should "
- "be raised instead."
- % auth.__class__.__name__,
- DeprecationWarning)
raise ValueError("Undefined principal id", principal_id)
Modified: Zope3/trunk/src/zope/app/security/tests/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/security/tests/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/tests/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,9 +15,9 @@
$Id$
"""
-from zope.app import zapi
-from zope.app.security.permission import Permission
-from zope.app.security.interfaces import IPermission
+import zope.component
+from zope.security.interfaces import IPermission
+from zope.security.permission import Permission
def addCheckerPublic():
"""Add the CheckerPublic permission as 'zope.Public'"""
@@ -29,5 +29,5 @@
it allows security computation to be bypassed.
"""
)
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(IPermission, perm, perm.id)
+ gsm = zope.component.getGlobalSiteManager()
+ gsm.registerUtility(perm, IPermission, perm.id)
Deleted: Zope3/trunk/src/zope/app/security/tests/test_adapter.py
===================================================================
--- Zope3/trunk/src/zope/app/security/tests/test_adapter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/tests/test_adapter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,28 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""
-$Id$
-"""
-import unittest
-from zope.testing.doctestunit import DocTestSuite
-
-
-def test_suite():
- return unittest.TestSuite((
- DocTestSuite('zope.app.security.adapter'),
- ))
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Modified: Zope3/trunk/src/zope/app/security/tests/test_directives.py
===================================================================
--- Zope3/trunk/src/zope/app/security/tests/test_directives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/tests/test_directives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,19 +17,18 @@
"""
import unittest
from pprint import PrettyPrinter
+
+import zope.security.zcml
from zope.interface import Interface, Attribute
from zope.testing import doctest
+from zope.component import provideUtility
+from zope.component.testing import setUp, tearDown, PlacelessSetup
from zope.configuration import xmlconfig
+from zope.security.checker import moduleChecker
+from zope.security.permission import Permission
+from zope.security.interfaces import IPermission
-import zope.app.security
-from zope.security.checker import moduleChecker
-from zope.app.testing import ztapi
-from zope.app.testing.placelesssetup import setUp, tearDown, PlacelessSetup
from zope.app.security import metaconfigure
-from zope.app.security.interfaces import IPermission
-from zope.app.security.permission import Permission
-from zope.configuration import xmlconfig
-from zope.app.security import fields
def pprint(ob, width=70):
PrettyPrinter(width=width).pprint(ob)
@@ -54,7 +53,7 @@
>>> moduleChecker(test_directives)
>>> perm = Permission(test_perm, '')
- >>> ztapi.provideUtility(IPermission, perm, test_perm)
+ >>> provideUtility(perm, IPermission, test_perm)
>>> metaconfigure.protectModule(test_directives, 'foo', test_perm)
Now, the checker should exist and have an access dictionary with the
@@ -194,7 +193,7 @@
class IDummy(Interface):
- perm = fields.Permission(title=u'')
+ perm = zope.security.zcml.Permission(title=u'')
perms = []
@@ -218,22 +217,28 @@
def testRedefinePermission(self):
self.assertEqual(perms, ['zope.Security'])
+def setUpAuth(test=None):
+ setUp(test)
+ from zope.app.authentication.placelesssetup import PlacelessSetup
+ PlacelessSetup().setUp()
+
def zcml(s):
context = xmlconfig.file('meta.zcml', package=zope.app.security)
xmlconfig.string(s, context)
def reset():
tearDown()
- setUp()
+ setUpAuth()
def test_suite():
return unittest.TestSuite((
doctest.DocTestSuite(setUp=setUp, tearDown=tearDown),
+ doctest.DocTestSuite('zope.security.zcml'),
unittest.makeSuite(DirectivesTest),
doctest.DocFileSuite(
'../globalprincipals.txt',
globs={'zcml': zcml, 'reset': reset},
- setUp=setUp, tearDown=tearDown,
+ setUp=setUpAuth, tearDown=tearDown,
)
))
Deleted: Zope3/trunk/src/zope/app/security/tests/test_fields.py
===================================================================
--- Zope3/trunk/src/zope/app/security/tests/test_fields.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/tests/test_fields.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,27 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Configuration field doc tests.
-
-$Id$
-"""
-import unittest
-from zope.testing.doctestunit import DocTestSuite
-
-def test_suite():
- return unittest.TestSuite((
- DocTestSuite('zope.app.security.fields'),
- ))
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
Modified: Zope3/trunk/src/zope/app/security/tests/test_protectclass.py
===================================================================
--- Zope3/trunk/src/zope/app/security/tests/test_protectclass.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/tests/test_protectclass.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,10 +18,10 @@
import unittest
from zope.interface import implements
from zope.security.checker import selectChecker
+from zope.security.permission import Permission
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.security.permission import Permission
from zope.app.security.interfaces import IPermission
from zope.app.security.protectclass import protectName, protectLikeUnto
from zope.app.security.protectclass import protectSetAttribute
Modified: Zope3/trunk/src/zope/app/security/tests/test_protectsubclass.py
===================================================================
--- Zope3/trunk/src/zope/app/security/tests/test_protectsubclass.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/tests/test_protectsubclass.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,11 +17,11 @@
"""
import unittest
from zope.security.checker import selectChecker
+from zope.security.permission import Permission
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
from zope.app.security.interfaces import IPermission
-from zope.app.security.permission import Permission
from zope.app.security.protectclass import protectName
class Test(PlacelessSetup, unittest.TestCase):
Modified: Zope3/trunk/src/zope/app/security/tests/test_securitydirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/security/tests/test_securitydirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/tests/test_securitydirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,7 +23,6 @@
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.servicenames import Authentication
from zope.app.security.interfaces import IAuthentication, IPermission
from zope.app.security.principalregistry import principalRegistry
from zope.app.security.settings import Allow
Modified: Zope3/trunk/src/zope/app/security/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/security/vocabulary.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/security/vocabulary.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,27 +17,19 @@
$Id$
"""
-import warnings
-import zope.deprecation
-
-from zope.security.checker import CheckerPublic
-from zope.app import zapi
+import zope.component
from zope.interface import implements, classProvides
from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
-from zope.schema.interfaces import ISourceQueriables
+from zope.schema.interfaces import ISourceQueriables, IVocabularyFactory
from zope.security.interfaces import IPermission
+from zope.security.checker import CheckerPublic
+
from zope.app.security.interfaces import IAuthentication
from zope.app.security.interfaces import PrincipalLookupError
from zope.app.security.interfaces import IPrincipalSource
from zope.app.component import queryNextUtility
from zope.app.component.vocabulary import UtilityVocabulary
-from zope.app.schema.interfaces import IVocabularyFactory
-# BBB Backward Compatibility
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError
-zope.deprecation.__show__.on()
-
class PermissionsVocabulary(UtilityVocabulary):
classProvides(IVocabularyFactory)
interface = IPermission
@@ -66,7 +58,7 @@
the special permission 'zope.Public':
>>> from zope.app.security.interfaces import IPermission
- >>> from zope.app.security.permission import Permission
+ >>> from zope.security.permission import Permission
>>> from zope.app.testing import ztapi
>>> ztapi.provideUtility(IPermission, Permission('zope.Public'),
... 'zope.Public')
@@ -106,7 +98,7 @@
def __init__(self, context):
terms = []
- permissions = zapi.getUtilitiesFor(IPermission, context)
+ permissions = zope.component.getUtilitiesFor(IPermission, context)
for name, permission in permissions:
if name == 'zope.Public':
terms.append(SimpleTerm(
@@ -144,8 +136,8 @@
simply monkey patch the `getUtility()` method to always return our
dummy authentication utility.
- >>> temp = zapi.getUtility
- >>> zapi.getUtility = lambda iface: DummyUtility()
+ >>> temp = zope.component.getUtility
+ >>> zope.component.getUtility = lambda iface: DummyUtility()
Now initialize the principal source and test the method
@@ -157,23 +149,13 @@
Now revert our patch.
- >>> zapi.getUtility = temp
+ >>> zope.component.getUtility = temp
"""
- auth = zapi.getUtility(IAuthentication)
+ auth = zope.component.getUtility(IAuthentication)
try:
auth.getPrincipal(id)
except PrincipalLookupError:
return False
- except NotFoundError: # BBB Backward Compatibility
- warnings.warn(
- "A %s instance raised a NotFoundError in "
- "getPrincipals. Raising NotFoundError in this "
- "method is deprecated and will no-longer be supported "
- "starting in Zope 3.3. PrincipalLookupError should "
- "be raised instead."
- % auth.__class__.__name__,
- DeprecationWarning)
- return False
else:
return True
@@ -208,17 +190,17 @@
>>> testingNextUtility(dummy1, dummy2, IAuthentication)
>>> testingNextUtility(dummy2, dummy3, IAuthentication)
- >>> temp = zapi.getUtility
- >>> zapi.getUtility = lambda iface: dummy1
+ >>> temp = zope.component.getUtility
+ >>> zope.component.getUtility = lambda iface: dummy1
>>> source = PrincipalSource()
>>> list(source.getQueriables())
[(u'0', dummy1), (u'1.1', 1), (u'1.2', 2), (u'1.3', 3), (u'2.4', 4)]
- >>> zapi.getUtility = temp
+ >>> zope.component.getUtility = temp
"""
i = 0
- auth = zapi.getUtility(IAuthentication)
+ auth = zope.component.getUtility(IAuthentication)
yielded = []
while True:
queriables = ISourceQueriables(auth, None)
Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -3,13 +3,6 @@
xmlns="http://namespaces.zope.org/browser"
i18n_domain="zope">
- <tool
- interface="..interfaces.IRole"
- title="Role"
- description="Roles are used to combine permissions and can be assigned
- to principals."
- />
-
<!-- RadioWidget for build a matrix for granting permissions -->
<zope:view
type="zope.publisher.interfaces.browser.IBrowserRequest"
@@ -91,7 +84,7 @@
<!-- Granting Roles and Permissions to Principals -->
<page
- for="zope.app.annotation.interfaces.IAnnotatable"
+ for="zope.annotation.interfaces.IAnnotatable"
name="grant.html"
permission="zope.Security"
template="granting.pt"
Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/ftests.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/ftests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/ftests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,12 +17,12 @@
"""
import unittest
+import zope.component
+from zope.security.interfaces import IPermission
+from zope.security.permission import Permission
from zope.app.testing import functional
-from zope.app.security.interfaces import IPermission
-from zope.app.security.permission import Permission
from zope.app.securitypolicy.role import Role
from zope.app.securitypolicy.interfaces import IRole
-from zope.app.tests import ztapi
class RolePermissionsTest(functional.BrowserTestCase):
@@ -87,7 +87,7 @@
def testAllRolePermissionsFormForLocalRoles(self):
role = Role(u"id", u"Local Role")
- ztapi.provideUtility(IRole, role)
+ zope.component.provideUtility(role, IRole)
self.testAllRolePermissions()
response = self.publish(
@@ -98,7 +98,7 @@
def testAllRolePermissionsFormForLocalPermissions(self):
permission = Permission(u"id", u"Local Permission")
- ztapi.provideUtility(IPermission, permission)
+ zope.component.provideUtility(permission, IPermission)
self.testAllRolePermissions()
response = self.publish(
@@ -109,7 +109,7 @@
def testRolesWithPermissionsFormForLocalPermission(self):
permission = Permission(u"id", u"Local Permission")
- ztapi.provideUtility(IPermission, permission)
+ zope.component.provideUtility(permission, IPermission, 'id')
response = self.publish(
'/++etc++site/@@AllRolePermissions.html',
Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/granting.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,8 +15,8 @@
- Permissions
- >>> from zope.app.security.permission import Permission
- >>> from zope.app.security.interfaces import IPermission
+ >>> from zope.security.permission import Permission
+ >>> from zope.security.interfaces import IPermission
>>> ztapi.provideUtility(IPermission, Permission(u'permission1',
... u'Permission 1'), u'permission1')
>>> ztapi.provideUtility(IPermission, Permission(u'permission2',
@@ -52,7 +52,7 @@
- Security-related Adapters
- >>> from zope.app.annotation.interfaces import IAnnotatable
+ >>> from zope.annotation.interfaces import IAnnotatable
>>> from zope.app.securitypolicy.interfaces import IPrincipalRoleManager
>>> from zope.app.securitypolicy.principalrole import \
... AnnotationPrincipalRoleManager
@@ -109,7 +109,7 @@
- Content Object
- >>> from zope.app.annotation.interfaces import IAttributeAnnotatable
+ >>> from zope.annotation.interfaces import IAttributeAnnotatable
>>> class Content:
... implements(IAttributeAnnotatable)
... __annotations__ = {}
Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/rolepermissionview.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,9 +19,9 @@
from zope.i18n import translate
from zope.interface import implements
+from zope.exceptions.interfaces import UserError
from zope.app import zapi
-from zope.app.exception.interfaces import UserError
from zope.app.i18n import ZopeMessageFactory as _
from zope.app.security.settings import Unset, Allow, Deny
from zope.app.security.interfaces import IPermission
Modified: Zope3/trunk/src/zope/app/securitypolicy/browser/tests/test_rolepermissionview.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/browser/tests/test_rolepermissionview.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/browser/tests/test_rolepermissionview.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,13 +20,12 @@
import zope.interface
from zope.i18n.interfaces import ITranslationDomain
from zope.i18nmessageid import Message
-from zope.publisher.browser import TestRequest
+from zope.publisher.browser import TestRequest, BrowserView
+from zope.exceptions.interfaces import UserError
+from zope.security.permission import Permission
+from zope.security.interfaces import IPermission
-from zope.app.exception.interfaces import UserError
-from zope.app.publisher.browser import BrowserView
from zope.app.testing import ztapi
-from zope.app.security.permission import Permission
-from zope.app.security.interfaces import IPermission
from zope.app.component.testing import PlacefulSetup
from zope.app.securitypolicy.role import Role
Modified: Zope3/trunk/src/zope/app/securitypolicy/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -5,7 +5,7 @@
<adapter factory=".rolepermission.AnnotationRolePermissionManager"
provides=".interfaces.IRolePermissionManager"
- for="zope.app.annotation.interfaces.IAnnotatable"
+ for="zope.annotation.interfaces.IAnnotatable"
trusted="true"
/>
@@ -20,7 +20,7 @@
<adapter factory=".principalrole.AnnotationPrincipalRoleManager"
provides=".interfaces.IPrincipalRoleManager"
- for="zope.app.annotation.interfaces.IAnnotatable"
+ for="zope.annotation.interfaces.IAnnotatable"
trusted="true"
/>
@@ -35,7 +35,7 @@
<adapter factory=".principalpermission.AnnotationPrincipalPermissionManager"
provides=".interfaces.IPrincipalPermissionManager"
- for="zope.app.annotation.interfaces.IAnnotatable"
+ for="zope.annotation.interfaces.IAnnotatable"
trusted="true"
/>
@@ -50,7 +50,7 @@
<adapter factory=".grantinfo.AnnotationGrantInfo"
provides=".interfaces.IGrantInfo"
- for="zope.app.annotation.interfaces.IAnnotatable"
+ for="zope.annotation.interfaces.IAnnotatable"
/>
<!-- protect Roles and Permissions -->
@@ -67,13 +67,13 @@
<subscriber
for=".interfaces.IRole
- ..component.interfaces.registration.IRegistrationActivatedEvent"
+ zope.component.interfaces.IRegistered"
handler=".role.setIdOnActivation"
/>
<subscriber
for=".interfaces.IRole
- ..component.interfaces.registration.IRegistrationDeactivatedEvent"
+ zope.component.interfaces.IUnregistered"
handler=".role.unsetIdOnDeactivation"
/>
Modified: Zope3/trunk/src/zope/app/securitypolicy/grantinfo.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/grantinfo.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/grantinfo.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,12 +15,10 @@
$Id$
"""
+from zope.annotation.interfaces import IAnnotations
from zope.app.security.settings import Unset
-
from zope.app.securitypolicy.interfaces import IGrantInfo
-from zope.app.annotation.interfaces import IAnnotations
-
from zope.app.securitypolicy.principalpermission \
import AnnotationPrincipalPermissionManager
prinperkey = AnnotationPrincipalPermissionManager.key
@@ -36,8 +34,6 @@
rolepermkey = AnnotationRolePermissionManager.key
del AnnotationRolePermissionManager
-
-
class AnnotationGrantInfo(object):
prinper = prinrole = permrole = {}
Modified: Zope3/trunk/src/zope/app/securitypolicy/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,7 +16,7 @@
$Id$
"""
from zope.configuration.exceptions import ConfigurationError
-from zope.app.component.metaconfigure import utility
+from zope.component.zcml import utility
from zope.app.securitypolicy.interfaces import IRole
from zope.app.securitypolicy.role import Role
Modified: Zope3/trunk/src/zope/app/securitypolicy/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/metadirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/metadirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,8 +17,7 @@
"""
from zope.interface import Interface
from zope.schema import Id
-from zope.app.security.metadirectives import IBaseDefineDirective
-from zope.app.security.fields import Permission
+from zope.security.zcml import Permission, IPermissionDirective
class IGrantAllDirective(Interface):
"""Grant Permissions to roles and principals and roles to principals."""
@@ -41,6 +40,6 @@
description=u"Specifies the Permission to be mapped.",
required=False)
-class IDefineRoleDirective(IBaseDefineDirective):
+class IDefineRoleDirective(IPermissionDirective):
"""Define a new role."""
Modified: Zope3/trunk/src/zope/app/securitypolicy/principalpermission.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/principalpermission.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/principalpermission.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,12 +17,11 @@
"""
from zope.interface import implements
-from zope.app.securitypolicy.interfaces import IPrincipalPermissionManager
+from zope.security.permission import allPermissions
from zope.app.security.settings import Allow, Deny, Unset
from zope.app.security.principal import checkPrincipal
-from zope.app.security.permission import allPermissions
-
+from zope.app.securitypolicy.interfaces import IPrincipalPermissionManager
from zope.app.securitypolicy.securitymap import SecurityMap
from zope.app.securitypolicy.securitymap import AnnotationSecurityMap
Modified: Zope3/trunk/src/zope/app/securitypolicy/role.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/role.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/role.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,9 +17,9 @@
"""
from persistent import Persistent
from zope.interface import implements
+from zope.component import getUtilitiesFor
+from zope.location import Location
-from zope.app import zapi
-from zope.app.location import Location
from zope.app.securitypolicy.interfaces import IRole
from zope.app.i18n import ZopeMessageFactory as _
@@ -42,11 +42,6 @@
self.title = title
self.description = description
-# BBB: Renamed component on 12/05/2004
-PersistentRole = LocalRole
-from zope.app.component.site import UtilityRegistration
-RoleRegistration = UtilityRegistration
-
def setIdOnActivation(role, event):
"""Set the permission id upon registration activation.
@@ -61,8 +56,8 @@
>>> role1 = LocalRole('Role 1', 'A first role')
>>> role1.id
u'<role not activated>'
- >>> from zope.app.component import registration
- >>> event = registration.RegistrationActivatedEvent(
+ >>> import zope.component.interfaces
+ >>> event = zope.component.interfaces.Registered(
... Registration(role1, 'role1'))
Now we pass the event into this function, and the id of the role should be
@@ -89,8 +84,8 @@
>>> role1 = LocalRole('Role 1', 'A first role')
>>> role1.id = 'role1'
- >>> from zope.app.component import registration
- >>> event = registration.RegistrationDeactivatedEvent(
+ >>> import zope.component.interfaces
+ >>> event = zope.component.interfaces.Unregistered(
... Registration(role1, 'role1'))
Now we pass the event into this function, and the id of the role should be
@@ -105,6 +100,6 @@
def checkRole(context, role_id):
- names = [name for name, util in zapi.getUtilitiesFor(IRole, context)]
+ names = [name for name, util in getUtilitiesFor(IRole, context)]
if not role_id in names:
raise ValueError("Undefined role id", role_id)
Modified: Zope3/trunk/src/zope/app/securitypolicy/rolepermission.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/rolepermission.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/rolepermission.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,8 +17,8 @@
"""
from zope.interface import implements
+from zope.security.permission import allPermissions
from zope.app.security.settings import Allow, Deny, Unset
-from zope.app.security.permission import allPermissions
from zope.app.securitypolicy.role import checkRole
from zope.app.securitypolicy.interfaces import IRolePermissionManager
Modified: Zope3/trunk/src/zope/app/securitypolicy/securitymap.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/securitymap.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/securitymap.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,7 +16,7 @@
$Id$
"""
from persistent import Persistent
-from zope.app.annotation import IAnnotations
+from zope.annotation import IAnnotations
from zope.security.management import queryInteraction
class SecurityMap(object):
Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalpermissionmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalpermissionmanager.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalpermissionmanager.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,16 +18,16 @@
import unittest
from zope.interface import implements
+from zope.annotation.attribute import AttributeAnnotations
+from zope.annotation.interfaces import IAttributeAnnotatable, IAnnotations
+from zope.security.interfaces import IPermission
+from zope.security.permission import Permission
from zope.app.testing import ztapi
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.annotation.interfaces import IAttributeAnnotatable, IAnnotations
from zope.app.security.principalregistry import principalRegistry
from zope.app.security.settings import Allow, Deny, Unset
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.security.interfaces import IPermission
-from zope.app.security.permission import Permission
from zope.app.securitypolicy.principalpermission \
import AnnotationPrincipalPermissionManager
Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalrolemanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalrolemanager.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationprincipalrolemanager.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,11 +16,11 @@
$Id$
"""
import unittest
+import zope.component
from zope.interface import implements
+from zope.annotation.interfaces import IAttributeAnnotatable
-from zope.app import zapi
from zope.app.testing import ztapi
-from zope.app.annotation.interfaces import IAttributeAnnotatable
from zope.app.security.principalregistry import principalRegistry
from zope.app.security.settings import Allow, Deny
from zope.app.component.testing import PlacefulSetup
@@ -34,7 +34,7 @@
def defineRole(id, title=None, description=None):
role = Role(id, title, description)
- ztapi.provideUtility(IRole, role, name=role.id)
+ zope.component.provideUtility(role, IRole, name=role.id)
return role
class Test(PlacefulSetup, unittest.TestCase):
Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationrolepermissionmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationrolepermissionmanager.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_annotationrolepermissionmanager.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,11 +17,11 @@
"""
import unittest
from zope.interface import implements
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.security.interfaces import IPermission
+from zope.security.permission import Permission
from zope.app.testing import ztapi
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.security.interfaces import IPermission
-from zope.app.security.permission import Permission
from zope.app.security.settings import Allow, Deny
from zope.app.component.testing import PlacefulSetup
Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_principalpermissionmanager.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,14 +17,12 @@
"""
import unittest
-from zope.app import zapi
+from zope.security.interfaces import IPermission
+from zope.security.permission import Permission
+
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
-
-from zope.app.security.interfaces import IPermission
from zope.app.security.interfaces import IAuthentication
-from zope.app.security.permission import Permission
-
from zope.app.security.settings import Allow, Deny, Unset
from zope.app.security.principalregistry import principalRegistry
Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_rolepermissionmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_rolepermissionmanager.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_rolepermissionmanager.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,15 +17,12 @@
"""
import unittest
-from zope.app.testing.placelesssetup import PlacelessSetup
+from zope.security.interfaces import IPermission
+from zope.security.permission import Permission
-from zope.app import zapi
+from zope.app.testing.placelesssetup import PlacelessSetup
from zope.app.testing import ztapi
-
-from zope.app.security.interfaces import IPermission
-from zope.app.security.permission import Permission
from zope.app.security.settings import Allow, Deny
-
from zope.app.securitypolicy.role import Role
from zope.app.securitypolicy.interfaces import IRole
from zope.app.securitypolicy.rolepermission \
Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_securitydirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,17 +17,15 @@
"""
import unittest
+import zope.component
from zope.configuration import xmlconfig
from zope.configuration.config import ConfigurationConflictError
+from zope.security.interfaces import IPermission
+from zope.security.permission import Permission
-from zope.app import zapi
from zope.app.testing import ztapi
-
from zope.app.testing.placelesssetup import PlacelessSetup
-
-from zope.app.security.interfaces import IPermission
from zope.app.security.interfaces import IAuthentication
-from zope.app.security.permission import Permission
from zope.app.security.settings import Allow
from zope.app.security.principalregistry import principalRegistry
@@ -61,7 +59,7 @@
context = xmlconfig.file("role.zcml",
zope.app.securitypolicy.tests)
- role = zapi.getUtility(IRole, "zope.Everyperson")
+ role = zope.component.getUtility(IRole, "zope.Everyperson")
self.failUnless(role.id.endswith('Everyperson'))
self.assertEqual(role.title, 'Tout le monde')
self.assertEqual(role.description,
Modified: Zope3/trunk/src/zope/app/securitypolicy/tests/test_zopepolicy.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/tests/test_zopepolicy.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/tests/test_zopepolicy.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,12 +18,14 @@
import unittest
from zope.testing.doctestunit import DocFileSuite
+from zope.annotation.interfaces import IAnnotatable
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.annotation.interfaces import IAnnotations
+from zope.annotation.attribute import AttributeAnnotations
+from zope.security.management import endInteraction
+
from zope.app import zapi
from zope.app.testing import placelesssetup, ztapi
-from zope.app.annotation.interfaces import IAnnotatable
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.annotation.interfaces import IAnnotations
-from zope.app.annotation.attribute import AttributeAnnotations
from zope.app.securitypolicy.interfaces import IGrantInfo
from zope.app.securitypolicy.interfaces import IPrincipalRoleManager
from zope.app.securitypolicy.interfaces import IPrincipalPermissionManager
@@ -36,7 +38,6 @@
import AnnotationRolePermissionManager
from zope.app.securitypolicy.grantinfo \
import AnnotationGrantInfo
-from zope.security.management import endInteraction
def setUp(test):
placelesssetup.setUp()
Modified: Zope3/trunk/src/zope/app/securitypolicy/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/vocabulary.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/vocabulary.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,10 +17,11 @@
$Id$
"""
+import zope.component
from zope.interface import implements, classProvides
from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
-from zope.app import zapi
-from zope.app.schema.interfaces import IVocabularyFactory
+from zope.schema.interfaces import IVocabularyFactory
+
from zope.app.securitypolicy.interfaces import IRole
from zope.app.securitypolicy.interfaces import IGrantVocabulary
@@ -62,7 +63,7 @@
def __init__(self, context):
terms = []
- roles = zapi.getUtilitiesFor(IRole, context)
+ roles = zope.component.getUtilitiesFor(IRole, context)
for name, role in roles:
terms.append(SimpleTerm(name, name, name))
super(RoleIdsVocabulary, self).__init__(terms)
Modified: Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.txt
===================================================================
--- Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/securitypolicy/zopepolicy.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,7 +17,7 @@
grants and denials, objects must be annotatable:
>>> import zope.interface
- >>> from zope.app.annotation.interfaces import IAttributeAnnotatable
+ >>> from zope.annotation.interfaces import IAttributeAnnotatable
>>> class Ob:
... zope.interface.implements(IAttributeAnnotatable)
Modified: Zope3/trunk/src/zope/app/servicenames.py
===================================================================
--- Zope3/trunk/src/zope/app/servicenames.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/servicenames.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,6 +15,10 @@
$Id$
"""
+import warnings
+warnings.warn("This module is deprecated and will go away in Zope 3.5.",
+ DeprecationWarning, 2)
+
from zope.component.servicenames import *
Authentication = 'Authentication'
Modified: Zope3/trunk/src/zope/app/session/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/session/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/session/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,7 +20,7 @@
<adapter
for="zope.publisher.interfaces.IRequest"
- provides="zope.app.traversing.interfaces.IPathAdapter"
+ provides="zope.traversing.interfaces.IPathAdapter"
factory=".session.Session"
name="session"
permission="zope.Public"
@@ -28,7 +28,7 @@
<class class=".session.Session">
<allow interface=".interfaces.ISession" />
- <implements interface="zope.app.traversing.interfaces.IPathAdapter" />
+ <implements interface="zope.traversing.interfaces.IPathAdapter" />
</class>
<class class=".http.CookieClientIdManager">
Modified: Zope3/trunk/src/zope/app/session/http.py
===================================================================
--- Zope3/trunk/src/zope/app/session/http.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/session/http.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,24 +15,24 @@
$Id$
"""
-from cStringIO import StringIO
-from persistent import Persistent
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.i18n import ZopeMessageFactory as _
-from zope.app import zapi
-from zope.app.session.interfaces import IClientIdManager
-from zope.app.component.interfaces import ILocalUtility
-from zope import schema
-from zope.interface import implements
-from zope.app.http.httpdate import build_http_date
-from zope.publisher.interfaces.http import IHTTPApplicationRequest
import hmac
import random
import re
import sha
import string
import time
+from cStringIO import StringIO
+from persistent import Persistent
+from zope import schema
+from zope.interface import implements
+from zope.publisher.interfaces.http import IHTTPApplicationRequest
+from zope.annotation.interfaces import IAttributeAnnotatable
+
+from zope.app.i18n import ZopeMessageFactory as _
+from zope.app.session.interfaces import IClientIdManager
+from zope.app.http.httpdate import build_http_date
+
__docformat__ = 'restructuredtext'
cookieSafeTrans = string.maketrans("+/", "-.")
@@ -73,9 +73,7 @@
class CookieClientIdManager(Persistent):
"""Session utility implemented using cookies."""
- implements(IClientIdManager, ICookieClientIdManager,
- ILocalUtility, IAttributeAnnotatable,
- )
+ implements(IClientIdManager, ICookieClientIdManager, IAttributeAnnotatable)
__parent__ = __name__ = None
Modified: Zope3/trunk/src/zope/app/session/session.py
===================================================================
--- Zope3/trunk/src/zope/app/session/session.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/session/session.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,14 +20,16 @@
from UserDict import IterableUserDict
from heapq import heapify, heappop
+import ZODB
+import ZODB.MappingStorage
from persistent import Persistent
+from BTrees.OOBTree import OOBTree
+
from zope import schema
from zope.interface import implements
-from zope.component import ComponentLookupError
-from zope.app.zapi import getUtility
-from BTrees.OOBTree import OOBTree
-from zope.app.component.interfaces import ILocalUtility
-from zope.app.annotation.interfaces import IAttributeAnnotatable
+from zope.component import getUtility
+from zope.component.interfaces import ComponentLookupError
+from zope.annotation.interfaces import IAttributeAnnotatable
from interfaces import \
IClientIdManager, IClientId, ISession, ISessionDataContainer, \
@@ -35,9 +37,6 @@
from http import ICookieClientIdManager
-import ZODB
-import ZODB.MappingStorage
-
__docformat__ = 'restructuredtext'
cookieSafeTrans = string.maketrans("+/", "-.")
@@ -73,7 +72,7 @@
"""A SessionDataContainer that stores data in the ZODB"""
__parent__ = __name__ = None
- implements(ISessionDataContainer, ILocalUtility, IAttributeAnnotatable)
+ implements(ISessionDataContainer, IAttributeAnnotatable)
_v_last_sweep = 0 # Epoch time sweep last run
Deleted: Zope3/trunk/src/zope/app/site/folder.py
===================================================================
--- Zope3/trunk/src/zope/app/site/folder.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/site/folder.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,34 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""A site management folder contains components and component registrations.
-
-$Id: folder.py 25177 2004-06-02 13:17:31Z jim $
-"""
-from zope.deprecation import deprecated
-from zope.app.container.btree import BTreeContainer
-
-from zope.app.component.site import SiteManagementFolder
-from zope.app.component.site import SMFolderFactory
-
-deprecated(('SiteManagementFolder', 'SMFolderFactory'),
- 'This class has moved to zope.app.component.site. '
- 'The reference will be gone in Zope 3.3.')
-
-# I really hope that noone is using this.
-class SiteManagementFolders(BTreeContainer):
- pass
-
-deprecated('SiteManagementFolders',
- 'This class has been deprecated. It was not used anyways. '
- 'The reference will be gone in Zope 3.3.')
Deleted: Zope3/trunk/src/zope/app/site/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/site/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/site/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,132 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Interfaces for folders.
-
-$Id: interfaces.py 27514 2004-09-13 15:54:05Z fdrake $
-"""
-import zope.schema
-from zope.deprecation import deprecated
-from zope.interface import Interface
-
-from zope.app.component.interfaces import registration
-from zope.app.container.interfaces import IContainer
-from zope.app.component.interfaces import IPossibleSite, ISite
-from zope.app.component.interfaces import ILocalSiteManager
-from zope.app.component.interfaces import ISiteManagementFolder
-
-deprecated(('IPossibleSite', 'ISite'),
- 'This interface has been moved to zope.app.component.interfaces. '
- 'The reference will be gone in Zope 3.3.')
-
-ISiteManager = ILocalSiteManager
-
-deprecated('ISiteManager',
- 'This interface has been moved to zope.app.component.interfaces '
- 'and been renamed ISiteManager. '
- 'The reference will be gone in Zope 3.3.')
-
-class ILocalService(registration.IRegisterable):
- """A local service isn't a local service if it doesn't implement this.
-
- The contract of a local service includes collaboration with
- services above it. A local service should also implement
- IRegisterable (which implies that it is adaptable to
- IRegistered). Implementing ILocalService implies this.
- """
-
-class ISimpleService(ILocalService):
- """Most local services should implement this instead of ILocalService.
-
- It implies a specific way of implementing IRegisterable,
- by subclassing IAttributeRegisterable.
- """
-
-deprecated(('ILocalService', 'ISimpleService'),
- 'The concept of services has been removed. Use utilities instead. '
- 'The reference will be gone in Zope 3.3.')
-
-class IComponentManager(Interface):
-
- def queryComponent(type=None, filter=None, all=0):
- """Return all components that match the given type and filter
-
- The objects are returned a sequence of mapping objects with keys:
-
- path -- The component path
-
- component -- The component
-
- all -- A flag indicating whether all component managers in
- this place should be queried, or just the local one.
-
- """
-
-deprecated('IComponentManager',
- 'This interface has been removed. It was horrible anyways. '
- 'The reference will be gone in Zope 3.3.')
-
-class IBindingAware(Interface):
-
- def bound(name):
- """Inform a service component that it is providing a service
-
- Called when an immediately-containing service manager binds
- this object to perform the named service.
- """
-
- def unbound(name):
- """Inform a service component that it is no longer providing a service
-
- Called when an immediately-containing service manager unbinds
- this object from performing the named service.
- """
-
-deprecated('IBindingAware',
- 'Now that services are gone, we do not need the binding support. '
- 'The reference will be gone in Zope 3.3.')
-
-class IServiceRegistration(registration.IComponentRegistration):
- """Service Registration
-
- Service registrations are dependent on the components that they
- configure. They register themselves as component dependents.
-
- The name of a service registration is used to determine the service
- type.
- """
-
- name = zope.schema.TextLine(
- title=u"Name",
- description=u"The name that is registered",
- readonly=True,
- # Don't allow empty or missing name:
- required=True,
- min_length=1,
- )
-
-deprecated('IServiceRegistration',
- 'The concept of services has been removed. Use utilities instead. '
- 'The reference will be gone in Zope 3.3.')
-
-class ISiteManagementFolders(IContainer, IComponentManager):
- """A collection of ISiteManagementFolder objects.
-
- An ISiteManagementFolders object supports simple containment as
- well as package query and lookup.
-
- """
-
-deprecated('ISiteManagementFolders',
- 'This interface has been removed. It was unused. '
- 'The reference will be gone in Zope 3.3.')
Deleted: Zope3/trunk/src/zope/app/site/service.py
===================================================================
--- Zope3/trunk/src/zope/app/site/service.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/site/service.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,54 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Service Manager code
-
-$Id: service.py 29078 2005-02-07 22:50:03Z garrett $
-"""
-__docformat__ = "reStructuredText"
-import zope.interface
-import zope.deprecation
-
-from zope.app.component.site import LocalSiteManager, UtilityRegistration
-from zope.app.component.interfaces.registration import \
- IRegisterableContainerContaining as IRegisterableContainerContainer
-
-zope.deprecation.__show__.off()
-from zope.component.bbb.service import IService
-from interfaces import IServiceRegistration
-zope.deprecation.__show__.on()
-
-zope.deprecation.deprecated(
- ('SiteManager', 'UtilityRegistration'),
- 'This class has been moved to zope.app.component.site. '
- 'The reference will be gone in Zope 3.3.')
-
-zope.deprecation.deprecated(
- 'IRegisterableContainerContainer',
- 'This interface has been moved to zope.app.component.interfaces '
- 'and been renamed to IRegisterableContainerContaining. '
- 'The reference will be gone in Zope 3.3.')
-
-ServiceManager = LocalSiteManager
-SiteManager = LocalSiteManager
-
-class ServiceRegistration(UtilityRegistration):
- zope.interface.implements(IServiceRegistration)
-
- def __init__(self, name, path, context=None):
- super(ServiceRegistration, self).__init__(name, IService, path)
-
-zope.deprecation.deprecated(
- ('ServiceManager', 'ServiceRegistration'),
- 'The concept of services has been removed. Use utilities instead. '
- 'The reference will be gone in Zope 3.3.')
Deleted: Zope3/trunk/src/zope/app/site/servicecontainer.py
===================================================================
--- Zope3/trunk/src/zope/app/site/servicecontainer.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/site/servicecontainer.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,28 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Service Manager Container
-
-$Id: servicecontainer.py 25177 2004-06-02 13:17:31Z jim $
-"""
-__docformat__ = "reStructuredText"
-from zope.deprecation import deprecated
-
-from zope.app.component.site import SiteManagerContainer
-
-ServiceManagerContainer = SiteManagerContainer
-
-deprecated('ServiceManagerContainer',
- 'This class has been moved to zope.app.component.site '
- 'and been renamed to SiteManagerContainer. '
- 'The reference will be gone in Zope 3.3.')
Modified: Zope3/trunk/src/zope/app/site/tests/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/site/tests/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/site/tests/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,6 +1,15 @@
-# BBB: Goes away in 3.3
+import zope.deferredimport
-from zope.app.component.testing import PlacefulSetup
+zope.deferredimport.deprecatedModule(
+ "zope.app.site.tests.placefulsetup",
+ "zope.app.component.testing",
+ "zope.app.site.tests.placefulsetup is deprecated and will go away "
+ "in Zope 3.5. Use zope.app.component.testing instead"
+ )
-def test_suite():
- return None
+zope.deferredimport.deprecated(
+ "Import of PlacefulSetup from zope.app.site.testing is deprecated "
+ "and will be disabled in Zope 3.5. Import from "
+ "zope.app.component.testing instead.",
+ PlacefulSetup = "zope.app.component.testing:PlacefulSetup",
+ )
Deleted: Zope3/trunk/src/zope/app/site/tests/placefulsetup.py
===================================================================
--- Zope3/trunk/src/zope/app/site/tests/placefulsetup.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/site/tests/placefulsetup.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1 +0,0 @@
-from zope.app.component.testing import *
Modified: Zope3/trunk/src/zope/app/size/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/size/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/size/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,51 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Adapters that give the size of an object.
-
-$Id$
-"""
-from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.size.interfaces import ISized
-from zope.interface import implements
-
-class DefaultSized(object):
- implements(ISized)
-
- def __init__(self, obj):
- try:
- size = int(obj.getSize())
- except (AttributeError, ValueError, TypeError):
- self._sortingSize = None, None
- else:
- self._sortingSize = 'byte', size
-
- def sizeForSorting(self):
- """See ISized"""
- return self._sortingSize
-
- def sizeForDisplay(self):
- """See ISized"""
- units, size = self._sortingSize
- if units == 'byte':
- return byteDisplay(size)
- return _('not-available', 'n/a')
-
-def byteDisplay(size):
- if size == 0:
- return _('0 KB')
- if size <= 1024:
- return _('1 KB')
- if size > 1048576:
- return _('${size} MB', mapping={'size': '%0.02f' % (size / 1048576.0)})
- return _('${size} KB', mapping={'size': '%d' % (size / 1024.0)})
+# This module has moved to zope.size
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.size',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/size/__init__.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.1
Deleted: Zope3/trunk/src/zope/app/size/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/size/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/size/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,13 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:global_translation="http://namespaces.zope.org/gts"
- i18n_domain="zope"
- >
-
- <adapter
- for="*"
- factory="zope.app.size.DefaultSized"
- provides="zope.app.size.interfaces.ISized"
- permission="zope.View" />
-
-</configure>
Modified: Zope3/trunk/src/zope/app/size/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/size/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/size/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,38 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Interfaces that give the size of an object.
-
-$Id$
-"""
-
-from zope.interface import Interface
-
-# basic units:
-# 'byte'
-# 'item' for example, number of subobjects for a folder
-# None for unsized things
-# 'line' for source-code like things
-
-class ISized(Interface):
-
- def sizeForSorting():
- """Returns a tuple (basic_unit, amount)
-
- Used for sorting among different kinds of sized objects.
- 'amount' need only be sortable among things that share the
- same basic unit."""
-
- def sizeForDisplay():
- """Returns a string giving the size.
- """
+# This module has moved to zope.size.interfaces
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.size.interfaces',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/size/interfaces.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.1
Deleted: Zope3/trunk/src/zope/app/size/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/size/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/size/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,92 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test ISized Adapter
-
-$Id$
-"""
-import unittest
-
-from zope.app.size.interfaces import ISized
-
-class DummyObject(object):
-
- def __init__(self, size):
- self._size = size
-
- def getSize(self):
- return self._size
-
-class Test(unittest.TestCase):
-
- def testImplementsISized(self):
- from zope.app.size import DefaultSized
- sized = DefaultSized(object())
- self.assert_(ISized.providedBy(sized))
-
- def testSizeWithBytes(self):
- from zope.app.size import DefaultSized
- obj = DummyObject(1023)
- sized = DefaultSized(obj)
- self.assertEqual(sized.sizeForSorting(), ('byte', 1023))
- self.assertEqual(sized.sizeForDisplay(), u'1 KB')
-
- def testSizeWithNone(self):
- from zope.app.size import DefaultSized
- obj = DummyObject(None)
- sized = DefaultSized(obj)
- self.assertEqual(sized.sizeForSorting(), (None, None))
- self.assertEqual(sized.sizeForDisplay(), u'not-available')
-
- def testSizeNotAvailable(self):
- from zope.app.size import DefaultSized
- sized = DefaultSized(object())
- self.assertEqual(sized.sizeForSorting(), (None, None))
- self.assertEqual(sized.sizeForDisplay(), u'not-available')
-
- def testVariousSizes(self):
- from zope.app.size import DefaultSized
-
- sized = DefaultSized(DummyObject(0))
- self.assertEqual(sized.sizeForSorting(), ('byte', 0))
- self.assertEqual(sized.sizeForDisplay(), u'0 KB')
-
- sized = DefaultSized(DummyObject(1))
- self.assertEqual(sized.sizeForSorting(), ('byte', 1))
- self.assertEqual(sized.sizeForDisplay(), u'1 KB')
-
- sized = DefaultSized(DummyObject(2048))
- self.assertEqual(sized.sizeForSorting(), ('byte', 2048))
- self.assertEqual(sized.sizeForDisplay(), u'${size} KB')
- self.assertEqual(sized.sizeForDisplay().mapping, {'size': '2'})
-
- sized = DefaultSized(DummyObject(2000000))
- self.assertEqual(sized.sizeForSorting(), ('byte', 2000000))
- self.assertEqual(sized.sizeForDisplay(), u'${size} MB')
- self.assertEqual(sized.sizeForDisplay().mapping, {'size': '1.91'})
-
- def test_byteDisplay(self):
- from zope.app.size import byteDisplay
- self.assertEqual(byteDisplay(0), u'0 KB')
- self.assertEqual(byteDisplay(1), u'1 KB')
- self.assertEqual(byteDisplay(2048), u'${size} KB')
- self.assertEqual(byteDisplay(2048).mapping, {'size': '2'})
- self.assertEqual(byteDisplay(2000000), u'${size} MB')
- self.assertEqual(byteDisplay(2000000).mapping, {'size': '1.91'})
-
-def test_suite():
- loader = unittest.TestLoader()
- return loader.loadTestsFromTestCase(Test)
-
-if __name__=='__main__':
- unittest.TextTestRunner().run(test_suite())
Modified: Zope3/trunk/src/zope/app/sqlexpr/sqlexpr.py
===================================================================
--- Zope3/trunk/src/zope/app/sqlexpr/sqlexpr.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/sqlexpr/sqlexpr.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,14 +15,14 @@
$Id$
"""
-from zope.component.exceptions import ComponentLookupError
+from zope.component import queryUtility, createObject
+from zope.component.interfaces import ComponentLookupError
from zope.interface import implements
from zope.tales.interfaces import ITALESExpression
from zope.tales.expressions import StringExpr
-from zope.app import zapi
-from zope.app.exception.interfaces import UserError
-from zope.app.rdb import queryForResults
-from zope.app.rdb.interfaces import IZopeDatabaseAdapter, IZopeConnection
+from zope.exceptions.interfaces import UserError
+from zope.rdb import queryForResults
+from zope.rdb.interfaces import IZopeDatabaseAdapter, IZopeConnection
class ConnectionError(UserError):
"""This exception is raised when the user did not specify an RDB
@@ -36,7 +36,7 @@
# TODO: It is hard-coded that the connection name variable is called
# 'sql_conn'. We should find a better solution.
conn_name = econtext.vars['sql_conn']
- adapter = zapi.queryUtility(IZopeDatabaseAdapter, conn_name)
+ adapter = queryUtility(IZopeDatabaseAdapter, conn_name)
if adapter is None:
raise ConnectionError("The RDB DA name, '%s' you specified is "
"not valid." % conn_name)
@@ -44,7 +44,7 @@
rdb = econtext.vars['rdb']
dsn = econtext.vars['dsn']
try:
- adapter = zapi.createObject(rdb, dsn)
+ adapter = createObject(rdb, dsn)
except ComponentLookupError:
raise ConnectionError("The factory id, '%s', you specified in "
"the `rdb` attribute did not match any "
Modified: Zope3/trunk/src/zope/app/sqlexpr/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/sqlexpr/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/sqlexpr/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,19 +17,18 @@
"""
import unittest
+import zope.component
from zope.interface import implements
from zope.component.factory import Factory
from zope.component.interfaces import IFactory
-from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.component.testing import PlacelessSetup
from zope.tales.tests.test_expressions import Data
from zope.tales.engine import Engine
+from zope.rdb.interfaces import IZopeDatabaseAdapter, IZopeConnection
+from zope.rdb.tests.stubs import ConnectionStub
-from zope.app.testing import ztapi
-from zope.app.rdb.interfaces import IZopeDatabaseAdapter, IZopeConnection
-from zope.app.rdb.tests.stubs import ConnectionStub
from zope.app.sqlexpr.sqlexpr import SQLExpr, ConnectionError
-
class AdapterStub(object):
implements(IZopeDatabaseAdapter)
@@ -68,12 +67,9 @@
def setUp(self):
super(SQLExprTest, self).setUp()
- ztapi.provideUtility(IFactory, Factory(AdapterStub),
- 'zope.da.Stub')
- ztapi.provideUtility(IFactory, Factory(lambda x: None),
- 'zope.Fake')
- ztapi.provideUtility(IZopeDatabaseAdapter, AdapterStub(''),
- 'test')
+ zope.component.provideUtility(Factory(AdapterStub), name='zope.da.Stub')
+ zope.component.provideUtility(Factory(lambda x: None), name='zope.Fake')
+ zope.component.provideUtility(AdapterStub(''), name='test')
def test_exprUsingRDBAndDSN(self):
context = Data(vars = {'rdb': 'zope.da.Stub', 'dsn': 'dbi://test'})
Modified: Zope3/trunk/src/zope/app/sqlscript/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/app/sqlscript/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/sqlscript/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -3,7 +3,7 @@
zope.documenttemplate
zope.interface
zope.schema
+zope.rdb
zope.app
zope.app.cache
zope.app.file
-zope.app.rdb
Modified: Zope3/trunk/src/zope/app/sqlscript/browser/sqlscript.py
===================================================================
--- Zope3/trunk/src/zope/app/sqlscript/browser/sqlscript.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/sqlscript/browser/sqlscript.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,13 +15,11 @@
$Id$
"""
+from zope.rdb.interfaces import DatabaseException
+from zope.traversing.browser import absoluteURL
from zope.app.form.browser.submit import Update
-from zope.app.rdb.interfaces import DatabaseException
-from zope.app import zapi
-
from zope.app.sqlscript.interfaces import ISQLScript
-
class SQLScriptTest(object):
"""Test the SQL inside the SQL Script
"""
@@ -125,7 +123,7 @@
name = self.context.contentName
container = self.context.context
obj = container[name]
- url = zapi.absoluteURL(obj, self.request)
+ url = absoluteURL(obj, self.request)
url = '%s/test.html' % url
return url
else:
Modified: Zope3/trunk/src/zope/app/sqlscript/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/sqlscript/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/sqlscript/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -30,7 +30,7 @@
set_schema=".interfaces.ISQLScript"
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
Modified: Zope3/trunk/src/zope/app/sqlscript/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/sqlscript/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/sqlscript/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,9 +16,9 @@
$Id$
"""
import zope.schema
-from zope.app import zapi
-from zope.app.rdb.interfaces import ISQLCommand
-from zope.app.i18n import ZopeMessageFactory as _
+from zope.rdb.interfaces import ISQLCommand
+from zope.i18nmessageid import MessageFactory
+_ = MessageFactory('zope')
class MissingInput(Exception):
pass
Modified: Zope3/trunk/src/zope/app/sqlscript/sqlscript.py
===================================================================
--- Zope3/trunk/src/zope/app/sqlscript/sqlscript.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/sqlscript/sqlscript.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,19 +21,19 @@
from persistent import Persistent
from persistent.dict import PersistentDict
+import zope.component
from zope.interface import implements, classProvides
from zope.interface.common.mapping import IEnumerableMapping
+from zope.schema.interfaces import IVocabularyFactory
+from zope.rdb import queryForResults
+from zope.rdb.interfaces import IZopeDatabaseAdapter
-from zope.app import zapi
-from zope.app.rdb import queryForResults
from zope.app.container.contained import Contained
-from zope.app.schema.interfaces import IVocabularyFactory
from zope.app.component.vocabulary import UtilityVocabulary
from zope.app.cache.caching import getCacheForObject, getLocationForCache
-from zope.app.rdb.interfaces import IZopeDatabaseAdapter
-from interfaces import ISQLScript
-from dtml import SQLDTML
+from zope.app.sqlscript.interfaces import ISQLScript
+from zope.app.sqlscript.dtml import SQLDTML
unparmre = re.compile(r'([\000- ]*([^\000- ="]+))')
@@ -105,11 +105,11 @@
def getConnection(self):
name = self.connectionName
- connection = zapi.getUtility(IZopeDatabaseAdapter, name)
+ connection = zope.component.getUtility(IZopeDatabaseAdapter, name)
return connection()
def __call__(self, **kw):
- """See zope.app.rdb.interfaces"""
+ """See zope.rdb.interfaces"""
# Try to resolve arguments
arg_values = {}
Modified: Zope3/trunk/src/zope/app/sqlscript/tests/test_sqlscript.py
===================================================================
--- Zope3/trunk/src/zope/app/sqlscript/tests/test_sqlscript.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/sqlscript/tests/test_sqlscript.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,21 +16,18 @@
"""
import unittest
from zope.interface import implements, classImplements
+from zope.component.testing import PlacelessSetup
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.annotation.interfaces import IAnnotatable, IAnnotations
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.annotation.attribute import AttributeAnnotations
+from zope.rdb.interfaces import IZopeDatabaseAdapter
+from zope.rdb.interfaces import IZopeConnection, IZopeCursor
from zope.app.testing import ztapi
-from zope.app.rdb.interfaces import IZopeDatabaseAdapter
-from zope.app.rdb.interfaces import IZopeConnection
-from zope.app.rdb.interfaces import IZopeCursor
-from zope.app.testing.placelesssetup import PlacelessSetup
-
-from zope.app.annotation.interfaces import IAnnotatable, IAnnotations
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.annotation.attribute import AttributeAnnotations
-
from zope.app.cache.interfaces import ICacheable, ICache
from zope.app.cache.annotationcacheable import AnnotationCacheable
from zope.app.cache.caching import getCacheForObject
-from zope.app.traversing.interfaces import IPhysicallyLocatable
from zope.app.sqlscript.sqlscript import SQLScript, Arguments
from zope.app.sqlscript.interfaces import ISQLScript
Modified: Zope3/trunk/src/zope/app/testing/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/app/testing/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/testing/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,4 +1,3 @@
-zope.app.event
zope.app.i18n
zope.app.container
zope.app.authentication
Copied: Zope3/trunk/src/zope/app/testing/back35.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/testing/back35.py)
Modified: Zope3/trunk/src/zope/app/testing/functional.py
===================================================================
--- Zope3/trunk/src/zope/app/testing/functional.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/testing/functional.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -32,7 +32,7 @@
from ZODB.DemoStorage import DemoStorage
from zope import interface, component
-from zope.publisher.browser import BrowserRequest
+from zope.publisher.browser import BrowserRequest, setDefaultSkin
from zope.publisher.http import HTTPRequest
from zope.publisher.publish import publish
from zope.publisher.xmlrpc import XMLRPCRequest
@@ -44,7 +44,7 @@
from zope.app import zapi
from zope.app.debug import Debugger
from zope.app.publication.http import HTTPPublication
-from zope.app.publication.browser import BrowserPublication, setDefaultSkin
+from zope.app.publication.browser import BrowserPublication
from zope.app.publication.xmlrpc import XMLRPCPublication
from zope.app.publication.soap import SOAPPublication
from zope.app.publication.interfaces import ISOAPRequestFactory
@@ -170,6 +170,7 @@
self.connection.close()
self.connection = None
self.db.close()
+ setSite(None)
def getRootFolder(self):
"""Returns the Zope root folder."""
@@ -284,10 +285,6 @@
class BrowserTestCase(CookieHandler, FunctionalTestCase):
"""Functional test case for Browser requests."""
- def tearDown(self):
- self.setSite(None)
- super(BrowserTestCase, self).tearDown()
-
def setSite(self, site):
"""Set the site which will be used to look up local components"""
setSite(site)
Modified: Zope3/trunk/src/zope/app/testing/placelesssetup.py
===================================================================
--- Zope3/trunk/src/zope/app/testing/placelesssetup.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/testing/placelesssetup.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,33 +15,30 @@
$Id$
"""
-from zope.app.testing import ztapi
from zope.schema.vocabulary import setVocabularyRegistry
-from zope.component.tests.placelesssetup \
- import PlacelessSetup as CAPlacelessSetup
-from zope.app.event.tests.placelesssetup \
- import PlacelessSetup as EventPlacelessSetup
-from zope.app.i18n.tests.placelesssetup \
- import PlacelessSetup as I18nPlacelessSetup
+from zope.component.testing import PlacelessSetup as CAPlacelessSetup
+from zope.component.eventtesting import PlacelessSetup as EventPlacelessSetup
+from zope.i18n.testing import PlacelessSetup as I18nPlacelessSetup
+from zope.traversing.browser.interfaces import IAbsoluteURL
+from zope.traversing.browser.absoluteurl import AbsoluteURL
+
+from zope.app.testing import ztapi
from zope.app.container.tests.placelesssetup \
import PlacelessSetup as ContainerPlacelessSetup
from zope.app.authentication.placelesssetup \
import PlacelessSetup as AuthenticationPlacelessSetup
from zope.app.security._protections import protect
-from zope.app.traversing.browser.interfaces import IAbsoluteURL
-from zope.app.traversing.browser.absoluteurl import AbsoluteURL
class PlacelessSetup(CAPlacelessSetup,
EventPlacelessSetup,
I18nPlacelessSetup,
ContainerPlacelessSetup,
- AuthenticationPlacelessSetup
- ):
+ AuthenticationPlacelessSetup):
def setUp(self, doctesttest=None):
CAPlacelessSetup.setUp(self)
- ContainerPlacelessSetup.setUp(self)
EventPlacelessSetup.setUp(self)
+ ContainerPlacelessSetup.setUp(self)
I18nPlacelessSetup.setUp(self)
AuthenticationPlacelessSetup.setUp(self)
# Register app-specific security declarations
Modified: Zope3/trunk/src/zope/app/testing/setup.py
===================================================================
--- Zope3/trunk/src/zope/app/testing/setup.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/testing/setup.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,121 +17,49 @@
"""
import zope.component
import zope.interface
-from zope.app import zapi
-from zope.app.testing import ztapi
-from zope.interface import classImplements
+import zope.traversing.api
+import zope.deferredimport
+zope.deferredimport.deprecatedFrom(
+ "Goes away in Zope 3.5",
+ "zope.app.testing.back35",
+ "addService",
+ )
-#############################################################################
-# BBB: Goes away in 3.3
-
-import zope.deprecation
-
-zope.deprecation.__show__.off()
-from zope.component.bbb.service import IService
-from zope.app.site.interfaces import ISimpleService
-zope.deprecation.__show__.on()
-
-from zope.app.component.site import UtilityRegistration
-
-def addService(servicemanager, name, service, suffix=''):
- """Add a service to a service manager
-
- This utility is useful for tests that need to set up services.
- """
- # Most local services implement ISimpleService in ZCML; therefore make
- # sure we got it here as well.
- zope.interface.directlyProvides(service, ISimpleService)
-
- default = zapi.traverse(servicemanager, 'default')
- default[name+suffix] = service
- registration = UtilityRegistration(name, IService, service, default)
- key = default.registrationManager.addRegistration(registration)
- zapi.traverse(default.registrationManager, key).status = ActiveStatus
- return default[name+suffix]
-
-def createServiceManager(folder, setsite=False):
- return createSiteManager(folder, setsite)
-
-zope.deprecation.deprecated(
- 'createServiceManager',
- '`ServiceManager`s became `SiteManager`s. Use `createSiteManager` '
- 'instead. Gone in Zope 3.3.')
-
-#############################################################################
-
#------------------------------------------------------------------------
# Annotations
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.annotation.interfaces import IAnnotations
-from zope.app.annotation.interfaces import IAttributeAnnotatable
+from zope.annotation.attribute import AttributeAnnotations
def setUpAnnotations():
- ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,
- AttributeAnnotations)
+ zope.component.provideAdapter(AttributeAnnotations)
#------------------------------------------------------------------------
# Dependencies
+from zope.annotation.interfaces import IAttributeAnnotatable
from zope.app.dependable import Dependable
from zope.app.dependable.interfaces import IDependable
def setUpDependable():
- ztapi.provideAdapter(IAttributeAnnotatable, IDependable,
- Dependable)
+ zope.component.provideAdapter(Dependable, (IAttributeAnnotatable,),
+ IDependable)
#------------------------------------------------------------------------
-# Registrations
-
-from zope.app.component.interfaces.registration import IComponentRegistration
-from zope.app.component.interfaces.registration import IRegistrationEvent
-from zope.app.component.registration import componentRegistrationEventNotify
-def setUpRegistered():
- ztapi.subscribe((IComponentRegistration, IRegistrationEvent), None,
- componentRegistrationEventNotify)
-
-#------------------------------------------------------------------------
# Traversal
-from zope.app.traversing.browser.interfaces import IAbsoluteURL
-from zope.app.container.traversal import ContainerTraversable
+from zope.traversing.interfaces import ITraversable
from zope.app.container.interfaces import ISimpleReadContainer
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.app.traversing.interfaces import IPhysicallyLocatable
-from zope.app.traversing.interfaces import ITraverser, ITraversable
-from zope.app.traversing.adapters import DefaultTraversable
-from zope.app.traversing.adapters import Traverser, RootPhysicallyLocatable
-from zope.app.location.traversing import LocationPhysicallyLocatable
-from zope.app.traversing.namespace import etc
-
+from zope.app.container.traversal import ContainerTraversable
def setUpTraversal():
- from zope.app.traversing.browser import SiteAbsoluteURL, AbsoluteURL
+ from zope.traversing.testing import setUp
+ setUp()
+ zope.component.provideAdapter(ContainerTraversable,
+ (ISimpleReadContainer,), ITraversable)
- ztapi.provideAdapter(None, ITraverser, Traverser)
- ztapi.provideAdapter(None, ITraversable, DefaultTraversable)
-
- ztapi.provideAdapter(
- ISimpleReadContainer, ITraversable, ContainerTraversable)
- ztapi.provideAdapter(
- None, IPhysicallyLocatable, LocationPhysicallyLocatable)
- ztapi.provideAdapter(
- IContainmentRoot, IPhysicallyLocatable, RootPhysicallyLocatable)
-
- # set up etc namespace
- ztapi.provideAdapter(None, ITraversable, etc, name="etc")
- ztapi.provideView(None, None, ITraversable, "etc", etc)
-
- ztapi.browserView(None, "absolute_url", AbsoluteURL)
- ztapi.browserView(IContainmentRoot, "absolute_url", SiteAbsoluteURL)
-
- ztapi.browserView(None, '', AbsoluteURL, providing=IAbsoluteURL)
- ztapi.browserView(IContainmentRoot, '', SiteAbsoluteURL,
- providing=IAbsoluteURL)
-
-
#------------------------------------------------------------------------
# ISiteManager lookup
from zope.app.component.site import SiteManagerAdapter
-from zope.component.interfaces import ISiteManager
+from zope.component.interfaces import IComponentLookup
from zope.interface import Interface
def setUpSiteManagerLookup():
- ztapi.provideAdapter(Interface, ISiteManager, SiteManagerAdapter)
+ zope.component.provideAdapter(SiteManagerAdapter, (Interface,),
+ IComponentLookup)
#------------------------------------------------------------------------
# Placeful setup
@@ -143,7 +71,6 @@
zope.app.component.hooks.setHooks()
setUpAnnotations()
setUpDependable()
- setUpRegistered()
setUpTraversal()
setUpSiteManagerLookup()
@@ -210,25 +137,22 @@
folder.setSiteManager(LocalSiteManager(folder))
if setsite:
setSite(folder)
- return zapi.traverse(folder, "++etc++site")
+ return zope.traversing.api.traverse(folder, "++etc++site")
#------------------------------------------------------------------------
# Local Utility Addition
-from zope.app.component.site import UtilityRegistration
-from zope.app.component.interfaces.registration import ActiveStatus
def addUtility(sitemanager, name, iface, utility, suffix=''):
"""Add a utility to a site manager
This helper function is useful for tests that need to set up utilities.
"""
folder_name = (name or (iface.__name__ + 'Utility')) + suffix
- default = zapi.traverse(sitemanager, 'default')
+ default = sitemanager['default']
default[folder_name] = utility
- registration = UtilityRegistration(name, iface, default[folder_name])
- key = default.registrationManager.addRegistration(registration)
- zapi.traverse(default.registrationManager, key).status = ActiveStatus
- return default[folder_name]
+ utility = default[folder_name]
+ sitemanager.registerUtility(utility, iface, name)
+ return utility
#------------------------------------------------------------------------
Modified: Zope3/trunk/src/zope/app/testing/ztapi.py
===================================================================
--- Zope3/trunk/src/zope/app/testing/ztapi.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/testing/ztapi.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,11 +16,11 @@
$Id$
"""
import zope.interface
+import zope.component
from zope.component.interfaces import IDefaultViewName
from zope.publisher.browser import IBrowserRequest
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
-from zope.app import zapi
-from zope.app.traversing.interfaces import ITraversable
+from zope.traversing.interfaces import ITraversable
def provideView(for_, type, providing, name, factory, layer=None):
if layer is None:
@@ -58,57 +58,39 @@
type=IBrowserRequest):
if layer is None:
layer = type
- gsm = zapi.getGlobalSiteManager()
- gsm.provideAdapter((for_, layer), IDefaultViewName, '', name)
+ gsm = zope.component.getGlobalSiteManager()
+ gsm.registerAdapter(name, (for_, layer), IDefaultViewName, '')
stypes = list, tuple
def provideAdapter(required, provided, factory, name='', with=()):
if isinstance(factory, (list, tuple)):
raise ValueError("Factory cannot be a list or tuple")
- gsm = zapi.getGlobalSiteManager()
+ gsm = zope.component.getGlobalSiteManager()
if with:
required = (required, ) + tuple(with)
elif not isinstance(required, stypes):
required = (required,)
- gsm.provideAdapter(required, provided, name, factory)
+ gsm.registerAdapter(factory, required, provided, name, event=False)
def subscribe(required, provided, factory):
- gsm = zapi.getGlobalSiteManager()
- gsm.subscribe(required, provided, factory)
+ gsm = zope.component.getGlobalSiteManager()
+ if provided is None:
+ gsm.registerHandler(factory, required, event=False)
+ else:
+ gsm.registerSubscriptionAdapter(factory, required, provided,
+ event=False)
+
-# BBB: Deprecated. Gone in 3.3
-def handle(required, handler):
- subscribe(required, None, handler)
-
def provideUtility(provided, component, name=''):
- gsm = zapi.getGlobalSiteManager()
- gsm.provideUtility(provided, component, name)
+ gsm = zope.component.getGlobalSiteManager()
+ gsm.registerUtility(component, provided, name, event=False)
def unprovideUtility(provided, name=''):
- gsm = zapi.getGlobalSiteManager()
- gsm.provideAdapter((), provided, name, None)
+ gsm = zope.component.getGlobalSiteManager()
+ gsm.unregisterUtility(provided=provided, name=name)
def provideNamespaceHandler(name, handler):
provideAdapter(None, ITraversable, handler, name=name)
provideView(None, None, ITraversable, name, handler)
-
-
-# BBB: Deprecated. Gone in 3.3.
-from zope.deprecation import deprecated
-
-def provideService(name, service, interface=None):
- services = zapi.getGlobalServices()
- if interface is not None:
- services.defineService(name, interface)
- services.provideService(name, service)
-
-deprecated('provideService',
- 'The concept of services has been removed. Use utilities instead. '
- 'The reference will be gone in 3.3.')
-
-deprecated('handle',
- 'The handle(required, handler) function as a shorter spelling of '
- 'subscribe(required, None, handler) has been deprecated to avoid '
- 'nomenclature confusion with zope.component.handle.')
Modified: Zope3/trunk/src/zope/app/tests/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/tests/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,30 +1,7 @@
-#
-# This file is necessary to make this directory a package.
-
-##############################################################################
-# BBB: backward-comptibility; 12/18/2004
-
-import sys
-from zope.deprecation.deprecation import DeprecationProxy
-import zope.app
-
-def deprecate(module):
- depmodule = DeprecationProxy(module)
- depmodule.deprecate(module.__dict__.keys(),
- 'The testing support code moved from zope.app.tests '
- 'to zope.app.testing. This reference go away in Zope '
- 'X3.3.')
- return depmodule
-
-
-from zope.app.testing import placelesssetup
-sys.modules['zope.app.tests.placelesssetup'] = deprecate(placelesssetup)
-from zope.app.testing import setup
-sys.modules['zope.app.tests.setup'] = deprecate(setup)
-from zope.app.testing import dochttp
-sys.modules['zope.app.tests.dochttp'] = deprecate(dochttp)
-from zope.app.testing import functional
-sys.modules['zope.app.tests.functional'] = deprecate(functional)
-from zope.app.testing import ztapi
-sys.modules['zope.app.tests.ztapi'] = deprecate(ztapi)
-#############################################################################
+# This module has moved to zope.app.testing
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.app.testing',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/tests/__init__.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.2
Name: svn:keywords
+ Id
Copied: Zope3/trunk/src/zope/app/tests/dochttp.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/tests/dochttp.py)
Copied: Zope3/trunk/src/zope/app/tests/functional.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/tests/functional.py)
Copied: Zope3/trunk/src/zope/app/tests/placelesssetup.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/tests/placelesssetup.py)
Copied: Zope3/trunk/src/zope/app/tests/setup.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/tests/setup.py)
Deleted: Zope3/trunk/src/zope/app/tests/test_datetimeparse.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/test_datetimeparse.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/tests/test_datetimeparse.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,107 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test datetime parser
-
-$Id$
-"""
-import unittest
-from zope.app.datetimeutils import parse, time, DateTimeError
-
-class Test(unittest.TestCase):
-
- def testParse(self):
- from zope.app.datetimeutils import parse
-
- self.assertEqual(parse('1999 12 31')[:6],
- (1999, 12, 31, 0, 0, 0))
- self.assertEqual(parse('1999 12 31 EST'),
- (1999, 12, 31, 0, 0, 0, 'EST'))
- self.assertEqual(parse('Dec 31, 1999')[:6],
- (1999, 12, 31, 0, 0, 0))
- self.assertEqual(parse('Dec 31 1999')[:6],
- (1999, 12, 31, 0, 0, 0))
- self.assertEqual(parse('Dec 31 1999')[:6],
- (1999, 12, 31, 0, 0, 0))
- self.assertEqual(parse('1999/12/31 1:2:3')[:6],
- (1999, 12, 31, 1, 2, 3))
- self.assertEqual(parse('1999-12-31 1:2:3')[:6],
- (1999, 12, 31, 1, 2, 3))
- self.assertEqual(parse('1999-12-31T01:02:03')[:6],
- (1999, 12, 31, 1, 2, 3))
- self.assertEqual(parse('1999-31-12 1:2:3')[:6],
- (1999, 12, 31, 1, 2, 3))
- self.assertEqual(parse('1999-31-12 1:2:3.456')[:5],
- (1999, 12, 31, 1, 2))
- self.assertEqual(int(parse('1999-31-12 1:2:3.456')[5]*1000+.000001),
- 3456)
- self.assertEqual(parse('1999-12-31T01:02:03.456')[:5],
- (1999, 12, 31, 1, 2))
- self.assertEqual(int(parse('1999-12-31T01:02:03.456')[5]*1000+.000001),
- 3456)
- self.assertEqual(parse('Tue, 24 Jul 2001 09:41:03 -0400'),
- (2001, 7, 24, 9, 41, 3, '-0400'))
- self.assertEqual(parse('1999-12-31T01:02:03.456-12')[6], '-1200')
- self.assertEqual(parse('1999-12-31T01:02:03.456+0030')[6], '+0030')
- self.assertEqual(parse('1999-12-31T01:02:03.456-00:30')[6], '-0030')
-
- def testTime(self):
- from time import gmtime
- from zope.app.datetimeutils import time
- self.assertEqual(gmtime(time('1999 12 31 GMT'))[:6],
- (1999, 12, 31, 0, 0, 0))
- self.assertEqual(gmtime(time('1999 12 31 EST'))[:6],
- (1999, 12, 31, 5, 0, 0))
- self.assertEqual(gmtime(time('1999 12 31 -0500'))[:6],
- (1999, 12, 31, 5, 0, 0))
- self.assertEqual(gmtime(time('1999-12-31T00:11:22Z'))[:6],
- (1999, 12, 31, 0, 11, 22))
- self.assertEqual(gmtime(time('1999-12-31T01:11:22+01:00'))[:6],
- (1999, 12, 31, 0, 11, 22))
-
- def testBad(self):
- from zope.app.datetimeutils import time, DateTimeError
- self.assertRaises(DateTimeError, parse, '1999')
- self.assertRaises(DateTimeError, parse, '1999-31-12 1:2:63.456')
- self.assertRaises(DateTimeError, parse, '1999-31-13 1:2:3.456')
- self.assertRaises(DateTimeError, parse, '1999-2-30 1:2:3.456')
- self.assertRaises(DateTimeError, parse, 'April 31, 1999 1:2:3.456')
-
- def testLeap(self):
- from zope.app.datetimeutils import time, DateTimeError
- self.assertRaises(DateTimeError, parse, '1999-2-29 1:2:3.456')
- self.assertRaises(DateTimeError, parse, '1900-2-29 1:2:3.456')
- self.assertEqual(parse('2000-02-29 1:2:3')[:6],
- (2000, 2, 29, 1, 2, 3))
- self.assertEqual(parse('2004-02-29 1:2:3')[:6],
- (2004, 2, 29, 1, 2, 3))
-
- def test_tzoffset(self):
- from zope.app.datetimeutils import _tzoffset
- self.assertEqual(_tzoffset('-0400', None), -4*60*60)
- self.assertEqual(_tzoffset('-0030', None), -30*60)
- self.assertEqual(_tzoffset('+0200', None), 2*60*60)
- self.assertEqual(_tzoffset('EET', None), 2*60*60)
-
- def testParseDatetimetz(self):
- from datetime import datetime
- from zope.app.datetimeutils import parseDatetimetz, tzinfo
- self.assertEqual(parseDatetimetz('1999-12-31T01:02:03.037-00:30'),
- datetime(1999, 12, 31, 1, 2, 3, 37000, tzinfo(-30)))
-
-def test_suite():
- loader=unittest.TestLoader()
- return loader.loadTestsFromTestCase(Test)
-
-if __name__=='__main__':
- unittest.TextTestRunner().run(test_suite())
Deleted: Zope3/trunk/src/zope/app/tests/test_decorator.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/test_decorator.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/tests/test_decorator.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,93 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Context Tests
-
-$Id$
-"""
-
-import pickle
-import unittest
-from zope.app.decorator import Decorator
-from zope.interface import Interface, implements, directlyProvides, providedBy
-from zope.interface import directlyProvidedBy, implementedBy
-from zope.testing.doctestunit import DocTestSuite
-from zope.security.interfaces import ForbiddenAttribute
-
-class I1(Interface):
- pass
-class I2(Interface):
- pass
-class I3(Interface):
- pass
-class I4(Interface):
- pass
-
-class D1(Decorator):
- implements(I1)
-
-class D2(Decorator):
- implements(I2)
-
-
-def check_forbidden_call(callable, *args):
- try:
- return callable(*args)
- except ForbiddenAttribute, e:
- return 'ForbiddenAttribute: %s' % e[0]
-
-
-def test_providedBy_iter_w_new_style_class():
- """
- >>> class X(object):
- ... implements(I3)
-
- >>> x = X()
- >>> directlyProvides(x, I4)
-
- >>> [interface.getName() for interface in list(providedBy(x))]
- ['I4', 'I3']
-
- >>> [interface.getName() for interface in list(providedBy(D1(x)))]
- ['I4', 'I3', 'I1']
-
- >>> [interface.getName() for interface in list(providedBy(D2(D1(x))))]
- ['I4', 'I3', 'I1', 'I2']
- """
-
-def test_providedBy_iter_w_classic_class():
- """
- >>> class X(object):
- ... implements(I3)
-
- >>> x = X()
- >>> directlyProvides(x, I4)
-
- >>> [interface.getName() for interface in list(providedBy(x))]
- ['I4', 'I3']
-
- >>> [interface.getName() for interface in list(providedBy(D1(x)))]
- ['I4', 'I3', 'I1']
-
- >>> [interface.getName() for interface in list(providedBy(D2(D1(x))))]
- ['I4', 'I3', 'I1', 'I2']
- """
-
-def test_suite():
- suite = DocTestSuite()
- suite.addTest(DocTestSuite('zope.app.decorator'))
- return suite
-
-
-if __name__ == '__main__':
- unittest.main()
Deleted: Zope3/trunk/src/zope/app/tests/test_standard_dates.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/test_standard_dates.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/tests/test_standard_dates.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,44 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Tests standard date parsing
-
-$Id$
-"""
-import unittest
-
-from zope.app.datetimeutils import time
-
-class Test(unittest.TestCase):
-
- def testiso8601_date(self):
- from zope.app.datetimeutils import iso8601_date
- self.assertEqual(iso8601_date(time("2000-01-01T01:01:01.234Z")),
- "2000-01-01T01:01:01Z")
-
- def testrfc850_date(self):
- from zope.app.datetimeutils import rfc850_date
- self.assertEqual(rfc850_date(time("2002-01-12T01:01:01.234Z")),
- "Saturday, 12-Jan-02 01:01:01 GMT")
-
- def testrfc1123_date(self):
- from zope.app.datetimeutils import rfc1123_date
- self.assertEqual(rfc1123_date(time("2002-01-12T01:01:01.234Z")),
- "Sat, 12 Jan 2002 01:01:01 GMT")
-
-def test_suite():
- loader=unittest.TestLoader()
- return loader.loadTestsFromTestCase(Test)
-
-if __name__=='__main__':
- unittest.TextTestRunner().run(test_suite())
Deleted: Zope3/trunk/src/zope/app/tests/test_tzinfo.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/test_tzinfo.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/tests/test_tzinfo.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,54 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test for the 'tzinfo() function
-
-$Id$
-"""
-
-from unittest import TestCase, TestSuite, main, makeSuite
-import pickle
-import datetime
-
-from zope.app.datetimeutils import tzinfo
-class Test(TestCase):
-
- def test(self):
-
- for minutes in 1439, 600, 1, 0, -1, -600, -1439:
- info1 = tzinfo(minutes)
- info2 = tzinfo(minutes)
-
- self.assertEqual(info1, info2)
- self.assert_(info1 is info2)
- self.assert_(pickle.loads(pickle.dumps(info1)) is info1)
-
-
- self.assertEqual(info1.utcoffset(None),
- datetime.timedelta(minutes=minutes))
-
- self.assertEqual(info1.dst(None), None)
- self.assertEqual(info1.tzname(None), None)
-
- for minutes in 900000, 1440*60, -1440*60, -900000:
- self.assertRaises(ValueError, tzinfo, minutes)
-
-
-
-def test_suite():
- return TestSuite((
- makeSuite(Test),
- ))
-
-if __name__=='__main__':
- main(defaultTest='test_suite')
Copied: Zope3/trunk/src/zope/app/tests/ztapi.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/tests/ztapi.py)
Modified: Zope3/trunk/src/zope/app/timezones.py
===================================================================
--- Zope3/trunk/src/zope/app/timezones.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/timezones.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,1202 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-""" Historical timezone data, ported from Zope2's DateTime.DateTimeZone.
-
-$Id$
-"""
-
-historical_zone_info = {
-'Brazil/Acre': ('Brazil/Acre', 101, 2,
-[ '561970800', '571644000', '593420400', '603093600', '625561200',
-'634543200', '656924400', '665992800', '688374000', '697442400',
-'719823600', '729496800', '751273200', '760946400', '782722800',
-'792396000', '814863600', '823845600', '846226800', '855295200',
-'877676400', '887436000', '909126000', '918799200', '940575600',
-'950248800', '972716400', '981698400', '1004079600', '1013148000',
-'1035529200', '1044597600', '1066978800', '1076738400', '1098428400',
-'1108101600', '1129878000', '1139551200', '1162018800', '1171000800',
-'1193382000', '1202450400', '1224831600', '1234591200', '1256281200',
-'1265954400', '1287730800', '1297404000', '1319180400', '1328853600',
-'1351234800', '1360303200', '1382684400', '1391752800', '1414134000',
-'1423893600', '1445583600', '1455256800', '1477033200', '1486706400',
-'1509174000', '1518156000', '1540537200', '1549605600', '1571986800',
-'1581055200', '1603436400', '1613109600', '1634886000', '1644559200',
-'1666335600', '1676008800', '1698476400', '1707458400', '1729839600',
-'1738908000', '1761289200', '1771048800', '1792738800', '1802412000',
-'1824188400', '1833861600', '1856329200', '1865311200', '1887692400',
-'1896760800', '1919142000', '1928210400', '1950591600', '1960351200',
-'1982041200', '1991714400', '2013490800', '2023164000', '2045631600',
-'2054613600', '2076994800', '2086063200', '2108444400', '2118204000',
-'2139894000',
-],
-'\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-18000, 0, 0), (-14400, 1, 4)], 'AST\x00ADT\x00'),
-'Brazil/DeNoronha': ('Brazil/DeNoronha', 101, 2,
-[ '561960000', '571633200', '593409600', '603082800', '625550400',
-'634532400', '656913600', '665982000', '688363200', '697431600',
-'719812800', '729486000', '751262400', '760935600', '782712000',
-'792385200', '814852800', '823834800', '846216000', '855284400',
-'877665600', '887425200', '909115200', '918788400', '940564800',
-'950238000', '972705600', '981687600', '1004068800', '1013137200',
-'1035518400', '1044586800', '1066968000', '1076727600', '1098417600',
-'1108090800', '1129867200', '1139540400', '1162008000', '1170990000',
-'1193371200', '1202439600', '1224820800', '1234580400', '1256270400',
-'1265943600', '1287720000', '1297393200', '1319169600', '1328842800',
-'1351224000', '1360292400', '1382673600', '1391742000', '1414123200',
-'1423882800', '1445572800', '1455246000', '1477022400', '1486695600',
-'1509163200', '1518145200', '1540526400', '1549594800', '1571976000',
-'1581044400', '1603425600', '1613098800', '1634875200', '1644548400',
-'1666324800', '1675998000', '1698465600', '1707447600', '1729828800',
-'1738897200', '1761278400', '1771038000', '1792728000', '1802401200',
-'1824177600', '1833850800', '1856318400', '1865300400', '1887681600',
-'1896750000', '1919131200', '1928199600', '1950580800', '1960340400',
-'1982030400', '1991703600', '2013480000', '2023153200', '2045620800',
-'2054602800', '2076984000', '2086052400', '2108433600', '2118193200',
-'2139883200',
-],
-'\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-7200, 0, 0), (-3600, 1, 4)], 'FST\x00FDT\x00'),
-'Brazil/East': ('Brazil/East', 101, 2,
-[ '561963600', '571636800', '593413200', '603086400', '625554000',
-'634536000', '656917200', '665985600', '688366800', '697435200',
-'719816400', '729489600', '751266000', '760939200', '782715600',
-'792388800', '814856400', '823838400', '846219600', '855288000',
-'877669200', '887428800', '909118800', '918792000', '940568400',
-'950241600', '972709200', '981691200', '1004072400', '1013140800',
-'1035522000', '1044590400', '1066971600', '1076731200', '1098421200',
-'1108094400', '1129870800', '1139544000', '1162011600', '1170993600',
-'1193374800', '1202443200', '1224824400', '1234584000', '1256274000',
-'1265947200', '1287723600', '1297396800', '1319173200', '1328846400',
-'1351227600', '1360296000', '1382677200', '1391745600', '1414126800',
-'1423886400', '1445576400', '1455249600', '1477026000', '1486699200',
-'1509166800', '1518148800', '1540530000', '1549598400', '1571979600',
-'1581048000', '1603429200', '1613102400', '1634878800', '1644552000',
-'1666328400', '1676001600', '1698469200', '1707451200', '1729832400',
-'1738900800', '1761282000', '1771041600', '1792731600', '1802404800',
-'1824181200', '1833854400', '1856322000', '1865304000', '1887685200',
-'1896753600', '1919134800', '1928203200', '1950584400', '1960344000',
-'1982034000', '1991707200', '2013483600', '2023156800', '2045624400',
-'2054606400', '2076987600', '2086056000', '2108437200', '2118196800',
-'2139886800',
-],
-'\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-10800, 0, 0), (-7200, 1, 4)], 'EST\x00EDT\x00'),
-'Brazil/West': ('Brazil/West', 101, 2,
-[ '561967200', '571640400', '593416800', '603090000', '625557600',
-'634539600', '656920800', '665989200', '688370400', '697438800',
-'719820000', '729493200', '751269600', '760942800', '782719200',
-'792392400', '814860000', '823842000', '846223200', '855291600',
-'877672800', '887432400', '909122400', '918795600', '940572000',
-'950245200', '972712800', '981694800', '1004076000', '1013144400',
-'1035525600', '1044594000', '1066975200', '1076734800', '1098424800',
-'1108098000', '1129874400', '1139547600', '1162015200', '1170997200',
-'1193378400', '1202446800', '1224828000', '1234587600', '1256277600',
-'1265950800', '1287727200', '1297400400', '1319176800', '1328850000',
-'1351231200', '1360299600', '1382680800', '1391749200', '1414130400',
-'1423890000', '1445580000', '1455253200', '1477029600', '1486702800',
-'1509170400', '1518152400', '1540533600', '1549602000', '1571983200',
-'1581051600', '1603432800', '1613106000', '1634882400', '1644555600',
-'1666332000', '1676005200', '1698472800', '1707454800', '1729836000',
-'1738904400', '1761285600', '1771045200', '1792735200', '1802408400',
-'1824184800', '1833858000', '1856325600', '1865307600', '1887688800',
-'1896757200', '1919138400', '1928206800', '1950588000', '1960347600',
-'1982037600', '1991710800', '2013487200', '2023160400', '2045628000',
-'2054610000', '2076991200', '2086059600', '2108440800', '2118200400',
-'2139890400',
-],
-'\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-14400, 0, 0), (-10800, 1, 4)], 'WST\x00WDT\x00'),
-'Canada/Atlantic': ('Canada/Atlantic', 138, 2,
-[ '-21492000', '-5770800', '9957600', '25678800', '41407200',
-'57733200', '73461600', '89182800', '104911200', '120632400',
-'136360800', '152082000', '167810400', '183531600', '199260000',
-'215586000', '230709600', '247035600', '262764000', '278485200',
-'294213600', '309934800', '325663200', '341384400', '357112800',
-'372834000', '388562400', '404888400', '420012000', '436338000',
-'452066400', '467787600', '483516000', '499237200', '514965600',
-'530686800', '544600800', '562136400', '576050400', '594190800',
-'607500000', '625640400', '638949600', '657090000', '671004000',
-'688539600', '702453600', '719989200', '733903200', '752043600',
-'765352800', '783493200', '796802400', '814942800', '828856800',
-'846392400', '860306400', '877842000', '891756000', '909291600',
-'923205600', '941346000', '954655200', '972795600', '986104800',
-'1004245200', '1018159200', '1035694800', '1049608800', '1067144400',
-'1081058400', '1099198800', '1112508000', '1130648400', '1143957600',
-'1162098000', '1175407200', '1193547600', '1207461600', '1224997200',
-'1238911200', '1256446800', '1270360800', '1288501200', '1301810400',
-'1319950800', '1333260000', '1351400400', '1365314400', '1382850000',
-'1396764000', '1414299600', '1428213600', '1445749200', '1459663200',
-'1477803600', '1491112800', '1509253200', '1522562400', '1540702800',
-'1554616800', '1572152400', '1586066400', '1603602000', '1617516000',
-'1635656400', '1648965600', '1667106000', '1680415200', '1698555600',
-'1712469600', '1730005200', '1743919200', '1761454800', '1775368800',
-'1792904400', '1806818400', '1824958800', '1838268000', '1856408400',
-'1869717600', '1887858000', '1901772000', '1919307600', '1933221600',
-'1950757200', '1964671200', '1982811600', '1996120800', '2014261200',
-'2027570400', '2045710800', '2059020000', '2077160400', '2091074400',
-'2108610000', '2122524000', '2140059600',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-10800, 1, 0), (-14400, 0, 4)], 'ADT\x00AST\x00'),
-'Canada/Central': ('Canada/Central', 138, 2,
-[ '-21484800', '-5763600', '9964800', '25686000', '41414400',
-'57740400', '73468800', '89190000', '104918400', '120639600',
-'136368000', '152089200', '167817600', '183538800', '199267200',
-'215593200', '230716800', '247042800', '262771200', '278492400',
-'294220800', '309942000', '325670400', '341391600', '357120000',
-'372841200', '388569600', '404895600', '420019200', '436345200',
-'452073600', '467794800', '483523200', '499244400', '514972800',
-'530694000', '544608000', '562143600', '576057600', '594198000',
-'607507200', '625647600', '638956800', '657097200', '671011200',
-'688546800', '702460800', '719996400', '733910400', '752050800',
-'765360000', '783500400', '796809600', '814950000', '828864000',
-'846399600', '860313600', '877849200', '891763200', '909298800',
-'923212800', '941353200', '954662400', '972802800', '986112000',
-'1004252400', '1018166400', '1035702000', '1049616000', '1067151600',
-'1081065600', '1099206000', '1112515200', '1130655600', '1143964800',
-'1162105200', '1175414400', '1193554800', '1207468800', '1225004400',
-'1238918400', '1256454000', '1270368000', '1288508400', '1301817600',
-'1319958000', '1333267200', '1351407600', '1365321600', '1382857200',
-'1396771200', '1414306800', '1428220800', '1445756400', '1459670400',
-'1477810800', '1491120000', '1509260400', '1522569600', '1540710000',
-'1554624000', '1572159600', '1586073600', '1603609200', '1617523200',
-'1635663600', '1648972800', '1667113200', '1680422400', '1698562800',
-'1712476800', '1730012400', '1743926400', '1761462000', '1775376000',
-'1792911600', '1806825600', '1824966000', '1838275200', '1856415600',
-'1869724800', '1887865200', '1901779200', '1919314800', '1933228800',
-'1950764400', '1964678400', '1982818800', '1996128000', '2014268400',
-'2027577600', '2045718000', '2059027200', '2077167600', '2091081600',
-'2108617200', '2122531200', '2140066800',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-18000, 1, 0), (-21600, 0, 4)], 'CDT\x00CST\x00'),
-'Canada/East-Saskatchewan': ('Canada/East-Saskatchewan', 0, 1,
-[ ],
-'',
-[(-21600, 0, 0)], 'CST\x00'),
-'Canada/Eastern': ('Canada/Eastern', 138, 2,
-[ '-21488400', '-5767200', '9961200', '25682400', '41410800',
-'57736800', '73465200', '89186400', '104914800', '120636000',
-'136364400', '152085600', '167814000', '183535200', '199263600',
-'215589600', '230713200', '247039200', '262767600', '278488800',
-'294217200', '309938400', '325666800', '341388000', '357116400',
-'372837600', '388566000', '404892000', '420015600', '436341600',
-'452070000', '467791200', '483519600', '499240800', '514969200',
-'530690400', '544604400', '562140000', '576054000', '594194400',
-'607503600', '625644000', '638953200', '657093600', '671007600',
-'688543200', '702457200', '719992800', '733906800', '752047200',
-'765356400', '783496800', '796806000', '814946400', '828860400',
-'846396000', '860310000', '877845600', '891759600', '909295200',
-'923209200', '941349600', '954658800', '972799200', '986108400',
-'1004248800', '1018162800', '1035698400', '1049612400', '1067148000',
-'1081062000', '1099202400', '1112511600', '1130652000', '1143961200',
-'1162101600', '1175410800', '1193551200', '1207465200', '1225000800',
-'1238914800', '1256450400', '1270364400', '1288504800', '1301814000',
-'1319954400', '1333263600', '1351404000', '1365318000', '1382853600',
-'1396767600', '1414303200', '1428217200', '1445752800', '1459666800',
-'1477807200', '1491116400', '1509256800', '1522566000', '1540706400',
-'1554620400', '1572156000', '1586070000', '1603605600', '1617519600',
-'1635660000', '1648969200', '1667109600', '1680418800', '1698559200',
-'1712473200', '1730008800', '1743922800', '1761458400', '1775372400',
-'1792908000', '1806822000', '1824962400', '1838271600', '1856412000',
-'1869721200', '1887861600', '1901775600', '1919311200', '1933225200',
-'1950760800', '1964674800', '1982815200', '1996124400', '2014264800',
-'2027574000', '2045714400', '2059023600', '2077164000', '2091078000',
-'2108613600', '2122527600', '2140063200',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-14400, 1, 0), (-18000, 0, 4)], 'EDT\x00EST\x00'),
-'Canada/Mountain': ('Canada/Mountain', 138, 2,
-[ '-21481200', '-5760000', '9968400', '25689600', '41418000',
-'57744000', '73472400', '89193600', '104922000', '120643200',
-'136371600', '152092800', '167821200', '183542400', '199270800',
-'215596800', '230720400', '247046400', '262774800', '278496000',
-'294224400', '309945600', '325674000', '341395200', '357123600',
-'372844800', '388573200', '404899200', '420022800', '436348800',
-'452077200', '467798400', '483526800', '499248000', '514976400',
-'530697600', '544611600', '562147200', '576061200', '594201600',
-'607510800', '625651200', '638960400', '657100800', '671014800',
-'688550400', '702464400', '720000000', '733914000', '752054400',
-'765363600', '783504000', '796813200', '814953600', '828867600',
-'846403200', '860317200', '877852800', '891766800', '909302400',
-'923216400', '941356800', '954666000', '972806400', '986115600',
-'1004256000', '1018170000', '1035705600', '1049619600', '1067155200',
-'1081069200', '1099209600', '1112518800', '1130659200', '1143968400',
-'1162108800', '1175418000', '1193558400', '1207472400', '1225008000',
-'1238922000', '1256457600', '1270371600', '1288512000', '1301821200',
-'1319961600', '1333270800', '1351411200', '1365325200', '1382860800',
-'1396774800', '1414310400', '1428224400', '1445760000', '1459674000',
-'1477814400', '1491123600', '1509264000', '1522573200', '1540713600',
-'1554627600', '1572163200', '1586077200', '1603612800', '1617526800',
-'1635667200', '1648976400', '1667116800', '1680426000', '1698566400',
-'1712480400', '1730016000', '1743930000', '1761465600', '1775379600',
-'1792915200', '1806829200', '1824969600', '1838278800', '1856419200',
-'1869728400', '1887868800', '1901782800', '1919318400', '1933232400',
-'1950768000', '1964682000', '1982822400', '1996131600', '2014272000',
-'2027581200', '2045721600', '2059030800', '2077171200', '2091085200',
-'2108620800', '2122534800', '2140070400',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-21600, 1, 0), (-25200, 0, 4)], 'MDT\x00MST\x00'),
-'Canada/Newfoundland': ('Canada/Newfoundland', 138, 2,
-[ '-21493800', '-5772600', '9955800', '25677000', '41405400',
-'57731400', '73459800', '89181000', '104909400', '120630600',
-'136359000', '152080200', '167808600', '183529800', '199258200',
-'215584200', '230707800', '247033800', '262762200', '278483400',
-'294211800', '309933000', '325661400', '341382600', '357111000',
-'372832200', '388560600', '404886600', '420010200', '436336200',
-'452064600', '467785800', '483514200', '499235400', '514963800',
-'530685000', '544599000', '562134600', '576048600', '594189000',
-'607498200', '625638600', '638947800', '657088200', '671002200',
-'688537800', '702451800', '719987400', '733901400', '752041800',
-'765351000', '783491400', '796800600', '814941000', '828855000',
-'846390600', '860304600', '877840200', '891754200', '909289800',
-'923203800', '941344200', '954653400', '972793800', '986103000',
-'1004243400', '1018157400', '1035693000', '1049607000', '1067142600',
-'1081056600', '1099197000', '1112506200', '1130646600', '1143955800',
-'1162096200', '1175405400', '1193545800', '1207459800', '1224995400',
-'1238909400', '1256445000', '1270359000', '1288499400', '1301808600',
-'1319949000', '1333258200', '1351398600', '1365312600', '1382848200',
-'1396762200', '1414297800', '1428211800', '1445747400', '1459661400',
-'1477801800', '1491111000', '1509251400', '1522560600', '1540701000',
-'1554615000', '1572150600', '1586064600', '1603600200', '1617514200',
-'1635654600', '1648963800', '1667104200', '1680413400', '1698553800',
-'1712467800', '1730003400', '1743917400', '1761453000', '1775367000',
-'1792902600', '1806816600', '1824957000', '1838266200', '1856406600',
-'1869715800', '1887856200', '1901770200', '1919305800', '1933219800',
-'1950755400', '1964669400', '1982809800', '1996119000', '2014259400',
-'2027568600', '2045709000', '2059018200', '2077158600', '2091072600',
-'2108608200', '2122522200', '2140057800',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-9000, 1, 0), (-12600, 0, 4)], 'NDT\x00NST\x00'),
-'Canada/Pacific': ('Canada/Pacific', 138, 2,
-[ '-21477600', '-5756400', '9972000', '25693200', '41421600',
-'57747600', '73476000', '89197200', '104925600', '120646800',
-'136375200', '152096400', '167824800', '183546000', '199274400',
-'215600400', '230724000', '247050000', '262778400', '278499600',
-'294228000', '309949200', '325677600', '341398800', '357127200',
-'372848400', '388576800', '404902800', '420026400', '436352400',
-'452080800', '467802000', '483530400', '499251600', '514980000',
-'530701200', '544615200', '562150800', '576064800', '594205200',
-'607514400', '625654800', '638964000', '657104400', '671018400',
-'688554000', '702468000', '720003600', '733917600', '752058000',
-'765367200', '783507600', '796816800', '814957200', '828871200',
-'846406800', '860320800', '877856400', '891770400', '909306000',
-'923220000', '941360400', '954669600', '972810000', '986119200',
-'1004259600', '1018173600', '1035709200', '1049623200', '1067158800',
-'1081072800', '1099213200', '1112522400', '1130662800', '1143972000',
-'1162112400', '1175421600', '1193562000', '1207476000', '1225011600',
-'1238925600', '1256461200', '1270375200', '1288515600', '1301824800',
-'1319965200', '1333274400', '1351414800', '1365328800', '1382864400',
-'1396778400', '1414314000', '1428228000', '1445763600', '1459677600',
-'1477818000', '1491127200', '1509267600', '1522576800', '1540717200',
-'1554631200', '1572166800', '1586080800', '1603616400', '1617530400',
-'1635670800', '1648980000', '1667120400', '1680429600', '1698570000',
-'1712484000', '1730019600', '1743933600', '1761469200', '1775383200',
-'1792918800', '1806832800', '1824973200', '1838282400', '1856422800',
-'1869732000', '1887872400', '1901786400', '1919322000', '1933236000',
-'1950771600', '1964685600', '1982826000', '1996135200', '2014275600',
-'2027584800', '2045725200', '2059034400', '2077174800', '2091088800',
-'2108624400', '2122538400', '2140074000',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-25200, 1, 0), (-28800, 0, 4)], 'PDT\x00PST\x00'),
-'Canada/Yukon': ('Canada/Yukon', 138, 2,
-[ '-21474000', '-5752800', '9975600', '25696800', '41425200',
-'57751200', '73479600', '89200800', '104929200', '120650400',
-'136378800', '152100000', '167828400', '183549600', '199278000',
-'215604000', '230727600', '247053600', '262782000', '278503200',
-'294231600', '309952800', '325681200', '341402400', '357130800',
-'372852000', '388580400', '404906400', '420030000', '436356000',
-'452084400', '467805600', '483534000', '499255200', '514983600',
-'530704800', '544618800', '562154400', '576068400', '594208800',
-'607518000', '625658400', '638967600', '657108000', '671022000',
-'688557600', '702471600', '720007200', '733921200', '752061600',
-'765370800', '783511200', '796820400', '814960800', '828874800',
-'846410400', '860324400', '877860000', '891774000', '909309600',
-'923223600', '941364000', '954673200', '972813600', '986122800',
-'1004263200', '1018177200', '1035712800', '1049626800', '1067162400',
-'1081076400', '1099216800', '1112526000', '1130666400', '1143975600',
-'1162116000', '1175425200', '1193565600', '1207479600', '1225015200',
-'1238929200', '1256464800', '1270378800', '1288519200', '1301828400',
-'1319968800', '1333278000', '1351418400', '1365332400', '1382868000',
-'1396782000', '1414317600', '1428231600', '1445767200', '1459681200',
-'1477821600', '1491130800', '1509271200', '1522580400', '1540720800',
-'1554634800', '1572170400', '1586084400', '1603620000', '1617534000',
-'1635674400', '1648983600', '1667124000', '1680433200', '1698573600',
-'1712487600', '1730023200', '1743937200', '1761472800', '1775386800',
-'1792922400', '1806836400', '1824976800', '1838286000', '1856426400',
-'1869735600', '1887876000', '1901790000', '1919325600', '1933239600',
-'1950775200', '1964689200', '1982829600', '1996138800', '2014279200',
-'2027588400', '2045728800', '2059038000', '2077178400', '2091092400',
-'2108628000', '2122542000', '2140077600',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-28800, 1, 0), (-32400, 0, 4)], 'YDT\x00YST\x00'),
-'Chile/Continental': ('Chile/Continental', 121, 2,
-[ '245217600', '258519600', '276667200', '289969200', '308721600',
-'321418800', '340171200', '352868400', '371620800', '384922800',
-'403070400', '416372400', '434520000', '447822000', '466574400',
-'479271600', '498024000', '510721200', '529473600', '542170800',
-'560923200', '574225200', '592372800', '605674800', '623822400',
-'637124400', '655876800', '668574000', '687326400', '700023600',
-'718776000', '732078000', '750225600', '763527600', '781675200',
-'794977200', '813124800', '826426800', '845179200', '857876400',
-'876628800', '889326000', '908078400', '921380400', '939528000',
-'952830000', '970977600', '984279600', '1003032000', '1015729200',
-'1034481600', '1047178800', '1065931200', '1079233200', '1097380800',
-'1110682800', '1128830400', '1142132400', '1160280000', '1173582000',
-'1192334400', '1205031600', '1223784000', '1236481200', '1255233600',
-'1268535600', '1286683200', '1299985200', '1318132800', '1331434800',
-'1350187200', '1362884400', '1381636800', '1394334000', '1413086400',
-'1425783600', '1444536000', '1457838000', '1475985600', '1489287600',
-'1507435200', '1520737200', '1539489600', '1552186800', '1570939200',
-'1583636400', '1602388800', '1615690800', '1633838400', '1647140400',
-'1665288000', '1678590000', '1696737600', '1710039600', '1728792000',
-'1741489200', '1760241600', '1772938800', '1791691200', '1804993200',
-'1823140800', '1836442800', '1854590400', '1867892400', '1886644800',
-'1899342000', '1918094400', '1930791600', '1949544000', '1962846000',
-'1980993600', '1994295600', '2012443200', '2025745200', '2043892800',
-'2057194800', '2075947200', '2088644400', '2107396800', '2120094000',
-'2138846400',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00',
-[(-10800, 1, 0), (-14400, 0, 4)], 'CDT\x00CST\x00'),
-'Chile/EasterIsland': ('Chile/EasterIsland', 121, 2,
-[ '245224800', '258526800', '276674400', '289976400', '308728800',
-'321426000', '340178400', '352875600', '371628000', '384930000',
-'403077600', '416379600', '434527200', '447829200', '466581600',
-'479278800', '498031200', '510728400', '529480800', '542178000',
-'560930400', '574232400', '592380000', '605682000', '623829600',
-'637131600', '655884000', '668581200', '687333600', '700030800',
-'718783200', '732085200', '750232800', '763534800', '781682400',
-'794984400', '813132000', '826434000', '845186400', '857883600',
-'876636000', '889333200', '908085600', '921387600', '939535200',
-'952837200', '970984800', '984286800', '1003039200', '1015736400',
-'1034488800', '1047186000', '1065938400', '1079240400', '1097388000',
-'1110690000', '1128837600', '1142139600', '1160287200', '1173589200',
-'1192341600', '1205038800', '1223791200', '1236488400', '1255240800',
-'1268542800', '1286690400', '1299992400', '1318140000', '1331442000',
-'1350194400', '1362891600', '1381644000', '1394341200', '1413093600',
-'1425790800', '1444543200', '1457845200', '1475992800', '1489294800',
-'1507442400', '1520744400', '1539496800', '1552194000', '1570946400',
-'1583643600', '1602396000', '1615698000', '1633845600', '1647147600',
-'1665295200', '1678597200', '1696744800', '1710046800', '1728799200',
-'1741496400', '1760248800', '1772946000', '1791698400', '1805000400',
-'1823148000', '1836450000', '1854597600', '1867899600', '1886652000',
-'1899349200', '1918101600', '1930798800', '1949551200', '1962853200',
-'1981000800', '1994302800', '2012450400', '2025752400', '2043900000',
-'2057202000', '2075954400', '2088651600', '2107404000', '2120101200',
-'2138853600',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00',
-[(-18000, 1, 0), (-21600, 0, 4)], 'EDT\x00EST\x00'),
-'Cuba': ('Cuba', 118, 2,
-[ '290581200', '308721600', '322030800', '340171200', '358318800',
-'371620800', '389768400', '403070400', '421218000', '434520000',
-'453272400', '466574400', '484722000', '498024000', '516171600',
-'529473600', '547621200', '560923200', '579070800', '592372800',
-'611125200', '623822400', '642574800', '655876800', '674024400',
-'687326400', '705474000', '718776000', '736923600', '750225600',
-'768373200', '781675200', '800427600', '813124800', '831877200',
-'845179200', '863326800', '876628800', '894776400', '908078400',
-'926226000', '939528000', '958280400', '970977600', '989730000',
-'1003032000', '1021179600', '1034481600', '1052629200', '1065931200',
-'1084078800', '1097380800', '1115528400', '1128830400', '1147582800',
-'1160280000', '1179032400', '1192334400', '1210482000', '1223784000',
-'1241931600', '1255233600', '1273381200', '1286683200', '1304830800',
-'1318132800', '1336885200', '1350187200', '1368334800', '1381636800',
-'1399784400', '1413086400', '1431234000', '1444536000', '1462683600',
-'1475985600', '1494738000', '1507435200', '1526187600', '1539489600',
-'1557637200', '1570939200', '1589086800', '1602388800', '1620536400',
-'1633838400', '1651986000', '1665288000', '1684040400', '1696737600',
-'1715490000', '1728792000', '1746939600', '1760241600', '1778389200',
-'1791691200', '1809838800', '1823140800', '1841893200', '1854590400',
-'1873342800', '1886644800', '1904792400', '1918094400', '1936242000',
-'1949544000', '1967691600', '1980993600', '1999141200', '2012443200',
-'2031195600', '2043892800', '2062645200', '2075947200', '2094094800',
-'2107396800', '2125544400', '2138846400',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-14400, 1, 0), (-18000, 0, 4)], 'CDT\x00CST\x00'),
-'Egypt': ('Egypt', 152, 2,
-[ '-305164800', '-291949200', '-273628800', '-260413200', '-242092800',
-'-228877200', '-210556800', '-197341200', '-178934400', '-165718800',
-'-147398400', '-134182800', '-115862400', '-102646800', '-84326400',
-'-71110800', '-52704000', '-39488400', '-21168000', '-7952400',
-'10368000', '23583600', '41904000', '55119600', '73526400',
-'86742000', '105062400', '118278000', '136598400', '149814000',
-'168134400', '181350000', '199756800', '212972400', '231292800',
-'244508400', '262828800', '276044400', '294364800', '307580400',
-'325987200', '339202800', '420595200', '433810800', '452217600',
-'465433200', '483753600', '496969200', '515289600', '528505200',
-'546825600', '560041200', '578448000', '591663600', '609984000',
-'623199600', '641520000', '654735600', '673056000', '686271600',
-'704678400', '717894000', '736214400', '749430000', '767750400',
-'780966000', '799286400', '812502000', '830908800', '844124400',
-'862444800', '875660400', '893980800', '907196400', '925516800',
-'938732400', '957139200', '970354800', '988675200', '1001890800',
-'1020211200', '1033426800', '1051747200', '1064962800', '1083369600',
-'1096585200', '1114905600', '1128121200', '1146441600', '1159657200',
-'1177977600', '1191193200', '1209600000', '1222815600', '1241136000',
-'1254351600', '1272672000', '1285887600', '1304208000', '1317423600',
-'1335830400', '1349046000', '1367366400', '1380582000', '1398902400',
-'1412118000', '1430438400', '1443654000', '1462060800', '1475276400',
-'1493596800', '1506812400', '1525132800', '1538348400', '1556668800',
-'1569884400', '1588291200', '1601506800', '1619827200', '1633042800',
-'1651363200', '1664578800', '1682899200', '1696114800', '1714521600',
-'1727737200', '1746057600', '1759273200', '1777593600', '1790809200',
-'1809129600', '1822345200', '1840752000', '1853967600', '1872288000',
-'1885503600', '1903824000', '1917039600', '1935360000', '1948575600',
-'1966982400', '1980198000', '1998518400', '2011734000', '2030054400',
-'2043270000', '2061590400', '2074806000', '2093212800', '2106428400',
-'2124748800', '2137964400',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(10800, 1, 0), (7200, 0, 8)], 'EET DST\x00EET\x00'),
-'GB-Eire': ('GB-Eire', 241, 4,
-[ '-1697238000', '-1680476400', '-1664146800', '-1650150000', '-1633906800',
-'-1617490800', '-1601852400', '-1586041200', '-1570402800', '-1552172400',
-'-1538348400', '-1522537200', '-1507503600', '-1490569200', '-1473634800',
-'-1458342000', '-1441321200', '-1428879600', '-1410735600', '-1396220400',
-'-1379286000', '-1364770800', '-1347836400', '-1333321200', '-1316386800',
-'-1301266800', '-1284332400', '-1269817200', '-1252882800', '-1238367600',
-'-1221433200', '-1206918000', '-1189983600', '-1175468400', '-1158534000',
-'-1144018800', '-1127084400', '-1111964400', '-1095030000', '-1080514800',
-'-1063580400', '-1049065200', '-1032130800', '-1017615600', '-1000681200',
-'-986166000', '-969231600', '-950482800', '-942015600', '-904518000',
-'-896050800', '-875487600', '-864601200', '-844038000', '-832546800',
-'-812588400', '-798073200', '-781052400', '-772066800', '-764809200',
-'-748479600', '-733359600', '-719449200', '-717030000', '-706748400',
-'-699490800', '-687999600', '-668041200', '-654735600', '-636591600',
-'-622076400', '-605746800', '-590626800', '-574297200', '-558572400',
-'-542242800', '-527122800', '-512607600', '-496278000', '-481158000',
-'-464223600', '-449708400', '-432774000', '-417654000', '-401324400',
-'-386204400', '-369270000', '-354754800', '-337820400', '-323305200',
-'-306975600', '-291855600', '-276735600', '-257986800', '-245286000',
-'-226537200', '-213231600', '-195087600', '-182386800', '-163638000',
-'-150937200', '-132188400', '-119487600', '-100738800', '-88038000',
-'-68684400', '-59007600', '-37238400', '57715200', '69814800',
-'89168400', '101264400', '120618000', '132714000', '152067600',
-'164163600', '183517200', '196218000', '214966800', '227667600',
-'246416400', '259117200', '278470800', '290566800', '309920400',
-'322016400', '341370000', '354675600', '372819600', '386125200',
-'404269200', '417574800', '435718800', '449024400', '467773200',
-'481078800', '499222800', '512528400', '530672400', '543978000',
-'562122000', '575427600', '593571600', '606877200', '625626000',
-'638326800', '657075600', '670381200', '688525200', '701830800',
-'719974800', '733280400', '751424400', '764730000', '782874000',
-'796179600', '814928400', '828234000', '846378000', '859683600',
-'877827600', '891133200', '909277200', '922582800', '940726800',
-'954032400', '972781200', '985482000', '1004230800', '1017536400',
-'1035680400', '1048986000', '1067130000', '1080435600', '1098579600',
-'1111885200', '1130029200', '1143334800', '1162083600', '1174784400',
-'1193533200', '1206838800', '1224982800', '1238288400', '1256432400',
-'1269738000', '1287882000', '1301187600', '1319331600', '1332637200',
-'1351386000', '1364691600', '1382835600', '1396141200', '1414285200',
-'1427590800', '1445734800', '1459040400', '1477184400', '1490490000',
-'1509238800', '1521939600', '1540688400', '1553994000', '1572138000',
-'1585443600', '1603587600', '1616893200', '1635037200', '1648342800',
-'1666486800', '1679792400', '1698541200', '1711846800', '1729990800',
-'1743296400', '1761440400', '1774746000', '1792890000', '1806195600',
-'1824339600', '1837645200', '1856394000', '1869094800', '1887843600',
-'1901149200', '1919293200', '1932598800', '1950742800', '1964048400',
-'1982192400', '1995498000', '2013642000', '2026947600', '2045696400',
-'2058397200', '2077146000', '2090451600', '2108595600', '2121901200',
-'2140045200',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x02\x00\x02\x00\x02\x00\x02\x00\x02\x00\x01\x00\x01\x00\x02\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x03\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(3600, 1, 0), (0, 0, 4), (7200, 1, 8), (3600, 0, 0)], 'BST\x00GMT\x00DST\x00'),
-'GMT': ('GMT', 0, 1,
-[ ],
-'',
-[(0, 0, 0)], 'GMT\x00'),
-'GMT+0': ('GMT+0', 0, 1,
-[ ],
-'',
-[(0, 0, 0)], 'GMT+0000\x00'),
-'GMT+0130': ('GMT+0130', 0, 1,
-[ ],
-'',
-[(5400, 0, 0)], 'GMT+0130\x00'),
-'GMT+0230': ('GMT+0230', 0, 1,
-[ ],
-'',
-[(9000, 0, 0)], 'GMT+0230\x00'),
-'GMT+0330': ('GMT+0330', 0, 1,
-[ ],
-'',
-[(12600, 0, 0)], 'GMT+0330\x00'),
-'GMT+0430': ('GMT+0430', 0, 1,
-[ ],
-'',
-[(16200, 0, 0)], 'GMT+0430\x00'),
-'GMT+0530': ('GMT+0530', 0, 1,
-[ ],
-'',
-[(19800, 0, 0)], 'GMT+0530\x00'),
-'GMT+0630': ('GMT+0630', 0, 1,
-[ ],
-'',
-[(23400, 0, 0)], 'GMT+0630\x00'),
-'GMT+0730': ('GMT+0730', 0, 1,
-[ ],
-'',
-[(27000, 0, 0)], 'GMT+0730\x00'),
-'GMT+0830': ('GMT+0830', 0, 1,
-[ ],
-'',
-[(30600, 0, 0)], 'GMT+0830\x00'),
-'GMT+0930': ('GMT+0930', 0, 1,
-[ ],
-'',
-[(34200, 0, 0)], 'GMT+0930\x00'),
-'GMT+1': ('GMT+1', 0, 1,
-[ ],
-'',
-[(3600, 0, 0)], 'GMT+0100\x00'),
-'GMT+10': ('GMT+10', 0, 1,
-[ ],
-'',
-[(36000, 0, 0)], 'GMT+1000\x00'),
-'GMT+1030': ('GMT+1030', 0, 1,
-[ ],
-'',
-[(37800, 0, 0)], 'GMT+1030\x00'),
-'GMT+11': ('GMT+11', 0, 1,
-[ ],
-'',
-[(39600, 0, 0)], 'GMT+1100\x00'),
-'GMT+1130': ('GMT+1130', 0, 1,
-[ ],
-'',
-[(41400, 0, 0)], 'GMT+1130\x00'),
-'GMT+12': ('GMT+12', 0, 1,
-[ ],
-'',
-[(43200, 0, 0)], 'GMT+1200\x00'),
-'GMT+1230': ('GMT+1230', 0, 1,
-[ ],
-'',
-[(45000, 0, 0)], 'GMT+1230\x00'),
-'GMT+13': ('GMT+13', 0, 1,
-[ ],
-'',
-[(46800, 0, 0)], 'GMT+1300\x00'),
-'GMT+2': ('GMT+2', 0, 1,
-[ ],
-'',
-[(7200, 0, 0)], 'GMT+0200\x00'),
-'GMT+3': ('GMT+3', 0, 1,
-[ ],
-'',
-[(10800, 0, 0)], 'GMT+0300\x00'),
-'GMT+4': ('GMT+4', 0, 1,
-[ ],
-'',
-[(14400, 0, 0)], 'GMT+0400\x00'),
-'GMT+5': ('GMT+5', 0, 1,
-[ ],
-'',
-[(18000, 0, 0)], 'GMT+0500\x00'),
-'GMT+6': ('GMT+6', 0, 1,
-[ ],
-'',
-[(21600, 0, 0)], 'GMT+0600\x00'),
-'GMT+7': ('GMT+7', 0, 1,
-[ ],
-'',
-[(25200, 0, 0)], 'GMT+0700\x00'),
-'GMT+8': ('GMT+8', 0, 1,
-[ ],
-'',
-[(28800, 0, 0)], 'GMT+0800\x00'),
-'GMT+9': ('GMT+9', 0, 1,
-[ ],
-'',
-[(32400, 0, 0)], 'GMT+0900\x00'),
-'GMT-0130': ('GMT-0130', 0, 1,
-[ ],
-'',
-[(-5400, 0, 0)], 'GMT-0130\x00'),
-'GMT-0230': ('GMT-0230', 0, 1,
-[ ],
-'',
-[(-9000, 0, 0)], 'GMT-0230\x00'),
-'GMT-0330': ('GMT-0330', 0, 1,
-[ ],
-'',
-[(-12600, 0, 0)], 'GMT-0330\x00'),
-'GMT-0430': ('GMT-0430', 0, 1,
-[ ],
-'',
-[(-16200, 0, 0)], 'GMT-0430\x00'),
-'GMT-0530': ('GMT-0530', 0, 1,
-[ ],
-'',
-[(-19800, 0, 0)], 'GMT-0530\x00'),
-'GMT-0630': ('GMT-0630', 0, 1,
-[ ],
-'',
-[(-23400, 0, 0)], 'GMT-0630\x00'),
-'GMT-0730': ('GMT-0730', 0, 1,
-[ ],
-'',
-[(-27000, 0, 0)], 'GMT-0730\x00'),
-'GMT-0830': ('GMT-0830', 0, 1,
-[ ],
-'',
-[(-30600, 0, 0)], 'GMT-0830\x00'),
-'GMT-0930': ('GMT-0930', 0, 1,
-[ ],
-'',
-[(-34200, 0, 0)], 'GMT-0930\x00'),
-'GMT-1': ('GMT-1', 0, 1,
-[ ],
-'',
-[(-3600, 0, 0)], 'GMT-0100\x00'),
-'GMT-10': ('GMT-10', 0, 1,
-[ ],
-'',
-[(-36000, 0, 0)], 'GMT-1000\x00'),
-'GMT-1030': ('GMT-1030', 0, 1,
-[ ],
-'',
-[(-37800, 0, 0)], 'GMT-1030\x00'),
-'GMT-11': ('GMT-11', 0, 1,
-[ ],
-'',
-[(-39600, 0, 0)], 'GMT-1100\x00'),
-'GMT-1130': ('GMT-1130', 0, 1,
-[ ],
-'',
-[(-41400, 0, 0)], 'GMT-1130\x00'),
-'GMT-12': ('GMT-12', 0, 1,
-[ ],
-'',
-[(-43200, 0, 0)], 'GMT-1200\x00'),
-'GMT-1230': ('GMT-1230', 0, 1,
-[ ],
-'',
-[(-45000, 0, 0)], 'GMT-1230\x00'),
-'GMT-2': ('GMT-2', 0, 1,
-[ ],
-'',
-[(-7200, 0, 0)], 'GMT-0200\x00'),
-'GMT-3': ('GMT-3', 0, 1,
-[ ],
-'',
-[(-10800, 0, 0)], 'GMT-0300\x00'),
-'GMT-4': ('GMT-4', 0, 1,
-[ ],
-'',
-[(-14400, 0, 0)], 'GMT-0400\x00'),
-'GMT-5': ('GMT-5', 0, 1,
-[ ],
-'',
-[(-18000, 0, 0)], 'GMT-0500\x00'),
-'GMT-6': ('GMT-6', 0, 1,
-[ ],
-'',
-[(-21600, 0, 0)], 'GMT-0600\x00'),
-'GMT-7': ('GMT-7', 0, 1,
-[ ],
-'',
-[(-25200, 0, 0)], 'GMT-0700\x00'),
-'GMT-8': ('GMT-8', 0, 1,
-[ ],
-'',
-[(-28800, 0, 0)], 'GMT-0800\x00'),
-'GMT-9': ('GMT-9', 0, 1,
-[ ],
-'',
-[(-32400, 0, 0)], 'GMT-0900\x00'),
-'Greenwich': ('Greenwich', 0, 1,
-[ ],
-'',
-[(0, 0, 0)], 'GMT\x00'),
-'Hongkong': ('Hongkong', 0, 1,
-[ ],
-'',
-[(28800, 0, 0)], 'HKT\x00'),
-'Iceland': ('Iceland', 0, 1,
-[ ],
-'',
-[(0, 0, 0)], 'WET\x00'),
-'Iran': ('Iran', 100, 2,
-[ '575418600', '590535000', '606868200', '621984600', '638317800',
-'653434200', '670372200', '684883800', '701821800', '716938200',
-'733271400', '748387800', '764721000', '779837400', '796170600',
-'811287000', '828225000', '842736600', '859674600', '874791000',
-'891124200', '906240600', '922573800', '937690200', '954023400',
-'969139800', '985473000', '1000589400', '1017527400', '1032039000',
-'1048977000', '1064093400', '1080426600', '1095543000', '1111876200',
-'1126992600', '1143325800', '1158442200', '1174775400', '1189891800',
-'1206829800', '1221946200', '1238279400', '1253395800', '1269729000',
-'1284845400', '1301178600', '1316295000', '1332628200', '1347744600',
-'1364682600', '1379194200', '1396132200', '1411248600', '1427581800',
-'1442698200', '1459031400', '1474147800', '1490481000', '1505597400',
-'1521930600', '1537047000', '1553985000', '1568496600', '1585434600',
-'1600551000', '1616884200', '1632000600', '1648333800', '1663450200',
-'1679783400', '1694899800', '1711837800', '1726349400', '1743287400',
-'1758403800', '1774737000', '1789853400', '1806186600', '1821303000',
-'1837636200', '1852752600', '1869085800', '1884202200', '1901140200',
-'1915651800', '1932589800', '1947706200', '1964039400', '1979155800',
-'1995489000', '2010605400', '2026938600', '2042055000', '2058388200',
-'2073504600', '2090442600', '2105559000', '2121892200', '2137008600',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(16200, 1, 0), (12600, 0, 4)], 'IDT\x00IST\x00'),
-'Israel': ('Israel', 42, 2,
-[ '609890400', '622587600', '640735200', '653432400', '670975200',
-'683672400', '704239200', '716936400', '735084000', '747781200',
-'765324000', '778021200', '798588000', '811285200', '829432800',
-'842130000', '862696800', '875394000', '892936800', '905634000',
-'923781600', '936478800', '957045600', '969742800', '987285600',
-'999982800', '1018130400', '1030827600', '1051394400', '1064091600',
-'1082239200', '1094936400', '1114898400', '1127595600', '1145743200',
-'1158440400', '1176588000', '1189285200', '1209247200', '1221944400',
-'1240092000', '1252789200',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(10800, 1, 0), (7200, 0, 4)], 'IDT\x00IST\x00'),
-'Jamaica': ('Jamaica', 148, 3,
-[ '-1633280400', '-1615140000', '-1601830800', '-1583690400', '-880218000',
-'-765396000', '-84387600', '-68666400', '-52938000', '-37216800',
-'-21488400', '-5767200', '9961200', '25682400', '41410800',
-'57736800', '73465200', '89186400', '104914800', '120636000',
-'126687600', '152085600', '162370800', '183535200', '199263600',
-'215589600', '230713200', '247039200', '262767600', '278488800',
-'294217200', '309938400', '325666800', '341388000', '357116400',
-'372837600', '388566000', '404892000', '420015600', '436341600',
-'452070000', '467791200', '483519600', '499240800', '514969200',
-'530690400', '544604400', '562140000', '576054000', '594194400',
-'607503600', '625644000', '638953200', '657093600', '671007600',
-'688543200', '702457200', '719992800', '733906800', '752047200',
-'765356400', '783496800', '796806000', '814946400', '828860400',
-'846396000', '860310000', '877845600', '891759600', '909295200',
-'923209200', '941349600', '954658800', '972799200', '986108400',
-'1004248800', '1018162800', '1035698400', '1049612400', '1067148000',
-'1081062000', '1099202400', '1112511600', '1130652000', '1143961200',
-'1162101600', '1175410800', '1193551200', '1207465200', '1225000800',
-'1238914800', '1256450400', '1270364400', '1288504800', '1301814000',
-'1319954400', '1333263600', '1351404000', '1365318000', '1382853600',
-'1396767600', '1414303200', '1428217200', '1445752800', '1459666800',
-'1477807200', '1491116400', '1509256800', '1522566000', '1540706400',
-'1554620400', '1572156000', '1586070000', '1603605600', '1617519600',
-'1635660000', '1648969200', '1667109600', '1680418800', '1698559200',
-'1712473200', '1730008800', '1743922800', '1761458400', '1775372400',
-'1792908000', '1806822000', '1824962400', '1838271600', '1856412000',
-'1869721200', '1887861600', '1901775600', '1919311200', '1933225200',
-'1950760800', '1964674800', '1982815200', '1996124400', '2014264800',
-'2027574000', '2045714400', '2059023600', '2077164000', '2091078000',
-'2108613600', '2122527600', '2140063200',
-],
-'\x00\x01\x00\x01\x02\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-14400, 1, 0), (-18000, 0, 4), (-14400, 1, 8)], 'EDT\x00EST\x00EWT\x00'),
-'Japan': ('Japan', 0, 1,
-[ ],
-'',
-[(32400, 0, 0)], 'JST\x00'),
-'Mexico/BajaNorte': ('Mexico/BajaNorte', 102, 2,
-[ '544615200', '562150800', '576064800', '594205200', '607514400',
-'625654800', '638964000', '657104400', '671018400', '688554000',
-'702468000', '720003600', '733917600', '752058000', '765367200',
-'783507600', '796816800', '814957200', '828871200', '846406800',
-'860320800', '877856400', '891770400', '909306000', '923220000',
-'941360400', '954669600', '972810000', '986119200', '1004259600',
-'1018173600', '1035709200', '1049623200', '1067158800', '1081072800',
-'1099213200', '1112522400', '1130662800', '1143972000', '1162112400',
-'1175421600', '1193562000', '1207476000', '1225011600', '1238925600',
-'1256461200', '1270375200', '1288515600', '1301824800', '1319965200',
-'1333274400', '1351414800', '1365328800', '1382864400', '1396778400',
-'1414314000', '1428228000', '1445763600', '1459677600', '1477818000',
-'1491127200', '1509267600', '1522576800', '1540717200', '1554631200',
-'1572166800', '1586080800', '1603616400', '1617530400', '1635670800',
-'1648980000', '1667120400', '1680429600', '1698570000', '1712484000',
-'1730019600', '1743933600', '1761469200', '1775383200', '1792918800',
-'1806832800', '1824973200', '1838282400', '1856422800', '1869732000',
-'1887872400', '1901786400', '1919322000', '1933236000', '1950771600',
-'1964685600', '1982826000', '1996135200', '2014275600', '2027584800',
-'2045725200', '2059034400', '2077174800', '2091088800', '2108624400',
-'2122538400', '2140074000',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-25200, 1, 0), (-28800, 0, 4)], 'PDT\x00PST\x00'),
-'Mexico/BajaSur': ('Mexico/BajaSur', 0, 1,
-[ ],
-'',
-[(-25200, 0, 0)], 'MST\x00'),
-'Mexico/General': ('Mexico/General', 0, 1,
-[ ],
-'',
-[(-21600, 0, 0)], 'CST\x00'),
-'Poland': ('Poland', 104, 2,
-[ '512524800', '528249600', '543974400', '559699200', '575424000',
-'591148800', '606873600', '622598400', '638323200', '654652800',
-'670377600', '686102400', '701827200', '717552000', '733276800',
-'749001600', '764726400', '780451200', '796176000', '811900800',
-'828230400', '843955200', '859680000', '875404800', '891129600',
-'906854400', '922579200', '938304000', '954028800', '969753600',
-'985478400', '1001808000', '1017532800', '1033257600', '1048982400',
-'1064707200', '1080432000', '1096156800', '1111881600', '1127606400',
-'1143331200', '1159056000', '1174780800', '1191110400', '1206835200',
-'1222560000', '1238284800', '1254009600', '1269734400', '1285459200',
-'1301184000', '1316908800', '1332633600', '1348963200', '1364688000',
-'1380412800', '1396137600', '1411862400', '1427587200', '1443312000',
-'1459036800', '1474761600', '1490486400', '1506211200', '1521936000',
-'1538265600', '1553990400', '1569715200', '1585440000', '1601164800',
-'1616889600', '1632614400', '1648339200', '1664064000', '1679788800',
-'1695513600', '1711843200', '1727568000', '1743292800', '1759017600',
-'1774742400', '1790467200', '1806192000', '1821916800', '1837641600',
-'1853366400', '1869091200', '1885420800', '1901145600', '1916870400',
-'1932595200', '1948320000', '1964044800', '1979769600', '1995494400',
-'2011219200', '2026944000', '2042668800', '2058393600', '2074723200',
-'2090448000', '2106172800', '2121897600', '2137622400',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(7200, 1, 0), (3600, 0, 8)], 'MET DST\x00MET\x00'),
-'Singapore': ('Singapore', 0, 1,
-[ ],
-'',
-[(28800, 0, 0)], 'SST\x00'),
-'Turkey': ('Turkey', 104, 2,
-[ '512517600', '528238800', '543967200', '559688400', '575416800',
-'591138000', '606866400', '622587600', '638316000', '654642000',
-'670370400', '686091600', '701820000', '717541200', '733269600',
-'748990800', '764719200', '780440400', '796168800', '811890000',
-'828223200', '843944400', '859672800', '875394000', '891122400',
-'906843600', '922572000', '938293200', '954021600', '969742800',
-'985471200', '1001797200', '1017525600', '1033246800', '1048975200',
-'1064696400', '1080424800', '1096146000', '1111874400', '1127595600',
-'1143324000', '1159045200', '1174773600', '1191099600', '1206828000',
-'1222549200', '1238277600', '1253998800', '1269727200', '1285448400',
-'1301176800', '1316898000', '1332626400', '1348952400', '1364680800',
-'1380402000', '1396130400', '1411851600', '1427580000', '1443301200',
-'1459029600', '1474750800', '1490479200', '1506200400', '1521928800',
-'1538254800', '1553983200', '1569704400', '1585432800', '1601154000',
-'1616882400', '1632603600', '1648332000', '1664053200', '1679781600',
-'1695502800', '1711836000', '1727557200', '1743285600', '1759006800',
-'1774735200', '1790456400', '1806184800', '1821906000', '1837634400',
-'1853355600', '1869084000', '1885410000', '1901138400', '1916859600',
-'1932588000', '1948309200', '1964037600', '1979758800', '1995487200',
-'2011208400', '2026936800', '2042658000', '2058386400', '2074712400',
-'2090440800', '2106162000', '2121890400', '2137611600',
-],
-'\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(14400, 1, 0), (10800, 0, 8)], 'EET DST\x00EET\x00'),
-'US/Alaska': ('US/Alaska', 148, 3,
-[ '-1633266000', '-1615125600', '-1601816400', '-1583676000', '-880203600',
-'-765381600', '-84373200', '-68652000', '-52923600', '-37202400',
-'-21474000', '-5752800', '9975600', '25696800', '41425200',
-'57751200', '73479600', '89200800', '104929200', '120650400',
-'126702000', '152100000', '162385200', '183549600', '199278000',
-'215604000', '230727600', '247053600', '262782000', '278503200',
-'294231600', '309952800', '325681200', '341402400', '357130800',
-'372852000', '388580400', '404906400', '420030000', '436356000',
-'452084400', '467805600', '483534000', '499255200', '514983600',
-'530704800', '544618800', '562154400', '576068400', '594208800',
-'607518000', '625658400', '638967600', '657108000', '671022000',
-'688557600', '702471600', '720007200', '733921200', '752061600',
-'765370800', '783511200', '796820400', '814960800', '828874800',
-'846410400', '860324400', '877860000', '891774000', '909309600',
-'923223600', '941364000', '954673200', '972813600', '986122800',
-'1004263200', '1018177200', '1035712800', '1049626800', '1067162400',
-'1081076400', '1099216800', '1112526000', '1130666400', '1143975600',
-'1162116000', '1175425200', '1193565600', '1207479600', '1225015200',
-'1238929200', '1256464800', '1270378800', '1288519200', '1301828400',
-'1319968800', '1333278000', '1351418400', '1365332400', '1382868000',
-'1396782000', '1414317600', '1428231600', '1445767200', '1459681200',
-'1477821600', '1491130800', '1509271200', '1522580400', '1540720800',
-'1554634800', '1572170400', '1586084400', '1603620000', '1617534000',
-'1635674400', '1648983600', '1667124000', '1680433200', '1698573600',
-'1712487600', '1730023200', '1743937200', '1761472800', '1775386800',
-'1792922400', '1806836400', '1824976800', '1838286000', '1856426400',
-'1869735600', '1887876000', '1901790000', '1919325600', '1933239600',
-'1950775200', '1964689200', '1982829600', '1996138800', '2014279200',
-'2027588400', '2045728800', '2059038000', '2077178400', '2091092400',
-'2108628000', '2122542000', '2140077600',
-],
-'\x00\x01\x00\x01\x02\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-28800, 1, 0), (-32400, 0, 5), (-28800, 1, 10)], 'AKDT\x00AKST\x00AKWT\x00'),
-'US/Aleutian': ('US/Aleutian', 149, 5,
-[ '-1633262400', '-1615122000', '-1601812800', '-1583672400', '-880200000',
-'-765378000', '-84369600', '-68648400', '-52920000', '-37198800',
-'-21470400', '-5749200', '9979200', '25700400', '41428800',
-'57754800', '73483200', '89204400', '104932800', '120654000',
-'126705600', '152103600', '162388800', '183553200', '199281600',
-'215607600', '230731200', '247057200', '262785600', '278506800',
-'294235200', '309956400', '325684800', '341406000', '357134400',
-'372855600', '388584000', '404910000', '420033600', '436359600',
-'439034400', '452088000', '467809200', '483537600', '499258800',
-'514987200', '530708400', '544622400', '562158000', '576072000',
-'594212400', '607521600', '625662000', '638971200', '657111600',
-'671025600', '688561200', '702475200', '720010800', '733924800',
-'752065200', '765374400', '783514800', '796824000', '814964400',
-'828878400', '846414000', '860328000', '877863600', '891777600',
-'909313200', '923227200', '941367600', '954676800', '972817200',
-'986126400', '1004266800', '1018180800', '1035716400', '1049630400',
-'1067166000', '1081080000', '1099220400', '1112529600', '1130670000',
-'1143979200', '1162119600', '1175428800', '1193569200', '1207483200',
-'1225018800', '1238932800', '1256468400', '1270382400', '1288522800',
-'1301832000', '1319972400', '1333281600', '1351422000', '1365336000',
-'1382871600', '1396785600', '1414321200', '1428235200', '1445770800',
-'1459684800', '1477825200', '1491134400', '1509274800', '1522584000',
-'1540724400', '1554638400', '1572174000', '1586088000', '1603623600',
-'1617537600', '1635678000', '1648987200', '1667127600', '1680436800',
-'1698577200', '1712491200', '1730026800', '1743940800', '1761476400',
-'1775390400', '1792926000', '1806840000', '1824980400', '1838289600',
-'1856430000', '1869739200', '1887879600', '1901793600', '1919329200',
-'1933243200', '1950778800', '1964692800', '1982833200', '1996142400',
-'2014282800', '2027592000', '2045732400', '2059041600', '2077182000',
-'2091096000', '2108631600', '2122545600', '2140081200',
-],
-'\x00\x01\x00\x01\x02\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03\x04\x03',
-[(-32400, 1, 0), (-36000, 0, 5), (-32400, 1, 10), (-36000, 0, 15), (-32400, 1, 20)], 'AHDT\x00AHST\x00AHWT\x00HAST\x00HADT\x00'),
-'US/Arizona': ('US/Arizona', 6, 3,
-[ '-1633273200', '-1615132800', '-1601823600', '-1583683200', '-880210800',
-'-765388800',
-],
-'\x00\x01\x00\x01\x02\x01',
-[(-21600, 1, 0), (-25200, 0, 4), (-21600, 1, 8)], 'MDT\x00MST\x00MWT\x00'),
-'US/Central': ('US/Central', 148, 3,
-[ '-1633276800', '-1615136400', '-1601827200', '-1583686800', '-880214400',
-'-765392400', '-84384000', '-68662800', '-52934400', '-37213200',
-'-21484800', '-5763600', '9964800', '25686000', '41414400',
-'57740400', '73468800', '89190000', '104918400', '120639600',
-'126691200', '152089200', '162374400', '183538800', '199267200',
-'215593200', '230716800', '247042800', '262771200', '278492400',
-'294220800', '309942000', '325670400', '341391600', '357120000',
-'372841200', '388569600', '404895600', '420019200', '436345200',
-'452073600', '467794800', '483523200', '499244400', '514972800',
-'530694000', '544608000', '562143600', '576057600', '594198000',
-'607507200', '625647600', '638956800', '657097200', '671011200',
-'688546800', '702460800', '719996400', '733910400', '752050800',
-'765360000', '783500400', '796809600', '814950000', '828864000',
-'846399600', '860313600', '877849200', '891763200', '909298800',
-'923212800', '941353200', '954662400', '972802800', '986112000',
-'1004252400', '1018166400', '1035702000', '1049616000', '1067151600',
-'1081065600', '1099206000', '1112515200', '1130655600', '1143964800',
-'1162105200', '1175414400', '1193554800', '1207468800', '1225004400',
-'1238918400', '1256454000', '1270368000', '1288508400', '1301817600',
-'1319958000', '1333267200', '1351407600', '1365321600', '1382857200',
-'1396771200', '1414306800', '1428220800', '1445756400', '1459670400',
-'1477810800', '1491120000', '1509260400', '1522569600', '1540710000',
-'1554624000', '1572159600', '1586073600', '1603609200', '1617523200',
-'1635663600', '1648972800', '1667113200', '1680422400', '1698562800',
-'1712476800', '1730012400', '1743926400', '1761462000', '1775376000',
-'1792911600', '1806825600', '1824966000', '1838275200', '1856415600',
-'1869724800', '1887865200', '1901779200', '1919314800', '1933228800',
-'1950764400', '1964678400', '1982818800', '1996128000', '2014268400',
-'2027577600', '2045718000', '2059027200', '2077167600', '2091081600',
-'2108617200', '2122531200', '2140066800',
-],
-'\x00\x01\x00\x01\x02\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-18000, 1, 0), (-21600, 0, 4), (-18000, 1, 8)], 'CDT\x00CST\x00CWT\x00'),
-'US/East-Indiana': ('US/East-Indiana', 6, 3,
-[ '-1633280400', '-1615140000', '-1601830800', '-1583690400', '-880218000',
-'-765396000',
-],
-'\x00\x01\x00\x01\x02\x01',
-[(-14400, 1, 0), (-18000, 0, 4), (-14400, 1, 8)], 'EDT\x00EST\x00EWT\x00'),
-'US/Eastern': ('US/Eastern', 148, 3,
-[ '-1633280400', '-1615140000', '-1601830800', '-1583690400', '-880218000',
-'-765396000', '-84387600', '-68666400', '-52938000', '-37216800',
-'-21488400', '-5767200', '9961200', '25682400', '41410800',
-'57736800', '73465200', '89186400', '104914800', '120636000',
-'126687600', '152085600', '162370800', '183535200', '199263600',
-'215589600', '230713200', '247039200', '262767600', '278488800',
-'294217200', '309938400', '325666800', '341388000', '357116400',
-'372837600', '388566000', '404892000', '420015600', '436341600',
-'452070000', '467791200', '483519600', '499240800', '514969200',
-'530690400', '544604400', '562140000', '576054000', '594194400',
-'607503600', '625644000', '638953200', '657093600', '671007600',
-'688543200', '702457200', '719992800', '733906800', '752047200',
-'765356400', '783496800', '796806000', '814946400', '828860400',
-'846396000', '860310000', '877845600', '891759600', '909295200',
-'923209200', '941349600', '954658800', '972799200', '986108400',
-'1004248800', '1018162800', '1035698400', '1049612400', '1067148000',
-'1081062000', '1099202400', '1112511600', '1130652000', '1143961200',
-'1162101600', '1175410800', '1193551200', '1207465200', '1225000800',
-'1238914800', '1256450400', '1270364400', '1288504800', '1301814000',
-'1319954400', '1333263600', '1351404000', '1365318000', '1382853600',
-'1396767600', '1414303200', '1428217200', '1445752800', '1459666800',
-'1477807200', '1491116400', '1509256800', '1522566000', '1540706400',
-'1554620400', '1572156000', '1586070000', '1603605600', '1617519600',
-'1635660000', '1648969200', '1667109600', '1680418800', '1698559200',
-'1712473200', '1730008800', '1743922800', '1761458400', '1775372400',
-'1792908000', '1806822000', '1824962400', '1838271600', '1856412000',
-'1869721200', '1887861600', '1901775600', '1919311200', '1933225200',
-'1950760800', '1964674800', '1982815200', '1996124400', '2014264800',
-'2027574000', '2045714400', '2059023600', '2077164000', '2091078000',
-'2108613600', '2122527600', '2140063200',
-],
-'\x00\x01\x00\x01\x02\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-14400, 1, 0), (-18000, 0, 4), (-14400, 1, 8)], 'EDT\x00EST\x00EWT\x00'),
-'US/Hawaii': ('US/Hawaii', 9, 4,
-[ '-1633260600', '-1615120200', '-1601811000', '-1583670600', '-1157283000',
-'-1157200200', '-880198200', '-765376200', '-712150200',
-],
-'\x00\x01\x00\x01\x00\x01\x02\x01\x03',
-[(-34200, 1, 0), (-37800, 0, 4), (-34200, 1, 8), (-36000, 0, 4)], 'HDT\x00HST\x00HWT\x00'),
-'US/Indiana-Starke': ('US/Indiana-Starke', 56, 4,
-[ '-1633276800', '-1615136400', '-1601827200', '-1583686800', '-880214400',
-'-765392400', '-84384000', '-68662800', '-52934400', '-37213200',
-'-21484800', '-5763600', '9964800', '25686000', '41414400',
-'57740400', '73468800', '89190000', '104918400', '120639600',
-'126691200', '152089200', '162374400', '183538800', '199267200',
-'215593200', '230716800', '247042800', '262771200', '278492400',
-'294220800', '309942000', '325670400', '341391600', '357120000',
-'372841200', '388569600', '404895600', '420019200', '436345200',
-'452073600', '467794800', '483523200', '499244400', '514972800',
-'530694000', '544608000', '562143600', '576057600', '594198000',
-'607507200', '625647600', '638956800', '657097200', '671011200',
-'688546800',
-],
-'\x00\x01\x00\x01\x02\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x03',
-[(-18000, 1, 0), (-21600, 0, 4), (-18000, 1, 8), (-18000, 0, 12)], 'CDT\x00CST\x00CWT\x00EST\x00'),
-'US/Michigan': ('US/Michigan', 138, 3,
-[ '-1633280400', '-1615140000', '-1601830800', '-1583690400', '-880218000',
-'-765396000', '-84387600', '-68666400', '104914800', '120636000',
-'126687600', '152085600', '162370800', '183535200', '199263600',
-'215589600', '230713200', '247039200', '262767600', '278488800',
-'294217200', '309938400', '325666800', '341388000', '357116400',
-'372837600', '388566000', '404892000', '420015600', '436341600',
-'452070000', '467791200', '483519600', '499240800', '514969200',
-'530690400', '544604400', '562140000', '576054000', '594194400',
-'607503600', '625644000', '638953200', '657093600', '671007600',
-'688543200', '702457200', '719992800', '733906800', '752047200',
-'765356400', '783496800', '796806000', '814946400', '828860400',
-'846396000', '860310000', '877845600', '891759600', '909295200',
-'923209200', '941349600', '954658800', '972799200', '986108400',
-'1004248800', '1018162800', '1035698400', '1049612400', '1067148000',
-'1081062000', '1099202400', '1112511600', '1130652000', '1143961200',
-'1162101600', '1175410800', '1193551200', '1207465200', '1225000800',
-'1238914800', '1256450400', '1270364400', '1288504800', '1301814000',
-'1319954400', '1333263600', '1351404000', '1365318000', '1382853600',
-'1396767600', '1414303200', '1428217200', '1445752800', '1459666800',
-'1477807200', '1491116400', '1509256800', '1522566000', '1540706400',
-'1554620400', '1572156000', '1586070000', '1603605600', '1617519600',
-'1635660000', '1648969200', '1667109600', '1680418800', '1698559200',
-'1712473200', '1730008800', '1743922800', '1761458400', '1775372400',
-'1792908000', '1806822000', '1824962400', '1838271600', '1856412000',
-'1869721200', '1887861600', '1901775600', '1919311200', '1933225200',
-'1950760800', '1964674800', '1982815200', '1996124400', '2014264800',
-'2027574000', '2045714400', '2059023600', '2077164000', '2091078000',
-'2108613600', '2122527600', '2140063200',
-],
-'\x00\x01\x00\x01\x02\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-14400, 1, 0), (-18000, 0, 4), (-14400, 1, 8)], 'EDT\x00EST\x00EWT\x00'),
-'US/Mountain': ('US/Mountain', 148, 3,
-[ '-1633273200', '-1615132800', '-1601823600', '-1583683200', '-880210800',
-'-765388800', '-84380400', '-68659200', '-52930800', '-37209600',
-'-21481200', '-5760000', '9968400', '25689600', '41418000',
-'57744000', '73472400', '89193600', '104922000', '120643200',
-'126694800', '152092800', '162378000', '183542400', '199270800',
-'215596800', '230720400', '247046400', '262774800', '278496000',
-'294224400', '309945600', '325674000', '341395200', '357123600',
-'372844800', '388573200', '404899200', '420022800', '436348800',
-'452077200', '467798400', '483526800', '499248000', '514976400',
-'530697600', '544611600', '562147200', '576061200', '594201600',
-'607510800', '625651200', '638960400', '657100800', '671014800',
-'688550400', '702464400', '720000000', '733914000', '752054400',
-'765363600', '783504000', '796813200', '814953600', '828867600',
-'846403200', '860317200', '877852800', '891766800', '909302400',
-'923216400', '941356800', '954666000', '972806400', '986115600',
-'1004256000', '1018170000', '1035705600', '1049619600', '1067155200',
-'1081069200', '1099209600', '1112518800', '1130659200', '1143968400',
-'1162108800', '1175418000', '1193558400', '1207472400', '1225008000',
-'1238922000', '1256457600', '1270371600', '1288512000', '1301821200',
-'1319961600', '1333270800', '1351411200', '1365325200', '1382860800',
-'1396774800', '1414310400', '1428224400', '1445760000', '1459674000',
-'1477814400', '1491123600', '1509264000', '1522573200', '1540713600',
-'1554627600', '1572163200', '1586077200', '1603612800', '1617526800',
-'1635667200', '1648976400', '1667116800', '1680426000', '1698566400',
-'1712480400', '1730016000', '1743930000', '1761465600', '1775379600',
-'1792915200', '1806829200', '1824969600', '1838278800', '1856419200',
-'1869728400', '1887868800', '1901782800', '1919318400', '1933232400',
-'1950768000', '1964682000', '1982822400', '1996131600', '2014272000',
-'2027581200', '2045721600', '2059030800', '2077171200', '2091085200',
-'2108620800', '2122534800', '2140070400',
-],
-'\x00\x01\x00\x01\x02\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-21600, 1, 0), (-25200, 0, 4), (-21600, 1, 8)], 'MDT\x00MST\x00MWT\x00'),
-'US/Pacific': ('US/Pacific', 148, 3,
-[ '-1633269600', '-1615129200', '-1601820000', '-1583679600', '-880207200',
-'-765385200', '-84376800', '-68655600', '-52927200', '-37206000',
-'-21477600', '-5756400', '9972000', '25693200', '41421600',
-'57747600', '73476000', '89197200', '104925600', '120646800',
-'126698400', '152096400', '162381600', '183546000', '199274400',
-'215600400', '230724000', '247050000', '262778400', '278499600',
-'294228000', '309949200', '325677600', '341398800', '357127200',
-'372848400', '388576800', '404902800', '420026400', '436352400',
-'452080800', '467802000', '483530400', '499251600', '514980000',
-'530701200', '544615200', '562150800', '576064800', '594205200',
-'607514400', '625654800', '638964000', '657104400', '671018400',
-'688554000', '702468000', '720003600', '733917600', '752058000',
-'765367200', '783507600', '796816800', '814957200', '828871200',
-'846406800', '860320800', '877856400', '891770400', '909306000',
-'923220000', '941360400', '954669600', '972810000', '986119200',
-'1004259600', '1018173600', '1035709200', '1049623200', '1067158800',
-'1081072800', '1099213200', '1112522400', '1130662800', '1143972000',
-'1162112400', '1175421600', '1193562000', '1207476000', '1225011600',
-'1238925600', '1256461200', '1270375200', '1288515600', '1301824800',
-'1319965200', '1333274400', '1351414800', '1365328800', '1382864400',
-'1396778400', '1414314000', '1428228000', '1445763600', '1459677600',
-'1477818000', '1491127200', '1509267600', '1522576800', '1540717200',
-'1554631200', '1572166800', '1586080800', '1603616400', '1617530400',
-'1635670800', '1648980000', '1667120400', '1680429600', '1698570000',
-'1712484000', '1730019600', '1743933600', '1761469200', '1775383200',
-'1792918800', '1806832800', '1824973200', '1838282400', '1856422800',
-'1869732000', '1887872400', '1901786400', '1919322000', '1933236000',
-'1950771600', '1964685600', '1982826000', '1996135200', '2014275600',
-'2027584800', '2045725200', '2059034400', '2077174800', '2091088800',
-'2108624400', '2122538400', '2140074000',
-],
-'\x00\x01\x00\x01\x02\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01\x00\x01',
-[(-25200, 1, 0), (-28800, 0, 4), (-25200, 1, 8)], 'PDT\x00PST\x00PWT\x00'),
-'US/Samoa': ('US/Samoa', 2, 3,
-[ '-86878800', '439038000',
-],
-'\x01\x02',
-[(-39600, 0, 0), (-39600, 0, 4), (-39600, 0, 8)], 'NST\x00BST\x00SST\x00'),
-'Universal': ('Universal', 0, 1,
-[ ],
-'',
-[(0, 0, 0)], 'GMT\x00'),
-}
-
-def dumpTimezoneInfo(_data):
-
- print "historical_zone_info = {"
-
- items = _data.items()
- items.sort()
- for key, value in items:
- v1, v2, v3, ilist, bitmap, two_by_three, two_nullterm = value
- print "'%s': ('%s', %s, %s," % (key, v1, v2, v3)
- print "[",
- while ilist:
- next_5, ilist = ilist[:5], ilist[5:]
- line = ", ".join(["'%s'" % x for x in next_5])
- print "%s," % line
- print "], "
- print "%s," % repr(bitmap)
- print "%s, %s)," % (repr(two_by_three), repr(two_nullterm))
-
- print "}"
-
-if __name__ == '__main__':
- dumpTimezoneInfo(historical_zone_info)
+# This module has moved to zope.datetime.timezones
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.datetime.timezones',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/timezones.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.3
Modified: Zope3/trunk/src/zope/app/traversing/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/traversing/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1 +1,7 @@
-#
+# This module has moved to zope.traversing
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.traversing',
+ "Zope 3.5",
+ )
Modified: Zope3/trunk/src/zope/app/traversing/adapters.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/adapters.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/traversing/adapters.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,199 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Adapters for the traversing mechanism
-
-$Id$
-"""
+# This module has moved to zope.traversing.adapters
+# and will go away in Zope 3.5
import zope.deprecation
-
-from types import StringTypes, MethodType
-
-from zope.app.traversing.interfaces import TraversalError
-from zope.interface import implements
-
-from zope.app.traversing.interfaces import IPhysicallyLocatable
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.app.traversing.interfaces import ITraverser, ITraversable
-
-from zope.app.traversing.namespace import namespaceLookup
-from zope.app.traversing.namespace import UnexpectedParameters
-from zope.app.traversing.namespace import nsParse
-
-# BBB Backward Compatibility (Can go away in 3.3)
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError
-zope.deprecation.__show__.on()
-
-import warnings
-
-_marker = object() # opaque marker that doesn't get security proxied
-
-class DefaultTraversable(object):
- """Traverses objects via attribute and item lookup"""
-
- implements(ITraversable)
-
- def __init__(self, subject):
- self._subject = subject
-
- def traverse(self, name, furtherPath):
- subject = self._subject
- __traceback_info__ = (subject, name, furtherPath)
- attr = getattr(subject, name, _marker)
- if attr is not _marker:
- return attr
- if hasattr(subject, '__getitem__'):
- try:
- return subject[name]
- except KeyError:
- pass
- raise TraversalError(subject, name)
-
-
-class RootPhysicallyLocatable(object):
- __doc__ = IPhysicallyLocatable.__doc__
-
- implements(IPhysicallyLocatable)
-
- __used_for__ = IContainmentRoot
-
- def __init__(self, context):
- self.context = context
-
- def getPath(self):
- "See IPhysicallyLocatable"
- return u'/'
-
- def getRoot(self):
- "See IPhysicallyLocatable"
- return self.context
-
- def getName(self):
- "See IPhysicallyLocatable"
- return u''
-
- def getNearestSite(self):
- "See IPhysicallyLocatable"
- return self.context
-
-
-class Traverser(object):
- """Provide traverse features"""
-
- implements(ITraverser)
-
- # This adapter can be used for any object.
-
- def __init__(self, wrapper):
- self.context = wrapper
-
- def traverse(self, path, default=_marker, request=None):
- if not path:
- return self.context
-
- if isinstance(path, StringTypes):
- path = path.split('/')
- if len(path) > 1 and not path[-1]:
- # Remove trailing slash
- path.pop()
- else:
- path = list(path)
-
- path.reverse()
- pop = path.pop
-
- curr = self.context
- if not path[-1]:
- # Start at the root
- pop()
- curr = IPhysicallyLocatable(self.context).getRoot()
- try:
- while path:
- name = pop()
- curr = traversePathElement(curr, name, path, request=request)
-
- return curr
- except TraversalError:
- if default == _marker:
- raise
- return default
-
-
-def traversePathElement(obj, name, further_path, default=_marker,
- traversable=None, request=None):
- """Traverse a single step 'name' relative to the given object.
-
- 'name' must be a string. '.' and '..' are treated specially, as well as
- names starting with '@' or '+'. Otherwise 'name' will be treated as a
- single path segment.
-
- 'further_path' is a list of names still to be traversed. This method
- is allowed to change the contents of 'further_path'.
-
- You can explicitly pass in an ITraversable as the 'traversable'
- argument. If you do not, the given object will be adapted to ITraversable.
-
- 'request' is passed in when traversing from presentation code. This
- allows paths like @@foo to work.
-
- Raises TraversalError if path cannot be found and 'default' was
- not provided.
-
- """
- __traceback_info__ = (obj, name)
-
- if name == '.':
- return obj
-
- if name == '..':
- return obj.__parent__
-
- if name and name[:1] in '@+':
- ns, nm = nsParse(name)
- if ns:
- return namespaceLookup(ns, nm, obj, request)
- else:
- nm = name
-
- if traversable is None:
- if obj.__class__ == dict:
- # Special-case dicts
- return obj[name]
-
- traversable = ITraversable(obj, None)
- if traversable is None:
- raise TraversalError('No traversable adapter found', obj)
-
- try:
- return traversable.traverse(nm, further_path)
- except TraversalError:
- if default is not _marker:
- return default
- else:
- raise
- except NotFoundError, v: # BBB Backward Compatibility
- warnings.warn(
- "A %s instance raised a NotFoundError in "
- "traverse. Raising NotFoundError in this "
- "method is deprecated and will no-longer be supported "
- "starting in Zope 3.3. TraversalError should "
- "be raised instead."
- % traversable.__class__.__name__,
- DeprecationWarning)
- if default is not _marker:
- return default
- else:
- raise
-
- return obj
+zope.deprecation.moved(
+ 'zope.traversing.adapters',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/traversing/adapters.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.21
Modified: Zope3/trunk/src/zope/app/traversing/api.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/api.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/traversing/api.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,250 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Convenience functions for traversing the object tree.
-
-$Id$
-"""
+# This module has moved to zope.traversing.api
+# and will go away in Zope 3.5
import zope.deprecation
-
-from zope.interface import moduleProvides
-from interfaces import IContainmentRoot, ITraversalAPI
-from interfaces import ITraverser, IPhysicallyLocatable, TraversalError
-
-# BBB Backward Compatibility (Can go away in 3.3)
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError
-zope.deprecation.__show__.on()
-
-import warnings
-
-moduleProvides(ITraversalAPI)
-__all__ = tuple(ITraversalAPI)
-
-_marker = object()
-
-def joinPath(path, *args):
- """Join the given relative paths to the given path.
-
- Returns a unicode path.
-
- The path should be well-formed, and not end in a '/' unless it is
- the root path. It can be either a string (ascii only) or unicode.
- The positional arguments are relative paths to be added to the
- path as new path segments. The path may be absolute or relative.
-
- A segment may not start with a '/' because that would be confused
- with an absolute path. A segment may not end with a '/' because we
- do not allow '/' at the end of relative paths. A segment may
- consist of . or .. to mean "the same place", or "the parent path"
- respectively. A '.' should be removed and a '..' should cause the
- segment to the left to be removed. joinPath('/', '..') should
- raise an exception.
- """
-
- if not args:
- # Concatenating u'' is much quicker than unicode(path)
- return u'' + path
- if path != '/' and path.endswith('/'):
- raise ValueError('path must not end with a "/": %s' % path)
- if path != '/':
- path += u'/'
- for arg in args:
- if arg.startswith('/') or arg.endswith('/'):
- raise ValueError("Leading or trailing slashes in path elements")
- return _normalizePath(path + u'/'.join(args))
-
-def getPath(obj):
- """Returns a string representing the physical path to the object.
- """
- return IPhysicallyLocatable(obj).getPath()
-
-def getRoot(obj):
- """Returns the root of the traversal for the given object.
- """
- return IPhysicallyLocatable(obj).getRoot()
-
-def traverse(object, path, default=_marker, request=None):
- """Traverse 'path' relative to the given object.
-
- 'path' is a string with path segments separated by '/'.
-
- 'request' is passed in when traversing from presentation code. This
- allows paths like @@foo to work.
-
- Raises TraversalError if path cannot be found
-
- Note: calling traverse with a path argument taken from an untrusted
- source, such as an HTTP request form variable, is a bad idea.
- It could allow a maliciously constructed request to call
- code unexpectedly.
- Consider using traverseName instead.
- """
- traverser = ITraverser(object)
- try:
- if default is _marker:
- return traverser.traverse(path, request=request)
- else:
- return traverser.traverse(path, default=default, request=request)
-
- # BBB Backward Compatibility, can go away in 3.3
- #
- except TraversalError:
- raise
- except NotFoundError, v:
- warnings.warn(
- "A %s instance raised a NotFoundError in "
- "traverse. Raising NotFoundError in this "
- "method is deprecated and will no-longer be supported "
- "staring in Zope 3.3. TraversalError should "
- "be raised instead."
- % traverser.__class__.__name__,
- DeprecationWarning)
- raise TraversalError(*tuple(v))
- #
- ###############################################################
-
-def traverseName(obj, name, default=_marker, traversable=None, request=None):
- """Traverse a single step 'name' relative to the given object.
-
- 'name' must be a string. '.' and '..' are treated specially, as well as
- names starting with '@' or '+'. Otherwise 'name' will be treated as a
- single path segment.
-
- You can explicitly pass in an ITraversable as the 'traversable'
- argument. If you do not, the given object will be adapted to ITraversable.
-
- 'request' is passed in when traversing from presentation code. This
- allows paths like @@foo to work.
-
- Raises TraversalError if path cannot be found and 'default' was
- not provided.
-
- """
- further_path = []
- if default is _marker:
- obj = traversePathElement(obj, name, further_path,
- traversable=traversable, request=request)
- else:
- obj = traversePathElement(obj, name, further_path, default=default,
- traversable=traversable, request=request)
- if further_path:
- raise NotImplementedError('further_path returned from traverse')
- else:
- return obj
-
-def getName(obj):
- """Get the name an object was traversed via
- """
- return IPhysicallyLocatable(obj).getName()
-
-def getParent(obj):
- """Returns the container the object was traversed via.
-
- Returns None if the object is a containment root.
- Raises TypeError if the object doesn't have enough context to get the
- parent.
- """
-
- if IContainmentRoot.providedBy(obj):
- return None
-
- parent = getattr(obj, '__parent__', None)
- if parent is not None:
- return parent
-
- raise TypeError("Not enough context information to get parent", obj)
-
-
-
-def getParents(obj):
- """Returns a list starting with the given object's parent followed by
- each of its parents.
-
- Raises a TypeError if the context doesn't go all the way down to
- a containment root.
- """
- if IContainmentRoot.providedBy(obj):
- return []
-
-
- parents = []
- w = obj
- while 1:
- w = w.__parent__
- if w is None:
- break
- parents.append(w)
-
- if parents and IContainmentRoot.providedBy(parents[-1]):
- return parents
-
- raise TypeError("Not enough context information to get all parents")
-
-
-def _normalizePath(path):
- """Normalize a path by resolving '.' and '..' path elements."""
-
- # Special case for the root path.
- if path == u'/':
- return path
-
- new_segments = []
- prefix = u''
- if path.startswith('/'):
- prefix = u'/'
- path = path[1:]
-
- for segment in path.split(u'/'):
- if segment == u'.':
- continue
- if segment == u'..':
- new_segments.pop() # raises IndexError if there is nothing to pop
- continue
- if not segment:
- raise ValueError('path must not contain empty segments: %s'
- % path)
- new_segments.append(segment)
-
- return prefix + u'/'.join(new_segments)
-
-def canonicalPath(path_or_object):
- """Returns a canonical absolute unicode path for the given path or object.
-
- Resolves segments that are '.' or '..'.
-
- Raises ValueError if a badly formed path is given.
- """
- if isinstance(path_or_object, (str, unicode)):
- path = path_or_object
- if not path:
- raise ValueError("path must be non-empty: %s" % path)
- else:
- path = getPath(path_or_object)
-
- path = u'' + path
-
- # Special case for the root path.
- if path == u'/':
- return path
-
- if path[0] != u'/':
- raise ValueError('canonical path must start with a "/": %s' % path)
- if path[-1] == u'/':
- raise ValueError('path must not end with a "/": %s' % path)
-
- # Break path into segments. Process '.' and '..' segments.
- return _normalizePath(path)
-
-# import this down here to avoid circular imports
-from zope.app.traversing.adapters import traversePathElement
+zope.deprecation.moved(
+ 'zope.traversing.api',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/traversing/api.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.27
Modified: Zope3/trunk/src/zope/app/traversing/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/browser/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/traversing/browser/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,20 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
-#
-##############################################################################
-"""Absolute URL View components
-
-$Id$
-"""
-
-from zope.app.traversing.browser.absoluteurl import AbsoluteURL
-from zope.app.traversing.browser.absoluteurl import SiteAbsoluteURL
+# This module has moved to zope.traversing.browser
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.traversing.browser',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/traversing/browser/__init__.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.5
Modified: Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,142 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
-#
-##############################################################################
-"""Absolute URL View components
-
-$Id$
-"""
-import urllib
-from zope.interface import implements
-from zope.proxy import sameProxiedObjects
-from zope.publisher.browser import IBrowserRequest
-
-import zope.component
-from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.publisher.browser import BrowserView
-from zope.app.traversing.browser.interfaces import IAbsoluteURL
-
-_insufficientContext = _("There isn't enough context to get URL information. "
- "This is probably due to a bug in setting up location "
- "information.")
-
-_safe = '@+' # Characters that we don't want to have quoted
-
-def absoluteURL(ob, request):
- return zope.component.getMultiAdapter((ob, request), IAbsoluteURL)()
-
-class AbsoluteURL(BrowserView):
- implements(IAbsoluteURL)
-
- def __unicode__(self):
- return urllib.unquote(self.__str__()).decode('utf-8')
-
- def __str__(self):
- context = self.context
- request = self.request
-
- # The application URL contains all the namespaces that are at the
- # beginning of the URL, such as skins, virtual host specifications and
- # so on.
- if (context is None
- or sameProxiedObjects(context, request.getVirtualHostRoot())):
- return request.getApplicationURL()
-
- container = getattr(context, '__parent__', None)
- if container is None:
- raise TypeError(_insufficientContext)
-
- url = str(zope.component.getMultiAdapter((container, request),
- name='absolute_url'))
- name = self._getContextName(context)
- if name is None:
- raise TypeError(_insufficientContext)
-
- if name:
- url += '/' + urllib.quote(name.encode('utf-8'), _safe)
-
- return url
-
- __call__ = __str__
-
- def _getContextName(self, context):
- return getattr(context, '__name__', None)
-
- def breadcrumbs(self):
- context = self.context
- request = self.request
-
- # We do this here do maintain the rule that we must be wrapped
- container = getattr(context, '__parent__', None)
- if container is None:
- raise TypeError(_insufficientContext)
-
- if sameProxiedObjects(context, request.getVirtualHostRoot()) or \
- isinstance(context, Exception):
- return ({'name':'', 'url': self.request.getApplicationURL()}, )
-
- base = tuple(zope.component.getMultiAdapter(
- (container, request), name='absolute_url').breadcrumbs())
-
- name = getattr(context, '__name__', None)
- if name is None:
- raise TypeError(_insufficientContext)
-
- if name:
- base += ({'name': name,
- 'url': ("%s/%s" % (base[-1]['url'],
- urllib.quote(name.encode('utf-8'),
- _safe)))
- }, )
-
- return base
-
-class SiteAbsoluteURL(BrowserView):
- implements(IAbsoluteURL)
-
- def __unicode__(self):
- return urllib.unquote(self.__str__()).decode('utf-8')
-
- def __str__(self):
- context = self.context
- request = self.request
-
- if sameProxiedObjects(context, request.getVirtualHostRoot()):
- return request.getApplicationURL()
-
- url = request.getApplicationURL()
- name = getattr(context, '__name__', None)
- if name:
- url += '/' + urllib.quote(name.encode('utf-8'), _safe)
-
- return url
-
- __call__ = __str__
-
- def breadcrumbs(self):
- context = self.context
- request = self.request
-
- if sameProxiedObjects(context, request.getVirtualHostRoot()):
- return ({'name':'', 'url': self.request.getApplicationURL()}, )
-
- base = ({'name':'', 'url': self.request.getApplicationURL()}, )
-
- name = getattr(context, '__name__', None)
- if name:
- base += ({'name': name,
- 'url': ("%s/%s" % (base[-1]['url'],
- urllib.quote(name.encode('utf-8'),
- _safe)))
- }, )
-
- return base
+# This module has moved to zope.traversing.browser.absoluteurl
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.traversing.browser.absoluteurl',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.2
Deleted: Zope3/trunk/src/zope/app/traversing/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/traversing/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/traversing/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,82 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser">
-
- <view
- for="zope.interface.Interface"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- provides="zope.publisher.interfaces.browser.IBrowserPublisher"
- factory="zope.app.publication.traversers.SimpleComponentTraverser"
- permission="zope.Public"
- allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
- />
-
- <view
- for="zope.app.container.interfaces.IItemContainer"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- provides="zope.publisher.interfaces.browser.IBrowserPublisher"
- factory="zope.app.container.traversal.ItemTraverser"
- permission="zope.Public"
- allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
- />
-
- <view
- for="zope.app.container.interfaces.ISimpleReadContainer"
- type="zope.publisher.interfaces.browser.IBrowserRequest"
- provides="zope.publisher.interfaces.browser.IBrowserPublisher"
- factory="zope.app.container.traversal.ItemTraverser"
- permission="zope.Public"
- allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
- />
-
- <view
- for="*"
- name="absolute_url"
- factory=".AbsoluteURL"
- type="zope.publisher.interfaces.http.IHTTPRequest"
- permission="zope.Public"
- allowed_interface=".interfaces.IAbsoluteURL"
- />
-
- <view
- for="*"
- factory=".AbsoluteURL"
- type="zope.publisher.interfaces.http.IHTTPRequest"
- permission="zope.Public"
- provides=".interfaces.IAbsoluteURL"
- />
-
- <view
- for="zope.app.traversing.interfaces.IContainmentRoot"
- name="absolute_url"
- factory=".SiteAbsoluteURL"
- type="zope.publisher.interfaces.http.IHTTPRequest"
- permission="zope.Public"
- allowed_interface=".interfaces.IAbsoluteURL"
- />
-
- <view
- for="zope.app.traversing.interfaces.IContainmentRoot"
- factory=".SiteAbsoluteURL"
- type="zope.publisher.interfaces.http.IHTTPRequest"
- permission="zope.Public"
- provides=".interfaces.IAbsoluteURL"
- />
-
- <browser:page
- for="*"
- name="absolute_url"
- class=".AbsoluteURL"
- permission="zope.Public"
- allowed_interface=".interfaces.IAbsoluteURL"
- />
-
- <browser:page
- for="zope.app.traversing.interfaces.IContainmentRoot"
- name="absolute_url"
- class=".SiteAbsoluteURL"
- permission="zope.Public"
- allowed_interface=".interfaces.IAbsoluteURL"
- />
-
-</configure>
Modified: Zope3/trunk/src/zope/app/traversing/browser/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/browser/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/traversing/browser/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,44 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE
-#
-##############################################################################
-"""Browser traversal interfaces
-
-$Id$
-"""
-from zope.interface import Interface
-
-class IAbsoluteURL(Interface):
-
- def __unicode__():
- """Returns the URL as a unicode string."""
-
- def __str__():
- """Returns an ASCII string with all unicode characters url quoted."""
-
- def __repr__():
- """Get a string representation """
-
- def __call__():
- """Returns an ASCII string with all unicode characters url quoted."""
-
- def breadcrumbs():
- """Returns a tuple like ({'name':name, 'url':url}, ...)
-
- Name is the name to display for that segment of the breadcrumbs.
- URL is the link for that segment of the breadcrumbs.
- """
-
-class IAbsoluteURLAPI(Interface):
-
- def absoluteURL(ob, request):
- """Compute the absolute URL of an object """
+# This module has moved to zope.traversing.browser.absoluteurl
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.traversing.browser.absoluteurl',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/traversing/browser/interfaces.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.3
Deleted: Zope3/trunk/src/zope/app/traversing/browser/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/browser/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/traversing/browser/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,217 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Test the AbsoluteURL view
-
-$Id$
-"""
-from unittest import TestCase, main, makeSuite
-
-from zope.app import zapi
-from zope.app.container.contained import contained
-from zope.app.testing import ztapi
-from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.traversing.browser.absoluteurl import absoluteURL
-from zope.app.traversing.browser.interfaces import IAbsoluteURL
-from zope.i18n.interfaces import IUserPreferredCharsets
-from zope.interface import Interface, implements
-from zope.interface.verify import verifyObject
-from zope.publisher.browser import TestRequest
-from zope.publisher.http import IHTTPRequest, HTTPCharsets
-
-class IRoot(Interface):
- pass
-
-class Root(object):
- implements(IRoot)
-
-class TrivialContent(object):
- """Trivial content object, used because instances of object are rocks."""
-
-class TestAbsoluteURL(PlacelessSetup, TestCase):
-
- def setUp(self):
- super(TestAbsoluteURL, self).setUp()
- from zope.app.traversing.browser import AbsoluteURL, SiteAbsoluteURL
- ztapi.browserView(None, 'absolute_url', AbsoluteURL)
- ztapi.browserView(IRoot, 'absolute_url', SiteAbsoluteURL)
- ztapi.browserView(None, '', AbsoluteURL, providing=IAbsoluteURL)
- ztapi.browserView(IRoot, '', SiteAbsoluteURL, providing=IAbsoluteURL)
- ztapi.provideAdapter(IHTTPRequest, IUserPreferredCharsets,
- HTTPCharsets)
-
- def test_interface(self):
- request = TestRequest()
- content = contained(TrivialContent(), Root(), name='a')
- view = zapi.getMultiAdapter((content, request), name='absolute_url')
-
- verifyObject(IAbsoluteURL, view)
-
- def testBadObject(self):
- request = TestRequest()
- view = zapi.getMultiAdapter((42, request), name='absolute_url')
- self.assertRaises(TypeError, view.__str__)
- self.assertRaises(TypeError, absoluteURL, 42, request)
-
- def testNoContext(self):
- request = TestRequest()
- view = zapi.getMultiAdapter((Root(), request), name='absolute_url')
- self.assertEqual(str(view), 'http://127.0.0.1')
- self.assertEqual(absoluteURL(Root(), request), 'http://127.0.0.1')
-
- def testBasicContext(self):
- request = TestRequest()
-
- content = contained(TrivialContent(), Root(), name='a')
- content = contained(TrivialContent(), content, name='b')
- content = contained(TrivialContent(), content, name='c')
- view = zapi.getMultiAdapter((content, request), name='absolute_url')
- self.assertEqual(str(view), 'http://127.0.0.1/a/b/c')
- self.assertEqual(absoluteURL(content, request),
- 'http://127.0.0.1/a/b/c')
-
- breadcrumbs = view.breadcrumbs()
- self.assertEqual(breadcrumbs,
- ({'name': '', 'url': 'http://127.0.0.1'},
- {'name': 'a', 'url': 'http://127.0.0.1/a'},
- {'name': 'b', 'url': 'http://127.0.0.1/a/b'},
- {'name': 'c', 'url': 'http://127.0.0.1/a/b/c'},
- ))
-
- def testBasicContext_unicode(self):
- #Tests so that AbsoluteURL handle unicode names as well
- request = TestRequest()
- root = Root()
- root.__name__ = u'\u0439'
-
- content = contained(TrivialContent(), root, name=u'\u0442')
- content = contained(TrivialContent(), content, name=u'\u0435')
- content = contained(TrivialContent(), content, name=u'\u0441')
- view = zapi.getMultiAdapter((content, request), name='absolute_url')
- self.assertEqual(str(view),
- 'http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81')
- self.assertEqual(view(),
- 'http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81')
- self.assertEqual(unicode(view),
- u'http://127.0.0.1/\u0439/\u0442/\u0435/\u0441')
- self.assertEqual(absoluteURL(content, request),
- 'http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81')
-
- breadcrumbs = view.breadcrumbs()
- self.assertEqual(breadcrumbs,
- ({'name': '', 'url': 'http://127.0.0.1'},
- {'name': u'\u0439', 'url': 'http://127.0.0.1/%D0%B9'},
- {'name': u'\u0442',
- 'url': 'http://127.0.0.1/%D0%B9/%D1%82'},
- {'name': u'\u0435',
- 'url': 'http://127.0.0.1/%D0%B9/%D1%82/%D0%B5'},
- {'name': u'\u0441',
- 'url':
- 'http://127.0.0.1/%D0%B9/%D1%82/%D0%B5/%D1%81'},
- ))
-
- def testRetainSkin(self):
- request = TestRequest()
- request._traversed_names = ('a', 'b')
- request._app_names = ('++skin++test', )
-
- content = contained(TrivialContent(), Root(), name='a')
- content = contained(TrivialContent(), content, name='b')
- content = contained(TrivialContent(), content, name='c')
- view = zapi.getMultiAdapter((content, request), name='absolute_url')
- base = 'http://127.0.0.1/++skin++test'
- self.assertEqual(str(view), base + '/a/b/c')
-
- breadcrumbs = view.breadcrumbs()
- self.assertEqual(breadcrumbs,
- ({'name': '', 'url': base + ''},
- {'name': 'a', 'url': base + '/a'},
- {'name': 'b', 'url': base + '/a/b'},
- {'name': 'c', 'url': base + '/a/b/c'},
- ))
-
- def testVirtualHosting(self):
- request = TestRequest()
-
- vh_root = TrivialContent()
- content = contained(vh_root, Root(), name='a')
- request._vh_root = content
- content = contained(TrivialContent(), content, name='b')
- content = contained(TrivialContent(), content, name='c')
- view = zapi.getMultiAdapter((content, request), name='absolute_url')
- self.assertEqual(str(view), 'http://127.0.0.1/b/c')
-
- breadcrumbs = view.breadcrumbs()
- self.assertEqual(breadcrumbs,
- ({'name': '', 'url': 'http://127.0.0.1'},
- {'name': 'b', 'url': 'http://127.0.0.1/b'},
- {'name': 'c', 'url': 'http://127.0.0.1/b/c'},
- ))
-
- def testVirtualHostingWithVHElements(self):
- request = TestRequest()
-
- vh_root = TrivialContent()
- content = contained(vh_root, Root(), name='a')
- request._vh_root = content
- content = contained(TrivialContent(), content, name='b')
- content = contained(TrivialContent(), content, name='c')
- view = zapi.getMultiAdapter((content, request), name='absolute_url')
- self.assertEqual(str(view), 'http://127.0.0.1/b/c')
-
- breadcrumbs = view.breadcrumbs()
- self.assertEqual(breadcrumbs,
- ({'name': '', 'url': 'http://127.0.0.1'},
- {'name': 'b', 'url': 'http://127.0.0.1/b'},
- {'name': 'c', 'url': 'http://127.0.0.1/b/c'},
- ))
-
- def testVirtualHostingInFront(self):
- request = TestRequest()
-
- root = Root()
- request._vh_root = contained(root, root, name='')
- content = contained(root, None)
- content = contained(TrivialContent(), content, name='a')
- content = contained(TrivialContent(), content, name='b')
- content = contained(TrivialContent(), content, name='c')
- view = zapi.getMultiAdapter((content, request), name='absolute_url')
- self.assertEqual(str(view), 'http://127.0.0.1/a/b/c')
-
- breadcrumbs = view.breadcrumbs()
- self.assertEqual(breadcrumbs,
- ({'name': '', 'url': 'http://127.0.0.1'},
- {'name': 'a', 'url': 'http://127.0.0.1/a'},
- {'name': 'b', 'url': 'http://127.0.0.1/a/b'},
- {'name': 'c', 'url': 'http://127.0.0.1/a/b/c'},
- ))
-
- def testNoContextInformation(self):
- request = TestRequest()
- view = zapi.getMultiAdapter((None, request), name='absolute_url')
- self.assertEqual(str(view), 'http://127.0.0.1')
- self.assertEqual(absoluteURL(None, request), 'http://127.0.0.1')
-
- def testVirtualHostingWithoutContextInformation(self):
- request = TestRequest()
- request._vh_root = contained(TrivialContent(), Root(), name='a')
- view = zapi.getMultiAdapter((None, request), name='absolute_url')
- self.assertEqual(str(view), 'http://127.0.0.1')
- self.assertEqual(absoluteURL(None, request), 'http://127.0.0.1')
-
-
-def test_suite():
- return makeSuite(TestAbsoluteURL)
-
-if __name__=='__main__':
- main(defaultTest='test_suite')
Deleted: Zope3/trunk/src/zope/app/traversing/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/traversing/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/traversing/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,117 +0,0 @@
-<configure xmlns="http://namespaces.zope.org/zope">
-
-<adapter
- for="*"
- factory="zope.app.traversing.adapters.Traverser"
- provides="zope.app.traversing.interfaces.ITraverser" />
-
-<adapter
- for="*"
- factory="zope.app.traversing.adapters.DefaultTraversable"
- provides="zope.app.traversing.interfaces.ITraversable" />
-
-<adapter
- provides="zope.app.traversing.interfaces.IPhysicallyLocatable"
- for="zope.app.traversing.interfaces.IContainmentRoot"
- factory="zope.app.traversing.adapters.RootPhysicallyLocatable" />
-
-<adapter
- name="etc"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.etc"
- />
-<view
- name="etc"
- type="zope.interface.Interface"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.etc"
- />
-
-<adapter
- name="attribute"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.attr"
- />
-<view
- name="attribute"
- type="zope.interface.Interface"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.attr"
- />
-
-<adapter
- name="adapter"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.adapter"
- />
-<view
- name="adapter"
- type="zope.interface.Interface"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.adapter"
- />
-
-<adapter
- name="item"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.item"
- />
-<view
- name="item" type="*"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.item"
- />
-
-<adapter
- name="acquire"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.acquire"
- />
-<view
- name="acquire" type="*"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.acquire"
- />
-
-<view
- name="view" type="*"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.view"
- />
-
-<view
- name="resource" type="*"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.resource"
- />
-
-<adapter
- name="lang"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.lang"
- />
-<view
- name="lang" type="*"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.lang"
- />
-
-<view
- name="skin" type="*"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.skin"
- />
-
-<view
- name="vh" type="*"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.vh"
- />
-
-<view
- name="debug" type="*"
- provides="zope.app.traversing.interfaces.ITraversable" for="*"
- factory="zope.app.traversing.namespace.debug"
- />
-
-</configure>
Modified: Zope3/trunk/src/zope/app/traversing/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/traversing/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,200 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Interfaces to do with traversing.
-
-$Id$
-"""
-from zope.interface import Interface
-
-class TraversalError(KeyError, LookupError):
- """There is no object for the name given to a traversal
- """
-
-class IContainmentRoot(Interface):
- """Marker interface to designate root objects
- """
-
-class INamespaceHandler(Interface):
-
- def __call__(name, object, request):
- """Access a name in a namespace
-
- The name lookup usually depends on an object and/or a
- request. If an object or request is unavailable, None will be passed.
-
- The parameters provided, are passed as a sequence of
- name, value items. The 'pname' argument has the original name
- before parameters were removed.
-
- It is not the responsibility of the handler to give the return value a
- location.
- """
-
-class IPhysicallyLocatable(Interface):
- """Objects that have a physical location in a containment hierarchy.
- """
-
- def getRoot():
- """Return the physical root object
- """
-
- def getPath():
- """Return the physical path to the object as a string.
- """
-
- def getName():
- """Return the last segment of the physical path.
- """
-
- def getNearestSite():
- """Return the site the object is contained in
-
- If the object is a site, the object itself is returned.
- """
-
-class ITraversable(Interface):
- """To traverse an object, this interface must be provided"""
-
- def traverse(name, furtherPath):
- """Get the next item on the path
-
- Should return the item corresponding to 'name' or raise
- TraversalError where appropriate.
-
- furtherPath is a list of names still to be traversed. This method is
- allowed to change the contents of furtherPath.
-
- """
-
-_RAISE_KEYERROR = object()
-
-class ITraverser(Interface):
- """Provide traverse features"""
-
- def traverse(path, default=_RAISE_KEYERROR, request=None):
- """
- Return an object given a path.
-
- Path is either an immutable sequence of strings or a slash ('/')
- delimited string.
-
- If the first string in the path sequence is an empty string,
- or the path begins with a '/', start at the root. Otherwise the path
- is relative to the current context.
-
- If the object is not found, return 'default' argument.
-
- 'request' is passed in when traversing from presentation code. This
- allows paths like @@foo to work.
- """
-
-class ITraversalAPI(Interface):
- """Common API functions to ease traversal computations
- """
-
- def joinPath(path, *args):
- """Join the given relative paths to the given path.
-
- Returns a unicode path.
-
- The path should be well-formed, and not end in a '/' unless it is
- the root path. It can be either a string (ascii only) or unicode.
- The positional arguments are relative paths to be added to the
- path as new path segments. The path may be absolute or relative.
-
- A segment may not start with a '/' because that would be confused
- with an absolute path. A segment may not end with a '/' because we
- do not allow '/' at the end of relative paths. A segment may
- consist of . or .. to mean "the same place", or "the parent path"
- respectively. A '.' should be removed and a '..' should cause the
- segment to the left to be removed. joinPath('/', '..') should
- raise an exception.
- """
-
- def getPath(obj):
- """Returns a string representing the physical path to the object.
- """
-
- def getRoot(obj):
- """Returns the root of the traversal for the given object.
- """
-
- def traverse(object, path, default=None, request=None):
- """Traverse 'path' relative to the given object.
-
- 'path' is a string with path segments separated by '/'.
-
- 'request' is passed in when traversing from presentation code. This
- allows paths like @@foo to work.
-
- Raises TraversalError if path cannot be found
-
- Note: calling traverse with a path argument taken from an untrusted
- source, such as an HTTP request form variable, is a bad idea.
- It could allow a maliciously constructed request to call
- code unexpectedly.
- Consider using traverseName instead.
- """
-
- def traverseName(obj, name, default=None, traversable=None,
- request=None):
- """Traverse a single step 'name' relative to the given object.
-
- 'name' must be a string. '.' and '..' are treated specially, as well as
- names starting with '@' or '+'. Otherwise 'name' will be treated as a
- single path segment.
-
- You can explicitly pass in an ITraversable as the
- 'traversable' argument. If you do not, the given object will
- be adapted to ITraversable.
-
- 'request' is passed in when traversing from presentation code. This
- allows paths like @@foo to work.
-
- Raises TraversalError if path cannot be found and 'default' was
- not provided.
-
- """
-
- def getName(obj):
- """Get the name an object was traversed via
- """
-
- def getParent(obj):
- """Returns the container the object was traversed via.
-
- Returns None if the object is a containment root.
- Raises TypeError if the object doesn't have enough context to get the
- parent.
- """
-
- def getParents(obj):
- """Returns a list starting with the given object's parent followed by
- each of its parents.
-
- Raises a TypeError if the context doesn't go all the way down to
- a containment root.
- """
-
- def canonicalPath(path_or_object):
- """Returns a canonical absolute unicode path for the path or object.
-
- Resolves segments that are '.' or '..'.
-
- Raises ValueError if a badly formed path is given.
- """
-
-class IPathAdapter(Interface):
- """Marker interface for adapters to be used in paths
- """
+# This module has moved to zope.traversing.interfaces
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.traversing.interfaces',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/traversing/interfaces.py
___________________________________________________________________
Name: cvs2svn:cvs-rev
- 1.2
Deleted: Zope3/trunk/src/zope/app/traversing/namespace.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/namespace.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/traversing/namespace.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,600 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""URL Namespace Implementations
-
-$Id$
-"""
-import re
-
-import zope.deprecation
-import zope.component
-import zope.interface
-from zope.i18n.interfaces import IModifiableUserPreferredLanguages
-from zope.component.exceptions import ComponentLookupError
-from zope.interface import providedBy, directlyProvides, directlyProvidedBy
-from zope.publisher.interfaces.browser import IBrowserSkinType
-from zope.security.proxy import removeSecurityProxy
-
-from zope.app.publisher.browser import applySkin
-from zope.app.traversing.interfaces import ITraversable, IPathAdapter
-from zope.app.traversing.interfaces import TraversalError
-
-# BBB Backward Compatibility (Can go away in 3.3)
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError
-zope.deprecation.__show__.on()
-
-import warnings
-
-
-class UnexpectedParameters(TraversalError):
- "Unexpected namespace parameters were provided."
-
-class ExcessiveDepth(TraversalError):
- "Too many levels of containment. We don't believe them."
-
-def namespaceLookup(ns, name, object, request=None):
- """Lookup a value from a namespace
-
- We look up a value using a view or an adapter, depending on
- whether a request is passed.
-
- Let's start with adapter-based transersal. We're going to use the
- component architecture, so we'll need to initialize it:
-
- >>> from zope.app.testing.placelesssetup import setUp, tearDown
- >>> setUp()
-
- >>> class I(zope.interface.Interface):
- ... 'Test interface'
- >>> class C(object):
- ... zope.interface.implements(I)
-
- We'll register a simple testing adapter:
-
- >>> class Adapter(object):
- ... def __init__(self, context):
- ... self.context = context
- ... def traverse(self, name, remaining):
- ... return name+'42'
-
- >>> from zope.app.testing import ztapi
- >>> ztapi.provideAdapter(I, ITraversable, Adapter, 'foo')
-
- Then given an object, we can traverse it with a
- namespace-qualified name:
-
- >>> namespaceLookup('foo', 'bar', C())
- 'bar42'
-
- If we give an invalid namespace, we'll get a not found error:
-
- >>> namespaceLookup('fiz', 'bar', C())
- Traceback (most recent call last):
- ...
- TraversalError: '++fiz++bar'
-
- We'll get the same thing if we provide a request:
-
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> namespaceLookup('foo', 'bar', C(), request)
- Traceback (most recent call last):
- ...
- TraversalError: '++foo++bar'
-
- We need to provide a view:
-
- >>> class View(object):
- ... def __init__(self, context, request):
- ... pass
- ... def traverse(self, name, remaining):
- ... return name+'fromview'
- >>> ztapi.browserView(I, 'foo', View, providing=ITraversable)
-
- >>> namespaceLookup('foo', 'bar', C(), request)
- 'barfromview'
-
- >>> tearDown()
- """
-
- if request is not None:
- traverser = zope.component.queryMultiAdapter((object, request),
- ITraversable, ns)
- else:
- traverser = zope.component.queryAdapter(object, ITraversable, ns)
-
- if traverser is None:
- raise TraversalError("++%s++%s" % (ns, name))
-
- return traverser.traverse(name, ())
-
-
-namespace_pattern = re.compile('[+][+]([a-zA-Z0-9_]+)[+][+]')
-
-def nsParse(name):
- """Parse a namespace-qualified name into a namespace name and a name
-
- Returns the namespace name and a name.
-
- A namespace-qualified name is usually of the form ++ns++name, as in:
-
- >>> nsParse('++acquire++foo')
- ('acquire', 'foo')
-
- The part inside the +s must be an identifier, so:
-
- >>> nsParse('++hello world++foo')
- ('', '++hello world++foo')
- >>> nsParse('+++acquire+++foo')
- ('', '+++acquire+++foo')
-
-
- But it may also be a @@foo, which implies the view namespace:
-
- >>> nsParse('@@foo')
- ('view', 'foo')
-
- >>> nsParse('@@@foo')
- ('view', '@foo')
-
- >>> nsParse('@foo')
- ('', '@foo')
-
- """
-
- ns = ''
- if name.startswith('@@'):
- ns = 'view'
- name = name[2:]
- else:
- match = namespace_pattern.match(name)
- if match:
- prefix, ns = match.group(0, 1)
- name = name[len(prefix):]
-
- return ns, name
-
-def getResource(site, name, request):
- resource = queryResource(site, name, request)
- if resource is None:
- raise TraversalError(site, name)
- return resource
-
-def queryResource(site, name, request, default=None):
- resource = zope.component.queryAdapter(request, name=name)
- if resource is None:
- return default
-
- # We need to set the __parent__ and __name__. We need the unproxied
- # resource to do this. We still return the proxied resource.
- r = removeSecurityProxy(resource)
-
- r.__parent__ = site
- r.__name__ = name
-
- return resource
-
-# ---- namespace processors below ----
-
-class SimpleHandler(object):
-
- zope.interface.implements(ITraversable)
-
- def __init__(self, context, request=None):
- """Simple handlers can be used as adapters or views
-
- They ignore their second constructor arg and store the first
- one in their context attr:
-
- >>> SimpleHandler(42).context
- 42
-
- >>> SimpleHandler(42, 43).context
- 42
- """
- self.context = context
-
-class acquire(SimpleHandler):
- """Traversal adapter for the acquire namespace
- """
-
- def traverse(self, name, remaining):
- """Acquire a name
-
- Let's set up some example data:
-
- >>> class testcontent(object):
- ... zope.interface.implements(ITraversable)
- ... def traverse(self, name, remaining):
- ... v = getattr(self, name, None)
- ... if v is None:
- ... raise TraversalError(name)
- ... return v
- ... def __repr__(self):
- ... return 'splat'
-
- >>> ob = testcontent()
- >>> ob.a = 1
- >>> ob.__parent__ = testcontent()
- >>> ob.__parent__.b = 2
- >>> ob.__parent__.__parent__ = testcontent()
- >>> ob.__parent__.__parent__.c = 3
-
- And acquire some names:
-
- >>> adapter = acquire(ob)
-
- >>> adapter.traverse('a', ())
- 1
-
- >>> adapter.traverse('b', ())
- 2
-
- >>> adapter.traverse('c', ())
- 3
-
- >>> adapter.traverse('d', ())
- Traceback (most recent call last):
- ...
- TraversalError: (splat, 'd')
- """
- i = 0
- ob = self.context
- while i < 200:
- i += 1
- traversable = ITraversable(ob, None)
- if traversable is not None:
- try:
- # ??? what do we do if the path gets bigger?
- path = []
- next = traversable.traverse(name, path)
- if path:
- continue
- except TraversalError:
- pass
-
- except NotFoundError, v: # BBB Backward Compatibility
- warnings.warn(
- "A %s instance raised a NotFoundError in "
- "traverse. Raising NotFoundError in this "
- "method is deprecated and will no-longer be supported "
- "staring in Zope 3.3. TraversalError should "
- "be raised instead."
- % traversable.__class__.__name__,
- DeprecationWarning)
- else:
- return next
-
- ob = getattr(ob, '__parent__', None)
- if ob is None:
- raise TraversalError(self.context, name)
-
- raise ExcessiveDepth(self.context, name)
-
-class attr(SimpleHandler):
-
- def traverse(self, name, ignored):
- """Attribute traversal adapter
-
- This adapter just provides traversal to attributes:
-
- >>> ob = {'x': 1}
- >>> adapter = attr(ob)
- >>> adapter.traverse('keys', ())()
- ['x']
-
- """
- return getattr(self.context, name)
-
-class item(SimpleHandler):
-
- def traverse(self, name, ignored):
- """Item traversal adapter
-
- This adapter just provides traversal to items:
-
- >>> ob = {'x': 42}
- >>> adapter = item(ob)
- >>> adapter.traverse('x', ())
- 42
- """
- return self.context[name]
-
-from zope.app.applicationcontrol.applicationcontrol \
- import applicationController
-from zope.app.traversing.interfaces import IContainmentRoot
-
-class etc(SimpleHandler):
-
- def traverse(self, name, ignored):
- # TODO:
- # This is here now to allow us to get site managers from a
- # separate namespace from the content. We add and etc
- # namespace to allow us to handle misc objects. We'll apply
- # YAGNI for now and hard code this. We'll want something more
- # general later. We were thinking of just calling "get"
- # methods, but this is probably too magic. In particular, we
- # will treat returned objects as sub-objects wrt security and
- # not all get methods may satisfy this assumption. It might be
- # best to introduce some sort of etc registry.
-
- ob = self.context
-
- if (name in ('process', 'ApplicationController')
- and IContainmentRoot.providedBy(ob)):
- return applicationController
-
- if name not in ('site',):
- raise TraversalError(ob, name)
-
- method_name = "getSiteManager"
- method = getattr(ob, method_name, None)
- if method is None:
- raise TraversalError(ob, name)
-
- try:
- return method()
- except ComponentLookupError:
- raise TraversalError(ob, name)
-
-
-class view(object):
-
- zope.interface.implements(ITraversable)
-
- def __init__(self, context, request):
- self.context = context
- self.request = request
-
- def traverse(self, name, ignored):
- view = zope.component.queryMultiAdapter((self.context, self.request),
- name=name)
- if view is None:
- raise TraversalError(self.context, name)
-
- return view
-
-class resource(view):
-
- def traverse(self, name, ignored):
- # The context is important here, since it becomes the parent of the
- # resource, which is needed to generate the absolute URL.
- return getResource(self.context, name, self.request)
-
-class lang(view):
-
- def traverse(self, name, ignored):
- self.request.shiftNameToApplication()
- languages = IModifiableUserPreferredLanguages(self.request)
- languages.setPreferredLanguages([name])
- return self.context
-
-class skin(view):
-
- def traverse(self, name, ignored):
- self.request.shiftNameToApplication()
- skin = zope.component.getUtility(IBrowserSkinType, name)
- applySkin(self.request, skin)
- return self.context
-
-class vh(view):
-
- def traverse(self, name, ignored):
-
- request = self.request
-
- traversal_stack = request.getTraversalStack()
- app_names = []
-
- if name:
- try:
- proto, host, port = name.split(":")
- except ValueError:
- raise ValueError("Vhost directive should have the form "
- "++vh++protocol:host:port")
-
- request.setApplicationServer(host, proto, port)
-
- if '++' in traversal_stack:
- segment = traversal_stack.pop()
- while segment != '++':
- app_names.append(segment)
- segment = traversal_stack.pop()
- request.setTraversalStack(traversal_stack)
- else:
- raise ValueError(
- "Must have a path element '++' after a virtual host "
- "directive.")
-
- request.setVirtualHostRoot(app_names)
-
- return self.context
-
-
-class adapter(SimpleHandler):
-
- def traverse(self, name, ignored):
- """Adapter traversal adapter
-
- This adapter provides traversal to named adapters registered to
- provide IPathAdapter.
-
- To demonstrate this, we need to register some adapters:
-
- >>> from zope.app.testing.placelesssetup import setUp, tearDown
- >>> setUp()
- >>> from zope.app.testing import ztapi
- >>> def adapter1(ob):
- ... return 1
- >>> def adapter2(ob):
- ... return 2
- >>> ztapi.provideAdapter(None, IPathAdapter, adapter1, 'a1')
- >>> ztapi.provideAdapter(None, IPathAdapter, adapter2, 'a2')
-
- Now, with these adapters in place, we can use the traversal adapter:
-
- >>> ob = object()
- >>> adapter = adapter(ob)
- >>> adapter.traverse('a1', ())
- 1
- >>> adapter.traverse('a2', ())
- 2
- >>> try:
- ... adapter.traverse('bob', ())
- ... except TraversalError:
- ... print 'no adapter'
- no adapter
-
- Cleanup:
-
- >>> tearDown()
- """
- try:
- return zope.component.getAdapter(self.context, IPathAdapter, name)
- except ComponentLookupError:
- raise TraversalError(self.context, name)
-
-
-class debug(view):
-
- def traverse(self, name, ignored):
- """Debug traversal adapter
-
- This adapter allows debugging flags to be set in the request.
- See IDebugFlags.
-
- Setup for demonstration:
-
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> ob = object()
- >>> adapter = debug(ob, request)
-
- in debug mode, ++debug++source enables source annotations
-
- >>> request.debug.sourceAnnotations
- False
- >>> adapter.traverse('source', ()) is ob
- True
- >>> request.debug.sourceAnnotations
- True
-
- ++debug++tal enables TAL markup in output
-
- >>> request.debug.showTAL
- False
- >>> adapter.traverse('tal', ()) is ob
- True
- >>> request.debug.showTAL
- True
-
- ++debug++errors enables tracebacks (by switching to debug skin)
-
- >>> from zope.app.testing import ztapi
- >>> from zope.publisher.interfaces.browser import IBrowserRequest
-
- >>> class Debug(IBrowserRequest):
- ... pass
- >>> directlyProvides(Debug, IBrowserSkinType)
- >>> ztapi.provideUtility(IBrowserSkinType, Debug, 'Debug')
-
- >>> Debug.providedBy(request)
- False
- >>> adapter.traverse('errors', ()) is ob
- True
- >>> Debug.providedBy(request)
- True
-
- You can specify several flags separated by commas
-
- >>> adapter.traverse('source,tal', ()) is ob
- True
-
- Unknown flag names cause exceptions
-
- >>> try:
- ... adapter.traverse('badflag', ())
- ... except ValueError:
- ... print 'unknown debugging flag'
- unknown debugging flag
-
- """
- if __debug__:
- request = self.request
- for flag in name.split(','):
- if flag == 'source':
- request.debug.sourceAnnotations = True
- elif flag == 'tal':
- request.debug.showTAL = True
- elif flag == 'errors':
- # TODO: I am not sure this is the best solution. What
- # if we want to enable tracebacks when also trying to
- # debug a different skin?
- skin = zope.component.getUtility(IBrowserSkinType, 'Debug')
- directlyProvides(request, providedBy(request)+skin)
- else:
- raise ValueError("Unknown debug flag: %s" % flag)
- return self.context
- else:
- raise ValueError("Debug flags only allowed in debug mode")
-
- if not __debug__:
- # If not in debug mode, we should get an error:
- traverse.__doc__ = """Disabled debug traversal adapter
-
- This adapter allows debugging flags to be set in the request,
- but it is disabled because Python was run with -O.
-
- Setup for demonstration:
-
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> ob = object()
- >>> adapter = debug(ob, request)
-
- in debug mode, ++debug++source enables source annotations
-
- >>> request.debug.sourceAnnotations
- False
- >>> adapter.traverse('source', ()) is ob
- Traceback (most recent call last):
- ...
- ValueError: Debug flags only allowed in debug mode
-
- ++debug++tal enables TAL markup in output
-
- >>> request.debug.showTAL
- False
- >>> adapter.traverse('tal', ()) is ob
- Traceback (most recent call last):
- ...
- ValueError: Debug flags only allowed in debug mode
-
- ++debug++errors enables tracebacks (by switching to debug skin)
-
- >>> Debug.providedBy(request)
- False
- >>> adapter.traverse('errors', ()) is ob
- Traceback (most recent call last):
- ...
- ValueError: Debug flags only allowed in debug mode
-
- You can specify several flags separated by commas
-
- >>> adapter.traverse('source,tal', ()) is ob
- Traceback (most recent call last):
- ...
- ValueError: Debug flags only allowed in debug mode
- """
Modified: Zope3/trunk/src/zope/app/tree/adapters.py
===================================================================
--- Zope3/trunk/src/zope/app/tree/adapters.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/tree/adapters.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,12 +21,12 @@
$Id$
"""
from zope.interface import Interface, implements
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
from zope.security import canAccess
from zope.security.interfaces import Unauthorized
+from zope.location.interfaces import ILocation
from zope.app import zapi
-from zope.app.location.interfaces import ILocation
from zope.app.container.interfaces import IReadContainer
from zope.app.component.interfaces import ISite
Modified: Zope3/trunk/src/zope/app/tree/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/tree/browser/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/tree/browser/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,14 +17,13 @@
"""
__docformat__ = 'restructuredtext'
+import zope.component
from zope.publisher.interfaces.browser import IBrowserRequest
-from zope.app.rotterdam import Rotterdam
+from zope.publisher.browser import BrowserView
-from zope.app import zapi
-from zope.app.publisher.browser import BrowserView
-
from zope.app.tree.interfaces import ITreeStateEncoder
from zope.app.tree.node import Node
+from zope.app.rotterdam import Rotterdam
class IStaticTreeLayer(IBrowserRequest):
"""Layer that we can register our own navigation macro for."""
@@ -46,7 +45,7 @@
root = self.context
expanded_nodes = []
if tree_state is not None:
- encoder = zapi.getUtility(ITreeStateEncoder)
+ encoder = zope.component.getUtility(ITreeStateEncoder)
expanded_nodes = encoder.decodeTreeState(tree_state)
node = Node(root, expanded_nodes, filter)
node.expand()
Modified: Zope3/trunk/src/zope/app/tree/browser/cookie.py
===================================================================
--- Zope3/trunk/src/zope/app/tree/browser/cookie.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/tree/browser/cookie.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,12 +15,13 @@
$Id$
"""
-from zope.app import zapi
+import zope.traversing.api
+from zope.traversing.interfaces import IContainmentRoot
+from zope.component.interfaces import IComponentLookup
+
from zope.app.container.interfaces import IContainer
from zope.app.folder.interfaces import IFolder
from zope.app.component.interfaces import ISite
-from zope.component.interfaces import ISiteManager
-from zope.app.traversing.interfaces import IContainmentRoot
from zope.app.tree.filters import OnlyInterfacesFilter
from zope.app.tree.browser import StatefulTreeView
Modified: Zope3/trunk/src/zope/app/tree/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/tree/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/tree/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -30,7 +30,7 @@
<adapter
provides=".interfaces.IUniqueId"
- for="zope.app.location.interfaces.ILocation"
+ for="zope.location.interfaces.ILocation"
factory=".adapters.LocationUniqueId"
/>
Modified: Zope3/trunk/src/zope/app/tree/tests/test_adapters.py
===================================================================
--- Zope3/trunk/src/zope/app/tree/tests/test_adapters.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/tree/tests/test_adapters.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,19 +18,17 @@
import unittest
from zope.interface import implements, directlyProvides
-from zope.component.exceptions import ComponentLookupError
+from zope.component.interfaces import ComponentLookupError
from zope.security.checker import defineChecker
from zope.security.checker import NamesChecker
+from zope.traversing.interfaces import IContainmentRoot
+from zope.location.interfaces import ILocation
-from zope.app.location.interfaces import ILocation
-from zope.app.container.interfaces import IReadContainer
from zope.app.component.interfaces import ISite
-from zope.app.traversing.interfaces import IContainmentRoot
-
+from zope.app.container.interfaces import IReadContainer
from zope.app.container.sample import SampleContainer
from zope.app.container.contained import setitem
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app import zapi
from zope.app.testing import ztapi
from zope.app.tree.interfaces import IUniqueId, IChildObjects, \
Modified: Zope3/trunk/src/zope/app/twisted/ftp/ftp.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/ftp/ftp.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/twisted/ftp/ftp.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,11 +20,10 @@
from types import StringTypes
from zope.interface import implements
-
from zope.publisher.interfaces import NotFound
from zope.security.interfaces import Unauthorized
from zope.exceptions import DuplicationError
-from zope.app.copypastemove import ItemNotFoundError
+from zope.copypastemove import ItemNotFoundError
from twisted.internet import threads, defer
from twisted.protocols import ftp
Modified: Zope3/trunk/src/zope/app/twisted/ftp/tests/demofs.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/ftp/tests/demofs.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/twisted/ftp/tests/demofs.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -14,14 +14,14 @@
$Id: demofs.py 27459 2004-09-07 01:45:52Z shane $
"""
import posixpath
+
+from zope.interface import implements
from zope.security.interfaces import Unauthorized
from zope.publisher.interfaces import NotFound
-
from zope.exceptions import DuplicationError
-from zope.app.copypastemove import ItemNotFoundError
+from zope.copypastemove import ItemNotFoundError
from zope.app.twisted.interfaces import IFileSystem
-from zope.interface import implements
execute = 1
read = 2
Modified: Zope3/trunk/src/zope/app/twisted/tests/test_inputbuffering.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/tests/test_inputbuffering.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/twisted/tests/test_inputbuffering.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -106,7 +106,6 @@
os.mkdir(self.dir)
self.path = sys.path
- self.python = sys.executable
self.config = os.path.join(self.dir, 'zope.conf')
self.zeo_port = zeo_port
self.port = ZEO.tests.testZEO.get_port()
@@ -189,7 +188,8 @@
def start(self):
os.spawnv(os.P_NOWAIT, sys.executable,
- (sys.executable, os.path.join(self.dir, "runzope"), ),
+ (sys.executable, '-Wignore',
+ os.path.join(self.dir, "runzope"), ),
)
def stop(self):
Modified: Zope3/trunk/src/zope/app/twisted/tests/test_zeo.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/tests/test_zeo.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/twisted/tests/test_zeo.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -125,7 +125,6 @@
os.mkdir(self.dir)
self.path = sys.path
- self.python = sys.executable
self.config = os.path.join(self.dir, 'zope.conf')
self.zeo_port = zeo_port
self.port = ZEO.tests.testZEO.get_port()
@@ -203,7 +202,8 @@
def start(self):
os.spawnv(os.P_NOWAIT, sys.executable,
- (sys.executable, os.path.join(self.dir, "runzope"), ),
+ (sys.executable, '-Wignore',
+ os.path.join(self.dir, "runzope"), ),
)
def stop(self):
@@ -306,7 +306,7 @@
def start(self):
return os.spawnv(os.P_WAIT, sys.executable,
- (sys.executable,
+ (sys.executable, '-Wignore',
os.path.join(self.dir, "runzope"),
)
)
Modified: Zope3/trunk/src/zope/app/undo/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/undo/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/undo/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,28 +18,19 @@
from datetime import datetime
import transaction
-
-import zope.deprecation
+import zope.component
from zope.interface import implements
-from zope.app.security.interfaces import PrincipalLookupError
+from zope.traversing.interfaces import IPhysicallyLocatable
-from zope.app import zapi
from zope.app.undo.interfaces import IUndoManager, UndoError
-from zope.app.traversing.interfaces import IPhysicallyLocatable
from zope.app.security.principalregistry import principalRegistry
from zope.app.security.interfaces import IPrincipal
+from zope.app.security.interfaces import PrincipalLookupError
-# BBB Backward Compatibility (Can go away in 3.3)
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError
-zope.deprecation.__show__.on()
-import warnings
-
-
def undoSetup(event):
# setup undo functionality
- sm = zapi.getGlobalSiteManager()
- sm.provideUtility(IUndoManager, ZODBUndoManager(event.database))
+ sm = zope.component.getGlobalSiteManager()
+ sm.registerUtility(ZODBUndoManager(event.database), IUndoManager)
class Prefix(unicode):
"""A prefix is equal to any string it is a prefix of.
@@ -158,15 +149,6 @@
except PrincipalLookupError:
# principals might have passed away
pass
- except NotFoundError: # BBB Backward Compatibility
- warnings.warn(
- "A %s instance raised a NotFoundError in "
- "getPrincipals. Raising NotFoundError in this "
- "method is deprecated and will no-longer be supported "
- "staring in Zope 3.3. PrincipalLookupError should "
- "be raised instead."
- % principalRegistry.__class__.__name__,
- DeprecationWarning)
return entries
def undoTransactions(self, ids):
Modified: Zope3/trunk/src/zope/app/undo/browser.py
===================================================================
--- Zope3/trunk/src/zope/app/undo/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/undo/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,10 +15,9 @@
$Id$
"""
+import zope.component
from zope.security.interfaces import ForbiddenAttribute
-
-from zope.app import zapi
-from zope.app.publisher.browser import BrowserView
+from zope.publisher.browser import BrowserView
from zope.app.undo.interfaces import IUndoManager
class UndoView(BrowserView):
@@ -29,7 +28,7 @@
transaction is an undo transaction.
"""
request = self.request
- undo = zapi.getUtility(IUndoManager)
+ undo = zope.component.getUtility(IUndoManager)
txn_info = undo.getPrincipalTransactions(request.principal, first=0,
last=1)
if txn_info:
@@ -40,7 +39,7 @@
"""Undo the authenticated principal's last transaction and
return where he/she came from"""
request = self.request
- undo = zapi.getUtility(IUndoManager)
+ undo = zope.component.getUtility(IUndoManager)
txn_info = undo.getPrincipalTransactions(request.principal, first=0,
last=1)
if txn_info:
@@ -51,14 +50,14 @@
def undoAllTransactions(self, ids):
"""Undo transactions specified in 'ids'."""
- undo = zapi.getUtility(IUndoManager)
+ undo = zope.component.getUtility(IUndoManager)
undo.undoTransactions(ids)
self._redirect()
def undoPrincipalTransactions(self, ids):
"""Undo transactions that were issued by the authenticated
user specified in 'ids'."""
- undo = zapi.getUtility(IUndoManager)
+ undo = zope.component.getUtility(IUndoManager)
undo.undoPrincipalTransactions(self.request.principal, ids)
self._redirect()
@@ -70,13 +69,13 @@
context = None
if not showall:
context = self.context
- undo = zapi.getUtility(IUndoManager)
+ undo = zope.component.getUtility(IUndoManager)
return undo.getTransactions(context, first, last)
def getPrincipalTransactions(self, first=0, last=-20, showall=False):
context = None
if not showall:
context = self.context
- undo = zapi.getUtility(IUndoManager)
+ undo = zope.component.getUtility(IUndoManager)
return undo.getPrincipalTransactions(self.request.principal, context,
first, last)
Modified: Zope3/trunk/src/zope/app/undo/tests/test_zodbundomanager.py
===================================================================
--- Zope3/trunk/src/zope/app/undo/tests/test_zodbundomanager.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/undo/tests/test_zodbundomanager.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -83,9 +83,9 @@
super(Test, self).setUp()
# provide location adapter
- from zope.app.location.traversing import LocationPhysicallyLocatable
- from zope.app.location.interfaces import ILocation
- from zope.app.traversing.interfaces import IPhysicallyLocatable
+ from zope.location.traversing import LocationPhysicallyLocatable
+ from zope.location.interfaces import ILocation
+ from zope.traversing.interfaces import IPhysicallyLocatable
ztapi.provideAdapter(ILocation, IPhysicallyLocatable,
LocationPhysicallyLocatable)
@@ -111,8 +111,8 @@
def testGetTransactionsInLocation(self):
from zope.interface import directlyProvides
- from zope.app.location import Location
- from zope.app.traversing.interfaces import IContainmentRoot
+ from zope.location import Location
+ from zope.traversing.interfaces import IContainmentRoot
root = Location()
spam = Location()
Modified: Zope3/trunk/src/zope/app/utility/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/utility/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/utility/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,5 +1,6 @@
##############################################################################
-# Copyright (c) 2003 Zope Corporation and Contributors.
+#
+# Copyright (c) 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -8,15 +9,23 @@
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
+#
##############################################################################
-"""Local utility service implementation.
+"""Deprecared utility package
-$Id: __init__.py 25177 2004-06-02 13:17:31Z jim $
+$Id$
"""
-import zope.deprecation
-zope.deprecation.__show__.off()
-from utility import LocalUtilityService
-zope.deprecation.__show__.on()
+import sys
+import warnings
-from zope.app.component.site import UtilityRegistration
+warnings.warn("This module is deprecated and will go away in Zope 3.5. ",
+ DeprecationWarning, 2)
+
+
+import zope.deferredimport
+
+zope.deferredimport.deprecated(
+ "This object is deprecated and will go away in Zope 3.5",
+ UtilityRegistration = "zope.app.component.back35:UtilityRegistration",
+ )
Property changes on: Zope3/trunk/src/zope/app/utility/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/utility/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/utility/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/utility/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,36 +1,3 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Interfaces pertaining to local utilities.
-
-$Id: interfaces.py 28582 2004-12-08 00:46:02Z srichter $
-"""
-import zope.component.interfaces
-from zope.deprecation import deprecated
-
-from zope.app.component.interfaces import IUtilityRegistration, ILocalUtility
-from zope.app.component.interfaces.registration import IRegistry
-
-deprecated(('IUtilityRegistration', 'ILocalUtility'),
- 'This interface has been moved to zope.app.component.interfaces. '
- 'The reference will be gone in Zope 3.3.')
-
-class ILocalUtilityService(
- zope.component.interfaces.IUtilityService,
- IRegistry,
- ):
- """Local Utility Service."""
-
-deprecated('ILocalUtilityService',
- 'The concept of services has been removed. Use site manager API. '
- 'The reference will be gone in Zope 3.3.')
+import warnings
+warnings.warn("This module is deprecated and will go away in Zope 3.5. ",
+ DeprecationWarning, 2)
Property changes on: Zope3/trunk/src/zope/app/utility/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/utility/utility.py
===================================================================
--- Zope3/trunk/src/zope/app/utility/utility.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/utility/utility.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,59 +1,3 @@
-##############################################################################
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-##############################################################################
-"""Local utility service implementation.
-
-Besides being functional, this module also serves as an example of
-creating a local service; see README.txt.
-
-$Id: utility.py 28662 2004-12-21 03:29:21Z srichter $
-"""
-from persistent import Persistent
-from zope.deprecation import deprecated
-
-from zope.app.component import getNextUtility, queryNextUtility
-from zope.app.component.testing import testingNextUtility
-from zope.app.component.site import UtilityRegistration
-from zope.app.container.contained import Contained
-
-deprecated(('getNextUtility', 'queryNextUtility'),
- 'This function has been moved to zope.app.component. '
- 'The reference will be gone in Zope 3.3.')
-
-deprecated('testingNextUtility',
- 'This function has been moved to zope.app.component.testing. '
- 'The reference will be gone in Zope 3.3.')
-
-deprecated('UtilityRegistration',
- 'This class has been moved to zope.app.component.site. '
- 'The reference will be gone in Zope 3.3.')
-
-
-class LocalUtilityService(Persistent, Contained):
- # I really hope noone noone is using this class manually!
- # ...6 months later: Yes, my book does. :(
-
- def getUtilitiesFor(self, interface):
- sm = self.__parent__.__parent__
- return sm.getUtilitiesFor(interface)
-
- def getUtility(self, interface, name=''):
- sm = self.__parent__.__parent__
- return sm.queryUtility(interface, name)
-
- def queryUtility(self, interface, name='', default=None):
- sm = self.__parent__.__parent__
- return sm.queryUtility(interface, name, default)
-
-
-deprecated('LocalUtilityService',
- 'Services have been removed. Use site manager API. '
- 'The reference will be gone in Zope 3.3.')
+import warnings
+warnings.warn("This module is deprecated and will go away in Zope 3.5. ",
+ DeprecationWarning, 2)
Property changes on: Zope3/trunk/src/zope/app/utility/utility.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/utility/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/utility/vocabulary.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/utility/vocabulary.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,28 +1,7 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Utility Vocabulary.
-
-This vocabulary provides terms for all utilities providing a given interface.
-
-$Id: vocabulary.py 28582 2004-12-08 00:46:02Z srichter $
-"""
-from zope.deprecation import deprecated
-
-from zope.app.component.vocabulary import *
-
-deprecated(('UtilityTerm', 'UtilityVocabulary', 'UtilityNameTerm',
- 'UtilityComponentInterfacesVocabulary', 'UtilityNames'),
- 'This class has been moved to zope.app.component.vocabulary. '
- 'The reference will be gone in X3.3.')
-
+# This module has moved to zope.size
+# and will go away in Zope 3.5
+import zope.deprecation
+zope.deprecation.moved(
+ 'zope.app.component.vocabulary',
+ "Zope 3.5",
+ )
Property changes on: Zope3/trunk/src/zope/app/utility/vocabulary.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/versioncontrol/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/versioncontrol/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/versioncontrol/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,20 +22,21 @@
that contain their own location information.
>>> import persistent
- >>> from zope import component, interface
- >>> import zope.app.annotation.attribute
- >>> import zope.app.annotation.interfaces
- >>> import zope.app.traversing.interfaces
+ >>> import zope.interface
+ >>> import zope.component
+ >>> import zope.traversing.interfaces
+ >>> import zope.annotation.attribute
+ >>> import zope.annotation.interfaces
>>> from zope.app.versioncontrol import interfaces
>>> marker = object()
>>> class Sample(persistent.Persistent):
- ... interface.implements(
+ ... zope.interface.implements(
... interfaces.IVersionable,
... interfaces.INonVersionedData,
- ... zope.app.annotation.interfaces.IAttributeAnnotatable,
- ... zope.app.traversing.interfaces.IPhysicallyLocatable,
+ ... zope.annotation.interfaces.IAttributeAnnotatable,
+ ... zope.traversing.interfaces.IPhysicallyLocatable,
... )
...
... # Methods defined by INonVersionedData
@@ -69,8 +70,8 @@
... def __repr__(self):
... return "<%s object>" % self.__class__.__name__
- >>> component.provideAdapter(
- ... zope.app.annotation.attribute.AttributeAnnotations)
+ >>> zope.component.provideAdapter(
+ ... zope.annotation.attribute.AttributeAnnotations)
Now we need to create a database with an instance of our sample object to work
with:
@@ -116,8 +117,7 @@
>>> repository = zope.app.versioncontrol.repository.Repository()
>>> zope.interface.verify.verifyObject(
- ... interfaces.IRepository,
- ... repository)
+ ... interfaces.IRepository, repository)
True
In order to actually use version control, there must be an
@@ -134,13 +134,12 @@
Let's register some subscribers so we can check that interesting
events are being fired for version control actions:
- >>> def showEvent(label, object, event):
- ... print label, "for", object
+ >>> @zope.component.adapter(None, interfaces.IVersionEvent)
+ ... def printEvent(object, event):
+ ... print event
+ ...
+ >>> zope.component.provideHandler(printEvent)
- >>> component.provideHandler(
- ... (lambda ob, evt: showEvent("applied version control", ob, evt)),
- ... (interface.Interface, interfaces.IVersionControlApplied))
-
Now, let's put an object under version control and verify that we can
determine that fact by checking against the interface:
Modified: Zope3/trunk/src/zope/app/versioncontrol/event.py
===================================================================
--- Zope3/trunk/src/zope/app/versioncontrol/event.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/versioncontrol/event.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -4,12 +4,11 @@
__docformat__ = "reStructuredText"
import zope.interface
-
-import zope.app.event.objectevent
+import zope.component.interfaces
import zope.app.versioncontrol.interfaces
-class VersionEvent(zope.app.event.objectevent.ObjectEvent):
+class VersionEvent(zope.component.interfaces.ObjectEvent):
def __init__(self, object, info):
super(VersionEvent, self).__init__(object)
Modified: Zope3/trunk/src/zope/app/versioncontrol/history.py
===================================================================
--- Zope3/trunk/src/zope/app/versioncontrol/history.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/versioncontrol/history.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -24,7 +24,7 @@
from BTrees.IIBTree import IIBTree
from BTrees.OOBTree import OOBTree
-import zope.app.location
+import zope.location
import zope.app.versioncontrol.utility
import zope.app.versioncontrol.version
@@ -32,7 +32,7 @@
from zope.app.versioncontrol.interfaces import VersionControlError
-class VersionHistory(persistent.Persistent, zope.app.location.Location):
+class VersionHistory(persistent.Persistent, zope.location.Location):
"""A version history maintains the information about the changes
to a particular version-controlled resource over time."""
@@ -216,7 +216,7 @@
return self._versions.keys()
-class BranchInfo(persistent.Persistent, zope.app.location.Location):
+class BranchInfo(persistent.Persistent, zope.location.Location):
"""A utility class to hold branch (line-of-descent) information.
It maintains the name of the branch, the version id of the root of
Modified: Zope3/trunk/src/zope/app/versioncontrol/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/versioncontrol/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/versioncontrol/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,19 +16,15 @@
$Id$
"""
import persistent.interfaces
-
import zope.interface
import zope.schema
+import zope.component.interfaces
+import zope.annotation.interfaces
from zope.schema.vocabulary import SimpleVocabulary
-
-import zope.app.annotation.interfaces
-import zope.app.event.interfaces
-
from zope.i18nmessageid import MessageFactory
_ = MessageFactory('zope.app.versioncontrol')
-
class VersionControlError(Exception):
pass
@@ -302,7 +298,7 @@
class IVersionable(persistent.interfaces.IPersistent,
- zope.app.annotation.interfaces.IAnnotatable):
+ zope.annotation.interfaces.IAnnotatable):
"""Version control is allowed for objects that provide this."""
class IVersioned(IVersionable):
@@ -326,7 +322,7 @@
# Events that are raised for interesting occurances:
-class IVersionEvent(zope.app.event.interfaces.IObjectEvent):
+class IVersionEvent(zope.component.interfaces.IObjectEvent):
"""Base interface for all version-control events."""
info = zope.interface.Attribute("Version info (IVersionInfo)")
Modified: Zope3/trunk/src/zope/app/versioncontrol/repository.py
===================================================================
--- Zope3/trunk/src/zope/app/versioncontrol/repository.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/versioncontrol/repository.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,13 +25,11 @@
import zope.event
import zope.interface
+import zope.datetime
+from zope.annotation.interfaces import IAnnotations
-from zope.app import datetimeutils
from zope.app import zapi
-
-from zope.app.annotation.interfaces import IAnnotations
-
-from zope.app.versioncontrol import event
+from zope.app.versioncontrol import nonversioned, utility, event
from zope.app.versioncontrol.history import VersionHistory
from zope.app.versioncontrol.interfaces import VersionControlError
from zope.app.versioncontrol.interfaces import IVersionable, IVersioned
@@ -40,13 +38,9 @@
from zope.app.versioncontrol.interfaces import CHECKED_IN, CHECKED_OUT
from zope.app.versioncontrol.interfaces import ACTION_CHECKIN, ACTION_CHECKOUT
from zope.app.versioncontrol.interfaces import ACTION_UNCHECKOUT, ACTION_UPDATE
-from zope.app.versioncontrol import nonversioned
-from zope.app.versioncontrol import utility
-
VERSION_INFO_KEY = "%s.%s" % (utility.__name__, utility.VersionInfo.__name__)
-
class Repository(persistent.Persistent):
"""The repository implementation manages the actual data of versions
and version histories. It does not handle user interface issues."""
@@ -500,8 +494,8 @@
sticky = ('B', selector)
else:
try:
- timestamp = datetimeutils.time(selector)
- except datetimeutils.DateTimeError:
+ timestamp = zope.datetime.time(selector)
+ except zope.datetime.DateTimeError:
raise VersionControlError(
'Invalid version selector: %s' % selector
)
Modified: Zope3/trunk/src/zope/app/versioncontrol/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/versioncontrol/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/versioncontrol/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,29 +18,27 @@
import sys
import unittest
import persistent
-
-from zope import component, interface
-from zope.component.tests.placelesssetup import PlacelessSetup
-from zope.testing import doctest, module
from transaction import abort
import zope.event
+import zope.location
+import zope.traversing.interfaces
+import zope.annotation.interfaces
+import zope.annotation.attribute
+import zope.component.testing
+import zope.component.eventtesting
+from zope import interface
+from zope.testing import doctest, module
-import zope.app.annotation.interfaces
-import zope.app.annotation.attribute
-import zope.app.location
import zope.app.versioncontrol.version
from zope.app.versioncontrol import interfaces, nonversioned
-import zope.app.traversing.interfaces
name = 'zope.app.versioncontrol.README'
-ps = PlacelessSetup()
-
def setUp(test):
- ps.setUp()
+ zope.component.testing.setUp(test)
+ zope.component.eventtesting.setUp(test)
module.setUp(test, name)
- zope.event.subscribers.append(eventHandler)
def tearDown(test):
module.tearDown(test, name)
@@ -48,19 +46,12 @@
db = test.globs.get('db')
if db is not None:
db.close()
- ps.tearDown()
- if eventHandler in zope.event.subscribers:
- zope.event.subscribers.remove(eventHandler)
+ zope.component.testing.tearDown(test)
-def eventHandler(event):
- print event
-
-
-class L(persistent.Persistent, zope.app.location.Location):
+class L(persistent.Persistent, zope.location.Location):
interface.implements(interfaces.IVersionable,
- zope.app.annotation.interfaces.IAttributeAnnotatable,
- zope.app.traversing.interfaces.IPhysicallyLocatable,
- )
+ zope.annotation.interfaces.IAttributeAnnotatable,
+ zope.traversing.interfaces.IPhysicallyLocatable)
def getPath(self):
return 'whatever'
@@ -116,14 +107,14 @@
"""\
cloneByPickle should not go outside a location
- >>> parent = zope.app.location.Location()
+ >>> parent = zope.location.Location()
>>> parent.poison = lambda: None
- >>> ob = zope.app.location.Location()
+ >>> ob = zope.location.Location()
>>> ob.__parent__ = parent
- >>> x = zope.app.location.Location()
+ >>> x = zope.location.Location()
>>> x.poison = lambda: None
>>> ob.x = x
- >>> ob.y = zope.app.location.Location()
+ >>> ob.y = zope.location.Location()
>>> ob.y.__parent__ = ob
>>> clone = zope.app.versioncontrol.version.cloneByPickle(ob)
>>> clone.__parent__ is ob.__parent__
@@ -147,9 +138,9 @@
>>> from ZODB.tests import util
>>> import transaction
>>> db = util.DB()
- >>> component.provideAdapter(
- ... zope.app.annotation.attribute.AttributeAnnotations)
- >>> component.provideAdapter(
+ >>> zope.component.provideAdapter(
+ ... zope.annotation.attribute.AttributeAnnotations)
+ >>> zope.component.provideAdapter(
... nonversioned.StandardNonVersionedDataAdapter,
... [None])
>>> import zope.app.versioncontrol.repository
Modified: Zope3/trunk/src/zope/app/versioncontrol/utility.py
===================================================================
--- Zope3/trunk/src/zope/app/versioncontrol/utility.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/versioncontrol/utility.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -24,6 +24,7 @@
from ZODB.serialize import referencesf
from ZODB.TimeStamp import TimeStamp
+import zope.location
import zope.security.management
import zope.app.versioncontrol.interfaces
@@ -82,8 +83,8 @@
return None
# TODO obviously no test for this
- if (zope.app.location.ILocation.providedBy(ob)
- and not zope.app.location.inside(ob, object)):
+ if (zope.location.ILocation.providedBy(ob)
+ and not zope.location.inside(ob, object)):
return '1' # go away
# The location check above should wake the object
Modified: Zope3/trunk/src/zope/app/versioncontrol/version.py
===================================================================
--- Zope3/trunk/src/zope/app/versioncontrol/version.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/versioncontrol/version.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -24,7 +24,7 @@
from BTrees.OOBTree import OOBTree
-import zope.app.location
+import zope.location
from zope.app.versioncontrol.interfaces import VersionControlError
from zope.app.versioncontrol.interfaces import INonVersionedData
@@ -45,8 +45,8 @@
if ignore_dict.has_key(id(ob)):
return 'ignored'
- if (zope.app.location.ILocation.providedBy(ob)
- and not zope.app.location.inside(ob, obj)):
+ if (zope.location.ILocation.providedBy(ob)
+ and not zope.location.inside(ob, obj)):
myid = id(ob)
ids[myid] = ob
return myid
@@ -68,7 +68,7 @@
return u.load()
-class Version(persistent.Persistent, zope.app.location.Location):
+class Version(persistent.Persistent, zope.location.Location):
"""A Version is a resource that contains a copy of a particular state
(content and dead properties) of a version-controlled resource. A
version is created by checking in a checked-out resource. The state
Modified: Zope3/trunk/src/zope/app/wfmc/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/app/wfmc/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/wfmc/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,10 +20,10 @@
import zope.interface
import zope.schema
import zope.configuration.fields
+import zope.wfmc.interfaces
from zope import wfmc
from zope.wfmc import xpdl
-from zope.app.component.metaconfigure import utility
-import zope.wfmc.interfaces
+from zope.component.zcml import utility
class IdefineXpdl(zope.interface.Interface):
Modified: Zope3/trunk/src/zope/app/wfmc/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/wfmc/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/wfmc/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -22,8 +22,6 @@
from zope.configuration import xmlconfig
from zope.testing import module, doctest
-import zope.app.annotation.interfaces
-import zope.app.annotation.attribute
import zope.app.wfmc
from zope.app.testing import placelesssetup
from zope.app.testing import ztapi
Modified: Zope3/trunk/src/zope/app/workflow/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/workflow/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -3,13 +3,6 @@
xmlns="http://namespaces.zope.org/browser"
>
- <tool
- interface="zope.app.workflow.interfaces.IProcessDefinition"
- title="Workflows"
- description="Workflow Process Definitions define a particular workflow
- for an object."
- />
-
<!-- Process Definition Import/Export -->
<page
Modified: Zope3/trunk/src/zope/app/workflow/browser/definition.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/browser/definition.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/browser/definition.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,10 +15,8 @@
$Id$
"""
-
-from zope.app.traversing.api import traverse
+from zope.traversing.api import traverse
# registration path changed
-from zope.app.component.interfaces.registration import IRegistered
from zope.app.workflow.interfaces import IProcessDefinitionImportHandler
from zope.app.workflow.interfaces import IProcessDefinitionExportHandler
Modified: Zope3/trunk/src/zope/app/workflow/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/workflow/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -59,7 +59,7 @@
class="zope.app.workflow.definition.ProcessDefinitionElementContainer">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
<require
@@ -76,7 +76,7 @@
<adapter
factory="zope.app.workflow.instance.ProcessInstanceContainerAdapter"
provides="zope.app.workflow.interfaces.IProcessInstanceContainer"
- for="zope.app.annotation.interfaces.IAnnotatable"
+ for="zope.annotation.interfaces.IAnnotatable"
permission="zope.workflow.UseProcessInstances"
trusted="true"
/>
Modified: Zope3/trunk/src/zope/app/workflow/definition.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/definition.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/definition.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,14 +18,12 @@
from persistent import Persistent
from persistent.dict import PersistentDict
+import zope.component
from zope.interface import implements, classProvides
-
-from zope.schema.interfaces import ITokenizedTerm
from zope.schema.interfaces import IVocabularyTokenized
+from zope.schema.interfaces import ITokenizedTerm, IVocabularyFactory
-from zope.app import zapi
from zope.app.container.contained import Contained, setitem, uncontained
-from zope.app.schema.interfaces import IVocabularyFactory
from zope.app.workflow.interfaces import IProcessDefinitionElementContainer
from zope.app.workflow.interfaces import IProcessDefinition
@@ -111,7 +109,7 @@
classProvides(IVocabularyFactory)
def __init__(self, context):
- self.sm = zapi.getSiteManager(context)
+ self.sm = zope.component.getSiteManager(context)
def __names(self):
return [name
Modified: Zope3/trunk/src/zope/app/workflow/instance.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/instance.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/instance.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,18 +17,17 @@
"""
from types import StringTypes
from persistent.dict import PersistentDict
+
+import zope.component
from zope.proxy import removeAllProxies
+from zope.annotation.interfaces import IAnnotatable, IAnnotations
+from zope.interface import implements
-from zope.app import zapi
-from zope.app.annotation.interfaces import IAnnotatable, IAnnotations
from zope.app.container.interfaces import IContained
+from zope.app.container.contained import Contained, setitem, uncontained
from zope.app.workflow.interfaces import IProcessInstance, IProcessDefinition
from zope.app.workflow.interfaces import IProcessInstanceContainer
-from zope.interface import implements
-
-from zope.app.container.contained import Contained, setitem, uncontained
-
class ProcessInstance(Contained):
"""Process Instance implementation.
@@ -52,7 +51,7 @@
def createProcessInstance(context, name):
"""Helper function to create a process instance from a process definition
name."""
- sm = zapi.getSiteManager(context)
+ sm = zope.component.getSiteManager(context)
pd = sm.queryUtility(IProcessDefinition, name)
return pd.createProcessInstance(name)
Modified: Zope3/trunk/src/zope/app/workflow/stateful/browser/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/browser/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/browser/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -159,7 +159,7 @@
<zope:adapter
factory=".filteradapter.FilterAdapter"
provides=".interfaces.IContentFilterAdapter"
- for="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ for="zope.annotation.interfaces.IAttributeAnnotatable"
permission="zope.View" /> <!-- TODO: is this permission right? -->
<!--include file="testobject.zcml"/-->
Modified: Zope3/trunk/src/zope/app/workflow/stateful/browser/contentworkflow.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/browser/contentworkflow.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/browser/contentworkflow.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,15 +15,16 @@
$Id$
"""
-from zope.app import zapi
-from zope.app.component.interface import nameToInterface, interfaceToName
+from zope.component import getUtilitiesFor
+from zope.component.interface import nameToInterface, interfaceToName
+from zope.interface import Interface
+from zope.publisher.browser import BrowserView
+from zope.schema import Choice, List
+from zope.security.proxy import removeSecurityProxy
+
from zope.app.i18n import ZopeMessageFactory as _
from zope.app.form.utility import setUpWidgets
from zope.app.form.interfaces import IInputWidget
-from zope.interface import Interface
-from zope.app.publisher.browser import BrowserView
-from zope.schema import Choice, List
-from zope.security.proxy import removeSecurityProxy
from zope.app.workflow.interfaces import IProcessDefinition
class IContentProcessMapping(Interface):
@@ -56,7 +57,7 @@
def getProcessInterfacesMapping(self):
mapping = []
- for name in [name for name, util in zapi.getUtilitiesFor(
+ for name in [name for name, util in getUtilitiesFor(
IProcessDefinition,
self.context,
)]:
Modified: Zope3/trunk/src/zope/app/workflow/stateful/browser/definition.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/browser/definition.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/browser/definition.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,19 +15,19 @@
$Id$
"""
-from zope.app import zapi
+import zope.component
from zope.proxy import removeAllProxies
-from zope.app.publisher.browser import BrowserView
+from zope.schema import getFields, Choice
+from zope.publisher.browser import BrowserView
+from zope.security.checker import CheckerPublic
+from zope.security.proxy import removeSecurityProxy
+
from zope.app.container.browser.adding import Adding
from zope.app.form.browser.submit import Update
from zope.app.form.browser.editview import EditView
from zope.app.form.interfaces import IInputWidget
from zope.app.workflow.stateful.definition import State, Transition
-from zope.schema import getFields, Choice
-
from zope.app.security.interfaces import IPermission
-from zope.security.checker import CheckerPublic
-from zope.security.proxy import removeSecurityProxy
from zope.app.form.utility import setUpWidget
class StatesContainerAdding(Adding):
@@ -123,8 +123,8 @@
set_perm_id = setPermWidget.getInputValue()
# get the right permission from the given id
- get_perm = zapi.getUtility(IPermission, get_perm_id)
- set_perm = zapi.getUtility(IPermission, set_perm_id)
+ get_perm = zope.component.getUtility(IPermission, get_perm_id)
+ set_perm = zope.component.getUtility(IPermission, set_perm_id)
# set the permission back to the instance
perms[name] = (get_perm, set_perm)
Modified: Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_contentworkflowsmanager.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_contentworkflowsmanager.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_contentworkflowsmanager.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,14 +19,12 @@
import re
from transaction import commit
-
from zope.interface import Interface
-from zope.app.component.interface import nameToInterface
+from zope.component.interface import nameToInterface
+
from zope.app import zapi
from zope.app.testing.functional import BrowserTestCase
from zope.app.testing.setup import addUtility
-from zope.app.component.interfaces.registration import ActiveStatus
-from zope.app.component.site import UtilityRegistration
from zope.app.workflow.stateful.definition import StatefulProcessDefinition
from zope.app.workflow.stateful.interfaces import IStatefulProcessDefinition,\
@@ -56,14 +54,8 @@
'ContentWorkflowsManager',
'new_value': 'mgr' })
- root = self.getRootFolder()
- default = zapi.traverse(root, '/++etc++site/default')
- rm = default.registrationManager
- registration = UtilityRegistration(
- 'cwm', IContentWorkflowsManager,
- zapi.traverse(root, self.basepath+'/mgr'))
- pd_id = rm.addRegistration(registration)
- zapi.traverse(rm, pd_id).status = ActiveStatus
+ sm.registerUtility(sm['default']['mgr'],
+ IContentWorkflowsManager, 'cwm')
def test_registry(self):
response = self.publish(
Modified: Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_processdefinition.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_processdefinition.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/browser/ftests/test_processdefinition.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -87,7 +87,7 @@
self.assertEqual(response.getStatus(), 200)
body = ' '.join(response.getBody().split())
- self.assert_(body.find('This object is not currently active.') >=0)
+ self.assert_(body.find("This object isn't yet registered.") >=0)
def test_transitions(self):
response = self.publish(
Modified: Zope3/trunk/src/zope/app/workflow/stateful/browser/instance.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/browser/instance.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/browser/instance.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,17 +15,17 @@
$Id$
"""
+from zope.component import getUtility
from zope.proxy import removeAllProxies
from zope.security.proxy import removeSecurityProxy
from zope.schema import getFields
+from zope.publisher.browser import BrowserView
+from zope.dublincore.interfaces import IZopeDublinCore
-from zope.app import zapi
from zope.app.form.browser.submit import Update
from zope.app.form.utility import setUpWidget, applyWidgetsChanges
from zope.app.form.interfaces import IInputWidget
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.publisher.browser import BrowserView
from zope.app.workflow.interfaces import IProcessDefinition
from zope.app.workflow.interfaces import IProcessInstanceContainer
@@ -122,8 +122,8 @@
def _getProcessDefinition(self, processInstance):
- return zapi.getUtility(IProcessDefinition,
- processInstance.processDefinitionName)
+ return getUtility(IProcessDefinition,
+ processInstance.processDefinitionName)
def widgets(self):
Modified: Zope3/trunk/src/zope/app/workflow/stateful/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -8,11 +8,8 @@
id="zope.app.workflow.StatefulProcessDefinition"
/>
<implements
- interface="zope.app.utility.interfaces.ILocalUtility"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
- <implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
- />
<require
permission="zope.workflow.ManageProcessDefinitions"
interface=".interfaces.IStatefulProcessDefinition"
@@ -36,7 +33,7 @@
interface=".interfaces.IStatefulStatesContainer"
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
@@ -52,7 +49,7 @@
set_schema=".interfaces.IState"
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
@@ -72,7 +69,7 @@
interface=".interfaces.IStatefulTransitionsContainer"
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
@@ -88,7 +85,7 @@
set_schema=".interfaces.ITransition"
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
@@ -101,11 +98,8 @@
/>
<implements
- interface="zope.app.utility.interfaces.ILocalUtility"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
- <implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
- />
<require
permission="zope.ManageServices"
@@ -139,7 +133,7 @@
are created. -->
<subscriber
for="..interfaces.IProcessInstanceContainerAdaptable
- zope.app.event.objectevent.IObjectCreatedEvent"
+ zope.lifecycleevent.IObjectCreatedEvent"
handler=".contentworkflow.NewObjectProcessInstanceCreator"
>
Modified: Zope3/trunk/src/zope/app/workflow/stateful/contentworkflow.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/contentworkflow.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/contentworkflow.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,15 +20,14 @@
from persistent import Persistent
from persistent.dict import PersistentDict
-from zope.app import zapi
-from zope.app.event.interfaces import IObjectCreatedEvent
-from zope.app.servicenames import Utilities
+from zope.component import getUtilitiesFor
+from zope.interface import implements, providedBy
+from zope.lifecycleevent.interfaces import IObjectCreatedEvent
from zope.app.workflow.interfaces import IProcessInstanceContainer
from zope.app.workflow.interfaces import IProcessInstanceContainerAdaptable
from zope.app.workflow.stateful.interfaces import IContentWorkflowsManager
from zope.app.workflow.instance import createProcessInstance
-from zope.interface import implements, providedBy
from zope.app.container.contained import Contained
@@ -37,7 +36,7 @@
pi_container = IProcessInstanceContainer(obj)
- for (ignored, cwf) in zapi.getUtilitiesFor(IContentWorkflowsManager):
+ for (ignored, cwf) in getUtilitiesFor(IContentWorkflowsManager):
# here we will lookup the configured processdefinitions
# for the newly created compoent. For every pd_name
# returned we will create a processinstance.
Modified: Zope3/trunk/src/zope/app/workflow/stateful/definition.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/definition.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/definition.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,13 +20,14 @@
from zope.interface import implements, classProvides
from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
+from zope.schema.interfaces import IVocabularyFactory
from zope.security.checker import CheckerPublic
+from zope.event import notify
+from zope.component.interfaces import ObjectEvent
+from zope.lifecycleevent import modified
from zope.app.container.interfaces import IReadContainer
from zope.app.container.contained import Contained, containedEvent
-from zope.event import notify
-from zope.app.event.objectevent import ObjectEvent, modified
-from zope.app.schema.interfaces import IVocabularyFactory
from zope.app.workflow.definition import ProcessDefinition
from zope.app.workflow.definition import ProcessDefinitionElementContainer
from zope.app.workflow.stateful.interfaces import IStatefulProcessDefinition
Modified: Zope3/trunk/src/zope/app/workflow/stateful/instance.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/instance.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/instance.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,8 +18,6 @@
from persistent import Persistent
from persistent.dict import PersistentDict
-from zope.app import zapi
-from zope.event import notify
from zope.app.workflow.interfaces import IProcessDefinition
from zope.app.workflow.stateful.interfaces import AUTOMATIC
from zope.app.workflow.stateful.interfaces import IAfterTransitionEvent
@@ -29,11 +27,12 @@
from zope.app.workflow.stateful.interfaces import ITransitionEvent
from zope.app.workflow.stateful.interfaces import IBeforeRelevantDataChangeEvent
from zope.app.workflow.stateful.interfaces import IAfterRelevantDataChangeEvent
-from zope.app.servicenames import Utilities
-from zope.app.traversing.api import getParent
from zope.app.workflow.instance import ProcessInstance
from zope.app.container.contained import Contained
+from zope.component import getUtility, getSiteManager
+from zope.event import notify
+from zope.traversing.api import getParent
from zope.security.interfaces import Unauthorized
from zope.interface import directlyProvides, implements
from zope.proxy import removeAllProxies
@@ -216,7 +215,7 @@
def getProcessDefinition(self):
"""Get the ProcessDefinition object from Workflow Utility."""
- return zapi.getUtility(IProcessDefinition, self.processDefinitionName)
+ return getUtility(IProcessDefinition, self.processDefinitionName)
def _getContext(self):
ctx = {}
@@ -273,9 +272,7 @@
if not script:
return True
if isinstance(script, (str, unicode)):
- #removed getServices in exchange for getSiteManager
- #sm = zapi.getServices(self)
- sm = zapi.getSiteManager(self)
+ sm = getSiteManager(self)
script = sm.resolve(script)
return script(contexts)
Modified: Zope3/trunk/src/zope/app/workflow/stateful/tests/test_contentworkflow.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/tests/test_contentworkflow.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/tests/test_contentworkflow.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,16 +19,13 @@
from zope.interface import Interface, implements
from zope.interface.verify import verifyClass
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.annotation.interfaces import IAnnotatable, IAttributeAnnotatable
+from zope.lifecycleevent import ObjectCreatedEvent
+from zope.lifecycleevent.interfaces import IObjectCreatedEvent
from zope.app import zapi
-from zope.app.annotation.interfaces import IAttributeAnnotatable
from zope.app.container.contained import Contained
-from zope.app.event.objectevent import ObjectCreatedEvent
-from zope.app.annotation.interfaces import IAnnotatable, IAttributeAnnotatable
-from zope.app.event.interfaces import IObjectCreatedEvent
-from zope.app.component.site import UtilityRegistration
-from zope.app.component.interfaces import ILocalUtility
-from zope.app.component.interfaces.registration import ActiveStatus
from zope.app.workflow.interfaces import IProcessDefinition
from zope.app.workflow.interfaces import IProcessInstanceContainerAdaptable
@@ -44,7 +41,7 @@
# define and create dummy ProcessDefinition (PD) for tests
class DummyProcessDefinition(Contained):
- implements(IProcessDefinition, IAttributeAnnotatable, ILocalUtility)
+ implements(IProcessDefinition, IAttributeAnnotatable)
def __init__(self, n):
self.n = n
Modified: Zope3/trunk/src/zope/app/workflow/stateful/tests/test_instance.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/tests/test_instance.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/tests/test_instance.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,23 +17,17 @@
"""
import unittest
+from zope import component
from zope.interface import Interface, implements
from zope.interface.verify import verifyClass
from zope.schema import Text, Int
-
-from zope.component.service import serviceManager
-from zope.app.event.tests.placelesssetup import events, clearEvents
-from zope.app.security.interfaces import IPermission
-from zope.app.security.permission import Permission
from zope.security.checker import CheckerPublic
from zope.security.management import newInteraction, endInteraction
+from zope.security.interfaces import IPermission
+from zope.security.permission import Permission
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.component.eventtesting import events, clearEvents
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.component.interfaces.registration import IRegisterable
-from zope.app.component.interfaces.registration import IRegistered
-from zope.app.component.interfaces.registration import ActiveStatus
-from zope.app.servicenames import Utilities
-
from zope.app.workflow.tests.workflowsetup import WorkflowSetup
from zope.app.workflow.interfaces import IProcessDefinition
from zope.app.workflow.instance import createProcessInstance
@@ -48,10 +42,7 @@
from zope.app.workflow.stateful.instance import StatefulProcessInstance
from zope.app.workflow.stateful.instance import StateChangeInfo
-from zope.app import zapi
-from zope.app.tests import ztapi
from zope.app.container.contained import contained
-from zope.app.utility import UtilityRegistration
from zope.app.testing import setup
@@ -104,7 +95,7 @@
setup.addUtility(self.sm, 'definition1', IProcessDefinition, pd)
- self.pd = zapi.getUtility(IProcessDefinition, name='definition1')
+ self.pd = component.getUtility(IProcessDefinition, name='definition1')
# give the pi some context to find a service
self.pi = createProcessInstance(self.sm, 'definition1')
# Let's also listen to the fired events
@@ -212,7 +203,7 @@
setup.addUtility(self.sm, 'definition1', IProcessDefinition, pd)
- self.pd = zapi.getUtility(IProcessDefinition, 'definition1')
+ self.pd = component.getUtility(IProcessDefinition, 'definition1')
# give the pi some context to find a service
self.pi = contained(
createProcessInstance(self.sm, 'definition1'),
@@ -294,7 +285,7 @@
setup.addUtility(self.sm, 'definition1', IProcessDefinition, pd)
- self.pd = zapi.getUtility(IProcessDefinition, 'definition1')
+ self.pd = component.getUtility(IProcessDefinition, 'definition1')
# give the pi some context to find a service
self.pi = contained(
createProcessInstance(self.sm, 'definition1'),
@@ -348,7 +339,7 @@
def setUp(self):
WorkflowSetup.setUp(self)
- ztapi.provideUtility(IPermission, Permission('deny', 'Deny'), 'deny')
+ component.provideUtility(Permission('deny', 'Deny'), IPermission, 'deny')
endInteraction()
newInteraction(ParticipationStub('test'))
@@ -376,7 +367,7 @@
setup.addUtility(self.sm, 'definition1', IProcessDefinition, pd)
- self.pd = zapi.getUtility(IProcessDefinition, 'definition1')
+ self.pd = component.getUtility(IProcessDefinition, 'definition1')
# give the process instance container (pic) some context to find a
# service (while this is not correct, it resembles the current
# behavior.
Modified: Zope3/trunk/src/zope/app/workflow/stateful/tests/test_xmlimportexport.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/tests/test_xmlimportexport.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/tests/test_xmlimportexport.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,27 +18,27 @@
import unittest
from StringIO import StringIO
-from zope.app import zapi
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.dublincore.annotatableadapter import ZDCAnnotatableAdapter
-from zope.app.annotation.interfaces import IAnnotatable, IAnnotations
-from zope.app.annotation.interfaces import IAttributeAnnotatable
-from zope.app.dublincore.interfaces import IZopeDublinCore
-from zope.app.security.interfaces import IPermission
-from zope.app.component.interfaces.registration import IRegisterable
+import zope.component
+from zope.interface import implements, classImplements, Interface
+from zope.interface.verify import verifyClass
+from zope.schema import TextLine
+from zope.annotation.attribute import AttributeAnnotations
+from zope.annotation.interfaces import IAnnotatable, IAnnotations
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter
+from zope.dublincore.interfaces import IZopeDublinCore
+from zope.security.interfaces import IPermission
+from zope.security.permission import Permission
+from zope.security.checker import CheckerPublic
+
from zope.app.workflow.interfaces import IProcessDefinitionExportHandler
from zope.app.workflow.interfaces import IProcessDefinitionImportHandler
-from zope.app.security.permission import Permission
-from zope.app.site.tests.placefulsetup import PlacefulSetup
+from zope.app.component.testing import PlacefulSetup
from zope.app.workflow.stateful.definition import StatefulProcessDefinition
from zope.app.workflow.stateful.definition import State, Transition
from zope.app.workflow.stateful.xmlimportexport import XMLExportHandler
from zope.app.workflow.stateful.xmlimportexport import XMLImportHandler
-from zope.app.tests import ztapi
-from zope.interface import implements, classImplements, Interface
-from zope.interface.verify import verifyClass
-from zope.schema import TextLine
-from zope.security.checker import CheckerPublic
+from zope.app.testing import ztapi
class ISchema(Interface):
@@ -94,7 +94,7 @@
class TestProcessDefinition(StatefulProcessDefinition):
- implements(IAttributeAnnotatable, IRegisterable)
+ implements(IAttributeAnnotatable)
# need to patch this cause these classes are used directly
# in the import/export classes
@@ -132,7 +132,7 @@
self.assertEqual(
testpd.schemaPermissions['title'],
- (CheckerPublic, zapi.getUtility(IPermission, 'zope.View')))
+ (CheckerPublic, zope.component.getUtility(IPermission, 'zope.View')))
self.assertEqual(len(testpd.states), 3)
self.assertEqual(len(testpd.transitions), 3)
Modified: Zope3/trunk/src/zope/app/workflow/stateful/xmlimportexport.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/xmlimportexport.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/stateful/xmlimportexport.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,14 +18,14 @@
from xml.sax import parseString
from xml.sax.handler import ContentHandler
+import zope.component
from zope.configuration.name import resolve
from zope.interface import implements
from zope.proxy import removeAllProxies
from zope.security.checker import CheckerPublic
from zope.security.proxy import removeSecurityProxy
+from zope.dublincore.interfaces import IZopeDublinCore
-from zope.app import zapi
-from zope.app.dublincore.interfaces import IZopeDublinCore
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app.security.interfaces import IPermission
from zope.app.workflow.interfaces import IProcessDefinitionImportHandler
@@ -95,7 +95,7 @@
elif perm_id == '':
perm = None
else:
- perm = zapi.getUtility(IPermission, perm_id)
+ perm = zope.component.getUtility(IPermission, perm_id)
if not fieldName in perms.keys():
perms[fieldName] = (CheckerPublic, CheckerPublic)
if type == u'get':
Modified: Zope3/trunk/src/zope/app/workflow/tests/test_instance.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/tests/test_instance.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/tests/test_instance.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,16 +17,14 @@
"""
import unittest
from zope.interface.verify import verifyClass
+from zope.annotation.interfaces import IAnnotations
+from zope.interface import implements
-from zope.app.annotation.interfaces import IAnnotations
from zope.app.testing.placelesssetup import PlacelessSetup
-
-from zope.app.workflow.interfaces import IProcessInstance
from zope.app.workflow.instance import ProcessInstance
-
-from zope.app.workflow.interfaces import IProcessInstanceContainer
from zope.app.workflow.instance import ProcessInstanceContainerAdapter, WFKey
-from zope.interface import implements
+from zope.app.workflow.interfaces import IProcessInstance
+from zope.app.workflow.interfaces import IProcessInstanceContainer
class TestAnnotations(dict):
implements(IAnnotations)
Modified: Zope3/trunk/src/zope/app/workflow/tests/workflowsetup.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/tests/workflowsetup.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/workflow/tests/workflowsetup.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,4 +1,4 @@
- ##############################################################################
+##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
@@ -16,43 +16,23 @@
$Id$
"""
from zope.interface import implements
-from zope.component.interfaces import IUtilityService
from zope.app import zapi
-from zope.app.annotation.interfaces import IAttributeAnnotatable
from zope.app.security.interfaces import IAuthenticationService
from zope.app.security.principalregistry import principalRegistry
-from zope.app.servicenames import Authentication, Utilities
-from zope.app.site.tests.placefulsetup import PlacefulSetup
-from zope.app.utility import LocalUtilityService
-from zope.app.tests import setup
+from zope.app.component.testing import PlacefulSetup
+from zope.app.testing import setup
class WorkflowSetup(PlacefulSetup):
def setUp(self):
- #getGlobalServices has been moved
- #self.root_sm = zapi.getGlobalServices()
self.root_sm = zapi.getGlobalSiteManager()
self.sm = PlacefulSetup.setUp(self, site=True)
- setup.addService(self.sm, Utilities, LocalUtilityService())
-
self.default = zapi.traverse(self.sm, "default")
- #moved to registrationManager
- #self.cm = self.default.getRegistrationManager()
self.cm = self.default.registrationManager
self.sm1 = self.makeSite('folder1')
- setup.addService(self.sm1, Utilities, LocalUtilityService())
-
self.default1 = zapi.traverse(self.sm1, "default")
- #moved to registrationManager
- #self.cm1 = self.default1.getRegistrationManager()
self.cm1 = self.default1.registrationManager
-
-
- def setupAuthService(self):
- self.root_sm.defineService(Authentication, IAuthenticationService)
- self.root_sm.provideService(Authentication, principalRegistry)
- return zapi.getService(Authentication, self.rootFolder)
Modified: Zope3/trunk/src/zope/app/xmlrpcintrospection/xmlrpcintrospection.py
===================================================================
--- Zope3/trunk/src/zope/app/xmlrpcintrospection/xmlrpcintrospection.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/xmlrpcintrospection/xmlrpcintrospection.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -139,7 +139,7 @@
for result in self._getRegistrationAdapters(interfaces):
if result.name == method_name:
- method = getattr(result.value, method_name)
+ method = getattr(result.factory, method_name)
return self._getFunctionSignature(method)
return 'undef'
@@ -151,7 +151,7 @@
for result in self._getRegistrationAdapters(interfaces):
if result.name == method_name:
- method = getattr(result.value, method_name)
+ method = getattr(result.factory, method_name)
return self._getFunctionHelp(method)
return 'undef'
Modified: Zope3/trunk/src/zope/app/zapi/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/zapi/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/zapi/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -28,23 +28,14 @@
__all__ = tuple(IZAPI)
from zope.component import *
-
from zope.app.publisher.browser import getDefaultViewName
from zope.app.publisher.browser import queryDefaultViewName
-from zope.app.traversing.api import *
-from zope.app.traversing.browser.absoluteurl import absoluteURL
-from zope.app.exception.interfaces import UserError
+from zope.traversing.api import *
+from zope.traversing.browser.absoluteurl import absoluteURL
+from zope.exceptions.interfaces import UserError
name = getName
def principals():
from zope.app.security.interfaces import IAuthentication
return getUtility(IAuthentication)
-
-# BBB: Gone in 3.3.
-from zope.deprecation import deprecated
-from zope.app import servicenames
-
-deprecated('servicenames',
- 'The concept of services has been removed. Please use utilities '
- 'instead. This reference will be removed in Zope 3.3.')
Modified: Zope3/trunk/src/zope/app/zapi/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/zapi/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/zapi/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,9 +17,9 @@
"""
from zope.interface import Attribute
from zope.component.interfaces import IComponentArchitecture
+from zope.traversing.interfaces import ITraversalAPI
+from zope.traversing.browser.interfaces import IAbsoluteURLAPI
from zope.app.publisher.browser import IDefaultViewNameAPI
-from zope.app.traversing.interfaces import ITraversalAPI
-from zope.app.traversing.browser.interfaces import IAbsoluteURLAPI
class IZAPI(
IComponentArchitecture,
@@ -64,7 +64,4 @@
def principals():
"""Return the authentication utility
"""
-
- # BBB: Deprecated. Gone in X3.3.
- servicenames = Attribute("Service Names")
Modified: Zope3/trunk/src/zope/app/zopeappgenerations/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/zopeappgenerations/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/zopeappgenerations/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,8 +23,8 @@
ZopeAppSchemaManager = SchemaManager(
- minimum_generation=0,
- generation=3,
+ minimum_generation=1,
+ generation=4,
package_name=key)
Deleted: Zope3/trunk/src/zope/app/zopeappgenerations/evolve1.py
===================================================================
--- Zope3/trunk/src/zope/app/zopeappgenerations/evolve1.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/zopeappgenerations/evolve1.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,198 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Evolve the ZODB from Zope X3.0 to a Zope X3.1 compatible format.
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-import zope.deprecation
-
-from zope.app import zapi
-from zope.app.component.interfaces.registration import IRegistrationManager
-from zope.app.component.interfaces.registration import IRegisterableContainer
-from zope.app.error.error import ErrorReportingUtility
-from zope.app.error.interfaces import IErrorReportingUtility
-from zope.app.principalannotation import PrincipalAnnotationUtility
-from zope.app.principalannotation.interfaces import IPrincipalAnnotationUtility
-from zope.app.component.interfaces.registration import ActiveStatus
-from zope.app.component.interfaces.registration import InactiveStatus
-from zope.app.zopeappgenerations import getRootFolder
-
-# Imports that are only available via backward-compatibility
-zope.deprecation.__show__.off()
-from zope.component.bbb.service import IService
-from zope.app.site.interfaces import ISite, IServiceRegistration
-from zope.app.utility import UtilityRegistration
-zope.deprecation.__show__.on()
-
-from zope.app.generations.utility import findObjectsProviding
-
-generation = 1
-
-def evolve(context):
- """Evolve the ZODB from a Zope X3.0 to a X3.1 compatible format.
-
- - The Principal Annotation Service was replaced by the Principal
- Annotation Utility. Thus all service registrations have to be changed to
- utility registrations.
-
- - The Error Reporting Service was replaced by the Error Reporting
- Utility. Thus, all service registrations have to be changed to utility
- registrations.
-
- - Component-based registrations used to keep track of their components via
- the component's path. Now it stores the component directly. All
- registrations are updated to this new format.
-
- - Converts all service registrations to utility registrations providing
- IService, which is the method used to simulate the old service API.
-
- - Remove 'RegistrationManager' object from all site management folders.
-
- - Remove all local adapter and utility service instances.
- """
- root = getRootFolder(context)
-
- for site in findObjectsProviding(root, ISite):
- sm = site.getSiteManager()
-
- # Remove old registration manager instances
- for rm in findObjectsProviding(sm, IRegistrationManager):
- # Make sure that we called the new registration manager
- # which will retrieve the old one, if necessary
- zapi.getParent(rm).registrationManager = rm
-
- # Do a hard core delete, because I want no whining and complaining
- container = zapi.getParent(rm)
- del container._SampleContainer__data[zapi.getName(rm)]
-
- # Make sure the new registration manager has the correct name:
- rm.__name__ = '++registrations++'
- rm.__parent__ = container
-
- for reg_container in findObjectsProviding(sm, IRegisterableContainer):
- manager = reg_container.registrationManager
-
- # Iterate through each registration and fix it up.
- for reg in tuple(manager.values()):
-
- # Regardless of registration type, we want to convert the
- # component path to component
- if ('_BBB_componentPath' in reg.__dict__ and
- reg._BBB_componentPath is not None):
-
- reg.component = reg.getComponent()
- del reg.__dict__['_BBB_componentPath']
-
- # Fixup and convert service registrations
- if IServiceRegistration.providedBy(reg):
- if reg.name == 'ErrorLogging':
- fixupErrorLogging(reg_container, reg)
-
- elif reg.name == 'PrincipalAnnotation':
- fixupPrincipalAnnotation(reg_container, reg)
-
- elif reg.name in ('Utilities', 'Adapters'):
- # Delete the registration
- reg.status = InactiveStatus
- del manager[zapi.name(reg)]
- # Delete the component
- c = reg.component
- del zapi.getParent(c)[zapi.name(c)]
-
- else:
- # Handle all outstanding service registrations
- # Create a new utility registration
- new_reg = UtilityRegistration(reg.name, IService,
- reg.component)
- manager.addRegistration(new_reg)
- new_reg.status = ActiveStatus
- # Delete the old registration
- reg.status = InactiveStatus
- del manager[zapi.getName(reg)]
-
- # Fixup utility registrations
- else:
- # Getting the provided interface converts the utility
- # registration automatically from 'interface' -> 'provided'
- reg.provided
- # Now let's reactivate the utility, so it will be
- # available within the new framework
- orig = reg.status
- reg.status = InactiveStatus
- reg.status = orig
-
-
-def fixupErrorLogging(reg_container, reg):
- # Fix up Error Reporting Service --> Utility
- # We do this by simply removing old Error Reporting Services and their
- # registrations and then add a new error reporting utility.
-
- errors = reg.component
- # Set the registration to unregistered and then delete it
- reg.status = InactiveStatus
- del zapi.getParent(reg)[zapi.name(reg)]
- # Get the properties from the old error reporting service and
- # delete it
- props = errors.getProperties()
- folder = zapi.getParent(errors)
- del folder._SampleContainer__data[zapi.name(errors)]
-
- # Only add a new error reporting utility, if there is none.
- if 'ErrorReporting' not in folder:
- # Create the error reporting utility and set its properties
- utility = ErrorReportingUtility()
- utility.setProperties(**props)
- folder['ErrorReporting'] = utility
- # Register the utility and set the registration active
- reg = UtilityRegistration('', IErrorReportingUtility, utility)
- reg_manager = folder.registrationManager
- key = reg_manager.addRegistration(reg)
- reg_manager[key].status = ActiveStatus
- else:
- # If there is one, then at least move the data
- folder['ErrorReporting'].__dict__.update(props)
-
-
-def fixupPrincipalAnnotation(reg_container, reg):
- # Fix up Principal Annotation Service --> Utility
- ann = reg.component
- # Set the registration to inactive and then delete it
- reg.status = InactiveStatus
- del zapi.getParent(reg)[zapi.name(reg)]
- # Get the instance dictionary from the old principal
- # annotation service and then delete the service
- props = ann.__dict__
- name = zapi.name(ann)
- folder = zapi.getParent(ann)
- del folder._SampleContainer__data[name]
-
- # Only add a new principal annotation utility, if there is none.
- utils = [obj for obj in folder.values()
- if IPrincipalAnnotationUtility.providedBy(obj)]
- if len(utils) == 0:
- # Create the principal annotation utility and set its
- # properties
- utility = PrincipalAnnotationUtility()
- utility.__dict__.update(props)
- folder[name] = utility
- # Register the utility and set the registration active
- reg = UtilityRegistration('', IPrincipalAnnotationUtility,
- utility)
- reg_manager = folder.getRegistrationManager()
- key = reg_manager.addRegistration(reg)
- reg_manager[key].status = ActiveStatus
- else:
- # If there is one, then at least move the data
- utils[0].__dict__.update(props)
Modified: Zope3/trunk/src/zope/app/zopeappgenerations/evolve3.py
===================================================================
--- Zope3/trunk/src/zope/app/zopeappgenerations/evolve3.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/zopeappgenerations/evolve3.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -29,7 +29,7 @@
from zope.app.component import registration
import zope.app.authentication.interfaces
from zope.app.authentication import groupfolder
-from zope.app.copypastemove.interfaces import IObjectMover
+from zope.copypastemove.interfaces import IObjectMover
generation = 3
Copied: Zope3/trunk/src/zope/app/zopeappgenerations/evolve4.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/app/zopeappgenerations/evolve4.py)
Modified: Zope3/trunk/src/zope/app/zptpage/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/zptpage/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/zptpage/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -28,13 +28,13 @@
interface=".interfaces.IRenderZPTPage"
/>
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable"
+ interface="zope.annotation.interfaces.IAttributeAnnotatable"
/>
</class>
<adapter
for="zope.app.folder.interfaces.IFolder"
- provides="zope.app.filerepresentation.interfaces.IFileFactory"
+ provides="zope.filerepresentation.interfaces.IFileFactory"
name=".pt"
factory=".zptpage.ZPTFactory"
permission="zope.ManageContent"
@@ -42,21 +42,21 @@
<adapter
for=".interfaces.IZPTPage"
- provides="zope.app.filerepresentation.interfaces.IReadFile"
+ provides="zope.filerepresentation.interfaces.IReadFile"
factory=".zptpage.ZPTReadFile"
permission="zope.ManageContent"
/>
<adapter
for=".interfaces.IZPTPage"
- provides="zope.app.filerepresentation.interfaces.IWriteFile"
+ provides="zope.filerepresentation.interfaces.IWriteFile"
factory=".zptpage.ZPTWriteFile"
permission="zope.ManageContent"
/>
<adapter
for=".interfaces.IZPTPage"
- provides="zope.app.size.interfaces.ISized"
+ provides="zope.size.interfaces.ISized"
factory=".zptpage.Sized"
trusted="y"
permission="zope.ManageContent"
Modified: Zope3/trunk/src/zope/app/zptpage/tests/test_zptpage.py
===================================================================
--- Zope3/trunk/src/zope/app/zptpage/tests/test_zptpage.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/zptpage/tests/test_zptpage.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,28 +15,24 @@
$Id$
"""
-
import unittest
+from zope.component import getMultiAdapter
from zope.interface import directlyProvides
from zope.interface.verify import verifyClass
from zope.security.interfaces import Forbidden
+from zope.security.checker import NamesChecker, defineChecker
+from zope.publisher.browser import TestRequest, BrowserView
+from zope.location.traversing import LocationPhysicallyLocatable
+from zope.traversing.adapters import Traverser, DefaultTraversable
+from zope.traversing.adapters import RootPhysicallyLocatable
+from zope.traversing.interfaces import ITraverser, ITraversable
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.traversing.interfaces import IContainmentRoot
-from zope.app import zapi
from zope.app.testing import ztapi
-from zope.publisher.browser import TestRequest
-from zope.app.publisher.browser import BrowserView
-
-# Wow, this is a lot of work. :(
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.traversing.adapters import Traverser, DefaultTraversable
-from zope.app.traversing.interfaces import ITraverser, ITraversable
-from zope.app.traversing.interfaces import IPhysicallyLocatable
-from zope.app.traversing.interfaces import IContainmentRoot
-from zope.security.checker import NamesChecker, defineChecker
from zope.app.container.contained import contained
-from zope.app.location.traversing import LocationPhysicallyLocatable
-from zope.app.traversing.adapters import RootPhysicallyLocatable
from zope.app.zptpage.interfaces import IZPTPage
from zope.app.zptpage.zptpage import ZPTPage, ZPTSourceView,\
@@ -110,7 +106,7 @@
defineChecker(AU, NamesChecker(['__str__']))
- from zope.app.traversing.namespace import view
+ from zope.traversing.namespace import view
ztapi.provideNamespaceHandler('view', view)
ztapi.browserView(IZPTPage, 'name', AU)
@@ -168,7 +164,7 @@
class SizedTests(unittest.TestCase):
def testInterface(self):
- from zope.app.size.interfaces import ISized
+ from zope.size.interfaces import ISized
self.failUnless(ISized.implementedBy(Sized))
self.failUnless(verifyClass(ISized, Sized))
@@ -227,7 +223,7 @@
page.setSource(html, content_type='text/plain')
request = TestRequest()
- view = zapi.getMultiAdapter((page, request), name='source.html')
+ view = getMultiAdapter((page, request), name='source.html')
self.assertEqual(str(view), html)
self.assertEqual(view(), html)
Modified: Zope3/trunk/src/zope/app/zptpage/zptpage.py
===================================================================
--- Zope3/trunk/src/zope/app/zptpage/zptpage.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/app/zptpage/zptpage.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,18 +20,18 @@
from zope.security.proxy import ProxyFactory
from zope.interface import implements
from zope.pagetemplate.pagetemplate import PageTemplate
+from zope.size.interfaces import ISized
+from zope.publisher.browser import BrowserView
+from zope.traversing.api import getPath
+from zope.filerepresentation.interfaces import IReadFile, IWriteFile
+from zope.filerepresentation.interfaces import IFileFactory
from zope.app.pagetemplate.engine import AppPT
from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.size.interfaces import ISized
-from zope.app.filerepresentation.interfaces import IReadFile, IWriteFile
-from zope.app.filerepresentation.interfaces import IFileFactory
from zope.app.container.contained import Contained
-from zope.app import zapi
from zope.app.publication.interfaces import IFileContent
+from zope.app.zptpage.interfaces import IZPTPage, IRenderZPTPage
-from interfaces import IZPTPage, IRenderZPTPage
-
class ZPTPage(AppPT, PageTemplate, Persistent, Contained):
implements(IZPTPage, IRenderZPTPage, IFileContent)
@@ -71,7 +71,7 @@
def pt_source_file(self):
try:
- return zapi.getPath(self)
+ return getPath(self)
except TypeError:
return None
@@ -151,7 +151,6 @@
page.setSource(data.decode('UTF-8'), content_type or 'text/html')
return page
-from zope.app.publisher.browser import BrowserView
class ZPTSourceView(BrowserView):
def __str__(self):
Modified: Zope3/trunk/src/zope/component/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/component/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -2,3 +2,4 @@
zope.interface
zope.testing
zope.deprecation
+zope.deferredimport
Modified: Zope3/trunk/src/zope/component/__init__.py
===================================================================
--- Zope3/trunk/src/zope/component/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,6 +16,7 @@
$Id$
"""
import sys
+import zope.deferredimport
import zope.interface
from types import ClassType
from zope.interface import moduleProvides, Interface
@@ -24,335 +25,54 @@
from zope.component.interfaces import IComponentRegistrationConvenience
from zope.component.interfaces import IDefaultViewName
from zope.component.interfaces import IFactory
-from zope.component.interfaces import ISiteManager
from zope.component.interfaces import ComponentLookupError
-from zope.component.site import globalSiteManager
+from zope.component.interfaces import IComponentLookup
-_class_types = type, ClassType
+zope.deferredimport.defineFrom(
+ 'zope.component.globalregistry',
+ 'globalSiteManager', 'getGlobalSiteManager',
+ 'provideUtility', 'provideAdapter',
+ 'provideSubscriptionAdapter', 'provideHandler',
+ )
-##############################################################################
-# BBB: Import some backward-compatibility; 12/10/2004
-from zope.component.bbb import exceptions
-sys.modules['zope.component.exceptions'] = exceptions
-from zope.component.bbb import service
-sys.modules['zope.component.service'] = service
-from zope.component.bbb import adapter
-sys.modules['zope.component.adapter'] = adapter
-from zope.component.bbb import utility
-sys.modules['zope.component.utility'] = utility
-from zope.component.bbb import servicenames
-sys.modules['zope.component.servicenames'] = servicenames
-from zope.component.bbb import contextdependent
-sys.modules['zope.component.contextdependent'] = contextdependent
+zope.deferredimport.defineFrom(
+ 'zope.component._api',
+ 'getSiteManager', 'queryAdapterInContext', 'getAdapterInContext',
+ 'getAdapter', 'queryAdapter', 'getMultiAdapter', 'queryMultiAdapter',
+ 'getAdapters', 'subscribers', 'handle', 'adapter_hook',
+ 'getUtility', 'queryUtility', 'getUtilitiesFor',
+ 'getAllUtilitiesRegisteredFor',
+ 'createObject', 'getFactoryInterfaces', 'getFactoriesFor',
+ )
-from zope.component.bbb import tests as bbb_tests
-bbb_tests.__warn__ = False
-from zope.component.bbb.tests import placelesssetup
-sys.modules['zope.component.tests.placelesssetup'] = placelesssetup
-from zope.component.bbb.tests import request
-sys.modules['zope.component.tests.request'] = request
-from zope.component.bbb.tests import components
-sys.modules['zope.component.tests.components'] = components
-bbb_tests.__warn__ = True
+zope.deferredimport.defineFrom(
+ 'zope.component._declaration',
+ 'adapter', 'adapts', 'adaptedBy',
+ )
-service.__warn__ = False
-service.serviceManager = service.GlobalServiceManager(
- 'serviceManager', __name__, globalSiteManager)
-service.__warn__ = True
+zope.deferredimport.deprecated(
+ "Use IComponentLookup instead. ISiteManager will be removed in Zope 3.5.",
+ ISiteManager = "zope.component.interfaces:IComponentLookup",
+ )
-from zope.component.bbb import getGlobalServices, getGlobalService
-from zope.component.bbb import getServices, getService
-from zope.component.bbb import getServiceDefinitions
-from zope.component.bbb import getView, queryView
-from zope.component.bbb import getMultiView, queryMultiView
-from zope.component.bbb import getViewProviding, queryViewProviding
-from zope.component.bbb import getDefaultViewName, queryDefaultViewName
-from zope.component.bbb import getResource, queryResource
-##############################################################################
-
-
-# Try to be hookable. Do so in a try/except to avoid a hard dependency.
-try:
- from zope.hookable import hookable
-except ImportError:
- def hookable(ob):
- return ob
-
moduleProvides(IComponentArchitecture, IComponentRegistrationConvenience)
__all__ = tuple(IComponentArchitecture)
-# SiteManager API
-
-def getGlobalSiteManager():
- return globalSiteManager
-
-def getSiteManager(context=None):
- if context is None:
- return getGlobalSiteManager()
- else:
- # Use the global site manager to adapt context to `ISiteManager`
- # to avoid the recursion implied by using a local `getAdapter()` call.
- try:
- return ISiteManager(context)
- except TypeError, error:
- raise ComponentLookupError(*error.args)
-
-getSiteManager = hookable(getSiteManager)
-
-
-# Adapter API
-
-def getAdapterInContext(object, interface, context):
- adapter = queryAdapterInContext(object, interface, context)
- if adapter is None:
- raise ComponentLookupError(object, interface)
- return adapter
-
-def queryAdapterInContext(object, interface, context, default=None):
- conform = getattr(object, '__conform__', None)
- if conform is not None:
- try:
- adapter = conform(interface)
- except TypeError:
- # We got a TypeError. It might be an error raised by
- # the __conform__ implementation, or *we* may have
- # made the TypeError by calling an unbound method
- # (object is a class). In the later case, we behave
- # as though there is no __conform__ method. We can
- # detect this case by checking whether there is more
- # than one traceback object in the traceback chain:
- if sys.exc_info()[2].tb_next is not None:
- # There is more than one entry in the chain, so
- # reraise the error:
- raise
- # This clever trick is from Phillip Eby
- else:
- if adapter is not None:
- return adapter
-
- if interface.providedBy(object):
- return object
-
- return getSiteManager(context).queryAdapter(object, interface, '', default)
-
-def getAdapter(object, interface=Interface, name=u'', context=None):
- adapter = queryAdapter(object, interface, name, None, context)
- if adapter is None:
- raise ComponentLookupError(object, interface, name)
- return adapter
-
-def queryAdapter(object, interface=Interface, name=u'', default=None,
- context=None):
- if context is None:
- return adapter_hook(interface, object, name, default)
- return getSiteManager(context).queryAdapter(object, interface, name,
- default)
-
-def getMultiAdapter(objects, interface=Interface, name=u'', context=None):
- adapter = queryMultiAdapter(objects, interface, name, context=context)
- if adapter is None:
- raise ComponentLookupError(objects, interface, name)
- return adapter
-
-def queryMultiAdapter(objects, interface=Interface, name=u'', default=None,
- context=None):
- try:
- sitemanager = getSiteManager(context)
- except ComponentLookupError:
- # Oh blast, no site manager. This should *never* happen!
- return default
-
- return sitemanager.queryMultiAdapter(objects, interface, name, default)
-
-def getAdapters(objects, provided, context=None):
- try:
- sitemanager = getSiteManager(context)
- except ComponentLookupError:
- # Oh blast, no site manager. This should *never* happen!
- return []
- return sitemanager.getAdapters(objects, provided)
-
-def subscribers(objects, interface, context=None):
- try:
- sitemanager = getSiteManager(context)
- except ComponentLookupError:
- # Oh blast, no site manager. This should *never* happen!
- return []
- return sitemanager.subscribers(objects, interface)
-
-def handle(*objects):
- sitemanager = getSiteManager(None)
- # iterating over subscribers assures they get executed
- for ignored in sitemanager.subscribers(objects, None):
- pass
-
-class _adapts_descr(object):
- def __init__(self, interfaces):
- self.interfaces = interfaces
-
- def __get__(self, inst, cls):
- if inst is None:
- return self.interfaces
- raise AttributeError('__component_adapts__')
-
-class adapter:
-
- def __init__(self, *interfaces):
- self.interfaces = interfaces
-
- def __call__(self, ob):
- if isinstance(ob, _class_types):
- ob.__component_adapts__ = _adapts_descr(self.interfaces)
- else:
- ob.__component_adapts__ = self.interfaces
-
- return ob
-
-def adapts(*interfaces):
- frame = sys._getframe(1)
- locals = frame.f_locals
-
- # Try to make sure we were called from a class def. In 2.2.0 we can't
- # check for __module__ since it doesn't seem to be added to the locals
- # until later on.
- if (locals is frame.f_globals) or (
- ('__module__' not in locals) and sys.version_info[:3] > (2, 2, 0)):
- raise TypeError("adapts can be used only from a class definition.")
-
- if '__component_adapts__' in locals:
- raise TypeError("adapts can be used only once in a class definition.")
-
- locals['__component_adapts__'] = _adapts_descr(interfaces)
-
-def adaptedBy(ob):
- return getattr(ob, '__component_adapts__', None)
-
-#############################################################################
-# Register the component architectures adapter hook, with the adapter hook
-# registry of the `zope.inteface` package. This way we will be able to call
-# interfaces to create adapters for objects. For example, `I1(ob)` is
-# equvalent to `getAdapterInContext(I1, ob, '')`.
-def adapter_hook(interface, object, name='', default=None):
- try:
- sitemanager = getSiteManager()
- except ComponentLookupError:
- # Oh blast, no site manager. This should *never* happen!
- return None
- return sitemanager.queryAdapter(object, interface, name, default)
-
-# Make the component architecture's adapter hook hookable
-adapter_hook = hookable(adapter_hook)
-
-import zope.interface.interface
-zope.interface.interface.adapter_hooks.append(adapter_hook)
-#############################################################################
-
-
-# Utility API
-
-def getUtility(interface, name='', context=None):
- utility = queryUtility(interface, name, context=context)
- if utility is not None:
- return utility
- raise ComponentLookupError(interface, name)
-
-def queryUtility(interface, name='', default=None, context=None):
- return getSiteManager(context).queryUtility(interface, name, default)
-
-def getUtilitiesFor(interface, context=None):
- return getSiteManager(context).getUtilitiesFor(interface)
-
-
-def getAllUtilitiesRegisteredFor(interface, context=None):
- return getSiteManager(context).getAllUtilitiesRegisteredFor(interface)
-
-
-# Factories
-
-def createObject(__factory_name, *args, **kwargs):
- # BBB: Goes away in 3.3
- if not isinstance(__factory_name, basestring):
- import warnings
- warnings.warn(
- "Passing a context as a first argument to createObject is "
- "deprecated. It will be unsupported in Zope X3.3. Use a "
- "context keyword argument instead.",
- DeprecationWarning, 2)
- context = __factory_name
- __factory_name, args = args[0], args[1:]
- else:
- context = kwargs.pop('context', None)
-
- return getUtility(IFactory, __factory_name, context)(*args, **kwargs)
-
-def getFactoryInterfaces(name, context=None):
- return getUtility(IFactory, name, context).getInterfaces()
-
-def getFactoriesFor(interface, context=None):
- utils = getSiteManager(context)
- for (name, factory) in utils.getUtilitiesFor(IFactory):
- interfaces = factory.getInterfaces()
- try:
- if interfaces.isOrExtends(interface):
- yield name, factory
- except AttributeError:
- for iface in interfaces:
- if iface.isOrExtends(interface):
- yield name, factory
- break
-
-
-# The following APIs provide registration support for Python code:
-
-def provideUtility(component, provides=None, name=u''):
- if provides is None:
- provides = list(providedBy(component))
- if len(provides) == 1:
- provides = provides[0]
- else:
- raise TypeError("Missing 'provides' argument")
-
- getGlobalSiteManager().provideUtility(provides, component, name)
-
-
-def provideAdapter(factory, adapts=None, provides=None, name=''):
- if provides is None:
- provides = list(implementedBy(factory))
- if len(provides) == 1:
- provides = provides[0]
- else:
- raise TypeError("Missing 'provides' argument")
-
- if adapts is None:
- try:
- adapts = factory.__component_adapts__
- except AttributeError:
- raise TypeError("Missing 'adapts' argument")
-
- getGlobalSiteManager().provideAdapter(adapts, provides, name, factory)
-
-def provideSubscriptionAdapter(factory, adapts=None, provides=None):
- if provides is None:
- provides = list(implementedBy(factory))
- if len(provides) == 1:
- provides = provides[0]
- else:
- raise TypeError("Missing 'provides' argument")
-
- if adapts is None:
- try:
- adapts = factory.__component_adapts__
- except AttributeError:
- raise TypeError("Missing 'adapts' argument")
-
- getGlobalSiteManager().subscribe(adapts, provides, factory)
-
-def provideHandler(factory, adapts=None):
-
- if adapts is None:
- try:
- adapts = factory.__component_adapts__
- except AttributeError:
- raise TypeError("Missing 'adapts' argument")
-
- getGlobalSiteManager().subscribe(adapts, None, factory)
+zope.deferredimport.deprecated(
+ "This object was deprecated long ago. Only import is allowed now "
+ "and will be disallows in Zope 3.5.",
+ getGlobalServices = "zope.component.back35:deprecated",
+ getGlobalService = "zope.component.back35:deprecated",
+ getService = "zope.component.back35:deprecated",
+ getServiceDefinitions = "zope.component.back35:deprecated",
+ getView = "zope.component.back35:deprecated",
+ queryView = "zope.component.back35:deprecated",
+ getMultiView = "zope.component.back35:deprecated",
+ queryMultiView = "zope.component.back35:deprecated",
+ getViewProviding = "zope.component.back35:deprecated",
+ queryViewProviding = "zope.component.back35:deprecated",
+ getDefaultViewName = "zope.component.back35:deprecated",
+ queryDefaultViewName = "zope.component.back35:deprecated",
+ getResource = "zope.component.back35:deprecated",
+ queryResource = "zope.component.back35:deprecated",
+ )
Copied: Zope3/trunk/src/zope/component/_api.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/_api.py)
Copied: Zope3/trunk/src/zope/component/_declaration.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/_declaration.py)
Copied: Zope3/trunk/src/zope/component/adapter.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/adapter.py)
Copied: Zope3/trunk/src/zope/component/back35.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/back35.py)
Modified: Zope3/trunk/src/zope/component/bbb/__init__.py
===================================================================
--- Zope3/trunk/src/zope/component/bbb/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/bbb/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,218 +17,4 @@
"""
__docformat__ = "reStructuredText"
-__warn__ = True
-import sys
-import warnings
-
-from zope.interface import Interface, providedBy
-from zope.component.bbb.interfaces import IServiceService, IDefaultViewName
-from zope.component.bbb.service import GlobalServiceManager
-
-# Try to be hookable. Do so in a try/except to avoid a hard dependency.
-try:
- from zope.hookable import hookable
-except ImportError:
- def hookable(ob):
- return ob
-
-def warningLevel():
- """Returns the number of the first stack frame outside of zope.component"""
- try:
- level = 2
- while sys._getframe(level).f_globals['__name__']=='zope.component.bbb':
- level += 1
- return level
- except ValueError:
- return 2
-
-
-def getGlobalServices():
- if __warn__:
- warnings.warn(
- "The concept of services has been deprecated. You probably want to "
- "use `getGlobalSiteManager()`.",
- DeprecationWarning, warningLevel())
- from zope.component import getGlobalSiteManager
- return GlobalServiceManager('servicemanager', 'zope.component.service',
- getGlobalSiteManager())
-
-def getGlobalService(name):
- if __warn__:
- warnings.warn(
- "The concept of services has been deprecated. You probably want to "
- "use `getGlobalSiteManager()` or `getUtility()`.",
- DeprecationWarning, warningLevel())
- return getGlobalServices().getService(name)
-
-def getServices(context=None):
- if __warn__:
- warnings.warn(
- "The concept of services has been deprecated. You probably want to "
- "use `getGlobalSiteManager()` or `getUtility()`.",
- DeprecationWarning, warningLevel())
- if context is None:
- return getGlobalServices()
- else:
- # Use the global service manager to adapt context to IServiceService
- # to avoid the recursion implied by using a local getAdapter call.
- try:
- return IServiceService(context)
- except TypeError, error:
- from zope.component.bbb.exceptions import ComponentLookupError
- raise ComponentLookupError(*error.args)
-
-getServices = hookable(getServices)
-
-def getService(name, context=None):
- if __warn__:
- warnings.warn(
- "The concept of services has been deprecated. You probably want to "
- "use `getGlobalSiteManager()` or `getUtility()`.",
- DeprecationWarning, warningLevel())
- return getServices(context).getService(name)
-
-def getServiceDefinitions(context=None):
- if __warn__:
- warnings.warn(
- "The concept of services has been deprecated.",
- DeprecationWarning, warningLevel())
- return getServices(context).getServiceDefinitions()
-
-# Presentation API
-
-def getView(object, name, request, providing=Interface, context=None):
- if __warn__:
- warnings.warn(
- "The concrete concept of a view has been deprecated. You want to "
- "use `getMultiAdapter((object, request), providing, name, "
- "context)`.",
- DeprecationWarning, warningLevel())
- view = queryView(object, name, request, context=context,
- providing=providing)
- if view is not None:
- return view
-
- from zope.component.bbb.exceptions import ComponentLookupError
- raise ComponentLookupError("Couldn't find view",
- name, object, context, request, providing)
-
-def queryView(object, name, request,
- default=None, providing=Interface, context=None):
- if __warn__:
- warnings.warn(
- "The concrete concept of a view has been deprecated. You want to "
- "use `queryMultiAdapter((object, request), providing, name, "
- "default, context)`.",
- DeprecationWarning, warningLevel())
- from zope.component import queryMultiAdapter
- return queryMultiAdapter((object, request), providing, name,
- default, context)
-
-queryView = hookable(queryView)
-
-def getMultiView(objects, request, providing=Interface, name='', context=None):
- if __warn__:
- warnings.warn(
- "The concrete concept of a view has been deprecated. You want to "
- "use `getMultiAdapter(objects+(request,), providing, name, "
- "context)`.",
- DeprecationWarning, warningLevel())
- view = queryMultiView(objects, request, providing, name, context=context)
- if view is not None:
- return view
-
- from zope.component.bbb.exceptions import ComponentLookupError
- raise ComponentLookupError("Couldn't find view",
- name, objects, context, request)
-
-def queryMultiView(objects, request, providing=Interface, name='',
- default=None, context=None):
- if __warn__:
- warnings.warn(
- "The concrete concept of a view has been deprecated. You want to "
- "use `getMultiAdapter(objects+(request,), providing, name, "
- "default, context)`.",
- DeprecationWarning, warningLevel())
- from zope.component import queryMultiAdapter
- return queryMultiAdapter(objects+(request,), providing, name,
- default, context)
-
-def getViewProviding(object, providing, request, context=None):
- if __warn__:
- warnings.warn(
- "The concrete concept of a view has been deprecated. You want to "
- "use `getMultiAdapter((object, request), providing, name, "
- "context)`.",
- DeprecationWarning, warningLevel())
- return getView(object, '', request, providing, context)
-
-def queryViewProviding(object, providing, request, default=None,
- context=None):
- if __warn__:
- warnings.warn(
- "The concrete concept of a view has been deprecated. You want to "
- "use `queryMultiAdapter((object, request), providing, name, "
- "default, context)`.",
- DeprecationWarning, warningLevel())
- return queryView(object, '', request, default, providing, context)
-
-def getDefaultViewName(object, request, context=None):
- if __warn__:
- warnings.warn(
- "The concrete concept of a view has been deprecated. You want to "
- "use `zapi.getDefaultViewName()` instead.",
- DeprecationWarning, warningLevel())
- view = queryDefaultViewName(object, request, context=context)
- if view is not None:
- return view
-
- from zope.component.bbb.exceptions import ComponentLookupError
- raise ComponentLookupError("Couldn't find default view name",
- context, request)
-
-def queryDefaultViewName(object, request, default=None, context=None):
- if __warn__:
- warnings.warn(
- "The concrete concept of a view has been deprecated. You want to "
- "use `zapi.queryDefaultViewName()` instead.",
- DeprecationWarning, warningLevel())
- from zope.component.bbb.exceptions import ComponentLookupError
- from zope.component import getSiteManager
- try:
- adapters = getSiteManager(context)
- except ComponentLookupError:
- # Oh blast, no adapter service. We're probably just running from a test
- return default
-
- name = adapters.adapters.lookup(map(providedBy, (object, request)),
- IDefaultViewName)
- if name is not None:
- return name
- return default
-
-def getResource(name, request, providing=Interface, context=None):
- if __warn__:
- warnings.warn(
- "The concrete concept of a resource has been deprecated. You want "
- "to use `getAdapter(request, providing, name, context)`",
- DeprecationWarning, warningLevel())
- view = queryResource(name, request, providing=providing, context=context)
- if view is not None:
- return view
-
- from zope.component.bbb.exceptions import ComponentLookupError
- raise ComponentLookupError("Couldn't find resource", name, request)
-
-def queryResource(name, request, default=None, providing=Interface,
- context=None):
- if __warn__:
- warnings.warn(
- "The concrete concept of a resource has been deprecated. You want "
- "to use `queryAdapter(request, providing, name, default, context)`",
- DeprecationWarning, warningLevel())
- from zope.component import queryAdapter
- return queryAdapter(request, providing, name, default, context)
-
-
Deleted: Zope3/trunk/src/zope/component/bbb/adapter.py
===================================================================
--- Zope3/trunk/src/zope/component/bbb/adapter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/bbb/adapter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,167 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Global Adapter Service
-
-$Id$
-"""
-__docformat__ = "reStructuredText"
-
-import sys
-import warnings
-from types import ClassType
-
-from zope.component.exceptions import ComponentLookupError
-from zope.component.interfaces import IAdapterService, IRegistry
-from zope.component.bbb.service import GlobalService
-from zope.component.site import AdapterRegistration, SubscriptionRegistration
-from zope.interface import implements, providedBy, Interface, implementedBy
-from zope.interface.interfaces import IInterface
-
-class IGlobalAdapterService(IAdapterService, IRegistry):
-
- def register(required, provided, name, factory, info=''):
- """Register an adapter factory
-
- :Parameters:
- - `required`: a sequence of specifications for objects to be
- adapted.
- - `provided`: The interface provided by the adapter
- - `name`: The adapter name
- - `factory`: The object used to compute the adapter
- - `info`: Provide some info about this particular adapter.
- """
-
- def subscribe(required, provided, factory, info=''):
- """Register a subscriber factory
-
- :Parameters:
- - `required`: a sequence of specifications for objects to be
- adapted.
- - `provided`: The interface provided by the adapter
- - `name`: The adapter name
- - `factory`: The object used to compute the subscriber
- - `info`: Provide some info about this particular adapter.
- """
-
-class AdapterService(object):
- """Base implementation of an adapter service, implementing only the
- `IAdapterService` interface.
-
- No write-methods were implemented.
- """
-
- implements(IAdapterService)
-
- def __init__(self, sitemanager=None):
- if sitemanager is None:
- from zope.component.site import GlobalSiteManager
- sitemanager = GlobalSiteManager()
- self.sm = sitemanager
-
- def __getattr__(self, name):
- attr = getattr(self.sm.adapters, name)
- if attr is not None:
- return attr
- raise AttributeError(name)
-
-
-class GlobalAdapterService(AdapterService, GlobalService):
- """Global Adapter Service implementation."""
-
- implements(IGlobalAdapterService)
-
- def __init__(self, sitemanager=None):
- super(GlobalAdapterService, self).__init__(sitemanager)
-
- def register(self, required, provided, name, factory, info=''):
- """Register an adapter
-
- >>> registry = GlobalAdapterService()
- >>> class R1(Interface):
- ... pass
- >>> class R2(R1):
- ... pass
- >>> class P1(Interface):
- ... pass
- >>> class P2(P1):
- ... pass
-
- >>> registry.register((R1, ), P2, 'bob', 'c1', 'd1')
- >>> registry.register((R1, ), P2, '', 'c2', 'd2')
- >>> registry.lookup((R2, ), P1, '')
- 'c2'
-
- >>> registrations = map(repr, registry.registrations())
- >>> registrations.sort()
- >>> for registration in registrations:
- ... print registration
- AdapterRegistration(('R1',), 'P2', '', 'c2', 'd2')
- AdapterRegistration(('R1',), 'P2', 'bob', 'c1', 'd1')
-
- Let's make sure that we can also register regular classes for
- adaptation.
-
- >>> class O1(object):
- ... pass
- >>> class O2(object):
- ... pass
- >>> class O3(object):
- ... def __init__(self, obj1, obj2=None):
- ... pass
-
- >>> registry.register((O1, ), R1, '', O3)
- >>> registry.queryAdapter(O1(), R1, '').__class__
- <class 'zope.component.bbb.adapter.O3'>
-
- >>> registry.register((O1, O2), R1, '', O3)
- >>> registry.queryMultiAdapter((O1(), O2()), R1, '').__class__
- <class 'zope.component.bbb.adapter.O3'>
- """
- self.sm.provideAdapter(required, provided, name, factory, info)
-
- def subscribe(self, required, provided, factory, info=''):
- """Register an subscriptions adapter
-
- >>> registry = GlobalAdapterService()
- >>> class R1(Interface):
- ... pass
- >>> class R2(R1):
- ... pass
- >>> class P1(Interface):
- ... pass
- >>> class P2(P1):
- ... pass
-
- >>> registry.subscribe((R1, ), P2, 'c1', 'd1')
- >>> registry.subscribe((R1, ), P2, 'c2', 'd2')
- >>> subscriptions = map(str, registry.subscriptions((R2, ), P1))
- >>> subscriptions.sort()
- >>> subscriptions
- ['c1', 'c2']
-
- >>> registrations = map(repr, registry.registrations())
- >>> registrations.sort()
- >>> for registration in registrations:
- ... print registration
- SubscriptionRegistration(('R1',), 'P2', 'c1', 'd1')
- SubscriptionRegistration(('R1',), 'P2', 'c2', 'd2')
-
- """
- self.sm.subscribe(required, provided, factory, info)
-
- def registrations(self):
- for registration in self.sm.registrations():
- if isinstance(registration,
- (AdapterRegistration, SubscriptionRegistration)):
- yield registration
Deleted: Zope3/trunk/src/zope/component/bbb/contextdependent.py
===================================================================
--- Zope3/trunk/src/zope/component/bbb/contextdependent.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/bbb/contextdependent.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,27 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""A simple mix-in class that implements IContextDependent.
-
-$Id$
-"""
-from zope.component.interfaces import IContextDependent
-from zope.interface import implements
-
-class ContextDependent(object):
- """standard boilerplate for context dependent objects"""
-
- implements(IContextDependent)
-
- def __init__(self, context):
- self.context = context
Deleted: Zope3/trunk/src/zope/component/bbb/exceptions.py
===================================================================
--- Zope3/trunk/src/zope/component/bbb/exceptions.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/bbb/exceptions.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,24 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Exceptions used by the Component Architecture
-
-$Id$
-"""
-from zope.component.interfaces import ComponentLookupError
-from zope.component.interfaces import Invalid, Misused
-
-
-__all__ = ["ComponentLookupError",
- "Invalid",
- "Misused"]
Deleted: Zope3/trunk/src/zope/component/bbb/service.py
===================================================================
--- Zope3/trunk/src/zope/component/bbb/service.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/bbb/service.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,172 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Service Manager implementation
-
-$Id$
-"""
-__warn__ = True
-import warnings
-
-from zope.exceptions import DuplicationError
-from zope.component.bbb.interfaces import IServiceService
-from zope.interface import implements, Interface, directlyProvides
-
-
-class IGlobalServiceManager(IServiceService):
-
- def defineService(name, interface):
- """Define a new service of the given name implementing the given
- interface. If the name already exists, raises
- DuplicationError"""
-
- def provideService(name, component):
- """Register a service component.
-
- Provide a service component to do the work of the named
- service. If a service component has already been assigned to
- this name, raise DuplicationError; if the name has not been
- defined, raises UndefinedService; if the component does not
- implement the registered interface for the service name,
- raises InvalidService.
-
- """
-
-class IService(Interface):
- """Marker interface that is used as utility interface to simulate
- services."""
-
-class IServiceDefinition(Interface):
- """Marker interface that is used as utility interface to store service
- defintions (name, interface)."""
-
-class UndefinedService(Exception):
- """An attempt to register a service that has not been defined
- """
-
-class InvalidService(Exception):
- """An attempt to register a service that doesn't implement
- the required interface
- """
-
-class GlobalServiceManager(object):
- """service manager"""
-
- implements(IGlobalServiceManager)
-
- def __init__(self, name=None, module=None, sitemanager=None):
- if __warn__:
- warnings.warn(
- "The concept of services has been deprecated. You now have "
- "only adapters and utilities, which are managed by the site "
- "manager, which is probably the object you want.",
- DeprecationWarning, 2)
- if sitemanager is None:
- from zope.component.site import GlobalSiteManager
- sitemanager = GlobalSiteManager()
- self.sm = sitemanager
- self.__name__ = name
- self.__module__ = module
-
- def _clear(self):
- pass
-
- def __reduce__(self):
- # Global service managers are pickled as global objects
- return self.__name__
-
- def defineService(self, name, interface):
- """see IGlobalServiceManager interface"""
-
- utils = self.sm.getAllUtilitiesRegisteredFor(IServiceDefinition)
- names = [n for n, iface in utils]
- if name in names:
- raise DuplicationError(name)
-
- self.sm.provideUtility(IServiceDefinition, (name, interface),
- name=name, strict=False)
-
- def getServiceDefinitions(self):
- """see IServiceService Interface"""
- defs = list(self.sm.getAllUtilitiesRegisteredFor(IServiceDefinition))
- return defs + [('Services', IServiceService)]
-
- def provideService(self, name, component, force=False):
- """see IGlobalServiceManager interface, above
-
- The force keyword allows one to replace an existing
- service. This is mostly useful in testing scenarios.
- """
-
- if not force and self.sm.queryUtility(IService, name) is not None:
- raise DuplicationError(name)
-
- utils = self.sm.getAllUtilitiesRegisteredFor(IServiceDefinition)
- if name not in [name for name, iface in utils]:
- raise UndefinedService(name)
-
- if not dict(self.getServiceDefinitions())[name].providedBy(component):
- raise InvalidService(name, component,
- dict(self.getServiceDefinitions())[name])
-
- if isinstance(component, GlobalService):
- component.__parent__ = self
- component.__name__ = name
-
- # Ignore the base services, since their functionality is provided by
- # the SM.
- if name in ('Adapters', 'Utilities', 'Services'):
- return
-
- directlyProvides(component, IService)
- self.sm.provideUtility(IService, component, name)
-
- def getService(self, name):
- """see IServiceService interface"""
- if name == 'Services':
- return self
-
- if name == 'Adapters':
- from zope.component.bbb.adapter import GlobalAdapterService
- return GlobalAdapterService(self.sm)
-
- if name == 'Utilities':
- from zope.component.bbb.utility import GlobalUtilityService
- return GlobalUtilityService(self.sm)
-
- service = self.sm.queryUtility(IService, name)
- if service is None:
- from zope.component.bbb.exceptions import ComponentLookupError
- raise ComponentLookupError(name)
-
- return service
-
-
-def GS(service_manager, service_name):
- return service_manager.getService(service_name)
-
-class GlobalService(object):
-
- def __reduce__(self):
- return GS, (self.__parent__, self.__name__)
-
-
-def __getSM(sitemanager=None):
- return GlobalServiceManager('serviceManager', __name__, sitemanager)
-
-def defineService(name, interface, sitemanager=None):
- if sitemanager is None:
- from zope.component.site import globalSiteManager
- sitemanager = globalSiteManager
- __getSM(sitemanager).defineService(name, interface)
-
Deleted: Zope3/trunk/src/zope/component/bbb/servicenames.py
===================================================================
--- Zope3/trunk/src/zope/component/bbb/servicenames.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/bbb/servicenames.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,20 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Default service names for CA core services
-
-$Id$
-"""
-Adapters = 'Adapters'
-Utilities = 'Utilities'
-Services = 'Services'
Deleted: Zope3/trunk/src/zope/component/bbb/utility.py
===================================================================
--- Zope3/trunk/src/zope/component/bbb/utility.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/bbb/utility.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,72 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""utility service
-
-$Id$
-"""
-from zope.component.exceptions import Invalid, ComponentLookupError
-from zope.component.interfaces import IUtilityService, IRegistry
-from zope.component.service import GlobalService, IService, IServiceDefinition
-from zope.component.site import UtilityRegistration
-import zope.interface
-
-class IGlobalUtilityService(IUtilityService, IRegistry):
-
- def provideUtility(providedInterface, component, name='', info=''):
- """Provide a utility
-
- A utility is a component that provides an interface.
- """
-
-class UtilityService(object):
- """Provide IUtilityService
-
- Mixin that superimposes utility management on adapter registery
- implementation
- """
-
- def __init__(self, sitemanager=None):
- self.__parent__ = None
- if sitemanager is None:
- from zope.component.site import GlobalSiteManager
- sitemanager = GlobalSiteManager()
- self.sm = sitemanager
-
- def __getattr__(self, name):
- attr = getattr(self.sm, name)
- if attr is not None:
- return attr
-
- attr = getattr(self.sm.utilities, name)
- if attr is not None:
- return attr
-
- raise AttributeError(name)
-
-
-class GlobalUtilityService(UtilityService, GlobalService):
-
- zope.interface.implementsOnly(IGlobalUtilityService)
-
- def __init__(self, sitemanager=None):
- super(GlobalUtilityService, self).__init__(sitemanager)
-
- def provideUtility(self, providedInterface, component, name='', info=''):
- self.sm.provideUtility(providedInterface, component, name, info)
-
- def registrations(self):
- for reg in self.sm.registrations():
- if isinstance(reg, UtilityRegistration):
- if not reg.provided in (IService, IServiceDefinition):
- yield reg
Copied: Zope3/trunk/src/zope/component/contextdependent.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/contextdependent.py)
Copied: Zope3/trunk/src/zope/component/event.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/event.py)
Copied: Zope3/trunk/src/zope/component/event.txt (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/event.txt)
Copied: Zope3/trunk/src/zope/component/eventtesting.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/eventtesting.py)
Copied: Zope3/trunk/src/zope/component/exceptions.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/exceptions.py)
Modified: Zope3/trunk/src/zope/component/factory.txt
===================================================================
--- Zope3/trunk/src/zope/component/factory.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/factory.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -101,7 +101,7 @@
>>> gsm = zope.component.getGlobalSiteManager()
>>> from zope.component.interfaces import IFactory
- >>> gsm.provideUtility(IFactory, factory, 'klass')
+ >>> gsm.registerUtility(factory, IFactory, 'klass')
Creating an Object
++++++++++++++++++
Copied: Zope3/trunk/src/zope/component/globalregistry.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/globalregistry.py)
Copied: Zope3/trunk/src/zope/component/interface.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/interface.py)
Modified: Zope3/trunk/src/zope/component/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/component/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,19 +15,14 @@
$Id$
"""
-import zope.deprecation
-from zope.interface import Interface, Attribute
+import zope.deferredimport
+from zope import interface
-# BBB: Can be removed in 3.3
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError
-zope.deprecation.__show__.on()
-
# BBB: Backward-compatibility; 12/05/2004
from bbb.interfaces import *
-class ComponentLookupError(NotFoundError):
+class ComponentLookupError(LookupError):
"""A component could not be found."""
class Invalid(Exception):
@@ -36,7 +31,28 @@
class Misused(Exception):
"""A component is being used (registered) for the wrong interface."""
-class IComponentArchitecture(Interface, IBBBComponentArchitecture):
+
+class IObjectEvent(interface.Interface):
+ """An event related to an object.
+
+ The object that generated this event is not necessarily the object
+ refered to by location.
+ """
+
+ object = interface.Attribute("The subject of the event.")
+
+
+class ObjectEvent(object):
+ interface.implements(IObjectEvent)
+
+ # for repr backward compatibility. In the next release cycle, we'll
+ # provide a testing framework that addresses repr migration.
+ __module__ = 'zope.app.event.objectevent'
+
+ def __init__(self, object):
+ self.object = object
+
+class IComponentArchitecture(interface.Interface):
"""The Component Architecture is defined by two key components: Adapters
and Utiltities. Both are managed by site managers. All other components
build on top of them.
@@ -55,9 +71,10 @@
If `context` is `None`, return the global site manager.
- If the `context` is not `None`, it is expected that an adapter from
- the `context` to `ISiteManager` can be found. If no adapter is found,
- a `ComponentLookupError` is raised.
+ If the `context` is not `None`, it is expected that an adapter
+ from the `context` to `IComponentLookup` can be found. If no
+ adapter is found, a `ComponentLookupError` is raised.
+
"""
# Utility API
@@ -94,7 +111,9 @@
# Adapter API
- def getAdapter(object, interface=Interface, name=u'', context=None):
+ def getAdapter(object,
+ interface=interface.Interface, name=u'',
+ context=None):
"""Get a named adapter to an interface for an object
Returns an adapter that can adapt object to interface. If a matching
@@ -129,7 +148,9 @@
returned.
"""
- def getMultiAdapter(objects, interface=Interface, name='', context=None):
+ def getMultiAdapter(objects,
+ interface=interface.Interface, name='',
+ context=None):
"""Look for a multi-adapter to an interface for an objects
Returns a multi-adapter that can adapt objects to interface. If a
@@ -146,8 +167,8 @@
named adapter methods with an empty string for a name.
"""
- def queryAdapter(object, interface=Interface, name=u'', default=None,
- context=None):
+ def queryAdapter(object, interface=interface.Interface, name=u'',
+ default=None, context=None):
"""Look for a named adapter to an interface for an object
Returns an adapter that can adapt object to interface. If a matching
@@ -182,7 +203,9 @@
returned.
"""
- def queryMultiAdapter(objects, interface=Interface, name=u'', default=None,
+ def queryMultiAdapter(objects,
+ interface=interface.Interface, name=u'',
+ default=None,
context=None):
"""Look for a multi-adapter to an interface for objects
@@ -275,48 +298,53 @@
create objects which implement the given interface.
"""
-
-class ISiteManager(Interface):
+class IComponentLookup(interface.Interface):
"""Component Manager for a Site
This object manages the components registered at a particular site. The
definition of a site is intentionally vague.
"""
- adapters = Attribute("Adapter Registry to manage all registered "
- "adapters.")
+ adapters = interface.Attribute(
+ "Adapter Registry to manage all registered adapters.")
- utilities = Attribute("Adapter Registry to manage all registered "
- "utilities.")
+ utilities = interface.Attribute(
+ "Adapter Registry to manage all registered utilities.")
- def queryAdapter(object, interface, name, default=None):
+ def queryAdapter(object, interface, name=u'', default=None):
"""Look for a named adapter to an interface for an object
If a matching adapter cannot be found, returns the default.
+ """
- The name consisting of an empty string is reserved for unnamed
- adapters. The unnamed adapter methods will often call the
- named adapter methods with an empty string for a name.
+ def getAdapter(object, interface, name=u''):
+ """Look for a named adapter to an interface for an object
+
+ If a matching adapter cannot be found, a ComponentLookupError
+ is raised.
"""
- def queryMultiAdapter(objects, interface, name, default=None):
- """Look for a multi-adapter to an interface for an object
+ def queryMultiAdapter(objects, interface, name=u'', default=None):
+ """Look for a multi-adapter to an interface for multiple objects
If a matching adapter cannot be found, returns the default.
+ """
- The name consisting of an empty string is reserved for unnamed
- adapters. The unnamed adapter methods will often call the
- named adapter methods with an empty string for a name.
+ def queryMultiAdapter(objects, interface, name=u''):
+ """Look for a multi-adapter to an interface for multiple objects
+
+ If a matching adapter cannot be found, a ComponentLookupError
+ is raised.
"""
def getAdapters(objects, provided):
"""Look for all matching adapters to a provided interface for objects
- Return a list of adapters that match. If an adapter is named, only the
- most specific adapter of a given name is returned.
+ Return an iterable of name-adapter pairs for adapters that
+ provide the given interface.
"""
- def subscribers(required, provided):
+ def subscribers(objects, provided):
"""Get subscribers
Subscribers are returned that provide the provided interface
@@ -324,6 +352,12 @@
required objects.
"""
+ def handle(*objects):
+ """Call handlers for the given objects
+
+ Handlers registered for the given objects are called.
+ """
+
def queryUtility(interface, name='', default=None):
"""Look up a utility that provides an interface.
@@ -345,8 +379,12 @@
returned.
"""
+zope.deferredimport.deprecated(
+ "Use IComponentLookup instead. ISiteManager will be removed in 2007.",
+ ISiteManager = "zope.component.interfaces:IComponentLookup",
+ )
-class IComponentRegistrationConvenience(Interface):
+class IComponentRegistrationConvenience(interface.Interface):
"""API for registering components.
CAUTION: This API should only be used from test or
@@ -428,7 +466,7 @@
activity.
"""
-class IRegistry(Interface):
+class IRegistry(interface.Interface):
"""Object that supports component registry
"""
@@ -436,12 +474,12 @@
"""Return an iterable of component registrations
"""
-class IFactory(Interface):
+class IFactory(interface.Interface):
"""A factory is responsible for creating other components."""
- title = Attribute("The factory title.")
+ title = interface.Attribute("The factory title.")
- description = Attribute("A brief description of the factory.")
+ description = interface.Attribute("A brief description of the factory.")
def __call__(*args, **kw):
"""Return an instance of the objects we're a factory for."""
@@ -454,3 +492,415 @@
created by this factory will implement. If the callable's Implements
instance cannot be created, an empty Implements instance is returned.
"""
+
+class IRegistration(interface.Interface):
+ """A registration-information object
+ """
+
+ registry = interface.Attribute("The registry having the registration")
+
+ name = interface.Attribute("The registration name")
+
+ info = interface.Attribute("""Information about the registration
+
+ This is information deemed useful to people browsing the
+ configuration of a system. It could, for example, include
+ commentary or information about the source of the configuration.
+ """)
+
+class IUtilityRegistration(IRegistration):
+ """Information about the registration of a utility
+ """
+
+ component = interface.Attribute("The object registered")
+ provided = interface.Attribute("The interface provided by the component")
+
+class _IBaseAdapterRegistration(IRegistration):
+ """Information about the registration of an adapter
+ """
+
+ factory = interface.Attribute("The factory used to create adapters")
+
+ required = interface.Attribute("""The adapted interfaces
+
+ This is a sequence of interfaces adapters by the registered
+ factory. The factory will be caled with a sequence of objects, as
+ positional arguments, that provide these interfaces.
+ """)
+
+ provided = interface.Attribute("""The interface provided by the adapters.
+
+ This interface is implemented by the factory
+ """)
+
+class IAdapterRegistration(_IBaseAdapterRegistration):
+ """Information about the registration of an adapter
+ """
+
+class ISubscriptionAdapterRegistration(_IBaseAdapterRegistration):
+ """Information about the registration of a subscription adapter
+ """
+
+class IHandlerRegistration(IRegistration):
+
+ handler = interface.Attribute("An object called used to handle an event")
+
+ required = interface.Attribute("""The handled interfaces
+
+ This is a sequence of interfaces handled by the registered
+ handler. The handler will be caled with a sequence of objects, as
+ positional arguments, that provide these interfaces.
+ """)
+
+class IRegistrationEvent(IObjectEvent):
+ """An event that involves a registration"""
+
+class RegistrationEvent(ObjectEvent):
+ """There has been a change in a registration
+ """
+ interface.implements(IRegistrationEvent)
+
+ def __repr__(self):
+ return "%s event:\n%r" % (self.__class__.__name__, self.object)
+
+class IRegistered(IRegistrationEvent):
+ """A component or factory was registered
+ """
+
+class Registered(RegistrationEvent):
+ interface.implements(IRegistered)
+
+class IUnregistered(IRegistrationEvent):
+ """A component or factory was registered
+ """
+
+class Unregistered(RegistrationEvent):
+ """A component or factory was registered
+ """
+ interface.implements(IUnregistered)
+
+class IComponentRegistry(interface.Interface):
+ """Register components
+ """
+
+ def registerUtility(component, provided=None, name=u'', comment=u''):
+ """Register a utility
+
+ component
+ The registered component
+
+ provided
+ This is the interface provided by the utility. If the
+ component provides a single interface, then this
+ argument is optional and the component-implemented
+ interface will be used.
+
+ name
+ The utility name.
+
+ info
+ An object that can be converted to a string to provide
+ information about the registration.
+
+ A Registered event is generated with an IUtilityRegistration.
+ """
+
+ def unregisterUtility(component=None, provided=None, name=u''):
+ """Unregister a utility
+
+ A boolean is returned indicating whether the registry was
+ changed. If the given component is None and there is no
+ component registered, or if the given component is not
+ None and is not registered, then the function returns
+ False, otherwise it returns True.
+
+ component
+ The registered component The given component can be
+ None, in which case any component registered to provide
+ the given provided interface with the given name is
+ unregistered.
+
+ provided
+ This is the interface provided by the utility. If the
+ component is not None and provides a single interface,
+ then this argument is optional and the
+ component-implemented interface will be used.
+
+ name
+ The utility name.
+
+ An UnRegistered event is generated with an IUtilityRegistration.
+ """
+
+ def registeredUtilities():
+ """Return an iterable of IUtilityRegistrations.
+
+ These registrations describe the current utility registrations
+ in the object.
+ """
+
+ def registerAdapter(factory, required=None, provided=None, name=u'',
+ info=u''):
+ """Register an adapter factory
+
+ Parameters:
+
+ factory
+ The object used to compute the adapter
+
+ required
+ This is a sequence of specifications for objects to be
+ adapted. If omitted, then the value of the factory's
+ __component_adapts__ attribute will be used. The
+ __component_adapts__ attribute is usually attribute is
+ normally set in class definitions using adapts
+ function, or for callables using the adapter
+ decorator. If the factory doesn't have a
+ __component_adapts__ adapts attribute, then this
+ argument is required.
+
+ provided
+ This is the interface provided by the adapter and
+ implemented by the factory. If the factory
+ implements a single interface, then this argument is
+ optional and the factory-implemented interface will be
+ used.
+
+ name
+ The adapter name.
+
+ info
+ An object that can be converted to a string to provide
+ information about the registration.
+
+ A Registered event is generated with an IAdapterRegistration.
+ """
+
+ def unregisterAdapter(factory=None, required=None,
+ provided=None, name=u''):
+ """Register an adapter factory
+
+ A boolean is returned indicating whether the registry was
+ changed. If the given component is None and there is no
+ component registered, or if the given component is not
+ None and is not registered, then the function returns
+ False, otherwise it returns True.
+
+ Parameters:
+
+ factory
+ This is the object used to compute the adapter. The
+ factory can be None, in which case any factory
+ registered to implement the given provided interface
+ for the given required specifications with the given
+ name is unregistered.
+
+ required
+ This is a sequence of specifications for objects to be
+ adapted. If the factory is not None and the required
+ arguments is omitted, then the value of the factory's
+ __component_adapts__ attribute will be used. The
+ __component_adapts__ attribute attribute is normally
+ set in class definitions using adapts function, or for
+ callables using the adapter decorator. If the factory
+ is None or doesn't have a __component_adapts__ adapts
+ attribute, then this argument is required.
+
+ provided
+ This is the interface provided by the adapter and
+ implemented by the factory. If the factory is not
+ None and implements a single interface, then this
+ argument is optional and the factory-implemented
+ interface will be used.
+
+ name
+ The adapter name.
+
+ An Unregistered event is generated with an IAdapterRegistration.
+ """
+
+ def registeredAdapters():
+ """Return an iterable of IAdapterRegistrations.
+
+ These registrations describe the current adapter registrations
+ in the object.
+ """
+
+ def registerSubscriptionAdapter(factory, required=None, provides=None,
+ name=u'', info=''):
+ """Register a subscriber factory
+
+ Parameters:
+
+ factory
+ The object used to compute the adapter
+
+ required
+ This is a sequence of specifications for objects to be
+ adapted. If omitted, then the value of the factory's
+ __component_adapts__ attribute will be used. The
+ __component_adapts__ attribute is usually attribute is
+ normally set in class definitions using adapts
+ function, or for callables using the adapter
+ decorator. If the factory doesn't have a
+ __component_adapts__ adapts attribute, then this
+ argument is required.
+
+ provided
+ This is the interface provided by the adapter and
+ implemented by the factory. If the factory implements
+ a single interface, then this argument is optional and
+ the factory-implemented interface will be used.
+
+ name
+ The adapter name.
+
+ Currently, only the empty string is accepted. Other
+ strings will be accepted in the future when support for
+ named subscribers is added.
+
+ info
+ An object that can be converted to a string to provide
+ information about the registration.
+
+ A Registered event is generated with an
+ ISubscriptionAdapterRegistration.
+ """
+
+ def unregisterSubscriptionAdapter(factory=None, required=None,
+ provides=None, name=u''):
+ """Register a subscriber factory
+
+ A boolean is returned indicating whether the registry was
+ changed. If the given component is None and there is no
+ component registered, or if the given component is not
+ None and is not registered, then the function returns
+ False, otherwise it returns True.
+
+ Parameters:
+
+ factory
+ This is the object used to compute the adapter. The
+ factory can be None, in which case any factories
+ registered to implement the given provided interface
+ for the given required specifications with the given
+ name are unregistered.
+
+ required
+ This is a sequence of specifications for objects to be
+ adapted. If the factory is not None and the required
+ arguments is omitted, then the value of the factory's
+ __component_adapts__ attribute will be used. The
+ __component_adapts__ attribute attribute is normally
+ set in class definitions using adapts function, or for
+ callables using the adapter decorator. If the factory
+ is None or doesn't have a __component_adapts__ adapts
+ attribute, then this argument is required.
+
+ provided
+ This is the interface provided by the adapter and
+ implemented by the factory. If the factory is not
+ None implements a single interface, then this argument
+ is optional and the factory-implemented interface will
+ be used.
+
+ name
+ The adapter name.
+
+ Note that this parameter is ignored and is reserved
+ for future use when named subscribers are implemented.
+
+ An Unregistered event is generated with an
+ ISubscriptionAdapterRegistration.
+ """
+
+ def registeredSubscriptionAdapters():
+ """Return an iterable of ISubscriptionAdapterRegistrations.
+
+ These registrations describe the current subscription adapter
+ registrations in the object.
+ """
+
+ def registerHandler(handler, adapts=None, name=u'', info=''):
+ """Register a handler.
+
+ A handler is a subscriber that doesn't compute an adapter
+ but performs some function when called.
+
+ Parameters:
+
+ handler
+ The object used to handle some event represented by
+ the objects passed to it.
+
+ required
+ This is a sequence of specifications for objects to be
+ adapted. If omitted, then the value of the factory's
+ __component_adapts__ attribute will be used. The
+ __component_adapts__ attribute is usually attribute is
+ normally set in class definitions using adapts
+ function, or for callables using the adapter
+ decorator. If the factory doesn't have a
+ __component_adapts__ adapts attribute, then this
+ argument is required.
+
+ name
+ The handler name.
+
+ Note that this parameter is ignored and is reserved
+ for future use when named handlers are implemented.
+
+ info
+ An object that can be converted to a string to provide
+ information about the registration.
+
+
+ A Registered event is generated with an IHandlerRegistration.
+ """
+
+ def unregisterHandler(handler=None, adapts=None, name=u''):
+ """Register a handler.
+
+ A handler is a subscriber that doesn't compute an adapter
+ but performs some function when called.
+
+ Parameters:
+
+ handler
+ This is the object used to handle some event
+ represented by the objects passed to it. The handler
+ can be None, in which case any handlers registered for
+ the given required specifications with the given are
+ unregistered.
+
+ required
+ This is a sequence of specifications for objects to be
+ adapted. If omitted, then the value of the factory's
+ __component_adapts__ attribute will be used. The
+ __component_adapts__ attribute is usually attribute is
+ normally set in class definitions using adapts
+ function, or for callables using the adapter
+ decorator. If the factory doesn't have a
+ __component_adapts__ adapts attribute, then this
+ argument is required.
+
+ name
+ The handler name.
+
+ Note that this parameter is ignored and is reserved
+ for future use when named handlers are implemented.
+
+ An Unregistered event is generated with an IHandlerRegistration.
+ """
+
+ def registeredHandlers():
+ """Return an iterable of IHandlerRegistrations.
+
+ These registrations describe the current handler registrations
+ in the object.
+ """
+
+
+class IComponents(IComponentLookup, IComponentRegistry):
+ """Component registration and access
+ """
Copied: Zope3/trunk/src/zope/component/meta.zcml (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/meta.zcml)
Copied: Zope3/trunk/src/zope/component/persistentregistry.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/persistentregistry.py)
Copied: Zope3/trunk/src/zope/component/persistentregistry.txt (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/persistentregistry.txt)
Copied: Zope3/trunk/src/zope/component/registry.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/registry.py)
Copied: Zope3/trunk/src/zope/component/registry.txt (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/registry.txt)
Copied: Zope3/trunk/src/zope/component/service.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/service.py)
Copied: Zope3/trunk/src/zope/component/servicenames.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/servicenames.py)
Modified: Zope3/trunk/src/zope/component/site.py
===================================================================
--- Zope3/trunk/src/zope/component/site.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/site.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -13,334 +13,26 @@
##############################################################################
"""Global Site Manager
+This module has been deprecated and will be removed. Most of the
+functionality now resides in the zope.component.globalregistry module.
+
$Id$
"""
__docformat__ = "reStructuredText"
-import types
-from zope.interface import implements, providedBy, implementedBy, declarations
-from zope.interface.adapter import AdapterRegistry
-from zope.interface.interfaces import IInterface
+import warnings
+warnings.warn("The zope.component.site module has been deprecated and "
+ "will be removed. Most of the functionality now resides "
+ "in the zope.component.globalregistry module.",
+ DeprecationWarning, stacklevel=2)
-from zope.component.interfaces import ISiteManager, IRegistry
-from zope.component.interfaces import ComponentLookupError, Invalid
-
-
-class IGlobalSiteManager(ISiteManager, IRegistry):
-
- def provideAdapter(required, provided, name, factory, info=''):
- """Register an adapter factory
-
- :Parameters:
- - `required`: a sequence of specifications for objects to be
- adapted.
- - `provided`: The interface provided by the adapter
- - `name`: The adapter name
- - `factory`: The object used to compute the adapter
- - `info`: Provide some info about this particular adapter.
- """
-
- def subscribe(required, provided, factory, info=''):
- """Register a subscriber factory
-
- :Parameters:
- - `required`: a sequence of specifications for objects to be
- adapted.
- - `provided`: The interface provided by the adapter
- - `name`: The adapter name
- - `factory`: The object used to compute the subscriber
- - `info`: Provide some info about this particular adapter.
- """
-
- def provideUtility(providedInterface, component, name='', info='',
- strict=True):
- """Register a utility
-
- If strict is true, then the specified component *must* implement the
- `providedInterface`. Turning strict off is particularly useful for
- tests.
- """
-
-
-class SiteManager(object):
- """Site Manager implementation"""
-
- def queryAdapter(self, object, interface, name, default=None):
- """See ISiteManager interface"""
- return self.adapters.queryAdapter(object, interface, name, default)
-
- def queryMultiAdapter(self, objects, interface, name='', default=None):
- """See ISiteManager interface"""
- return self.adapters.queryMultiAdapter(objects, interface, name,
- default)
-
- def getAdapters(self, objects, provided):
- """See ISiteManager interface"""
- result = []
- for name, factory in self.adapters.lookupAll(map(providedBy, objects),
- provided):
- adapter = factory(*objects)
- if adapter is not None:
- result.append((name, adapter))
- return result
-
- def subscribers(self, required, provided):
- """See ISiteManager interface"""
- return self.adapters.subscribers(required, provided)
-
- def queryUtility(self, interface, name='', default=None):
- """See ISiteManager interface"""
-
- byname = self.utilities._null.get(interface)
- if byname:
- return byname.get(name, default)
- else:
- return default
-
- def getUtilitiesFor(self, interface):
- byname = self.utilities._null.get(interface)
- if byname:
- for item in byname.iteritems():
- yield item
-
- def getAllUtilitiesRegisteredFor(self, interface):
- return iter(self.utilities._null.get(('s', interface)) or ())
-
-
-class GlobalSiteManager(SiteManager):
- """Global Site Manager implementation."""
-
- implements(IGlobalSiteManager)
-
- def __init__(self, name=None):
- self.__name__ = name
- self._registrations = {}
- self.adapters = GlobalAdapterRegistry(self, 'adapters')
- self.utilities = GlobalAdapterRegistry(self, 'utilities')
-
-
- def provideAdapter(self, required, provided, name, factory, info=''):
- """Register an adapter
-
- >>> from zope.interface import Interface
- >>> registry = GlobalSiteManager()
- >>> class R1(Interface):
- ... pass
- >>> class R2(R1):
- ... pass
- >>> class P1(Interface):
- ... pass
- >>> class P2(P1):
- ... pass
-
- >>> registry.provideAdapter((R1, ), P2, 'bob', 'c1', 'd1')
- >>> registry.provideAdapter((R1, ), P2, '', 'c2', 'd2')
- >>> registry.adapters.lookup((R2, ), P1, '')
- 'c2'
-
- >>> registrations = map(repr, registry.registrations())
- >>> registrations.sort()
- >>> for registration in registrations:
- ... print registration
- AdapterRegistration(('R1',), 'P2', '', 'c2', 'd2')
- AdapterRegistration(('R1',), 'P2', 'bob', 'c1', 'd1')
-
- Let's make sure that we can also register regular classes for
- adaptation.
-
- >>> class O1(object):
- ... pass
- >>> class O2(object):
- ... pass
- >>> class O3(object):
- ... def __init__(self, obj1, obj2=None):
- ... pass
-
- >>> registry.provideAdapter((O1, ), R1, '', O3)
- >>> registry.queryAdapter(O1(), R1, '').__class__
- <class 'zope.component.site.O3'>
-
- >>> registry.provideAdapter((O1, O2), R1, '', O3)
- >>> registry.queryMultiAdapter((O1(), O2()), R1, '').__class__
- <class 'zope.component.site.O3'>
- """
- if IInterface.providedBy(required):
- raise TypeError('the required argument should be a list of'
- ' interfaces, not a single interface')
- ifaces = []
- for iface in required:
- if not IInterface.providedBy(iface) and iface is not None:
- if not isinstance(iface, (type, types.ClassType)):
- raise TypeError(iface, IInterface)
- iface = implementedBy(iface)
-
- ifaces.append(iface)
- required = tuple(ifaces)
-
- self._registrations[(required, provided, name)] = AdapterRegistration(
- required, provided, name, factory, info)
-
- self.adapters.register(required, provided, name, factory)
-
- def subscribe(self, required, provided, factory, info=''):
- """Register an subscriptions adapter
-
- >>> from zope.interface import Interface
- >>> registry = GlobalSiteManager()
- >>> class R1(Interface):
- ... pass
- >>> class R2(R1):
- ... pass
- >>> class P1(Interface):
- ... pass
- >>> class P2(P1):
- ... pass
-
- >>> registry.subscribe((R1, ), P2, 'c1', 'd1')
- >>> registry.subscribe((R1, ), P2, 'c2', 'd2')
- >>> subscriptions = map(str,
- ... registry.adapters.subscriptions((R2, ), P1))
- >>> subscriptions.sort()
- >>> subscriptions
- ['c1', 'c2']
-
- >>> registrations = map(repr, registry.registrations())
- >>> registrations.sort()
- >>> for registration in registrations:
- ... print registration
- SubscriptionRegistration(('R1',), 'P2', 'c1', 'd1')
- SubscriptionRegistration(('R1',), 'P2', 'c2', 'd2')
- """
- ifaces = []
- for iface in required:
- if not IInterface.providedBy(iface) and \
- not isinstance(iface, declarations.Implements) and \
- iface is not None:
- if not isinstance(iface, (type, types.ClassType)):
- raise TypeError(iface, IInterface)
- iface = implementedBy(iface)
-
- ifaces.append(iface)
- required = tuple(ifaces)
-
- registration = SubscriptionRegistration(
- required, provided, factory, info)
-
- self._registrations[(required, provided)] = (
- self._registrations.get((required, provided), ())
- +
- (registration, )
- )
-
- self.adapters.subscribe(required, provided, factory)
-
- def provideUtility(self, providedInterface, component, name='', info='',
- strict=True):
-
- if strict and not providedInterface.providedBy(component):
- raise Invalid("The registered component doesn't provide "
- "the promised interface.")
-
- self.utilities.register((), providedInterface, name, component)
-
- # Also subscribe to support getAllUtilitiesRegisteredFor:
- self.utilities.subscribe((), providedInterface, component)
-
- self._registrations[(providedInterface, name)] = UtilityRegistration(
- providedInterface, name, component, info)
-
- def registrations(self):
- for registration in self._registrations.itervalues():
- if isinstance(registration, tuple):
- for r in registration:
- yield r
- else:
- yield registration
-
- def __reduce__(self):
- # Global site managers are pickled as global objects
- return self.__name__
-
-
-def GAR(siteManager, registryName):
- return getattr(siteManager, registryName)
-
-class GlobalAdapterRegistry(AdapterRegistry):
- """A global adapter registry
-
- This adapter registry's main purpose is to be picklable in combination
- with a site manager.
- """
- def __init__(self, parent=None, name=None):
- self.__parent__ = parent
- self.__name__ = name
- super(GlobalAdapterRegistry, self).__init__()
-
- def __reduce__(self):
- return GAR, (self.__parent__, self.__name__)
-
-
-# Global Site Manager Instance
-globalSiteManager = GlobalSiteManager('globalSiteManager')
-
-# Register our cleanup with zope.testing.cleanup to make writing unit tests
-# simpler.
-from zope.testing.cleanup import addCleanUp
-addCleanUp(lambda : globalSiteManager.__init__(globalSiteManager.__name__))
-del addCleanUp
-
-
-
-class AdapterRegistration(object):
- """Registration for a simple adapter."""
-
- def __init__(self, required, provided, name, value, doc=''):
- (self.required, self.provided, self.name, self.value, self.doc
- ) = required, provided, name, value, doc
-
- def __repr__(self):
- return '%s(%r, %r, %r, %r, %r)' % (
- self.__class__.__name__,
- tuple([getattr(r, '__name__', None) for r in self.required]),
- getattr(self.provided, '__name__', None), self.name,
- self.value, self.doc,
- )
-
- def __cmp__(self, other):
- return cmp(self.__repr__(), other.__repr__())
-
-
-class SubscriptionRegistration(object):
- """Registration for a subscription adapter."""
-
- def __init__(self, required, provided, value, doc):
- (self.required, self.provided, self.value, self.doc
- ) = required, provided, value, doc
-
- def __repr__(self):
- return '%s(%r, %r, %r, %r)' % (
- self.__class__.__name__,
- tuple([getattr(r, '__name__', None) for r in self.required]),
- getattr(self.provided, '__name__', None), self.value, self.doc,
- )
-
- def __cmp__(self, other):
- return cmp(self.__repr__(), other.__repr__())
-
-
-class UtilityRegistration(object):
-
- def __init__(self, provided, name, component, doc):
- (self.provided, self.name, self.component, self.doc
- ) = provided, name, component, doc
-
- def __repr__(self):
- return '%s(%r, %r, %r, %r)' % (
- self.__class__.__name__,
- getattr(self.provided, '__name__', None), self.name,
- getattr(self.component, '__name__', self.component), self.doc,
- )
-
- def __cmp__(self, other):
- return cmp(self.__repr__(), other.__repr__())
-
+from zope.component.registry import Components as SiteManager
+from zope.component.registry import AdapterRegistration
+from zope.component.registry import SubscriptionRegistration
+from zope.component.registry import UtilityRegistration
+from zope.component.globalregistry import BaseGlobalComponents \
+ as GlobalSiteManager
+from zope.component.globalregistry import base as globalSiteManager
+from zope.component.globalregistry import GAR
+from zope.component.globalregistry \
+ import _IGlobalSiteManager as IGlobalSiteManager
Property changes on: Zope3/trunk/src/zope/component/site.py
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: Zope3/trunk/src/zope/component/socketexample.txt
===================================================================
--- Zope3/trunk/src/zope/component/socketexample.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/socketexample.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -83,9 +83,7 @@
>>> import zope.component
>>> gsm = zope.component.getGlobalSiteManager()
-
- >>> gsm.provideAdapter((IGermanSocket,), IUSSocket, '',
- ... GermanToUSSocketAdapter)
+ >>> gsm.registerAdapter(GermanToUSSocketAdapter, (IGermanSocket,), IUSSocket)
`zope.component` is the component architecture API that is being
presented by this file. You registered an adapter from `IGermanSocket`
@@ -162,10 +160,10 @@
Now, we need a way to keep the two adapters apart. Thus we register them with
a name:
- >>> gsm.provideAdapter((IGermanSocket,), IUSSocket, 'shaver',
- ... GermanToUSSocketAdapter)
- >>> gsm.provideAdapter((IGermanSocket,), IUSSocket, 'dvd',
- ... GermanToUSSocketAdapterAndTransformer)
+ >>> gsm.registerAdapter(GermanToUSSocketAdapter,
+ ... (IGermanSocket,), IUSSocket, 'shaver',)
+ >>> gsm.registerAdapter(GermanToUSSocketAdapterAndTransformer,
+ ... (IGermanSocket,), IUSSocket, 'dvd')
Now we simply look up the adapters using their labels (called *name*):
@@ -192,7 +190,7 @@
Sometimes you want to know all adapters that are available. Let's say you want
to know about all the adapters that convert a German to a US socket type:
- >>> sockets = zope.component.getAdapters((bathroomDE,), IUSSocket)
+ >>> sockets = list(zope.component.getAdapters((bathroomDE,), IUSSocket))
>>> len(sockets)
3
>>> names = [name for name, socket in sockets]
@@ -239,8 +237,8 @@
You now register the combination, so that you know you can create a
`IUSGroundedSocket`:
- >>> gsm.provideAdapter((IGermanSocket, IGrounder), IUSGroundedSocket, 'mp3',
- ... GroundedGermanToUSSocketAdapter)
+ >>> gsm.registerAdapter(GroundedGermanToUSSocketAdapter,
+ ... (IGermanSocket, IGrounder), IUSGroundedSocket, 'mp3')
Given the grounder
@@ -318,15 +316,17 @@
>>> class PowderExtinguisher(FireExtinguisher):
... pass
- >>> gsm.subscribe((IFire,), IFireExtinguisher, PowderExtinguisher)
+ >>> gsm.registerSubscriptionAdapter(PowderExtinguisher,
+ ... (IFire,), IFireExtinguisher)
>>> class Blanket(FireExtinguisher):
... pass
- >>> gsm.subscribe((IFire,), IFireExtinguisher, Blanket)
+ >>> gsm.registerSubscriptionAdapter(Blanket, (IFire,), IFireExtinguisher)
>>> class SprinklerSystem(FireExtinguisher):
... pass
- >>> gsm.subscribe((IFire,), IFireExtinguisher, SprinklerSystem)
+ >>> gsm.registerSubscriptionAdapter(SprinklerSystem,
+ ... (IFire,), IFireExtinguisher)
Now let use all these things to put out the fire:
@@ -378,7 +378,7 @@
Like for adapters, we now have to add the newly-acquired generator to our
inventory by registering it as a utility:
- >>> gsm.provideUtility(IUSSocket, generator)
+ >>> gsm.registerUtility(generator, IUSSocket)
We can now get the utility using
@@ -430,7 +430,7 @@
Once it arrives, we add it to our inventory:
- >>> gsm.provideUtility(IUSSocket, panel, 'Solar Panel')
+ >>> gsm.registerUtility(panel, IUSSocket, 'Solar Panel')
You can now access the solar panel using
@@ -501,7 +501,7 @@
implemented interface from the class. We now register the factory:
>>> from zope.component.interfaces import IFactory
- >>> gsm.provideUtility(IFactory, factory, 'SolarPanel')
+ >>> gsm.registerUtility(factory, IFactory, 'SolarPanel')
We can now get a list of interfaces the produced object will provide:
@@ -528,7 +528,7 @@
Once you register several factories
- >>> gsm.provideUtility(IFactory, Factory(Generator), 'Generator')
+ >>> gsm.registerUtility(Factory(Generator), IFactory, 'Generator')
you can also determine, which available factories will create objects
providing a certian interface:
@@ -555,22 +555,22 @@
>>> gsm = zope.component.getGlobalSiteManager()
- >>> from zope.component.site import globalSiteManager
+ >>> from zope.component import globalSiteManager
>>> gsm is globalSiteManager
True
- >>> from zope.component.interfaces import ISiteManager
- >>> ISiteManager.providedBy(gsm)
+ >>> from zope.component.interfaces import IComponentLookup
+ >>> IComponentLookup.providedBy(gsm)
True
- >>> from zope.component.site import IGlobalSiteManager
- >>> IGlobalSiteManager.providedBy(gsm)
+ >>> from zope.component.interfaces import IComponents
+ >>> IComponents.providedBy(gsm)
True
You can also lookup at site manager in a given context. The only requirement
is that the context can be adapted to a site manager. So let's create a
special site manager:
- >>> from zope.component.site import SiteManager
- >>> sm = SiteManager()
+ >>> from zope.component.globalregistry import BaseGlobalComponents
+ >>> sm = BaseGlobalComponents()
Now we create a context that adapts to the site manager via the `__conform__`
method as specied in PEP 246.
@@ -579,7 +579,7 @@
... def __init__(self, sm):
... self.sm = sm
... def __conform__(self, interface):
- ... if interface.isOrExtends(ISiteManager):
+ ... if interface.isOrExtends(IComponentLookup):
... return self.sm
We now instantiate the `Context` with our special site manager:
Modified: Zope3/trunk/src/zope/component/testing.py
===================================================================
--- Zope3/trunk/src/zope/component/testing.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/testing.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,20 +15,15 @@
$Id$
"""
-from zope.testing import cleanup
-# A mix-in class inheriting from CleanUp that also connects the CA services
-class PlacelessSetup(cleanup.CleanUp):
+# HACK to make sure basicmost event subscriber is installed
+import zope.component.event
- def setUp(self):
- super(PlacelessSetup, self).setUp()
+# we really don't need special setup now:
+from zope.testing.cleanup import CleanUp as PlacelessSetup
- def tearDown(self):
- super(PlacelessSetup, self).tearDown()
-
-
def setUp(test=None):
- cleanup.setUp()
+ PlacelessSetup().setUp()
def tearDown(test=None):
- cleanup.tearDown()
+ PlacelessSetup().tearDown()
Modified: Zope3/trunk/src/zope/component/tests.py
===================================================================
--- Zope3/trunk/src/zope/component/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/component/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,27 +15,114 @@
$Id: test_api.py 28632 2004-12-16 17:42:59Z srichter $
"""
+import re
import unittest
-
-from zope.interface import Interface, implements
+from zope import interface, component
from zope.interface.verify import verifyObject
-from zope.testing import doctest
+from zope.interface.interfaces import IInterface
+from zope.testing import doctest, renormalizing
-import zope.component
from zope.component.interfaces import ComponentLookupError
from zope.component.interfaces import IComponentArchitecture
-from zope.component.interfaces import ISiteManager
+from zope.component.interfaces import IComponentLookup
from zope.component.testing import setUp, tearDown
-class I1(Interface):
+# side effect gets component-based event dispatcher installed.
+# we should obviously make this more explicit
+import zope.component.event
+
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "Use zope.component.testing.placelesssetup",
+ placelesssetup = "zope.component.testing",
+ )
+
+class I1(interface.Interface):
pass
-class I2(Interface):
+class I2(interface.Interface):
pass
-class I3(Interface):
+class I3(interface.Interface):
pass
+class ITestType(IInterface):
+ pass
+
+class U:
+
+ def __init__(self, name):
+ self.__name__ = name
+
+ def __repr__(self):
+ return "%s(%s)" % (self.__class__.__name__, self.__name__)
+
+class U1(U):
+ interface.implements(I1)
+
+class U12(U):
+ interface.implements(I1, I2)
+
+class IA1(interface.Interface):
+ pass
+
+class IA2(interface.Interface):
+ pass
+
+class IA3(interface.Interface):
+ pass
+
+class A:
+
+ def __init__(self, *context):
+ self.context = context
+
+ def __repr__(self):
+ return "%s%r" % (self.__class__.__name__, self.context)
+
+class A12_1(A):
+ component.adapts(I1, I2)
+ interface.implements(IA1)
+
+class A12_(A):
+ component.adapts(I1, I2)
+
+class A_2(A):
+ interface.implements(IA2)
+
+class A_3(A):
+ interface.implements(IA3)
+
+class A1_12(U):
+ component.adapts(I1)
+ interface.implements(IA1, IA2)
+
+class A1_2(U):
+ component.adapts(I1)
+ interface.implements(IA2)
+
+class A1_23(U):
+ component.adapts(I1)
+ interface.implements(IA1, IA3)
+
+def noop(*args):
+ pass
+
+ at component.adapter(I1)
+def handle1(x):
+ print 'handle1', x
+
+def handle(*objects):
+ print 'handle', objects
+
+ at component.adapter(I1)
+def handle3(x):
+ print 'handle3', x
+
+ at component.adapter(I1)
+def handle4(x):
+ print 'handle4', x
+
class Ob(object):
- implements(I1)
+ interface.implements(I1)
def __repr__(self):
return '<instance Ob>'
@@ -43,33 +130,33 @@
ob = Ob()
class Ob2(object):
- implements(I2)
+ interface.implements(I2)
def __repr__(self):
return '<instance Ob2>'
class Comp(object):
- implements(I2)
+ interface.implements(I2)
def __init__(self, context):
self.context = context
comp = Comp(1)
class Comp2(object):
- implements(I3)
+ interface.implements(I3)
def __init__(self, context):
self.context = context
-class ConformsToISiteManager(object):
- """This object allows the sitemanager to conform/adapt to `ISiteManager`
- and thus to itself."""
+class ConformsToIComponentLookup(object):
+ """This object allows the sitemanager to conform/adapt to
+ `IComponentLookup` and thus to itself."""
def __init__(self, sitemanager):
self.sitemanager = sitemanager
def __conform__(self, interface):
"""This method is specified by the adapter PEP to do the adaptation."""
- if interface is ISiteManager:
+ if interface is IComponentLookup:
return self.sitemanager
@@ -77,32 +164,32 @@
"""Ensure that the component architecture API is provided by
`zope.component`.
- >>> import zope.component
- >>> verifyObject(IComponentArchitecture, zope.component)
+ >>> verifyObject(IComponentArchitecture, component)
True
"""
def test_getGlobalSiteManager():
"""One of the most important functions is to get the global site manager.
- >>> from zope.component.site import IGlobalSiteManager, globalSiteManager
+ >>> from zope.component.interfaces import IComponentLookup
+ >>> from zope.component.globalregistry import base
Get the global site manager via the CA API function:
- >>> gsm = zope.component.getGlobalSiteManager()
+ >>> gsm = component.getGlobalSiteManager()
Make sure that the global site manager implements the correct interface
and is the global site manager instance we expect to get.
- >>> IGlobalSiteManager.providedBy(gsm)
+ >>> IComponentLookup.providedBy(gsm)
True
- >>> globalSiteManager is gsm
+ >>> base is gsm
True
Finally, ensure that we always get the same global site manager, otherwise
our component registry will always be reset.
- >>> zope.component.getGlobalSiteManager() is gsm
+ >>> component.getGlobalSiteManager() is gsm
True
"""
@@ -111,20 +198,21 @@
manager instance.
We don't know anything about the default service manager, except that it
- is an `ISiteManager`.
+ is an `IComponentLookup`.
- >>> ISiteManager.providedBy(zope.component.getSiteManager())
+ >>> IComponentLookup.providedBy(component.getSiteManager())
True
Calling `getSiteManager()` with no args is equivalent to calling it with a
context of `None`.
- >>> zope.component.getSiteManager() is zope.component.getSiteManager(None)
+ >>> component.getSiteManager() is component.getSiteManager(None)
True
- If the context passed to `getSiteManager()` is not `None`, it is adapted
- to `ISiteManager` and this adapter returned. So, we create a context that
- can be adapted to `ISiteManager` using the `__conform__` API.
+ If the context passed to `getSiteManager()` is not `None`, it is
+ adapted to `IComponentLookup` and this adapter returned. So, we
+ create a context that can be adapted to `IComponentLookup` using
+ the `__conform__` API.
Let's create the simplest stub-implementation of a site manager possible:
@@ -133,21 +221,21 @@
Now create a context that knows how to adapt to our newly created site
manager.
- >>> context = ConformsToISiteManager(sitemanager)
+ >>> context = ConformsToIComponentLookup(sitemanager)
Now make sure that the `getSiteManager()` API call returns the correct
site manager.
- >>> zope.component.getSiteManager(context) is sitemanager
+ >>> component.getSiteManager(context) is sitemanager
True
- Using a context that is not adaptable to `ISiteManager` should fail.
+ Using a context that is not adaptable to `IComponentLookup` should fail.
- >>> zope.component.getSiteManager(ob) #doctest: +NORMALIZE_WHITESPACE
+ >>> component.getSiteManager(ob) #doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
ComponentLookupError: ('Could not adapt', <instance Ob>,
- <InterfaceClass zope.component.interfaces.ISiteManager>)
+ <InterfaceClass zope.component.interfaces.IComponentLookup>)
"""
def testAdapterInContext(self):
@@ -160,7 +248,7 @@
`__conform__()` method:
>>> class Component(object):
- ... implements(I1)
+ ... interface.implements(I1)
... def __conform__(self, iface, default=None):
... if iface == I2:
... return 42
@@ -175,41 +263,41 @@
We now have to create a site manager (other than the default global one)
with which we can register adapters for `I1`.
- >>> from zope.component.site import GlobalSiteManager
- >>> sitemanager = GlobalSiteManager()
+ >>> from zope.component.globalregistry import BaseGlobalComponents
+ >>> sitemanager = BaseGlobalComponents()
Now we create a new `context` that knows how to get to our custom site
manager.
- >>> context = ConformsToISiteManager(sitemanager)
+ >>> context = ConformsToIComponentLookup(sitemanager)
We now register an adapter from `I1` to `I3`:
- >>> sitemanager.provideAdapter((I1,), I3, '', lambda x: 43)
+ >>> sitemanager.registerAdapter(lambda x: 43, (I1,), I3, '')
If an object implements the interface you want to adapt to,
`getAdapterInContext()` should simply return the object.
- >>> zope.component.getAdapterInContext(ob, I1, context)
+ >>> component.getAdapterInContext(ob, I1, context)
<Component implementing 'I1'>
- >>> zope.component.queryAdapterInContext(ob, I1, context)
+ >>> component.queryAdapterInContext(ob, I1, context)
<Component implementing 'I1'>
If an object conforms to the interface you want to adapt to,
`getAdapterInContext()` should simply return the conformed object.
- >>> zope.component.getAdapterInContext(ob, I2, context)
+ >>> component.getAdapterInContext(ob, I2, context)
42
- >>> zope.component.queryAdapterInContext(ob, I2, context)
+ >>> component.queryAdapterInContext(ob, I2, context)
42
If an adapter isn't registered for the given object and interface, and you
provide no default, raise ComponentLookupError...
- >>> class I4(Interface):
+ >>> class I4(interface.Interface):
... pass
- >>> zope.component.getAdapterInContext(ob, I4, context) \\
+ >>> component.getAdapterInContext(ob, I4, context) \\
... #doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
@@ -218,15 +306,15 @@
...otherwise, you get the default:
- >>> zope.component.queryAdapterInContext(ob, I4, context, 44)
+ >>> component.queryAdapterInContext(ob, I4, context, 44)
44
If you ask for an adapter for which something's registered you get the
registered adapter
- >>> zope.component.getAdapterInContext(ob, I3, context)
+ >>> component.getAdapterInContext(ob, I3, context)
43
- >>> zope.component.queryAdapterInContext(ob, I3, context)
+ >>> component.queryAdapterInContext(ob, I3, context)
43
"""
@@ -239,7 +327,7 @@
If an adapter isn't registered for the given object and interface, and you
provide no default, raise `ComponentLookupError`...
- >>> zope.component.getAdapter(ob, I2, '') #doctest: +NORMALIZE_WHITESPACE
+ >>> component.getAdapter(ob, I2, '') #doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
ComponentLookupError: (<instance Ob>,
@@ -248,20 +336,20 @@
...otherwise, you get the default
- >>> zope.component.queryAdapter(ob, I2, '', '<default>')
+ >>> component.queryAdapter(ob, I2, '', '<default>')
'<default>'
Now get the global site manager and register an adapter from `I1` to `I2`
without a name:
- >>> zope.component.getGlobalSiteManager().provideAdapter(
- ... (I1,), I2, '', Comp)
+ >>> component.getGlobalSiteManager().registerAdapter(
+ ... Comp, (I1,), I2, '')
You should get a sensible error message if you forget that the 'requires'
argument is supposed to be a sequence
- >>> zope.component.getGlobalSiteManager().provideAdapter(
- ... I1, I2, '', Comp)
+ >>> component.getGlobalSiteManager().registerAdapter(
+ ... Comp, I1, I2, '')
Traceback (most recent call last):
...
TypeError: the required argument should be a list of interfaces, not a single interface
@@ -269,7 +357,7 @@
You can now simply access the adapter using the `getAdapter()` API
function:
- >>> adapter = zope.component.getAdapter(ob, I2, '')
+ >>> adapter = component.getAdapter(ob, I2, '')
>>> adapter.__class__ is Comp
True
>>> adapter.context is ob
@@ -283,8 +371,8 @@
First, we need to register an adapter:
- >>> zope.component.getGlobalSiteManager().provideAdapter(
- ... [I1], I2, '', Comp)
+ >>> component.getGlobalSiteManager().registerAdapter(
+ ... Comp, [I1], I2, '')
Then we try to adapt `ob` to provide an `I2` interface by calling the `I2`
interface with the obejct as first argument:
@@ -316,13 +404,13 @@
First we register some named adapter:
- >>> zope.component.getGlobalSiteManager().provideAdapter(
- ... [I1], I2, 'foo', lambda x: 0)
+ >>> component.getGlobalSiteManager().registerAdapter(
+ ... lambda x: 0, [I1], I2, 'foo')
If an adapter isn't registered for the given object and interface,
and you provide no default, raise `ComponentLookupError`...
- >>> zope.component.getAdapter(ob, I2, 'bar') \\
+ >>> component.getAdapter(ob, I2, 'bar') \\
... #doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
@@ -331,17 +419,17 @@
...otherwise, you get the default
- >>> zope.component.queryAdapter(ob, I2, 'bar', '<default>')
+ >>> component.queryAdapter(ob, I2, 'bar', '<default>')
'<default>'
But now we register an adapter for the object having the correct name
- >>> zope.component.getGlobalSiteManager().provideAdapter(
- ... [I1], I2, 'bar', Comp)
+ >>> component.getGlobalSiteManager().registerAdapter(
+ ... Comp, [I1], I2, 'bar')
so that the lookup succeeds:
- >>> adapter = zope.component.getAdapter(ob, I2, 'bar')
+ >>> adapter = component.getAdapter(ob, I2, 'bar')
>>> adapter.__class__ is Comp
True
>>> adapter.context is ob
@@ -361,7 +449,7 @@
objects and interface, and you provide no default, raise
`ComponentLookupError`...
- >>> zope.component.getMultiAdapter((ob, ob2), I3) \\
+ >>> component.getMultiAdapter((ob, ob2), I3) \\
... #doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
@@ -372,7 +460,7 @@
...otherwise, you get the default
- >>> zope.component.queryMultiAdapter((ob, ob2), I3, default='<default>')
+ >>> component.queryMultiAdapter((ob, ob2), I3, default='<default>')
'<default>'
Note that the name is not a required attribute here.
@@ -381,20 +469,20 @@
handles to context objects:
>>> class DoubleAdapter(object):
- ... implements(I3)
+ ... interface.implements(I3)
... def __init__(self, first, second):
... self.first = first
... self.second = second
Now we can register the multi-adapter using
- >>> zope.component.getGlobalSiteManager().provideAdapter(
- ... (I1, I2), I3, '', DoubleAdapter)
+ >>> component.getGlobalSiteManager().registerAdapter(
+ ... DoubleAdapter, (I1, I2), I3, '')
Notice how the required interfaces are simply provided by a tuple. Now we
can get the adapter:
- >>> adapter = zope.component.getMultiAdapter((ob, ob2), I3)
+ >>> adapter = component.getMultiAdapter((ob, ob2), I3)
>>> adapter.__class__ is DoubleAdapter
True
>>> adapter.first is ob
@@ -407,8 +495,8 @@
"""Providing an adapter for None says that your adapter can adapt anything
to `I2`.
- >>> zope.component.getGlobalSiteManager().provideAdapter(
- ... (None,), I2, '', Comp)
+ >>> component.getGlobalSiteManager().registerAdapter(
+ ... Comp, (None,), I2, '')
>>> adapter = I2(ob)
>>> adapter.__class__ is Comp
@@ -433,26 +521,24 @@
Let's register some adapters first:
- >>> zope.component.getGlobalSiteManager().provideAdapter(
- ... [I1], I2, '', Comp)
- >>> zope.component.getGlobalSiteManager().provideAdapter(
- ... [None], I2, 'foo', Comp)
+ >>> component.getGlobalSiteManager().registerAdapter(
+ ... Comp, [I1], I2, '')
+ >>> component.getGlobalSiteManager().registerAdapter(
+ ... Comp, [None], I2, 'foo')
Now we get all the adapters that are registered for `ob` that provide
`I2`:
- >>> adapters = zope.component.getAdapters((ob,), I2)
- >>> adapters.sort()
+ >>> adapters = sorted(component.getAdapters((ob,), I2))
>>> [(name, adapter.__class__.__name__) for name, adapter in adapters]
[(u'', 'Comp'), (u'foo', 'Comp')]
Note that the output doesn't include None values. If an adapter
factory returns None, it is as if it wasn't present.
- >>> zope.component.getGlobalSiteManager().provideAdapter(
- ... [I1], I2, 'nah', lambda context: None)
- >>> adapters = zope.component.getAdapters((ob,), I2)
- >>> adapters.sort()
+ >>> component.getGlobalSiteManager().registerAdapter(
+ ... lambda context: None, [I1], I2, 'nah')
+ >>> adapters = sorted(component.getAdapters((ob,), I2))
>>> [(name, adapter.__class__.__name__) for name, adapter in adapters]
[(u'', 'Comp'), (u'foo', 'Comp')]
@@ -467,7 +553,7 @@
course. The pure instatiation of an object does not make it a utility. If
you do not specify a default, you get a `ComponentLookupError`...
- >>> zope.component.getUtility(I1) #doctest: +NORMALIZE_WHITESPACE
+ >>> component.getUtility(I1) #doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
ComponentLookupError: \
@@ -475,18 +561,18 @@
...otherwise, you get the default
- >>> zope.component.queryUtility(I1, default='<default>')
+ >>> component.queryUtility(I1, default='<default>')
'<default>'
- >>> zope.component.queryUtility(I2, default='<default>')
+ >>> component.queryUtility(I2, default='<default>')
'<default>'
Now we declare `ob` to be the utility providing `I1`
- >>> zope.component.getGlobalSiteManager().provideUtility(I1, ob)
+ >>> component.getGlobalSiteManager().registerUtility(ob, I1)
so that the component is now available:
- >>> zope.component.getUtility(I1) is ob
+ >>> component.getUtility(I1) is ob
True
"""
@@ -495,11 +581,11 @@
Just because you register an utility having no name
- >>> zope.component.getGlobalSiteManager().provideUtility(I1, ob)
+ >>> component.getGlobalSiteManager().registerUtility(ob, I1)
does not mean that they are available when you specify a name:
- >>> zope.component.getUtility(I1, name='foo') \\
+ >>> component.getUtility(I1, name='foo') \\
... #doctest: +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
@@ -509,17 +595,17 @@
...otherwise, you get the default
- >>> zope.component.queryUtility(I1, name='foo', default='<default>')
+ >>> component.queryUtility(I1, name='foo', default='<default>')
'<default>'
Registering the utility under the correct name
- >>> zope.component.getGlobalSiteManager().provideUtility(
- ... I1, ob, name='foo')
+ >>> component.getGlobalSiteManager().registerUtility(
+ ... ob, I1, name='foo')
really helps:
- >>> zope.component.getUtility(I1, 'foo') is ob
+ >>> component.getUtility(I1, 'foo') is ob
True
"""
@@ -534,24 +620,23 @@
... pass
>>> class Ob11(Ob):
- ... implements(I11)
+ ... interface.implements(I11)
>>> ob11 = Ob11()
>>> ob_bob = Ob()
Now we register the new utilities:
- >>> gsm = zope.component.getGlobalSiteManager()
- >>> gsm.provideUtility(I1, ob)
- >>> gsm.provideUtility(I11, ob11)
- >>> gsm.provideUtility(I1, ob_bob, name='bob')
- >>> gsm.provideUtility(I2, Comp(2))
+ >>> gsm = component.getGlobalSiteManager()
+ >>> gsm.registerUtility(ob, I1)
+ >>> gsm.registerUtility(ob11, I11)
+ >>> gsm.registerUtility(ob_bob, I1, name='bob')
+ >>> gsm.registerUtility(Comp(2), I2)
We can now get all the utilities that provide interface `I1`:
- >>> uts = list(zope.component.getAllUtilitiesRegisteredFor(I1))
- >>> uts = [util.__class__.__name__ for util in uts]
- >>> uts.sort()
+ >>> uts = list(component.getAllUtilitiesRegisteredFor(I1))
+ >>> uts = sorted([util.__class__.__name__ for util in uts])
>>> uts
['Ob', 'Ob', 'Ob11']
@@ -583,9 +668,8 @@
We want to make sure that an `adapts()` call in a class definition
doesn't affect instances.
- >>> import zope.component
>>> class C:
- ... zope.component.adapts()
+ ... component.adapts()
>>> C.__component_adapts__
()
@@ -600,35 +684,192 @@
We need to make sure that it is possible to pickle the global site manager
and its two global adapter registries.
- >>> from zope.component import site
+ >>> from zope.component import globalSiteManager
>>> import cPickle
- >>> pickle = cPickle.dumps(site.globalSiteManager)
+ >>> pickle = cPickle.dumps(globalSiteManager)
>>> sm = cPickle.loads(pickle)
- >>> sm is site.globalSiteManager
+ >>> sm is globalSiteManager
True
Now let's ensure that the registries themselves can be pickled as well:
- >>> pickle = cPickle.dumps(site.globalSiteManager.adapters)
+ >>> pickle = cPickle.dumps(globalSiteManager.adapters)
>>> adapters = cPickle.loads(pickle)
- >>> adapters is site.globalSiteManager.adapters
+ >>> adapters is globalSiteManager.adapters
True
"""
+def test_persistent_component_managers():
+ """
+Here, we'll demonstrate that changes work even when data are stored in
+a database and when accessed from multiple connections.
+
+Start by setting up a database and creating two transaction
+managers and database connections to work with.
+
+ >>> import ZODB.tests.util
+ >>> db = ZODB.tests.util.DB()
+ >>> import transaction
+ >>> t1 = transaction.TransactionManager()
+ >>> c1 = db.open(transaction_manager=t1)
+ >>> r1 = c1.root()
+ >>> t2 = transaction.TransactionManager()
+ >>> c2 = db.open(transaction_manager=t2)
+ >>> r2 = c2.root()
+
+Create a set of components registries in the database, alternating
+connections.
+
+ >>> from zope.component.persistentregistry import PersistentComponents
+
+ >>> _ = t1.begin()
+ >>> r1[1] = PersistentComponents('1')
+ >>> t1.commit()
+
+ >>> _ = t2.begin()
+ >>> r2[2] = PersistentComponents('2', (r2[1], ))
+ >>> t2.commit()
+
+ >>> _ = t1.begin()
+ >>> r1[3] = PersistentComponents('3', (r1[1], ))
+ >>> t1.commit()
+
+ >>> _ = t2.begin()
+ >>> r2[4] = PersistentComponents('4', (r2[2], r2[3]))
+ >>> t2.commit()
+
+ >>> _ = t1.begin()
+ >>> r1[1].__bases__
+ ()
+ >>> r1[2].__bases__ == (r1[1], )
+ True
+
+ >>> r1[1].registerUtility(U1(1))
+ >>> r1[1].queryUtility(I1)
+ U1(1)
+ >>> r1[2].queryUtility(I1)
+ U1(1)
+ >>> t1.commit()
+
+ >>> _ = t2.begin()
+ >>> r2[1].registerUtility(U1(2))
+ >>> r2[2].queryUtility(I1)
+ U1(2)
+
+ >>> r2[4].queryUtility(I1)
+ U1(2)
+ >>> t2.commit()
+
+
+ >>> _ = t1.begin()
+ >>> r1[1].registerUtility(U12(1), I2)
+ >>> r1[4].queryUtility(I2)
+ U12(1)
+ >>> t1.commit()
+
+
+ >>> _ = t2.begin()
+ >>> r2[3].registerUtility(U12(3), I2)
+ >>> r2[4].queryUtility(I2)
+ U12(3)
+ >>> t2.commit()
+
+ >>> _ = t1.begin()
+
+ >>> r1[1].registerHandler(handle1, info="First handler")
+ >>> r1[2].registerHandler(handle, required=[U])
+
+ >>> r1[3].registerHandler(handle3)
+
+ >>> r1[4].registerHandler(handle4)
+
+ >>> r1[4].handle(U1(1))
+ handle1 U1(1)
+ handle3 U1(1)
+ handle (U1(1),)
+ handle4 U1(1)
+
+ >>> t1.commit()
+
+ >>> _ = t2.begin()
+ >>> r2[4].handle(U1(1))
+ handle1 U1(1)
+ handle3 U1(1)
+ handle (U1(1),)
+ handle4 U1(1)
+ >>> t2.abort()
+
+ >>> db.close()
+ """
+
+def persistent_registry_doesnt_scew_up_subsribers():
+ """
+ >>> import ZODB.tests.util
+ >>> db = ZODB.tests.util.DB()
+ >>> import transaction
+ >>> t1 = transaction.TransactionManager()
+ >>> c1 = db.open(transaction_manager=t1)
+ >>> r1 = c1.root()
+ >>> t2 = transaction.TransactionManager()
+ >>> c2 = db.open(transaction_manager=t2)
+ >>> r2 = c2.root()
+
+ >>> from zope.component.persistentregistry import PersistentComponents
+
+ >>> _ = t1.begin()
+ >>> r1[1] = PersistentComponents('1')
+ >>> r1[1].registerHandler(handle1)
+ >>> r1[1].registerSubscriptionAdapter(handle1, provided=I2)
+ >>> _ = r1[1].unregisterHandler(handle1)
+ >>> _ = r1[1].unregisterSubscriptionAdapter(handle1, provided=I2)
+ >>> t1.commit()
+ >>> _ = t1.begin()
+ >>> r1[1].registerHandler(handle1)
+ >>> r1[1].registerSubscriptionAdapter(handle1, provided=I2)
+ >>> t1.commit()
+
+ >>> _ = t2.begin()
+ >>> len(list(r2[1].registeredHandlers()))
+ 1
+ >>> len(list(r2[1].registeredSubscriptionAdapters()))
+ 1
+ >>> t2.abort()
+
+ """
+
+def tearDownRegistryTests(tests):
+ import zope.event
+ zope.event.subscribers.pop()
+
+def clearZCML(test=None):
+ tearDown()
+ setUp()
+
+ from zope.configuration.xmlconfig import XMLConfig
+ XMLConfig('meta.zcml', component)()
+
def test_suite():
+ checker = renormalizing.RENormalizing([
+ (re.compile('at 0x[0-9a-f]+'), 'at <SOME ADDRESS>'),
+ ])
+
return unittest.TestSuite((
doctest.DocTestSuite(setUp=setUp, tearDown=tearDown),
- doctest.DocTestSuite('zope.component.site'),
+ doctest.DocTestSuite('zope.component.interface',
+ setUp=setUp, tearDown=tearDown),
doctest.DocFileSuite('README.txt',
setUp=setUp, tearDown=tearDown),
doctest.DocFileSuite('socketexample.txt',
setUp=setUp, tearDown=tearDown),
doctest.DocFileSuite('factory.txt',
setUp=setUp, tearDown=tearDown),
+ doctest.DocFileSuite('registry.txt', checker=checker,
+ tearDown=tearDownRegistryTests),
+ doctest.DocFileSuite('event.txt',
+ setUp=setUp, tearDown=tearDown),
+ doctest.DocFileSuite('zcml.txt',
+ setUp=setUp, tearDown=tearDown),
))
if __name__ == "__main__":
unittest.main(defaultTest='test_suite')
-
-# BBB: Import some backward-compatibility; 12/10/2004
-from zope.component.bbb.tests import placelesssetup
Copied: Zope3/trunk/src/zope/component/utility.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/utility.py)
Copied: Zope3/trunk/src/zope/component/zcml.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/zcml.py)
Copied: Zope3/trunk/src/zope/component/zcml.txt (from rev 67629, Zope3/branches/jim-adapter/src/zope/component/zcml.txt)
Modified: Zope3/trunk/src/zope/contentprovider/README.txt
===================================================================
--- Zope3/trunk/src/zope/contentprovider/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/contentprovider/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -391,7 +391,7 @@
>>> print errorview()
Traceback (most recent call last):
...
- ContentProviderLookupError: u'mypage.UnknownName'
+ ContentProviderLookupError: mypage.UnknownName
Additional Data from TAL
Modified: Zope3/trunk/src/zope/contentprovider/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/contentprovider/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/contentprovider/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,9 +20,8 @@
import zope.component
import zope.interface
from zope.tales import interfaces
-from zope.app.publisher.interfaces import browser
+from zope.publisher.interfaces import browser
-
class IUpdateNotCalled(zope.interface.common.interfaces.IRuntimeError):
"""Update Not Called
Copied: Zope3/trunk/src/zope/contenttype (from rev 67629, Zope3/branches/jim-adapter/src/zope/contenttype)
Copied: Zope3/trunk/src/zope/copypastemove (from rev 67629, Zope3/branches/jim-adapter/src/zope/copypastemove)
Copied: Zope3/trunk/src/zope/datetime (from rev 67629, Zope3/branches/jim-adapter/src/zope/datetime)
Copied: Zope3/trunk/src/zope/decorator (from rev 67629, Zope3/branches/jim-adapter/src/zope/decorator)
Copied: Zope3/trunk/src/zope/deferredimport (from rev 67629, Zope3/branches/jim-adapter/src/zope/deferredimport)
Modified: Zope3/trunk/src/zope/deprecation/README.txt
===================================================================
--- Zope3/trunk/src/zope/deprecation/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/deprecation/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -8,6 +8,9 @@
provides a simple function called `deprecated(names, reason)` to deprecate the
previously mentioned Python objects.
+Deprecating objects inside a module
+-----------------------------------
+
Let's start with a demonstration of deprecating any name inside a module. To
demonstrate the functionality, I have placed the following code inside the
`tests.py` file of this package:
@@ -54,12 +57,6 @@
...README.txt:1: DeprecationWarning: demo3: demo3 is no more.
...
-Also, once a deprecation warning has been displayed, it is not shown again:
-
- >>> from zope.deprecation import tests
- >>> tests.demo1
- 1
-
Deprecation can also happen inside a function. When we first access
``demo4``, it can be accessed without problems, then we call a
function that sets the deprecation message and we get the message upon
@@ -74,6 +71,9 @@
...
4
+Deprecating methods and properties
+----------------------------------
+
New let's see how properties and methods can be deprecated. We are going to
use the same function as before, except that this time, we do not pass in names
as first argument, but the method or attribute itself. The function then
@@ -93,6 +93,10 @@
...
... def splat(self):
... return 4
+ ...
+ ... @deprecation.deprecate("clap() is no more.")
+ ... def clap(self):
+ ... return 5
And here is the result:
@@ -111,9 +115,180 @@
3
>>> my.splat()
4
+ >>> my.clap()
+ From tests.py's showwarning():
+ ...README.txt:1: DeprecationWarning: clap() is no more.
+ ...
+ 5
+Deprecating modules
+-------------------
-Temporarily Turning Off Deprecation Warnings
+It is also possible to deprecate whole modules. This is useful when
+creating module aliases for backward compatibility. Let's imagine,
+the ``zope.deprecation`` module used to be called ``zope.wanda`` and
+we'd like to retain backward compatibility:
+
+ >>> import zope.deprecation
+ >>> import sys
+ >>> sys.modules['zope.wanda'] = deprecation.deprecated(
+ ... zope.deprecation, 'A module called Wanda is now zope.deprecation.')
+
+Now we can import ``wanda``, but when accessing things from it, we get
+our deprecation message as expected:
+
+ >>> from zope.wanda import deprecated
+ From tests.py's showwarning():
+ ...README.txt:1: DeprecationWarning: A module called Wanda is now zope.deprecation.
+ ...
+
+Before we move on, we should clean up:
+
+ >>> del deprecated
+ >>> del sys.modules['zope.wanda']
+
+Moving modules
+--------------
+
+When a module is moved, you often want to support importing from the
+old location for a while, generating a deprecation warning when
+someone uses the old location. This can be done using the moved
+function.
+
+To see how this works, we'll use a helper function to create two fake
+modules in the zope.deprecation package. First will create a module
+in the "old" location that used the moved function to indicate the a
+module on the new location should be used:
+
+ >>> create_module(old_location=
+ ... '''
+ ... import zope.deprecation
+ ... zope.deprecation.moved('zope.deprecation.new_location', 'version 2')
+ ... ''')
+
+and we define the module in the new location:
+
+ >>> create_module(new_location=
+ ... '''\
+ ... print "new module imported"
+ ... x = 42
+ ... ''')
+
+Now, if we import the old location, we'll see the output of importing
+the old location:
+
+ >>> import zope.deprecation.old_location
+ ... # doctest: +NORMALIZE_WHITESPACE
+ From tests.py's showwarning():
+ ...zope/deprecation/README.txt:1:
+ DeprecationWarning: zope.deprecation.old_location has moved to
+ zope.deprecation.new_location.
+ Import of zope.deprecation.old_location will become unsupported
+ in version 2
+ ===============
+ new module imported
+
+ >>> zope.deprecation.old_location.x
+ 42
+
+Moving packages
+---------------
+
+When moving packages, you need to leave placeholders for each
+module. Let's look at an example:
+
+ >>> create_module({
+ ... 'new_package.__init__': '''\
+ ... print __name__, 'imported'
+ ... x=0
+ ... ''',
+ ... 'new_package.m1': '''\
+ ... print __name__, 'imported'
+ ... x=1
+ ... ''',
+ ... 'new_package.m2': '''\
+ ... print __name__, 'imported'
+ ... def x():
+ ... pass
+ ... ''',
+ ... 'new_package.m3': '''\
+ ... print __name__, 'imported'
+ ... x=3
+ ... ''',
+ ... 'old_package.__init__': '''\
+ ... import zope.deprecation
+ ... zope.deprecation.moved('zope.deprecation.new_package', 'version 2')
+ ... ''',
+ ... 'old_package.m1': '''\
+ ... import zope.deprecation
+ ... zope.deprecation.moved('zope.deprecation.new_package.m1', 'version 2')
+ ... ''',
+ ... 'old_package.m2': '''\
+ ... import zope.deprecation
+ ... zope.deprecation.moved('zope.deprecation.new_package.m2', 'version 2')
+ ... ''',
+ ... })
+
+
+
+Now, if we import the old modules, we'll get warnings:
+
+ >>> import zope.deprecation.old_package
+ ... # doctest: +NORMALIZE_WHITESPACE
+ From tests.py's showwarning():
+ ...zope/deprecation/README.txt:1: DeprecationWarning:
+ zope.deprecation.old_package has moved to zope.deprecation.new_package.
+ Import of zope.deprecation.old_package will become unsupported in version 2
+ ===============
+ zope.deprecation.new_package imported
+
+ >>> zope.deprecation.old_package.x
+ 0
+
+ >>> import zope.deprecation.old_package.m1
+ ... # doctest: +NORMALIZE_WHITESPACE
+ From tests.py's showwarning():
+ ...zope/deprecation/README.txt:1: DeprecationWarning:
+ zope.deprecation.old_package.m1 has moved to zope.deprecation.new_package.m1.
+ Import of zope.deprecation.old_package.m1 will become unsupported in
+ version 2
+ ===============
+ zope.deprecation.new_package.m1 imported
+
+ >>> zope.deprecation.old_package.m1.x
+ 1
+
+ >>> import zope.deprecation.old_package.m2
+ ... # doctest: +NORMALIZE_WHITESPACE
+ From tests.py's showwarning():
+ ...zope/deprecation/README.txt:1: DeprecationWarning:
+ zope.deprecation.old_package.m2 has moved to zope.deprecation.new_package.m2.
+ Import of zope.deprecation.old_package.m2 will become unsupported in
+ version 2
+ ===============
+ zope.deprecation.new_package.m2 imported
+
+ >>> zope.deprecation.old_package.m2.x is zope.deprecation.new_package.m2.x
+ True
+
+ >>> (zope.deprecation.old_package.m2.x.func_globals
+ ... is zope.deprecation.new_package.m2.__dict__)
+ True
+
+ >>> zope.deprecation.old_package.m2.x.__module__
+ 'zope.deprecation.new_package.m2'
+
+We'll get an error if we try to import m3, because we didn't create a
+placeholder for it:
+
+ >>> import zope.deprecation.old_package.m3
+ Traceback (most recent call last):
+ ...
+ ImportError: No module named m3
+
+
+
+Temporarily turning off deprecation warnings
--------------------------------------------
In some cases it is desireable to turn off the deprecation warnings for a
Modified: Zope3/trunk/src/zope/deprecation/__init__.py
===================================================================
--- Zope3/trunk/src/zope/deprecation/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/deprecation/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,7 +17,8 @@
"""
__docformat__ = "reStructuredText"
-from zope.deprecation.deprecation import deprecated, ShowSwitch
+from zope.deprecation.deprecation import deprecated, deprecate, ShowSwitch
+from zope.deprecation.deprecation import moved
# This attribute can be used to temporarly deactivate deprecation
# warnings, so that backward-compatibility code can import other
Modified: Zope3/trunk/src/zope/deprecation/deprecation.py
===================================================================
--- Zope3/trunk/src/zope/deprecation/deprecation.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/deprecation/deprecation.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -90,7 +90,35 @@
delattr(self.__original_module, name)
+class DeprecatedModule(object):
+ def __init__(self, module, msg):
+ self.__original_module = module
+ self.__msg = msg
+
+ def __getattribute__(self, name):
+ if name.startswith('_DeprecatedModule__'):
+ return ogetattr(self, name)
+
+ if name == '__class__':
+ return types.ModuleType
+
+ if zope.deprecation.__show__():
+ warnings.warn(self.__msg, DeprecationWarning, 2)
+
+ return getattr(ogetattr(self, '_DeprecatedModule__original_module'),
+ name)
+
+ def __setattr__(self, name, value):
+ if name.startswith('_DeprecatedModule__'):
+ return object.__setattr__(self, name, value)
+ setattr(self.__original_module, name, value)
+
+ def __delattr__(self, name):
+ if name.startswith('_DeprecatedModule__'):
+ return object.__delattr__(self, name)
+ delattr(self.__original_module, name)
+
class DeprecatedGetProperty(object):
def __init__(self, prop, message):
@@ -129,7 +157,9 @@
def deprecated(specifier, message):
"""Deprecate the given names."""
- # We are inside a module
+ # A string specifier (or list of strings) means we're called
+ # top-level in a module and are to deprecate things inside this
+ # module
if isinstance(specifier, (str, unicode, list, tuple)):
globals = sys._getframe(1).f_globals
modname = globals['__name__']
@@ -139,9 +169,12 @@
sys.modules[modname].deprecate(specifier, message)
- # ... that means the specifier is a method or attribute of the class
- if isinstance(specifier, types.FunctionType):
+ # Anything else can mean the specifier is a function/method,
+ # module, or just an attribute of a class
+ elif isinstance(specifier, types.FunctionType):
return DeprecatedMethod(specifier, message)
+ elif isinstance(specifier, types.ModuleType):
+ return DeprecatedModule(specifier, message)
else:
prop = specifier
if hasattr(prop, '__get__') and hasattr(prop, '__set__') and \
@@ -151,3 +184,33 @@
return DeprecatedGetSetProperty(prop, message)
elif hasattr(prop, '__get__'):
return DeprecatedGetProperty(prop, message)
+
+class deprecate(object):
+ """Deprecation decorator"""
+
+ def __init__(self, msg):
+ self.msg = msg
+
+ def __call__(self, func):
+ return DeprecatedMethod(func, self.msg)
+
+def moved(to_location, unsupported_in=None):
+ old = sys._getframe(1).f_globals['__name__']
+ message = '%s has moved to %s.' % (old, to_location)
+ if unsupported_in:
+ message += " Import of %s will become unsupported in %s" % (
+ old, unsupported_in)
+
+ warnings.warn(message, DeprecationWarning, 3)
+ __import__(to_location)
+
+ fromdict = sys.modules[to_location].__dict__
+ tomod = sys.modules[old]
+ tomod.__doc__ = message
+ todict = tomod.__dict__
+
+ for name, v in fromdict.iteritems():
+ if name not in tomod.__dict__:
+ setattr(tomod, name, v)
+
+
Modified: Zope3/trunk/src/zope/deprecation/tests.py
===================================================================
--- Zope3/trunk/src/zope/deprecation/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/deprecation/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,10 +15,15 @@
$Id$
"""
+
+import os
+import shutil
import sys
+import tempfile
import unittest
import warnings
from zope.testing import doctest
+import zope.deprecation
# Used in doctests
from deprecation import deprecated
@@ -36,18 +41,60 @@
"""Demonstrate that deprecate() also works in a local scope."""
deprecated('demo4', 'demo4 is no more.')
-orig_showwarning = warnings.showwarning
+def warn(message, type_, stacklevel):
+ print "From tests.py's showwarning():"
+
+ frame = sys._getframe(stacklevel)
+ path = frame.f_globals['__file__']
+ file = open(path)
+ lineno = frame.f_lineno
+ for i in range(lineno):
+ line = file.readline()
-def showwarning(message, category, filename, lineno, file=None):
- sys.stdout.write("From tests.py's showwarning():\n")
- sys.stdout.write(
- warnings.formatwarning(message, category, filename, lineno))
+ print "%s:%s: %s: %s\n %s" % (
+ path,
+ frame.f_lineno,
+ type_.__name__,
+ message,
+ line.strip(),
+ )
+
+def setUpCreateModule(test):
+ d = test.globs['tmp_d'] = tempfile.mkdtemp('deprecation')
+
+ def create_module(modules=(), **kw):
+ modules = dict(modules)
+ modules.update(kw)
+ for name, src in modules.iteritems():
+ pname = name.split('.')
+ if pname[-1] == '__init__':
+ os.mkdir(os.path.join(d, *pname[:-1]))
+ name = '.'.join(pname[:-1])
+ open(os.path.join(d, *pname)+'.py', 'w').write(src)
+ test.globs['created_modules'].append(name)
+
+ test.globs['created_modules'] = []
+ test.globs['create_module'] = create_module
+
+ zope.deprecation.__path__.append(d)
+
+def tearDownCreateModule(test):
+ zope.deprecation.__path__.pop()
+ shutil.rmtree(test.globs['tmp_d'])
+ for name in test.globs['created_modules']:
+ sys.modules.pop(name, None)
+
def setUp(test):
- warnings.showwarning = showwarning
+ test.globs['saved_warn'] = warnings.warn
+ warnings.warn = warn
+ setUpCreateModule(test)
def tearDown(test):
- warnings.showwarning = orig_showwarning
+ tearDownCreateModule(test)
+ warnings.warn = test.globs['saved_warn']
+ del object.__getattribute__(sys.modules['zope.deprecation.tests'],
+ '_DeprecationProxy__deprecated')['demo4']
def test_suite():
return unittest.TestSuite((
Copied: Zope3/trunk/src/zope/dublincore (from rev 67629, Zope3/branches/jim-adapter/src/zope/dublincore)
Modified: Zope3/trunk/src/zope/exceptions/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/exceptions/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/exceptions/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,3 +1,2 @@
zope.interface
zope.testing
-zope.deprecation
Modified: Zope3/trunk/src/zope/exceptions/__init__.py
===================================================================
--- Zope3/trunk/src/zope/exceptions/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/exceptions/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,29 +18,9 @@
$Id$
"""
+from zope.exceptions.interfaces import DuplicationError, IDuplicationError
+from zope.exceptions.interfaces import UserError, IUserError
-import zope.deprecation
-
-zope.deprecation.deprecated('INotFoundError',
- 'This interface has been deprecated. '
- 'Use standard interface instead '
- 'The reference will be gone in 3.3')
-
-zope.deprecation.deprecated('NotFoundError',
- 'This class has been deprecated. '
- 'Use standard exceptions instead '
- 'The reference will be gone in 3.3')
-
-# Turn of deprecation warning here for the above import that are here for BBB
-# The depreaction above and within the _notfounderror module will do the job.
-zope.deprecation.__show__.off()
-from zope.exceptions._notfounderror import NotFoundError, INotFoundError
-zope.deprecation.__show__.on()
-
-from zope.exceptions._duplicate import DuplicationError, IDuplicationError
-
-# Importing these interfaces from here is deprecated!
-
# avoid depency on zope.security:
try:
import zope.security
Deleted: Zope3/trunk/src/zope/exceptions/_duplicate.py
===================================================================
--- Zope3/trunk/src/zope/exceptions/_duplicate.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/exceptions/_duplicate.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,25 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Duplication Error
-
-$Id$
-"""
-from zope.interface import implements, Interface
-
-class IDuplicationError(Interface):
- pass
-
-class DuplicationError(Exception):
- """A duplicate registration was attempted"""
- implements(IDuplicationError)
Deleted: Zope3/trunk/src/zope/exceptions/_notfounderror.py
===================================================================
--- Zope3/trunk/src/zope/exceptions/_notfounderror.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/exceptions/_notfounderror.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,48 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Not Found Error
-
-$Id$
-"""
-
-from zope.deprecation import deprecated
-
-from zope.interface.common.interfaces import IKeyError
-from zope.interface import implements
-
-deprecated('INotFoundError',
- 'This interface has been deprecated. '
- 'Use standard interface instead '
- 'The reference will be gone in 3.3')
-
-deprecated('NotFoundError',
- 'This class has been deprecated. '
- 'Use standard exceptions instead '
- 'The reference will be gone in 3.3')
-
-class INotFoundError(IKeyError):
- pass
-
-class NotFoundError(KeyError, LookupError):
- """A resource could not be found.
-
- This exception is deprecated. It will, over time, be replaced
- with more specific exception types.
-
- Eventually, when this exception type is used as a base class, it
- will become an alias for LookupError. Client code should not depend
- on it extnding KeyError.
-
- """
- implements(INotFoundError)
Modified: Zope3/trunk/src/zope/exceptions/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/exceptions/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/exceptions/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -30,10 +30,27 @@
effort to clearly present the information provided by the
ITracebackSupplement.
"""
+from zope.interface import Interface, Attribute, implements
+class IDuplicationError(Interface):
+ pass
-from zope.interface import Interface, Attribute
+class DuplicationError(Exception):
+ """A duplicate registration was attempted"""
+ implements(IDuplicationError)
+class IUserError(Interface):
+ """User error exceptions
+ """
+
+class UserError(Exception):
+ """User errors
+
+ These exceptions should generally be displayed to users unless
+ they are handled.
+ """
+ implements(IUserError)
+
class ITracebackSupplement(Interface):
"""Provides valuable information to supplement an exception traceback.
Copied: Zope3/trunk/src/zope/filerepresentation (from rev 67629, Zope3/branches/jim-adapter/src/zope/filerepresentation)
Modified: Zope3/trunk/src/zope/formlib/__init__.py
===================================================================
--- Zope3/trunk/src/zope/formlib/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/formlib/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -11,8 +11,13 @@
#
##############################################################################
"""
-
$Id$
"""
-from zope.formlib.page import Page
+# BBB 2006/04/19 -- to be removed after 12 months
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "It has moved to zope.publisher.browser.BrowserPage. This reference "
+ "will be gone in Zope 3.5.",
+ Page = 'zope.publisher.browser:BrowserPage',
+ )
Modified: Zope3/trunk/src/zope/formlib/form.py
===================================================================
--- Zope3/trunk/src/zope/formlib/form.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/formlib/form.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -10,11 +10,10 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Forms
$Id$
"""
-
import datetime
import re
import sys
@@ -22,27 +21,26 @@
import zope.event
import zope.i18n
+import zope.i18nmessageid
+import zope.security
+import zope.interface.interfaces
+import zope.publisher.browser
import zope.publisher.interfaces.browser
-
from zope import component, interface, schema
-
from zope.interface.common import idatetime
from zope.interface.interface import InterfaceClass
-import zope.interface.interfaces
from zope.schema.interfaces import IField
from zope.schema.interfaces import ValidationError
import zope.security
+from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
import zope.app.container.interfaces
-import zope.app.event.objectevent
import zope.app.form.browser.interfaces
from zope.app.form.interfaces import IInputWidget, IDisplayWidget
from zope.app.form.interfaces import WidgetsError, MissingInputError
from zope.app.form.interfaces import InputErrors, WidgetInputError
from zope.app.pagetemplate import ViewPageTemplateFile
-from zope.app.publisher.browser import BrowserView
-import zope.formlib.page
from zope.formlib import interfaces, namedtemplate
from zope.formlib.i18n import _
@@ -595,7 +593,7 @@
if not self.available():
return ''
label = self.label
- if isinstance(label, (zope.i18n.Message, zope.i18n.MessageID)):
+ if isinstance(label, zope.i18nmessageid.Message):
label = zope.i18n.translate(self.label, context=self.form.request)
return ('<input type="submit" id="%s" name="%s" value="%s"'
' class="button" />' %
@@ -676,7 +674,7 @@
return result
-class FormBase(zope.formlib.page.Page):
+class FormBase(zope.publisher.browser.BrowserPage):
label = u''
@@ -783,8 +781,7 @@
@action(_("Apply"), condition=haveInputWidgets)
def handle_edit_action(self, action, data):
if applyChanges(self.context, self.form_fields, data, self.adapters):
- zope.event.notify(
- zope.app.event.objectevent.ObjectModifiedEvent(self.context))
+ zope.event.notify(ObjectModifiedEvent(self.context))
formatter = self.request.locale.dates.getFormatter(
'dateTime', 'medium')
@@ -843,8 +840,7 @@
def createAndAdd(self, data):
ob = self.create(data)
- zope.event.notify(
- zope.app.event.objectevent.ObjectCreatedEvent(ob))
+ zope.event.notify(ObjectCreatedEvent(ob))
return self.add(ob)
def create(self, data):
Modified: Zope3/trunk/src/zope/formlib/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/formlib/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/formlib/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -10,28 +10,30 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""
+"""Form interfaces
$Id$
"""
-
import re
from zope import interface, schema
-import zope.publisher.interfaces.browser
-import zope.schema.vocabulary
+from zope.publisher.interfaces.browser import IBrowserPage
+##############################################################################
+# BBB 2006/04/19 -- to be removed after 12 months
+
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "It has moved to zope.publisher.interfaces.browser.IBrowserPage. "
+ "This reference will be gone in Zope 3.5.",
+ IPage = 'zope.publisher.interfaces.browser:IBrowserPage',
+ )
+
+##############################################################################
+
class FormError(Exception):
"""There was an error in managing the form
"""
-class IPage(zope.publisher.interfaces.browser.IBrowserPublisher):
- """Web page
- """
-
- def __call__(*args, **kw):
- """Compute a response body
- """
-
def reConstraint(pat, explanation):
pat = re.compile(pat)
@@ -377,12 +379,12 @@
FormBase = interface.Attribute("""Base class for creating forms
The FormBase class provides reuasable implementation for creating
- forms. It implements ISubPage, IPage, and IFormBaseCustomization.
+ forms. It implements ISubPage, IBrowserPage, and IFormBaseCustomization.
Subclasses will override or use attributes defined by
IFormBaseCustomization.
""")
-class IFormBaseCustomization(ISubPage, IPage):
+class IFormBaseCustomization(ISubPage, IBrowserPage):
"""Attributes provided by the Form base class
These attributes may be used or overridden.
@@ -687,7 +689,7 @@
"""
-class IPageForm(IForm, IPage):
+class IPageForm(IForm, IBrowserPage):
"""A component that displays a form as a page.
"""
Modified: Zope3/trunk/src/zope/formlib/namedtemplate.py
===================================================================
--- Zope3/trunk/src/zope/formlib/namedtemplate.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/formlib/namedtemplate.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,7 +16,7 @@
"""
from zope import component, interface
-import zope.app.traversing.interfaces
+import zope.traversing.interfaces
class INamedTemplate(interface.Interface):
"""A template that is looked up by name
@@ -67,7 +67,7 @@
# TODO need test
class NamedTemplatePathAdapter(object):
- interface.implements(zope.app.traversing.interfaces.IPathAdapter)
+ interface.implements(zope.traversing.interfaces.IPathAdapter)
def __init__(self, context):
self.context = context
Modified: Zope3/trunk/src/zope/formlib/page.py
===================================================================
--- Zope3/trunk/src/zope/formlib/page.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/formlib/page.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -12,22 +12,14 @@
##############################################################################
"""Simple Page support
+This module has been deprecated and will be gone in Zope 3.5.
+
$Id$
"""
-
-from zope import interface
-from zope.publisher.interfaces import NotFound
-from zope.app.publisher.browser import BrowserView
-from zope.formlib.interfaces import IPage
-
-class Page(BrowserView):
- """Simple page-support class
- """
-
- interface.implements(IPage)
-
- def browserDefault(self, request):
- return self, ()
-
- def publishTraverse(self, request, name):
- raise NotFound(self, name, request)
+# BBB 2006/04/19 -- to be removed after 12 months
+import zope.deferredimport
+zope.deferredimport.deprecated(
+ "It has moved to zope.publisher.browser.BrowserPage. This reference "
+ "will be gone in Zope 3.5.",
+ Page = 'zope.publisher.browser:BrowserPage',
+ )
Deleted: Zope3/trunk/src/zope/formlib/page.txt
===================================================================
--- Zope3/trunk/src/zope/formlib/page.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/formlib/page.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,121 +0,0 @@
-=====
-Pages
-=====
-
-This is an experimental facility for defining pages in Python.
-
-A page is a view that's implemented in Python and registered in ZCML.
-
-The goal of pages is to put definitions in Python, rather than in
-ZCML.
-
-Pages are simply objects that implement views. There are a number of
-mix-in classes that make this easier.
-
-There are different kinds of pages:
-
-- Adapters, which provide some interface
-
-- Pages, which provide published objects
-
-What are the sorts of facilities we need?
-
-- Browser Publishing -- A browser-published object needs to provide
- IBrowserPublisher.
-
-- Widget management
-
- - Widget set up
-
- - We can set up widgets for input, editing, or display
-
- - select widget type
-
- - initialize widgets with existing data in edit case
-
- - Input processing
-
- - Actions/buttons
-
-A major goal is to make creating pages simple and explicit
-
-Creating simple pages
-=====================
-
-To create a page, which is an object that is published as a page,
-you need to provide an object that:
-
-- has a __call__ method and that
-
-- provides IBrowserPublisher, and
-
-If ZPT is going to be used, then your object should also provide
-request and context attributes.
-
-The Page base class provides a standard constructor
-and a simple implementation of IBrowserPublisher:
-
- >>> import zope.formlib
- >>> class MyPage(zope.formlib.Page):
- ... pass
-
- >>> from zope.publisher.browser import TestRequest
- >>> request = TestRequest()
- >>> context = object()
- >>> page = MyPage(context, request)
-
- >>> from zope.publisher.interfaces.browser import IBrowserPublisher
- >>> IBrowserPublisher.providedBy(page)
- True
-
- >>> page.browserDefault(request) == (page, ())
- True
-
- >>> page.publishTraverse(request, 'bob') # doctest: +ELLIPSIS
- Traceback (most recent call last):
- ...
- NotFound: Object: <MyPage object at ...>, name: 'bob'
-
- >>> page.request is request
- True
-
- >>> page.context is context
- True
-
-But it doesn't supply a __call__ method:
-
- >>> page()
- Traceback (most recent call last):
- ...
- TypeError: 'MyPage' object is not callable
-
-It is the subclass' responsibility to do that.
-
-If we want to use a page template, we will normally store that
-template in a file and use a ViewPageTemplateFile to add it to a
-class:
-
- >>> from zope.app.pagetemplate import ViewPageTemplateFile
- >>> class MyPage(zope.formlib.Page):
- ... __call__ = ViewPageTemplateFile('sample.pt')
-
-(See sample.pt in this directory to see the sample template.)
-
-Now, we'll create a content object and use it with our new page:
-
- >>> class MyContent:
- ... def __init__(self, name):
- ... self.name = name
-
- >>> context = MyContent('bob')
-
- >>> page = MyPage(context, request)
- >>> print page(1, 2, x=3, y=4)
- <html><body>
- Hello bob
- The URL is http://127.0.0.1
- The positional arguments were (1, 2)
- The keyword argument x is 3
- </body></html>
- <BLANKLINE>
-
Modified: Zope3/trunk/src/zope/formlib/tests.py
===================================================================
--- Zope3/trunk/src/zope/formlib/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/formlib/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -14,21 +14,22 @@
$Id$
"""
-
import unittest
import pytz
+
from zope import component, interface
import zope.interface.common.idatetime
-import zope.i18n
+import zope.i18n.testing
import zope.publisher.interfaces
import zope.publisher.interfaces.browser
import zope.schema.interfaces
+import zope.traversing.adapters
+import zope.component.testing
+
import zope.app.form.browser
import zope.app.form.browser.exception
import zope.app.form.browser.interfaces
import zope.app.form.interfaces
-from zope.app.testing import placelesssetup
-import zope.app.traversing.adapters
from zope.formlib import interfaces, namedtemplate, form
@@ -38,9 +39,9 @@
return pytz.timezone('US/Hawaii')
def pageSetUp(test):
- placelesssetup.setUp(test)
+ zope.component.testing.setUp(test)
component.provideAdapter(
- zope.app.traversing.adapters.DefaultTraversable,
+ zope.traversing.adapters.DefaultTraversable,
[None],
)
@@ -74,7 +75,8 @@
return '\n'.join(result)
def formSetUp(test):
- placelesssetup.setUp(test)
+ zope.component.testing.setUp(test)
+ zope.i18n.testing.setUp(test)
component.provideAdapter(
zope.app.form.browser.TextWidget,
[zope.schema.interfaces.ITextLine,
@@ -301,10 +303,10 @@
We also need to provide a traversal adapter for the view namespace
that lets us look up the macros.
- >>> import zope.app.traversing.interfaces
+ >>> import zope.traversing.interfaces
>>> class view:
... component.adapts(None, None)
- ... interface.implements(zope.app.traversing.interfaces.ITraversable)
+ ... interface.implements(zope.traversing.interfaces.ITraversable)
... def __init__(self, ob, r=None):
... pass
... def traverse(*args):
@@ -315,7 +317,7 @@
And we have to register the default traversable adapter (I wish we had
push templates):
- >>> from zope.app.traversing.adapters import DefaultTraversable
+ >>> from zope.traversing.adapters import DefaultTraversable
>>> component.provideAdapter(DefaultTraversable, [None])
We need to set up the translation framework. We'll just provide a
@@ -441,19 +443,15 @@
from zope.testing import doctest
return unittest.TestSuite((
doctest.DocFileSuite(
- 'page.txt',
- setUp=pageSetUp, tearDown=placelesssetup.tearDown,
- ),
- doctest.DocFileSuite(
'form.txt',
- setUp=formSetUp, tearDown=placelesssetup.tearDown,
+ setUp=formSetUp, tearDown=zope.component.testing.tearDown,
),
doctest.DocTestSuite(
- setUp=formSetUp, tearDown=placelesssetup.tearDown,
+ setUp=formSetUp, tearDown=zope.component.testing.tearDown,
),
doctest.DocFileSuite(
'namedtemplate.txt',
- setUp=pageSetUp, tearDown=placelesssetup.tearDown,
+ setUp=pageSetUp, tearDown=zope.component.testing.tearDown,
),
))
Modified: Zope3/trunk/src/zope/i18n/__init__.py
===================================================================
--- Zope3/trunk/src/zope/i18n/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/i18n/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,12 +18,6 @@
import re
import warnings
-# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.i18nmessageid import MessageIDFactory, MessageID
-zope.deprecation.__show__.on()
-
from zope.i18nmessageid import MessageFactory, Message
from zope.i18n.interfaces import ITranslationDomain
from zope.i18n.interfaces import IFallbackTranslationDomainFactory
@@ -41,7 +35,7 @@
def _translate(msgid, domain=None, mapping=None, context=None,
target_language=None, default=None):
- if isinstance(msgid, (MessageID, Message)):
+ if isinstance(msgid, Message):
domain = msgid.domain
default = msgid.default
mapping = msgid.mapping
Copied: Zope3/trunk/src/zope/i18n/locales/configure.zcml (from rev 67629, Zope3/branches/jim-adapter/src/zope/i18n/locales/configure.zcml)
Deleted: Zope3/trunk/src/zope/i18n/messageid.py
===================================================================
--- Zope3/trunk/src/zope/i18n/messageid.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/i18n/messageid.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,36 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Provide a backwards compatible import location for i18n message
-ids. This module will be removed from Zope 3.3.
-
-$Id$
-"""
-##############################################################################
-# BBB 2005/10/10 -- remove the whole module for Zope 3.3
-#
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.i18nmessageid import MessageID, MessageIDFactory
-from zope.i18nmessageid import Message, MessageFactory
-zope.deprecation.__show__.on()
-
-zope.deprecation.deprecated(
- ('MessageID', 'MessageIDFactory' 'Message', 'MessageFactory'),
- "The zope.i18n.messageid module as a backwards-compatible import "
- "location for i18n message ids has been deprecated and will be "
- "removed from Zope 3.3. Please use Message and MessageFactory "
- "from the zope.i18nmessageid package instead."
- )
-#
-##############################################################################
Copied: Zope3/trunk/src/zope/i18n/meta.zcml (from rev 67629, Zope3/branches/jim-adapter/src/zope/i18n/meta.zcml)
Copied: Zope3/trunk/src/zope/i18n/testing.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/i18n/testing.py)
Modified: Zope3/trunk/src/zope/i18n/tests/test_itranslationdomain.py
===================================================================
--- Zope3/trunk/src/zope/i18n/tests/test_itranslationdomain.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/i18n/tests/test_itranslationdomain.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,7 +20,7 @@
from zope.interface import implements
import zope.component
-from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.component.testing import PlacelessSetup
from zope.i18n.negotiator import negotiator
from zope.i18n.interfaces import INegotiator, IUserPreferredLanguages
Modified: Zope3/trunk/src/zope/i18n/tests/test_negotiator.py
===================================================================
--- Zope3/trunk/src/zope/i18n/tests/test_negotiator.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/i18n/tests/test_negotiator.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,7 +19,7 @@
from zope.i18n.negotiator import Negotiator
from zope.i18n.interfaces import IUserPreferredLanguages
-from zope.component.tests.placelesssetup import PlacelessSetup
+from zope.component.testing import PlacelessSetup
from zope.interface import implements
class Env(object):
Modified: Zope3/trunk/src/zope/i18n/tests/test_translationdomain.py
===================================================================
--- Zope3/trunk/src/zope/i18n/tests/test_translationdomain.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/i18n/tests/test_translationdomain.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,7 +20,7 @@
from zope.i18n.gettextmessagecatalog import GettextMessageCatalog
from zope.i18n.tests.test_itranslationdomain import \
TestITranslationDomain, Environment
-from zope.i18n import MessageIDFactory
+from zope.i18nmessageid import MessageFactory
from zope.i18n.interfaces import ITranslationDomain
import zope.component
@@ -80,13 +80,13 @@
u'Hello!')
def testMessageIDTranslate(self):
- factory = MessageIDFactory('default')
+ factory = MessageFactory('default')
translate = self._domain.translate
msgid = factory(u'short_greeting', 'default')
self.assertEqual(translate(msgid, target_language='en'), u'Hello!')
# MessageID attributes override arguments
- msgid = factory('43-not-there', 'this ${that} the other')
- msgid.mapping["that"] = "THAT"
+ msgid = factory('43-not-there', 'this ${that} the other',
+ mapping={'that': 'THAT'})
self.assertEqual(
translate(msgid, target_language='en', default="default",
mapping={"that": "that"}), "this THAT the other")
@@ -100,7 +100,7 @@
zope.component.provideUtility(domain, ITranslationDomain, 'other')
- factory = MessageIDFactory('other')
+ factory = MessageFactory('other')
msgid = factory(u'short_greeting', 'default')
self.assertEqual(
self._domain.translate(msgid, target_language='en'), u'Hello!')
Copied: Zope3/trunk/src/zope/i18n/tests/test_zcml.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/i18n/tests/test_zcml.py)
Modified: Zope3/trunk/src/zope/i18n/translationdomain.py
===================================================================
--- Zope3/trunk/src/zope/i18n/translationdomain.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/i18n/translationdomain.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,17 +15,11 @@
$Id$
"""
-# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.i18nmessageid import MessageID, Message
-zope.deprecation.__show__.on()
-
+from zope.component import getUtility
+from zope.i18nmessageid import Message
from zope.i18n import interpolate
from zope.i18n.simpletranslationdomain import SimpleTranslationDomain
-from zope.component import getUtility
-from zope.i18n.interfaces import ITranslationDomain
-from zope.i18n.interfaces import INegotiator
+from zope.i18n.interfaces import ITranslationDomain, INegotiator
# The configuration should specify a list of fallback languages for the
# site. If a particular catalog for a negotiated language is not available,
@@ -84,7 +78,7 @@
target_language = negotiator.getLanguage(langs, context)
# MessageID attributes override arguments
- if isinstance(msgid, (Message, MessageID)):
+ if isinstance(msgid, Message):
if msgid.domain != self.domain:
util = getUtility(ITranslationDomain, msgid.domain)
mapping = msgid.mapping
Copied: Zope3/trunk/src/zope/i18n/zcml.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/i18n/zcml.py)
Modified: Zope3/trunk/src/zope/i18nmessageid/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/i18nmessageid/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/i18nmessageid/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,2 +1 @@
zope.testing
-zope.deprecation
Modified: Zope3/trunk/src/zope/i18nmessageid/__init__.py
===================================================================
--- Zope3/trunk/src/zope/i18nmessageid/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/i18nmessageid/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,24 +15,4 @@
$Id$
"""
-##############################################################################
-# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3
-#
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.i18nmessageid.messageid import MessageID, MessageIDFactory
-zope.deprecation.__show__.on()
-zope.deprecation.deprecated('MessageID',
- 'Mutable i18n messages ("message ids") have been '
- 'deprecated in favour of immutable ones and will '
- 'be removed in Zope 3.3. Please use '
- 'zope.i18nmessageid.Message instead.')
-zope.deprecation.deprecated('MessageIDFactory',
- 'Mutable i18n messages ("message ids") have been '
- 'deprecated in favour of immutable ones and will '
- 'be removed in Zope 3.3. Please use '
- 'use zope.i18nmessageid.MessageFactory instead.')
-#
-##############################################################################
-
from zope.i18nmessageid.message import Message, MessageFactory
Deleted: Zope3/trunk/src/zope/i18nmessageid/messageid.py
===================================================================
--- Zope3/trunk/src/zope/i18nmessageid/messageid.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/i18nmessageid/messageid.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,114 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Message IDs.
-
-$Id$
-"""
-import zope.deprecation
-zope.deprecation.deprecated('MessageID',
- 'Mutable i18n messages ("message ids") have been '
- 'deprecated in favour of immutable ones and will '
- 'be removed in Zope 3.3. Please use '
- 'zope.i18nmessageid.Message instead.')
-zope.deprecation.deprecated('MessageIDFactory',
- 'Mutable i18n messages ("message ids") have been '
- 'deprecated in favour of immutable ones and will '
- 'be removed in Zope 3.3. Please use '
- 'use zope.i18nmessageid.MessageFactory instead.')
-
-class MessageID(unicode):
- """Message ID.
-
- This is a string used as a message ID. It has a domain attribute that is
- its source domain, and a default attribute that is its default text to
- display when there is no translation. domain may be None meaning there is
- no translation domain. default may also be None, in which case the
- message id itself implicitly serves as the default text.
-
- MessageID objects also have a mapping attribute which must be set after
- construction of the object. This is used when translating and
- substituting variables.
-
- To instanciate MessageIDs, it is recommended to use MessageIDFactory:
-
- >>> fact = MessageIDFactory('test')
-
- Now we can use the factory to make MessageIDs. Note that MessageID
- is a subclass of unicode:
-
- >>> id = fact(u'this is a test')
- >>> isinstance(id, MessageID)
- True
- >>> isinstance(id, unicode)
- True
-
- Additional parameters, such as the i18n domain and the default
- text are available through attributes:
-
- >>> id.domain
- 'test'
- >>> id.default
- u'this is a test'
-
- You can also reset the default text:
-
- >>> id.default = u'blah'
- >>> id.default
- u'blah'
-
- It is quite common to pass an abstract identifier as message id
- and then a default text:
-
- >>> id = fact(u'test-id', 'default test')
- >>> id
- u'test-id'
- >>> id.default
- u'default test'
- >>> id.domain
- 'test'
- """
-
- __slots__ = ('domain', 'default', 'mapping')
-
- def __new__(cls, ustr, domain=None, default=None):
- self = unicode.__new__(cls, ustr)
- self.domain = domain
- if default is None:
- self.default = ustr
- else:
- self.default = unicode(default)
- self.mapping = {}
- return self
-
- def __getstate__(self):
- return unicode(self), self.domain, self.default, self.mapping
-
- def __setstate__(self, (ustr, domain, default, mapping)):
- super(MessageID, self).__init__(ustr)
- self.domain = domain
- if default is None:
- self.default = ustr
- else:
- self.default = default
- self.mapping = mapping
-
-
-class MessageIDFactory(object):
- """Factory for creating MessageIDs."""
-
- def __init__(self, domain):
- self._domain = domain
-
- def __call__(self, ustr, default=None):
- return MessageID(ustr, self._domain, default)
Modified: Zope3/trunk/src/zope/i18nmessageid/tests.py
===================================================================
--- Zope3/trunk/src/zope/i18nmessageid/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/i18nmessageid/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,7 +20,6 @@
def test_suite():
return unittest.TestSuite((
- DocTestSuite('zope.i18nmessageid.messageid'),
DocTestSuite('zope.i18nmessageid.message'),
DocFileSuite('messages.txt', package='zope.i18nmessageid'),
))
Modified: Zope3/trunk/src/zope/interface/__init__.py
===================================================================
--- Zope3/trunk/src/zope/interface/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/interface/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -66,7 +66,7 @@
from zope.interface.declarations import alsoProvides, implementer
from zope.interface.declarations import implements, implementsOnly
from zope.interface.declarations import classProvides, moduleProvides
-from zope.interface.declarations import Declaration
+from zope.interface.declarations import noLongerProvides, Declaration
from zope.interface.exceptions import Invalid
# The following are to make spec pickles cleaner
Modified: Zope3/trunk/src/zope/interface/adapter.py
===================================================================
--- Zope3/trunk/src/zope/interface/adapter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/interface/adapter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -1,744 +1,528 @@
-############################################################################
+##############################################################################
#
-# Copyright (c) 2002 Zope Corporation and Contributors.
+# Copyright (c) 2004 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
-############################################################################
-"""Adapter-style interface registry
+##############################################################################
+"""Adapter management
-This implementation is based on a notion of "surrogate" interfaces.
-
$Id$
"""
-# Implementation notes
-
-# We keep a collection of surrogates.
-
-# A surrogate is a surrogate for a specification (interface or
-# declaration). We use weak references in order to remove surrogates
-# if the corresponding specification goes away.
-
-# Each surrogate keeps track of:
-
-# - The adapters registered directly for that surrogate, and
-
-# - The "implied" adapters, which is the adapters that can be computed
-# from instances of that surrogate.
-
-# The later data structure takes into account adapters registered for
-# specifications that the registered surrogate extends.
-
-# The registrations are of the form:
-
-# {(subscription, with, name, specification) -> factories}
-
-# where:
-
-# 'subscription' is a flag indicating if this registration is for
-# subscription adapters.
-
-# 'with' is a tuple of specs that is non-empty only in the case
-# of multi-adapters.
-
-# 'name' is a unicode adapter name. Unnamed adapters have an empty
-# name.
-
-# 'specification' is the interface being adapted to, the provided interface.
-
-# 'factories' is normally a tuple of factories, but can be anything.
-# (See the "raw" option to the query-adapter calls.) For subscription
-# adapters, it is a tuple of tuples of factories.
-
-# The implied adapters are held in a single dictionary. The items in the
-# dictionary are of several forms:
-
-# For single adapters:
-#
-# {specification -> {name -> object}
-#
-# where object is usually a sequence of factories
-
-# For multiple adapters:
-#
-# {(specification, order) -> {name -> {with -> object}}}
-
-# For single subscription adapters:
-#
-# {('s', specification) -> tuple([object])}
-
-# For multiple-subscription adapters:
-#
-# {('s', specification, order) -> {with -> tuple([object])}}
-
-
-from __future__ import generators
-
import weakref
-from zope.interface.ro import ro
-from zope.interface.declarations import providedBy
-from zope.interface.interface import InterfaceClass, Interface
+from zope.interface import providedBy, Interface, ro
-Default = InterfaceClass("Default", (), {})
-Null = InterfaceClass("Null", (), {})
+class readproperty(object):
-# 2.2 backwards compatability
-try:
- enumerate
-except NameError:
- def enumerate(l):
- i = 0
- for o in l:
- yield i, o
- i += 1
-try:
- basestring
-except NameError:
- basestring = (str, unicode)
-
-
-class ReadProperty(object):
-
def __init__(self, func):
self.func = func
def __get__(self, inst, class_):
if inst is None:
return self
- return self.func(inst)
-class Surrogate(object):
- """Specification surrogate
+ func = self.func
+ return func(inst)
+
- A specification surrogate is used to hold adapter registrations on
- behalf of a specification.
- """
+_delegated = ('lookup', 'queryMultiAdapter', 'lookup1', 'queryAdapter',
+ 'adapter_hook', 'lookupAll', 'names',
+ 'subscriptions', 'subscribers')
- def __init__(self, spec, registry):
- self.spec = spec.weakref()
- self.registry = registry
- spec.subscribe(self)
- self.adapters = {}
- self.dependents = weakref.WeakKeyDictionary()
+_marker = object
+class AdapterRegistry(object):
- self.registry = registry
- self.__bases__ = [registry.get(base) for base in spec.__bases__]
- for base in self.__bases__:
- base.subscribe(self)
+ def __init__(self, bases=()):
+ self._adapters = []
+ self._subscribers = []
+ self._provided = {}
+ self._init_non_persistent()
+ self.__bases__ = bases
- def dirty(self):
- if 'get' in self.__dict__:
- # Not already dirty
- del self.selfImplied
- del self.multImplied
- del self.get
+ def _init_non_persistent(self):
+ self._v_subregistries = weakref.WeakKeyDictionary()
+ self._v_lookup = lookup = AdapterLookup(self)
+ for name in _delegated:
+ self.__dict__[name] = getattr(lookup, name)
- bases = [self.registry.get(base) for base in self.spec().__bases__]
- if bases != self.__bases__:
- # Our bases changed. unsubscribe from the old ones
- # and subscribe to the new ones
- for base in self.__bases__:
- base.unsubscribe(self)
+ def __getstate__(self):
+ state = super(AdapterRegistry, self).__getstate__().copy()
+ for name in _delegated:
+ state.pop(name, 0)
+ return state
- self.__bases__ = bases
- for base in bases:
- base.subscribe(self)
+ def __setstate__(self, state):
+ super(AdapterRegistry, self).__setstate__(state)
+ self._init_non_persistent()
- for dependent in self.dependents.keys():
- dependent.dirty()
+ @apply
+ def __bases__():
+
+ def get(self):
+ return self.__dict__['__bases__']
- def clean(self):
- for base in self.__bases__:
- base.unsubscribe(self)
- self.__bases__ = [self.registry.get(base)
- for base in self.spec().__bases__]
- for base in self.__bases__:
- base.subscribe(self)
+ def set(self, v):
+ old = self.__dict__.get('__bases__', ())
+ for r in old:
+ if r not in v:
+ r._removeSubregistry(self)
+ for r in v:
+ if r not in old:
+ r._addSubregistry(self)
+
+ self.__dict__['__bases__'] = v
+ self.ro = ro.ro(self)
+ self.changed(self)
+
+ return property(get, set)
- self.selfImplied, self.multImplied = adapterImplied(self.adapters)
+ def _addSubregistry(self, r):
+ self._v_subregistries[r] = 1
- implied = {}
+ def _removeSubregistry(self, r):
+ if r in self._v_subregistries:
+ del self._v_subregistries[r]
- ancestors = ro(self)
+ def changed(self, originally_changed):
+ try:
+ lookup = self._v_lookup
+ except AttributeError:
+ pass
+ else:
+ lookup.changed(originally_changed)
- # Collect implied data in reverse order to have more specific data
- # override less-specific data.
- ancestors.reverse()
- for ancestor in ancestors:
- ancestor_spec = ancestor.spec()
+ for sub in self._v_subregistries.keys():
+ sub.changed(originally_changed)
+
+ @readproperty
+ def _v_extendors(self):
+ _v_extendors = {}
+ for provided in self._provided:
+ for i in provided.__iro__:
+ extendors = _v_extendors.get(i, ())
+ if provided not in extendors:
+ _v_extendors[i] = (
+ [e for e in extendors if provided.isOrExtends(e)]
+ +
+ [provided]
+ +
+ [e for e in extendors if not provided.isOrExtends(e)]
+ )
+ self._v_extendors = _v_extendors
+ return self._v_extendors
- for key, v in ancestor.selfImplied.iteritems():
+ def register(self, required, provided, name, value):
+ if value is None:
+ self.unregister(required, provided, name, value)
+ return
- # key is specification or ('s', specification)
- subscription = isinstance(key, tuple) and key[0] == 's'
- if subscription:
- # v is tuple of subs
- implied[key] = implied.get(key, ()) + v
- else:
- oldbyname = implied.get(key)
- if not oldbyname:
- implied[key] = oldbyname = {}
+ required = tuple(map(_convert_None_to_Interface, required))
+ name = _normalize_name(name)
+ order = len(required)
+ byorder = self._adapters
+ while len(byorder) <= order:
+ byorder.append({})
+ components = byorder[order]
+ key = required + (provided,)
+
+ for k in key:
+ d = components.get(k)
+ if d is None:
+ d = {}
+ components[k] = d
+ components = d
- # v is name -> object
- oldbyname.update(v)
+ if components.get(name) == value:
+ return
+
+ components[name] = value
- for key, v in ancestor.multImplied.iteritems():
- # key is (specification, order)
- # or ('s', specification, order)
- subscription = key[0] == 's'
- if subscription:
- oldwithobs = implied.get(key)
- if not oldwithobs:
- oldwithobs = implied[key] = {}
+ n = self._provided.get(provided, 0) + 1
+ self._provided[provided] = n
+ if n == 1 and '_v_extendors' in self.__dict__:
+ del self.__dict__['_v_extendors']
- # v is {with -> tuple([object])}
- for with, objects in v.iteritems():
- oldwithobs[with] = oldwithobs.get(with, ()) + objects
+ self.changed(self)
- else:
- oldbyname = implied.get(key)
- if not oldbyname:
- implied[key] = oldbyname = {}
+ def registered(self, required, provided, name=u''):
+ required = tuple(map(_convert_None_to_Interface, required))
+ name = _normalize_name(name)
+ order = len(required)
+ byorder = self._adapters
+ if len(byorder) <= order:
+ return None
+ components = byorder[order]
+ key = required + (provided,)
+
+ for k in key:
+ d = components.get(k)
+ if d is None:
+ return None
+ components = d
- # v is {name -> {with -> ?}}
- for name, withobs in v.iteritems():
+ return components.get(name)
+
+ def unregister(self, required, provided, name, value=None):
+ required = tuple(map(_convert_None_to_Interface, required))
+ order = len(required)
+ byorder = self._adapters
+ if order >= len(byorder):
+ return False
+ components = byorder[order]
+ key = required + (provided,)
+
+ for k in key:
+ d = components.get(k)
+ if d is None:
+ return
+ components = d
- # withobs is {with -> value}
+ old = components.get(name)
+ if old is None:
+ return
+ if (value is not None) and (old != value):
+ return
- # If ancestor is not the default,
- # add in ancestor so we can get ordering right
- if ancestor_spec is not Default:
- withobs = dict([
- (((ancestor_spec,) + with), value)
- for (with, value) in withobs.iteritems()
- ])
+ del components[name]
+ n = self._provided[provided] - 1
+ if n == 0:
+ del self._provided[provided]
+ if '_v_extendors' in self.__dict__:
+ del self.__dict__['_v_extendors']
+ else:
+ self._provided[provided] = n
- oldwithobs = oldbyname.get(name)
- if not oldwithobs:
- oldwithobs = oldbyname[name] = {}
+ self.changed(self)
- # withobs is {with -> object}
- oldwithobs.update(withobs)
+ return
- # Now flatten with mappings to tuples
- for key, v in implied.iteritems():
- if isinstance(key, tuple):
- if key[0] == 's':
- # subscriptions
- if isinstance(v, dict):
- implied[key] = v.items()
- else:
- byname = v
- for name, value in byname.iteritems():
- if isinstance(value, dict):
- # We have {with -> value}
- # convert it to [(with, value]
- byname[name] = value.items()
- self.get = implied.get
+ def subscribe(self, required, provided, value):
+ required = tuple(map(_convert_None_to_Interface, required))
+ name = u''
+ order = len(required)
+ byorder = self._subscribers
+ while len(byorder) <= order:
+ byorder.append({})
+ components = byorder[order]
+ key = required + (provided,)
+
+ for k in key:
+ d = components.get(k)
+ if d is None:
+ d = {}
+ components[k] = d
+ components = d
- def get(self, key):
- """Get an implied value
+ components[name] = components.get(name, ()) + (value, )
- This is only called when the surrogate is dirty
- """
- self.clean()
- return self.__dict__['get'](key)
+ if provided is not None:
+ n = self._provided.get(provided, 0) + 1
+ self._provided[provided] = n
+ if n == 1 and '_v_extendors' in self.__dict__:
+ del self.__dict__['_v_extendors']
- def selfImplied(self):
- """Return selfImplied when dirty
- """
- self.clean()
- return self.__dict__['selfImplied']
- selfImplied = ReadProperty(selfImplied)
+ self.changed(self)
- def multiImplied(self):
- """Return _multiImplied when dirty
- """
- self.clean()
- return self.__dict__['multiImplied']
- multiImplied = ReadProperty(multiImplied)
+ def unsubscribe(self, required, provided, value=None):
+ required = tuple(map(_convert_None_to_Interface, required))
+ order = len(required)
+ byorder = self._subscribers
+ if order >= len(byorder):
+ return
+ components = byorder[order]
+ key = required + (provided,)
+
+ for k in key:
+ d = components.get(k)
+ if d is None:
+ return
+ components = d
- def subscribe(self, dependent):
- self.dependents[dependent] = self.dependents.get(dependent, 0) + 1
+ old = components.get(u'')
+ if not old:
+ return
- def unsubscribe(self, dependent):
- n = self.dependents.get(dependent, 0) - 1
- if not n:
- del self.dependents[dependent]
- elif n > 0:
- self.dependents[dependent] = n
+ if value is None:
+ new = ()
else:
- raise KeyError(dependent)
+ new = tuple([v for v in old if v != value])
- def _adaptTo(self, specification, object, name='', with=()):
- if object is None:
- try:
- del self.adapters[False, tuple(with), name, specification]
- except KeyError:
- pass
- else:
- self.adapters[False, tuple(with), name, specification
- ] = object
+ if new == old:
+ return
+
+ components[u''] = new
- self.dirty()
+ if provided is not None:
+ n = self._provided[provided] + len(new) - len(old)
+ if n == 0:
+ del self._provided[provided]
+ if '_v_extendors' in self.__dict__:
+ del self.__dict__['_v_extendors']
- def _subscriptionAdaptTo(self, specification, object, with=()):
- if object is None:
- raise TypeError("Unregistering subscription adapters isn't "
- "implemented")
+ self.changed(self)
- key = (True, tuple(with), '', specification)
- self.adapters[key] = self.adapters.get(key, ()) + (object, )
- self.dirty()
+ # XXX hack to fake out twisted's use of a private api. We need to get them
+ # to use the new registed method.
+ def get(self, _):
+ class XXXTwistedFakeOut:
+ selfImplied = {}
+ return XXXTwistedFakeOut
- def changed(self, which=None):
- self.dirty()
- def __repr__(self):
- return '<%s(%s)>' % (self.__class__.__name__, self.spec())
+_not_in_mapping = object()
class AdapterLookup(object):
- # Adapter lookup support
- # We have a class here because we want to provide very
- # fast lookup support in C and making this part of the adapter
- # registry itself would provide problems if someone wanted
- # persistent adapter registries, because we want C slots for fast
- # lookup that would clash with persistence-supplied slots.
- # so this class acts a little bit like a lookup adapter for the adapter
- # registry.
- def __init__(self, registry, surrogates, _remove):
+ def __init__(self, registry):
self._registry = registry
- self._surrogateClass = registry._surrogateClass
- self._default = registry._default
- self._null = registry._null
- self._surrogates = surrogates
- self._remove = _remove
+ self._cache = {}
+ self._mcache = {}
+ self._scache = {}
+ self._required = {}
- def lookup(self, required, provided, name='', default=None):
- order = len(required)
- if order == 1:
- # Simple adapter:
- s = self.get(required[0])
- byname = s.get(provided)
- if byname:
- value = byname.get(name)
- else:
- value = None
+ def changed(self, originally_changed):
+ self._cache.clear()
+ self._mcache.clear()
+ self._scache.clear()
+ for r in self._required.keys():
+ r = r()
+ if r is not None:
+ r.unsubscribe(self)
+ self._required.clear()
+
+ def _getcache(self, provided, name):
+ cache = self._cache.get(provided)
+ if cache is None:
+ cache = {}
+ self._cache[provided] = cache
+ if name:
+ c = cache.get(name)
+ if c is None:
+ c = {}
+ cache[name] = c
+ cache = c
+ return cache
- if value is None:
- byname = self._default.get(provided)
- if byname:
- value = byname.get(name, default)
- else:
- return default
+ def _subscribe(self, *required):
+ _refs = self._required
+ for r in required:
+ ref = r.weakref()
+ if ref not in _refs:
+ r.subscribe(self)
+ _refs[ref] = 1
- return value
+ def lookup(self, required, provided, name=u'', default=None):
+ cache = self._getcache(provided, name)
+ if len(required) == 1:
+ result = cache.get(required[0], _not_in_mapping)
+ else:
+ result = cache.get(tuple(required), _not_in_mapping)
- elif order == 0:
- # null adapter
- byname = self._null.get(provided)
- if byname:
- return byname.get(name, default)
- else:
- return default
+ if result is _not_in_mapping:
+ result = None
+ order = len(required)
+ for registry in self._registry.ro:
+ byorder = registry._adapters
+ if order >= len(byorder):
+ continue
- # Multi adapter
+ extendors = registry._v_extendors.get(provided)
+ if not extendors:
+ continue
- with = required
- key = provided, order
+ components = byorder[order]
+ result = _lookup(components, required, extendors, name, 0,
+ order)
+ if result is not None:
+ break
- for surrogate in self.get(required[0]), self._default:
- byname = surrogate.get(key)
- if byname:
- bywith = byname.get(name)
- if bywith:
- # Selecting multi-adapters is not just a matter of
- # matching the required interfaces of the adapter
- # to the ones passed. Several adapters might
- # match, but we only want the best one. We use a
- # ranking algorithm to determine the best match.
- # `best` carries the rank and value of the best
- # found adapter.
- best = None
- for rwith, value in bywith:
- # the `rank` describes how well the found
- # adapter matches.
- rank = []
- for rspec, spec in zip(rwith, with):
- if not spec.isOrExtends(rspec):
- break # This one is no good
-
- # Determine the rank of this particular
- # specification.
- rank.append(list(spec.__sro__).index(rspec))
- else:
- # If the new rank is better than the best
- # previously recorded one, make the new
- # adapter the best one found.
- rank = tuple(rank)
- if best is None or rank < best[0]:
- best = rank, value
- # If any match was found, return the best one.
- if best:
- return best[1]
-
- with = with[1:] # on second pass through, don't use first spec
-
- return default
-
- def lookup1(self, required, provided, name='', default=None):
- return self.lookup((required,), provided, name, default)
-
- def adapter_hook(self, interface, object, name='', default=None):
- """Hook function used when calling interfaces.
-
- When called from Interface.__adapt__, only the interface and
- object parameters will be passed.
-
- If the factory produces `None`, then the default is returned. This
- allows us to prevent adaptation (if desired) and make the factory
- decide whether an adapter will be available.
- """
- factory = self.lookup1(providedBy(object), interface, name)
- if factory is not None:
- adapter = factory(object)
- if adapter is not None:
- return adapter
- return default
-
- def queryAdapter(self, object, interface, name='', default=None):
- # Note that we rarely call queryAdapter directly
- # We usually end up calling adapter_hook
- return self.adapter_hook(interface, object, name, default)
-
- def subscriptions(self, required, provided):
- if provided is None:
- provided = Null
-
- order = len(required)
- if order == 1:
- # Simple subscriptions:
- s = self.get(required[0])
- result = s.get(('s', provided))
- if result:
- result = list(result)
+ self._subscribe(*required)
+ if len(required) == 1:
+ cache[required[0]] = result
else:
- result = []
+ cache[tuple(required)] = result
- default = self._default.get(('s', provided))
- if default:
- result.extend(default)
+ if result is None:
+ return default
- return result
+ return result
- elif order == 0:
- result = self._null.get(('s', provided))
- if result:
- return list(result)
- else:
- return []
+ def queryMultiAdapter(self, objects, provided, name=u'', default=None):
+ factory = self.lookup(map(providedBy, objects), provided, name)
+ if factory is None:
+ return default
- # Multi
- key = 's', provided, order
- with = required[1:]
- result = []
+ result = factory(*objects)
+ if result is None:
+ return default
- for surrogate in self.get(required[0]), self._default:
- bywith = surrogate.get(key)
- if not bywith:
- continue
+ return result
+
+ def lookup1(self, required, provided, name=u'', default=None):
+ cache = self._getcache(provided, name)
+ result = cache.get(required, _not_in_mapping)
+ if result is _not_in_mapping:
+ return self.lookup((required, ), provided, name, default)
- for rwith, values in bywith:
- for rspec, spec in zip(rwith, with):
- if not spec.isOrExtends(rspec):
- break # This one is no good
- else:
- # we didn't break, so we have a match
- result.extend(values)
+ if result is None:
+ return default
return result
- def queryMultiAdapter(self, objects, interface, name='', default=None):
- factory = self.lookup(map(providedBy, objects), interface, name)
+
+ def queryAdapter(self, object, provided, name=u'', default=None):
+ return self.adapter_hook(provided, object, name, default)
+
+ def adapter_hook(self, provided, object, name=u'', default=None):
+ required = providedBy(object)
+ cache = self._getcache(provided, name)
+ factory = cache.get(required, _not_in_mapping)
+ if factory is _not_in_mapping:
+ factory = self.lookup((required, ), provided, name)
+
if factory is not None:
- return factory(*objects)
+ result = factory(object)
+ if result is not None:
+ return result
return default
- def subscribers(self, objects, interface):
- subscriptions = self.subscriptions(map(providedBy, objects), interface)
- subscribers = [subscription(*objects)
- for subscription in subscriptions]
- # Filter None values
- return [x for x in subscribers if x is not None]
-
- def get(self, declaration):
- if declaration is None:
- return self._default
-
- ref = declaration.weakref(self._remove)
- surrogate = self._surrogates.get(ref)
- if surrogate is None:
- surrogate = self._surrogateClass(declaration, self._registry)
- self._surrogates[ref] = surrogate
-
- return surrogate
-
-
-class AdapterRegistry(object):
- """Adapter registry
- """
-
- # Implementation note:
- # We are like a weakref dict ourselves. We can't use a weakref
- # dict because we have to use spec.weakref() rather than
- # weakref.ref(spec) to get weak refs to specs.
-
- _surrogateClass = Surrogate
-
- def __init__(self):
- default = self._surrogateClass(Default, self)
- self._default = default
- null = self._surrogateClass(Null, self)
- self._null = null
-
- # Create separate lookup object and copy it's methods
- surrogates = {Default.weakref(): default, Null.weakref(): null}
- def _remove(k):
- try:
- del surrogates[k]
- except KeyError:
- pass
- lookup = AdapterLookup(self, surrogates, _remove)
-
- for name in ('lookup', 'lookup1', 'queryAdapter', 'get',
- 'adapter_hook', 'subscriptions',
- 'queryMultiAdapter', 'subscribers',
- ):
- setattr(self, name, getattr(lookup, name))
-
- def register(self, required, provided, name, value):
- if required:
- with = []
- for iface in required[1:]:
- if iface is None:
- iface = Interface
- with.append(iface)
- with = tuple(with)
- required = self.get(required[0])
- else:
- with = ()
- required = self._null
-
- if not isinstance(name, basestring):
- raise TypeError("The name provided to provideAdapter "
- "must be a string or unicode")
-
- required._adaptTo(provided, value, unicode(name), with)
-
def lookupAll(self, required, provided):
- order = len(required)
- if order == 1:
- # Simple adapter:
- s = self.get(required[0])
- byname = s.get(provided)
- if byname:
- for item in byname.iteritems():
- yield item
+ cache = self._mcache.get(provided)
+ if cache is None:
+ cache = {}
+ self._mcache[provided] = cache
- defbyname = self._default.get(provided)
- if defbyname:
- for name, value in defbyname.iteritems():
- if name in byname:
- continue
- yield name, value
+ required = tuple(required)
+ result = cache.get(required, _not_in_mapping)
+ if result is _not_in_mapping:
+ order = len(required)
+ result = {}
+ for registry in reversed(self._registry.ro):
+ byorder = registry._adapters
+ if order >= len(byorder):
+ continue
+ extendors = registry._v_extendors.get(provided)
+ if not extendors:
+ continue
+ components = byorder[order]
+ _lookupAll(components, required, extendors, result, 0, order)
- return
+ self._subscribe(*required)
+ cache[required] = result
- elif order == 0:
- # null adapter
- byname = self._null.get(provided)
- if byname:
- for item in byname.iteritems():
- yield item
+ return result.iteritems()
- return
+ def names(self, required, provided):
+ return [c[0] for c in self.lookupAll(required, provided)]
+ def subscriptions(self, required, provided):
+ cache = self._scache.get(provided)
+ if cache is None:
+ cache = {}
+ self._scache[provided] = cache
- # Multi adapter
+ required = tuple(required)
+ result = cache.get(required, _not_in_mapping)
+ if result is _not_in_mapping:
+ order = len(required)
+ result = []
+ for registry in reversed(self._registry.ro):
+ byorder = registry._subscribers
+ if order >= len(byorder):
+ continue
- with = required
- key = provided, order
- first = ()
-
- for surrogate in self.get(required[0]), self._default:
- byname = surrogate.get(key)
- if byname:
- for name, bywith in byname.iteritems():
- if not bywith or name in first:
+ if provided is None:
+ extendors = (provided, )
+ else:
+ extendors = registry._v_extendors.get(provided)
+ if extendors is None:
continue
- # See comments on lookup() above
- best = None
- for rwith, value in bywith:
- # the `rank` describes how well the found
- # adapter matches.
- rank = []
- for rspec, spec in zip(rwith, with):
- if not spec.isOrExtends(rspec):
- break # This one is no good
+ _subscriptions(byorder[order], required, extendors, u'',
+ result, 0, order)
- # Determine the rank of this particular
- # specification.
- rank.append(list(spec.__sro__).index(rspec))
- else:
- # If the new rank is better than the best
- # previously recorded one, make the new
- # adapter the best one found.
- rank = tuple(rank)
- if best is None or rank < best[0]:
- best = rank, value
+ self._subscribe(*required)
+ cache[required] = result
- # If any match was found, return the best one.
- if best:
- yield name, best[1]
+ return result
- first = byname
-
- with = with[1:] # on second pass through, don't use first spec
-
- def subscribe(self, required, provided, value):
- if required:
- required, with = self.get(required[0]), tuple(required[1:])
- else:
- required = self._null
- with = ()
-
+ def subscribers(self, objects, provided):
+ subscriptions = self.subscriptions(map(providedBy, objects), provided)
if provided is None:
- provided = Null
-
- required._subscriptionAdaptTo(provided, value, with)
-
-def mextends(with, rwith):
- if len(with) == len(rwith):
- for w, r in zip(with, rwith):
- if not w.isOrExtends(r):
- break
+ result = ()
+ for subscription in subscriptions:
+ subscription(*objects)
else:
- return True
- return False
+ result = []
+ for subscription in subscriptions:
+ subscriber = subscription(*objects)
+ if subscriber is not None:
+ result.append(subscriber)
+ return result
+
+def _convert_None_to_Interface(x):
+ if x is None:
+ return Interface
+ else:
+ return x
-def adapterImplied(adapters):
- implied = {}
- multi = {}
+def _normalize_name(name):
+ if isinstance(name, basestring):
+ return unicode(name)
- # This dictionary is used to catch situations specific adapters
- # override less specific adapters.
- # Because subscriptions are cumulative, registered doesn't apply.
- registered = {}
+ raise TypeError("name must be a regular or unicode string")
- # Add adapters and interfaces directly implied by same:
+def _lookup(components, specs, provided, name, i, l):
+ if i < l:
+ for spec in specs[i].__sro__:
+ comps = components.get(spec)
+ if comps:
+ r = _lookup(comps, specs, provided, name, i+1, l)
+ if r is not None:
+ return r
+ else:
+ for iface in provided:
+ comps = components.get(iface)
+ if comps:
+ r = comps.get(name)
+ if r is not None:
+ return r
+
+ return None
- for key, value in adapters.iteritems():
+def _lookupAll(components, specs, provided, result, i, l):
+ if i < l:
+ for spec in reversed(specs[i].__sro__):
+ comps = components.get(spec)
+ if comps:
+ _lookupAll(comps, specs, provided, result, i+1, l)
+ else:
+ for iface in reversed(provided):
+ comps = components.get(iface)
+ if comps:
+ result.update(comps)
- # TODO: Backward compatibility
- # BBB ? Don't need to handle 3-tuples some day
- try:
- (subscription, with, name, target) = key
- except ValueError:
- (with, name, target) = key
- subscription = False
-
- if subscription:
- if with:
- _add_multi_sub_adapter(with, target, multi, value)
- else:
- _add_named_sub_adapter(target, implied, value)
- else:
- if with:
- _add_multi_adapter(with, name, target, target, multi,
- registered, value)
- else:
- _add_named_adapter(target, target, name, implied,
- registered, value)
-
- return implied, multi
-
-def _add_named_adapter(target, provided, name, implied,
- registered, value):
-
- ikey = target
- rkey = target, name
-
- byname = implied.get(ikey)
- if not byname:
- byname = implied[ikey] = {}
-
- if (name not in byname
- or
- (rkey in registered and registered[rkey].extends(provided))
- ):
-
- registered[rkey] = provided
- byname[name] = value
-
- for b in target.__bases__:
- _add_named_adapter(b, provided, name, implied,
- registered, value)
-
-def _add_multi_adapter(with, name, target, provided, implied,
- registered, object):
-
- ikey = target, (len(with) + 1)
- byname = implied.get(ikey)
- if not byname:
- byname = implied[ikey] = {}
-
- bywith = byname.get(name)
- if not bywith:
- bywith = byname[name] = {}
-
-
- rkey = ikey, name, with # The full key has all 4
- if (with not in bywith
- or
- (rkey not in registered or registered[rkey].extends(provided))
- ):
- # This is either a new entry or it is an entry for a more
- # general interface that is closer provided than what we had
- # before
- registered[rkey] = provided
- bywith[with] = object
-
- for b in target.__bases__:
- _add_multi_adapter(with, name, b, provided, implied,
- registered, object)
-
-def _add_named_sub_adapter(target, implied, objects):
- key = ('s', target)
- implied[key] = implied.get(key, ()) + objects
-
- for b in target.__bases__:
- _add_named_sub_adapter(b, implied, objects)
-
-def _add_multi_sub_adapter(with, target, implied, objects):
- key = 's', target, (len(with) + 1)
- bywith = implied.get(key)
- if not bywith:
- bywith = implied[key] = {}
-
- bywith[with] = bywith.get(with, ()) + objects
-
- for b in target.__bases__:
- _add_multi_sub_adapter(with, b, implied, objects)
+def _subscriptions(components, specs, provided, name, result, i, l):
+ if i < l:
+ for spec in reversed(specs[i].__sro__):
+ comps = components.get(spec)
+ if comps:
+ _subscriptions(comps, specs, provided, name, result, i+1, l)
+ else:
+ for iface in reversed(provided):
+ comps = components.get(iface)
+ if comps:
+ comps = comps.get(name)
+ if comps:
+ result.extend(comps)
Modified: Zope3/trunk/src/zope/interface/adapter.txt
===================================================================
--- Zope3/trunk/src/zope/interface/adapter.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/interface/adapter.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -115,6 +115,32 @@
>>> registry.lookup([IR2], IP1, '')
21
+Finding out what, if anything, is registered
+--------------------------------------------
+
+We can ask if there is an adapter registered for a collection of
+interfaces. This is different than lookup, because it looks for an
+exact match.
+
+ >>> print registry.registered([IR1], IP1)
+ 11
+
+ >>> print registry.registered([IR1], IP2)
+ 12
+
+ >>> print registry.registered([IR1], IP2, 'bob')
+ Bob's 12
+
+
+ >>> print registry.registered([IR2], IP1)
+ 21
+
+ >>> print registry.registered([IR2], IP2)
+ None
+
+In the last example, None was returned because nothing was registered
+exactly for the given interfaces.
+
lookup1
-------
@@ -394,43 +420,36 @@
Note that, unlike regular adapters, subscriptions are unnamed.
-The order of returned subscriptions is not specified.
-
You can have multiple subscribers for the same specification::
>>> registry.subscribe([IR1], IP2, 'sub12 2')
- >>> subs = registry.subscriptions([IR1], IP2)
- >>> subs.sort()
- >>> subs
+ >>> registry.subscriptions([IR1], IP2)
['sub12 1', 'sub12 2']
+If subscribers are registered for the same required interfaces, they
+are returned in the order of definition.
+
You can register subscribers for all specifications using None::
>>> registry.subscribe([None], IP1, 'sub_1')
- >>> subs = registry.subscriptions([IR2], IP1)
- >>> subs.sort()
- >>> subs
- ['sub12 1', 'sub12 2', 'sub_1']
+ >>> registry.subscriptions([IR2], IP1)
+ ['sub_1', 'sub12 1', 'sub12 2']
+Note that the new subscriber is returned first. Subscribers defined
+for more general required interfaces are returned before subscribers
+for more general interfaces.
+
Subscriptions may be combined over multiple compatible specifications::
- >>> subs = registry.subscriptions([IR2], IP1)
- >>> subs.sort()
- >>> subs
- ['sub12 1', 'sub12 2', 'sub_1']
+ >>> registry.subscriptions([IR2], IP1)
+ ['sub_1', 'sub12 1', 'sub12 2']
>>> registry.subscribe([IR1], IP1, 'sub11')
- >>> subs = registry.subscriptions([IR2], IP1)
- >>> subs.sort()
- >>> subs
- ['sub11', 'sub12 1', 'sub12 2', 'sub_1']
+ >>> registry.subscriptions([IR2], IP1)
+ ['sub_1', 'sub12 1', 'sub12 2', 'sub11']
>>> registry.subscribe([IR2], IP2, 'sub22')
- >>> subs = registry.subscriptions([IR2], IP1)
- >>> subs.sort()
- >>> subs
- ['sub11', 'sub12 1', 'sub12 2', 'sub22', 'sub_1']
- >>> subs = registry.subscriptions([IR2], IP2)
- >>> subs.sort()
- >>> subs
+ >>> registry.subscriptions([IR2], IP1)
+ ['sub_1', 'sub12 1', 'sub12 2', 'sub11', 'sub22']
+ >>> registry.subscriptions([IR2], IP2)
['sub12 1', 'sub12 2', 'sub22']
Subscriptions can be on multiple specifications::
@@ -445,28 +464,41 @@
>>> registry.subscribe([None, IQ], IP2, 'sub_q2')
>>> registry.subscriptions([IS, IQ], IP2)
['sub_q2']
- >>> subs = registry.subscriptions([IR1, IQ], IP2)
- >>> subs.sort()
- >>> subs
- ['sub1q2', 'sub_q2']
+ >>> registry.subscriptions([IR1, IQ], IP2)
+ ['sub_q2', 'sub1q2']
You can have subscriptions that are indepenent of any specifications::
- >>> registry.subscriptions([], IP1)
+ >>> list(registry.subscriptions([], IP1))
[]
>>> registry.subscribe([], IP2, 'sub2')
>>> registry.subscriptions([], IP1)
['sub2']
>>> registry.subscribe([], IP1, 'sub1')
- >>> subs = registry.subscriptions([], IP1)
- >>> subs.sort()
- >>> subs
- ['sub1', 'sub2']
+ >>> registry.subscriptions([], IP1)
+ ['sub2', 'sub1']
>>> registry.subscriptions([], IP2)
['sub2']
+Unregistering subscribers
+-------------------------
+We can unregister subscribers. When unregistering a subscriber, we
+can unregister a specific subscriber:
+
+ >>> registry.unsubscribe([IR1], IP1, 'sub11')
+ >>> registry.subscriptions([IR1], IP1)
+ ['sub_1', 'sub12 1', 'sub12 2']
+
+If we don't specify a value, then all subscribers matching the given
+interfaces will be unsubscribed:
+
+ >>> registry.unsubscribe([IR1], IP2)
+ >>> registry.subscriptions([IR1], IP1)
+ ['sub_1']
+
+
Subscription adapters
---------------------
Modified: Zope3/trunk/src/zope/interface/declarations.py
===================================================================
--- Zope3/trunk/src/zope/interface/declarations.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/interface/declarations.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -46,8 +46,8 @@
def __init__(self, *interfaces):
Specification.__init__(self, _normalizeargs(interfaces))
- def changed(self):
- Specification.changed(self)
+ def changed(self, originally_changed):
+ Specification.changed(self, originally_changed)
try:
del self._v_attrs
except AttributeError:
@@ -236,22 +236,7 @@
__radd__ = __add__
- def __nonzero__(self):
- """Test whether there are any interfaces in a specification.
- >>> from zope.interface import Interface
- >>> class I1(Interface): pass
- ...
- >>> spec = Declaration(I1)
- >>> int(bool(spec))
- 1
- >>> spec = Declaration()
- >>> int(bool(spec))
- 0
- """
- return bool(self.__iro__)
-
-
##############################################################################
#
# Implementation specifications
@@ -271,6 +256,8 @@
def __repr__(self):
return '<implementedBy %s>' % (self.__name__)
+ def __reduce__(self):
+ return implementedBy, (self.inherit, )
def implementedByFallback(cls):
"""Return the interfaces implemented for a class' instances
@@ -942,6 +929,45 @@
"""
directlyProvides(object, directlyProvidedBy(object), *interfaces)
+def noLongerProvides(object, interface):
+ """
+ This removes a directly provided interface from an object.
+ Consider the following two interfaces:
+
+ >>> from zope.interface import Interface
+ >>> class I1(Interface): pass
+ ...
+ >>> class I2(Interface): pass
+ ...
+
+ ``I1`` is provided through the class, ``I2`` is directly provided
+ by the object:
+
+ >>> class C(object):
+ ... implements(I1)
+ >>> c = C()
+ >>> alsoProvides(c, I2)
+ >>> I2.providedBy(c)
+ True
+
+ Remove I2 from c again:
+
+ >>> noLongerProvides(c, I2)
+ >>> I2.providedBy(c)
+ False
+
+ Removing an interface that is provided through the class is not possible:
+
+ >>> noLongerProvides(c, I1)
+ Traceback (most recent call last):
+ ...
+ ValueError: Can only remove directly provided interfaces.
+
+ """
+ directlyProvides(object, directlyProvidedBy(object)-interface)
+ if interface.providedBy(object):
+ raise ValueError("Can only remove directly provided interfaces.")
+
class ClassProvidesBasePy(object):
def __get__(self, inst, cls):
@@ -1209,30 +1235,6 @@
1
>>> int(providedBy(c).extends(I5))
1
-
- nonzero:
-
- >>> from zope.interface import Interface
- >>> class I1(Interface):
- ... pass
- >>> class I2(Interface):
- ... pass
- >>> class C(object):
- ... implements(I1)
- >>> c = C()
- >>> int(bool(providedBy(c)))
- 1
- >>> directlyProvides(c, I2)
- >>> int(bool(providedBy(c)))
- 1
- >>> class C(object):
- ... pass
- >>> c = C()
- >>> int(bool(providedBy(c)))
- 0
- >>> directlyProvides(c, I2)
- >>> int(bool(providedBy(c)))
- 1
"""
return Provides(cls, direct)
Modified: Zope3/trunk/src/zope/interface/interface.py
===================================================================
--- Zope3/trunk/src/zope/interface/interface.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/interface/interface.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -134,7 +134,7 @@
...
>>> spec = Declaration()
>>> int(spec.extends(Interface))
- 0
+ 1
>>> spec = Declaration(I2)
>>> int(spec.extends(Interface))
1
@@ -157,6 +157,8 @@
except ImportError:
pass
+
+
class Specification(SpecificationBase):
"""Specifications
@@ -249,7 +251,7 @@
for b in bases:
b.subscribe(self)
- self.changed()
+ self.changed(self)
__bases__ = property(
@@ -257,7 +259,7 @@
__setBases,
)
- def changed(self):
+ def changed(self, originally_changed):
"""We, or something we depend on, have changed
"""
@@ -265,10 +267,17 @@
implied.clear()
ancestors = ro(self)
+
+ try:
+ if Interface not in ancestors:
+ ancestors.append(Interface)
+ except NameError:
+ pass # defining Interface itself
+
self.__sro__ = tuple(ancestors)
self.__iro__ = tuple([ancestor for ancestor in ancestors
if isinstance(ancestor, InterfaceClass)
- ])
+ ])
for ancestor in ancestors:
# We directly imply our ancestors:
@@ -276,7 +285,7 @@
# Now, advise our dependents of change:
for dependent in self.dependents.keys():
- dependent.changed()
+ dependent.changed(originally_changed)
def interfaces(self):
@@ -333,7 +342,7 @@
...
>>> spec = Declaration()
>>> int(spec.extends(Interface))
- 0
+ 1
>>> spec = Declaration(I2)
>>> int(spec.extends(Interface))
1
@@ -907,8 +916,9 @@
from zope.interface.interfaces import IMethod
classImplements(Method, IMethod)
- from zope.interface.interfaces import IInterface
+ from zope.interface.interfaces import IInterface, ISpecification
classImplements(InterfaceClass, IInterface)
+ classImplements(Specification, ISpecification)
# We import this here to deal with module dependencies.
from zope.interface.declarations import providedBy, implementedBy
Modified: Zope3/trunk/src/zope/interface/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/interface/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/interface/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -483,6 +483,31 @@
adds I2 to the interfaces directly provided by ob.
"""
+ def alsoProvides(object, *interfaces):
+ """Declare additional interfaces directly for an object::
+
+ alsoProvides(ob, I1)
+
+ is equivalent to::
+
+ directivelyProvides(ob, directlyProvidedBy(ob), I1)
+ """
+
+ def noLongerProvides(object, interface):
+ """Remove an interface from the list of an object's directly
+ provided interfaces::
+
+ noLongerProvides(ob, I1)
+
+ is equivalent to::
+
+ directlyProvides(ob, directlyProvidedBy(ob)-I1)
+
+ with the exception that if ``I1`` is an interface that is
+ provided by ``ob`` through the class's implementation,
+ ValueError is raised.
+ """
+
def implements(*interfaces):
"""Declare interfaces implemented by instances of a class
@@ -635,13 +660,32 @@
provided interface, and a name.
"""
- def lookup(required, provided, name, default=None):
+ def lookup(required, provided, name='', default=None):
"""Lookup a value
A value is looked up based on a *sequence* of required
specifications, a provided interface, and a name.
"""
+ def queryMultiAdapter(objects, provided, name=u'', default=None):
+ """Adapt a sequence of objects to a named, provided, interface
+ """
+
+ def lookup1(required, provided, name=u'', default=None):
+ """Lookup a value using a single required interface
+
+ A value is looked up based on a single required
+ specifications, a provided interface, and a name.
+ """
+
+ def queryAdapter(object, provided, name=u'', default=None):
+ """Adapt an object using a registered adapter factory.
+ """
+
+ def adapter_hook(provided, object, name=u'', default=None):
+ """Adapt an object using a registered adapter factory.
+ """
+
def lookupAll(required, provided):
"""Find all adapters from the required to the provided interfaces
@@ -652,7 +696,7 @@
"""Return the names for which there are registered objects
"""
- def subscribe(required, provided, subscriber):
+ def subscribe(required, provided, subscriber, name=u''):
"""Register a subscriber
A subscriber is registered for a *sequence* of required
@@ -662,9 +706,13 @@
equivalent) interfaces.
"""
- def subscriptions(required, provided):
+ def subscriptions(required, provided, name=u''):
"""Get a sequence of subscribers
Subscribers for a *sequence* of required interfaces, and a provided
interface are returned.
"""
+
+ def subscribers(objects, provided, name=u''):
+ """Get a sequence of subscription adapters
+ """
Modified: Zope3/trunk/src/zope/interface/tests/test_declarations.py
===================================================================
--- Zope3/trunk/src/zope/interface/tests/test_declarations.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/interface/tests/test_declarations.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -389,7 +389,20 @@
"""
+def test_picklability_of_implements_specifications():
+ """
+ Sometimes, we need to pickle implements specs. We should be able
+ to do so as long as the class is picklable.
+
+ >>> import pickle
+ >>> pickle.loads(pickle.dumps(implementedBy(C))) is implementedBy(C)
+ True
+
+
+ """
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(Test))
Copied: Zope3/trunk/src/zope/lifecycleevent (from rev 67629, Zope3/branches/jim-adapter/src/zope/lifecycleevent)
Copied: Zope3/trunk/src/zope/location (from rev 67629, Zope3/branches/jim-adapter/src/zope/location)
Modified: Zope3/trunk/src/zope/proxy/__init__.py
===================================================================
--- Zope3/trunk/src/zope/proxy/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/proxy/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -29,3 +29,6 @@
while isProxy(p):
p = getProxiedObject(p)
yield p
+
+def non_overridable(func):
+ return property(lambda self: func.__get__(self))
Modified: Zope3/trunk/src/zope/proxy/_zope_proxy_proxy.c
===================================================================
--- Zope3/trunk/src/zope/proxy/_zope_proxy_proxy.c 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/proxy/_zope_proxy_proxy.c 2006-04-27 00:54:03 UTC (rev 67630)
@@ -234,6 +234,18 @@
if (descriptor != NULL) {
if (PyType_HasFeature(descriptor->ob_type, Py_TPFLAGS_HAVE_CLASS)
&& descriptor->ob_type->tp_descr_get != NULL) {
+
+ if (descriptor->ob_type->tp_descr_set == NULL)
+ {
+ res = PyObject_GetAttr(wrapped, name);
+ if (res != NULL)
+ goto finally;
+ if (PyErr_ExceptionMatches(PyExc_AttributeError))
+ PyErr_Clear();
+ else
+ goto finally;
+ }
+
res = descriptor->ob_type->tp_descr_get(
descriptor,
self,
@@ -278,17 +290,13 @@
Py_INCREF(name);
descriptor = WrapperType_Lookup(self->ob_type, name);
- if (descriptor != NULL) {
- if (PyType_HasFeature(descriptor->ob_type, Py_TPFLAGS_HAVE_CLASS) &&
- descriptor->ob_type->tp_descr_set != NULL) {
- res = descriptor->ob_type->tp_descr_set(descriptor, self, value);
- } else {
- PyErr_Format(PyExc_TypeError,
- "Tried to set attribute '%s' on wrapper, but it is not"
- " a data descriptor", PyString_AS_STRING(name));
- }
+ if (descriptor != NULL
+ && PyType_HasFeature(descriptor->ob_type, Py_TPFLAGS_HAVE_CLASS)
+ && descriptor->ob_type->tp_descr_set != NULL)
+ {
+ res = descriptor->ob_type->tp_descr_set(descriptor, self, value);
goto finally;
- }
+ }
wrapped = Proxy_GET_OBJECT(self);
if (wrapped == NULL) {
Modified: Zope3/trunk/src/zope/proxy/tests/test_proxy.py
===================================================================
--- Zope3/trunk/src/zope/proxy/tests/test_proxy.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/proxy/tests/test_proxy.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,6 +21,7 @@
from zope.testing.doctestunit import DocTestSuite
from zope.proxy import ProxyBase
+import zope.proxy
class Thing:
"""This class is expected to be a classic class."""
@@ -552,7 +553,67 @@
"""
+def test_get_descriptors_in_proxy_class():
+ """
+ A non-data descriptor in a proxy class doesn't hide an attribute on
+ a proxied object or prevent writing the attribute.
+ >>> class ReadDescr(object):
+ ... def __get__(self, i, c):
+ ... return 'read'
+
+ >>> class MyProxy(ProxyBase):
+ ... __slots__ = ()
+ ...
+ ... z = ReadDescr()
+ ... q = ReadDescr()
+
+ >>> class MyOb:
+ ... q = 1
+
+ >>> o = MyOb()
+ >>> p = MyProxy(o)
+ >>> p.q
+ 1
+
+ >>> p.z
+ 'read'
+
+ >>> p.z = 1
+ >>> o.z, p.z
+ (1, 1)
+
+ """
+
+def test_non_overridable():
+ """
+ Normally, methods defined in proxies are overridden by
+ methods of proxied objects. This applies to all non-data
+ descriptors. The non_overridable function can be used to
+ convert a non-data descriptor to a data descriptor that disallows
+ writes. This function can be used as a decorator to make functions
+ defined in proxy classes take precedence over functions defined
+ in proxied objects.
+
+
+ >>> class MyProxy(ProxyBase):
+ ... __slots__ = ()
+ ...
+ ... @zope.proxy.non_overridable
+ ... def foo(self):
+ ... return 'MyProxy foo'
+
+ >>> class MyOb:
+ ... def foo(self):
+ ... return 'MyOb foo'
+
+ >>> o = MyOb()
+ >>> p = MyProxy(o)
+ >>> p.foo()
+ 'MyProxy foo'
+
+ """
+
def test_suite():
suite = unittest.makeSuite(ProxyTestCase)
suite.addTest(DocTestSuite())
Modified: Zope3/trunk/src/zope/publisher/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/publisher/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/publisher/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -2,6 +2,7 @@
zope.exceptions
zope.i18n
zope.interface
+zope.location
zope.proxy
zope.security
zope.testing
Modified: Zope3/trunk/src/zope/publisher/browser.py
===================================================================
--- Zope3/trunk/src/zope/publisher/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/publisher/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -24,16 +24,24 @@
from types import ListType, TupleType, StringType
from cgi import FieldStorage
+import zope.component
from zope.interface import implements, directlyProvides
+from zope.interface import directlyProvidedBy, providedBy
from zope.i18n.interfaces import IUserPreferredLanguages
from zope.i18n.interfaces import IUserPreferredCharsets
+from zope.location import Location
+
+from zope.publisher.interfaces import NotFound
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.publisher.interfaces.browser import IDefaultSkin
from zope.publisher.interfaces.browser import IBrowserApplicationRequest
-
+from zope.publisher.interfaces.browser import IBrowserView
+from zope.publisher.interfaces.browser import IBrowserPage
+from zope.publisher.interfaces.browser import IBrowserSkinType
+from zope.publisher.interfaces.http import IHTTPRequest
from zope.publisher.http import HTTPRequest, HTTPResponse
-
__ArrayTypes = (ListType, TupleType)
start_of_header_search=re.compile('(<head[^>]*>)', re.I).search
@@ -782,7 +790,7 @@
return lang
class BrowserLanguages(object):
-
+ zope.component.adapts(IHTTPRequest)
implements(IUserPreferredLanguages)
def __init__(self, request):
@@ -828,3 +836,195 @@
accepts.reverse()
return [lang for quality, lang in accepts]
+
+class BrowserView(Location):
+ """Browser View.
+
+ >>> view = BrowserView("context", "request")
+ >>> view.context
+ 'context'
+ >>> view.request
+ 'request'
+
+ >>> view.__parent__
+ 'context'
+ >>> view.__parent__ = "parent"
+ >>> view.__parent__
+ 'parent'
+ """
+ implements(IBrowserView)
+
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def __getParent(self):
+ return getattr(self, '_parent', self.context)
+
+ def __setParent(self, parent):
+ self._parent = parent
+
+ __parent__ = property(__getParent, __setParent)
+
+class BrowserPage(BrowserView):
+ """Browser page
+
+ To create a page, which is an object that is published as a page,
+ you need to provide an object that:
+
+ - has a __call__ method and that
+
+ - provides IBrowserPublisher, and
+
+ - if ZPT is going to be used, then your object should also provide
+ request and context attributes.
+
+ The BrowserPage base class provides a standard constructor and a
+ simple implementation of IBrowserPublisher:
+
+ >>> class MyPage(BrowserPage):
+ ... pass
+
+ >>> request = TestRequest()
+ >>> context = object()
+ >>> page = MyPage(context, request)
+
+ >>> from zope.publisher.interfaces.browser import IBrowserPublisher
+ >>> IBrowserPublisher.providedBy(page)
+ True
+
+ >>> page.browserDefault(request) == (page, ())
+ True
+
+ >>> page.publishTraverse(request, 'bob') # doctest: +ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ NotFound: Object: <zope.publisher.browser.MyPage object at ...>, name: 'bob'
+
+ >>> page.request is request
+ True
+
+ >>> page.context is context
+ True
+
+ But it doesn't supply a __call__ method:
+
+ >>> page()
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Subclasses should override __call__ to provide a response body
+
+ It is the subclass' responsibility to do that.
+
+ """
+ implements(IBrowserPage)
+
+ def browserDefault(self, request):
+ return self, ()
+
+ def publishTraverse(self, request, name):
+ raise NotFound(self, name, request)
+
+ def __call__(self, *args, **kw):
+ raise NotImplementedError("Subclasses should override __call__ to "
+ "provide a response body")
+
+def setDefaultSkin(request):
+ """Sets the default skin for the request.
+
+ The default skin is a marker interface that can be registered as an
+ adapter that provides IDefaultSkin for the request type.
+
+ If a default skin is not available, the default layer
+ (IDefaultBrowserLayer) is used.
+
+ To illustrate, we'll first use setDefaultSkin without a registered
+ IDefaultSkin adapter:
+
+ >>> class Request(object):
+ ... implements(IBrowserRequest)
+
+ >>> request = Request()
+ >>> IDefaultBrowserLayer.providedBy(request)
+ False
+
+ >>> setDefaultSkin(request)
+ >>> IDefaultBrowserLayer.providedBy(request)
+ True
+
+ When we register a default layer, however:
+
+ >>> from zope.interface import Interface
+ >>> class IMySkin(Interface):
+ ... pass
+ >>> zope.component.provideAdapter(IMySkin, (IBrowserRequest,),
+ ... IDefaultSkin)
+
+ setDefaultSkin uses the layer instead of IDefaultBrowserLayer.providedBy:
+
+ >>> request = Request()
+ >>> IMySkin.providedBy(request)
+ False
+ >>> IDefaultSkin.providedBy(request)
+ False
+
+ >>> setDefaultSkin(request)
+
+ >>> IMySkin.providedBy(request)
+ True
+ >>> IDefaultBrowserLayer.providedBy(request)
+ False
+
+ Any interfaces that are directly provided by the request coming into this
+ method are replaced by the applied layer/skin interface:
+
+ >>> request = Request()
+ >>> class IFoo(Interface):
+ ... pass
+ >>> directlyProvides(request, IFoo)
+ >>> IFoo.providedBy(request)
+ True
+ >>> setDefaultSkin(request)
+ >>> IFoo.providedBy(request)
+ False
+
+ """
+ adapters = zope.component.getSiteManager().adapters
+ skin = adapters.lookup((providedBy(request),), IDefaultSkin, '')
+ if skin is not None:
+ directlyProvides(request, skin)
+ else:
+ directlyProvides(request, IDefaultBrowserLayer)
+
+def applySkin(request, skin):
+ """Change the presentation skin for this request.
+
+ >>> import pprint
+ >>> from zope.interface import Interface
+ >>> class SkinA(Interface): pass
+ >>> directlyProvides(SkinA, IBrowserSkinType)
+ >>> class SkinB(Interface): pass
+ >>> directlyProvides(SkinB, IBrowserSkinType)
+ >>> class IRequest(Interface): pass
+
+ >>> class Request(object):
+ ... implements(IRequest)
+
+ >>> req = Request()
+
+ >>> applySkin(req, SkinA)
+ >>> pprint.pprint(list(providedBy(req).interfaces()))
+ [<InterfaceClass zope.publisher.browser.SkinA>,
+ <InterfaceClass zope.publisher.browser.IRequest>]
+
+ >>> applySkin(req, SkinB)
+ >>> pprint.pprint(list(providedBy(req).interfaces()))
+ [<InterfaceClass zope.publisher.browser.SkinB>,
+ <InterfaceClass zope.publisher.browser.IRequest>]
+ """
+ # Remove all existing skin declarations (commonly the default skin).
+ ifaces = [iface for iface in directlyProvidedBy(request)
+ if not IBrowserSkinType.providedBy(iface)]
+ # Add the new skin.
+ ifaces.append(skin)
+ directlyProvides(request, *ifaces)
Modified: Zope3/trunk/src/zope/publisher/http.py
===================================================================
--- Zope3/trunk/src/zope/publisher/http.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/publisher/http.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -26,7 +26,6 @@
from tempfile import TemporaryFile
from zope import component, interface
-
from zope.deprecation import deprecation
from zope.publisher import contenttype
@@ -974,6 +973,7 @@
class HTTPCharsets(object):
+ component.adapts(IHTTPRequest)
interface.implements(IUserPreferredCharsets)
def __init__(self, request):
Modified: Zope3/trunk/src/zope/publisher/interfaces/__init__.py
===================================================================
--- Zope3/trunk/src/zope/publisher/interfaces/__init__.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/publisher/interfaces/__init__.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,27 +15,21 @@
$Id$
"""
-
__docformat__ = "reStructuredText"
-import zope.deprecation
+import zope.deferredimport
-from zope.interface import Interface
-from zope.interface import Attribute
-from zope.security.interfaces import Unauthorized
+zope.deferredimport.deprecated(
+ "ILayer will go away in Zope 3.5",
+ ILayer = 'zope.publisher.interfaces.back35:ILayer',
+ )
+
from zope.component.interfaces import IPresentationRequest
-from zope.interface import implements
-from zope.interface.interfaces import IInterface
+from zope.interface import Interface, Attribute, implements
from zope.interface.common.mapping import IEnumerableMapping
-from zope.interface.common.interfaces import IException
-from zope.security.interfaces import IParticipation
+from zope.interface.common.interfaces import IException, ILookupError
+from zope.security.interfaces import Unauthorized, IParticipation
-# BBB : can be remove in 3.3
-zope.deprecation.__show__.off()
-from zope.exceptions import NotFoundError, INotFoundError
-zope.deprecation.__show__.on()
-
-
class IPublishingException(IException):
pass
@@ -48,14 +42,14 @@
class TraversalException(PublishingException):
implements(ITraversalException)
-class INotFound(INotFoundError, ITraversalException):
+class INotFound(ILookupError, ITraversalException):
def getObject():
'Returns the object that was being traversed.'
def getName():
'Returns the name that was being traversed.'
-class NotFound(NotFoundError, TraversalException):
+class NotFound(LookupError, TraversalException):
implements(INotFound)
def __init__(self, ob, name, request=None):
@@ -464,21 +458,3 @@
class IRequest(IPublisherRequest, IPublicationRequest, IApplicationRequest):
"""The basic request contract
"""
-
-
-##############################################################################
-#
-# BBB 2006/02/18, to be removed after 12 months
-#
-
-class ILayer(IInterface):
- """A grouping of related views for a request."""
-
-import zope.deprecation
-zope.deprecation.deprecated('ILayer',
- 'The zope.publisher.interfaces.ILayer '
- 'interface has been deprecated and will '
- 'go away in Zope 3.5.')
-
-#
-##############################################################################
Copied: Zope3/trunk/src/zope/publisher/interfaces/back35.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/publisher/interfaces/back35.py)
Modified: Zope3/trunk/src/zope/publisher/interfaces/browser.py
===================================================================
--- Zope3/trunk/src/zope/publisher/interfaces/browser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/publisher/interfaces/browser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,13 +20,13 @@
from zope.interface import Interface, Attribute, directlyProvides
from zope.interface.interfaces import IInterface
+from zope.component.interfaces import IView
from zope.publisher.interfaces import IPublication
from zope.publisher.interfaces import IPublishTraverse
from zope.publisher.interfaces.http import IHTTPApplicationRequest
from zope.publisher.interfaces.http import IHTTPRequest
-
class IBrowserApplicationRequest(IHTTPApplicationRequest):
"""Browser-specific requests
"""
@@ -106,7 +106,15 @@
the base href.
"""
+class IBrowserPage(IBrowserPublisher):
+ """Browser page"""
+ def __call__(*args, **kw):
+ """Compute a response body"""
+
+class IBrowserView(IView):
+ """Browser View"""
+
class IDefaultBrowserLayer(IBrowserRequest):
"""The default layer."""
@@ -119,10 +127,7 @@
#
# mark the default layer for BBB reasons
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.publisher.interfaces import ILayer
-zope.deprecation.__show__.on()
+from zope.publisher.interfaces.back35 import ILayer
directlyProvides(IDefaultBrowserLayer, ILayer)
import zope.deprecation
Copied: Zope3/trunk/src/zope/publisher/tests/test_browser.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/publisher/tests/test_browser.py)
Copied: Zope3/trunk/src/zope/rdb (from rev 67629, Zope3/branches/jim-adapter/src/zope/rdb)
Modified: Zope3/trunk/src/zope/schema/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/schema/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/schema/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -592,3 +592,10 @@
When the vocabulary cannot be found, LookupError is raised.
"""
+
+class IVocabularyFactory(Interface):
+ """Can create vocabularies."""
+
+ def __call__(self, context):
+ """The context provides a location that the vocabulary can make use
+ of."""
Copied: Zope3/trunk/src/zope/security/adapter.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/security/adapter.py)
Modified: Zope3/trunk/src/zope/security/checker.py
===================================================================
--- Zope3/trunk/src/zope/security/checker.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/security/checker.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -645,7 +645,9 @@
_Declaration_checker = InterfaceChecker(
IDeclaration,
_implied=CheckerPublic,
- subscribe=CheckerPublic)
+ subscribe=CheckerPublic,
+ unsubscribe=CheckerPublic,
+ )
def f():
yield f
Copied: Zope3/trunk/src/zope/security/meta.zcml (from rev 67629, Zope3/branches/jim-adapter/src/zope/security/meta.zcml)
Copied: Zope3/trunk/src/zope/security/permission.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/security/permission.py)
Copied: Zope3/trunk/src/zope/security/tests/test_adapter.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/security/tests/test_adapter.py)
Modified: Zope3/trunk/src/zope/security/tests/test_checker.py
===================================================================
--- Zope3/trunk/src/zope/security/tests/test_checker.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/security/tests/test_checker.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,19 +18,16 @@
from unittest import TestCase, TestSuite, main, makeSuite
from zope.interface import implements
from zope.interface.verify import verifyObject
-from zope.security.checker import Checker, NamesChecker, CheckerPublic
from zope.testing.cleanup import CleanUp
from zope.proxy import getProxiedObject
-from zope.security.interfaces import ISecurityPolicy
+from zope.security.interfaces import ISecurityPolicy, Unauthorized
from zope.security.interfaces import Forbidden, ForbiddenAttribute
-from zope.security.interfaces import Unauthorized
from zope.security.management import setSecurityPolicy, newInteraction
from zope.security.management import endInteraction, getInteraction
-from zope.security.proxy import removeSecurityProxy
-from zope.security.proxy import getChecker
-from zope.security.proxy import Proxy
+from zope.security.proxy import removeSecurityProxy, getChecker, Proxy
from zope.security.checker import defineChecker, undefineChecker, ProxyFactory
from zope.security.checker import canWrite, canAccess
+from zope.security.checker import Checker, NamesChecker, CheckerPublic
from zope.security.checker import BasicTypes, _checkers, NoProxy, _clear
import types, pickle
Copied: Zope3/trunk/src/zope/security/tests/test_permission.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/security/tests/test_permission.py)
Copied: Zope3/trunk/src/zope/security/zcml.py (from rev 67629, Zope3/branches/jim-adapter/src/zope/security/zcml.py)
Copied: Zope3/trunk/src/zope/sendmail (from rev 67629, Zope3/branches/jim-adapter/src/zope/sendmail)
Copied: Zope3/trunk/src/zope/size (from rev 67629, Zope3/branches/jim-adapter/src/zope/size)
Modified: Zope3/trunk/src/zope/tal/dummyengine.py
===================================================================
--- Zope3/trunk/src/zope/tal/dummyengine.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/tal/dummyengine.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,14 +20,9 @@
from zope.interface import implements
from zope.tal.taldefs import NAME_RE, TALExpressionError, ErrorInfo
from zope.tal.interfaces import ITALExpressionCompiler, ITALExpressionEngine
+from zope.i18nmessageid import Message
from zope.i18n.interfaces import ITranslationDomain
-# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.i18nmessageid import MessageID, Message
-zope.deprecation.__show__.on()
-
Default = object()
name_match = re.compile(r"(?s)(%s):(.*)\Z" % NAME_RE).match
@@ -142,7 +137,7 @@
def evaluateText(self, expr):
text = self.evaluate(expr)
- if isinstance(text, (str, unicode, MessageID, Message)):
+ if isinstance(text, (str, unicode, Message)):
return text
if text is not None and text is not Default:
text = str(text)
@@ -298,7 +293,7 @@
# by calling that method.
# MessageID attributes override arguments
- if isinstance(msgid, (MessageID, Message)):
+ if isinstance(msgid, Message):
domain = msgid.domain
mapping = msgid.mapping
default = msgid.default
@@ -325,7 +320,7 @@
def translate(self, msgid, domain=None, mapping=None, default=None):
- if isinstance(msgid, (MessageID, Message)):
+ if isinstance(msgid, Message):
domain = msgid.domain
if domain == 'a_very_explicit_domain_setup_by_template_developer_that_wont_be_taken_into_account_by_the_ZPT_engine':
Modified: Zope3/trunk/src/zope/tal/talinterpreter.py
===================================================================
--- Zope3/trunk/src/zope/tal/talinterpreter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/tal/talinterpreter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -23,12 +23,7 @@
# Do not use cStringIO here! It's not unicode aware. :(
from StringIO import StringIO
-# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.i18nmessageid import MessageID, Message
-zope.deprecation.__show__.on()
-
+from zope.i18nmessageid import Message
from zope.tal.taldefs import quote, TAL_VERSION, METALError
from zope.tal.taldefs import isCurrentVersion
from zope.tal.taldefs import getProgramVersion, getProgramMode
@@ -37,7 +32,7 @@
# Avoid constructing this tuple over and over
-I18nMessageTypes = (MessageID, Message)
+I18nMessageTypes = (Message,)
TypesToTranslate = I18nMessageTypes + (str, unicode)
Modified: Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py
===================================================================
--- Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -30,13 +30,8 @@
from zope.tal.dummyengine import MultipleDomainsDummyEngine
from zope.tal.dummyengine import DummyTranslationDomain
from zope.tal.tests import utils
+from zope.i18nmessageid import Message
-# BBB 2005/10/10 -- MessageIDs are to be removed for Zope 3.3
-import zope.deprecation
-zope.deprecation.__show__.off()
-from zope.i18nmessageid import MessageID, Message
-zope.deprecation.__show__.on()
-
class TestCaseBase(unittest.TestCase):
def _compile(self, source):
@@ -455,22 +450,13 @@
"Foo <span tal:replace='bar' i18n:name='bar' /></div>")
self._check(program, u"<div>FOO \u00C0</div>\n")
-
-class I18NCornerTestCaseMessageID(I18NCornerTestCaseBase):
+class I18NCornerTestCaseMessage(I18NCornerTestCaseBase):
def factory(self, msgid, default=None, mapping={}, domain=None):
- m = MessageID(msgid, default=default)
- m.mapping = mapping
- return m
+ return Message(msgid, domain=domain, default=default, mapping=mapping)
-class UnusedExplicitDomainTestCase(I18NCornerTestCaseMessageID):
+class UnusedExplicitDomainTestCase(I18NCornerTestCaseMessage):
- def factory(self, msgid, default=None, mapping={}, domain=None):
- m = MessageID(msgid, default=default, domain=domain)
- m.mapping = mapping
- return m
-
-
def setUp(self):
# MultipleDomainsDummyEngine is a Engine
# where default domain transforms to uppercase
@@ -538,11 +524,6 @@
' tal:content="baz" />')
self._check(program, '<div>BAZVALUE</div>\n')
-class I18NCornerTestCaseMessage(I18NCornerTestCaseBase):
-
- def factory(self, msgid, default=None, mapping={}):
- return Message(msgid, default=default, mapping=mapping)
-
class ScriptTestCase(TestCaseBase):
def setUp(self):
@@ -762,7 +743,6 @@
suite.addTest(unittest.makeSuite(MacroExtendTestCase))
suite.addTest(unittest.makeSuite(OutputPresentationTestCase))
suite.addTest(unittest.makeSuite(ScriptTestCase))
- suite.addTest(unittest.makeSuite(I18NCornerTestCaseMessageID))
suite.addTest(unittest.makeSuite(I18NCornerTestCaseMessage))
suite.addTest(unittest.makeSuite(UnusedExplicitDomainTestCase))
suite.addTest(unittest.makeSuite(TestSourceAnnotations))
Copied: Zope3/trunk/src/zope/traversing (from rev 67629, Zope3/branches/jim-adapter/src/zope/traversing)
Modified: Zope3/trunk/src/zope/viewlet/DEPENDENCIES.cfg
===================================================================
--- Zope3/trunk/src/zope/viewlet/DEPENDENCIES.cfg 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/viewlet/DEPENDENCIES.cfg 2006-04-27 00:54:03 UTC (rev 67630)
@@ -7,3 +7,4 @@
zope.schema
zope.security
zope.tales
+zope.traversing
Modified: Zope3/trunk/src/zope/viewlet/README.txt
===================================================================
--- Zope3/trunk/src/zope/viewlet/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/viewlet/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -56,7 +56,7 @@
>>> from zope.publisher.browser import TestRequest
>>> request = TestRequest()
- >>> from zope.app.publisher.interfaces.browser import IBrowserView
+ >>> from zope.publisher.interfaces.browser import IBrowserView
>>> class View(object):
... zope.interface.implements(IBrowserView)
... def __init__(self, context, request):
@@ -170,7 +170,7 @@
>>> leftColumn['stock']
Traceback (most recent call last):
...
- ComponentLookupError: 'No provider with name `stock` found.'
+ ComponentLookupError: No provider with name `stock` found.
>>> leftColumn.get('stock') is None
True
@@ -417,7 +417,7 @@
Since we want to also provide the size of a file, here a simple implementation
of the ``ISized`` interface:
- >>> from zope.app import size
+ >>> from zope import size
>>> class FileSized(object):
... zope.interface.implements(size.interfaces.ISized)
... zope.component.adapts(IFile)
Modified: Zope3/trunk/src/zope/viewlet/directives.txt
===================================================================
--- Zope3/trunk/src/zope/viewlet/directives.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/viewlet/directives.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -37,7 +37,7 @@
>>> from zope.publisher.browser import TestRequest
>>> request = TestRequest()
- >>> from zope.app.publisher.browser import BrowserView
+ >>> from zope.publisher.browser import BrowserView
>>> view = BrowserView(content, request)
Now let's lookup the manager. This particular registration is pretty boring:
Modified: Zope3/trunk/src/zope/viewlet/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/viewlet/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/viewlet/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,10 +19,10 @@
import zope.interface
import zope.schema
-from zope.app.i18n import ZopeMessageFactory as _
-
from zope.contentprovider.interfaces import IContentProvider
from zope.interface.common.mapping import IReadMapping
+from zope.i18nmessageid import MessageFactory
+_ = MessageFactory('zope')
class IViewlet(IContentProvider):
"""A content provider that is managed by another content provider, known
Modified: Zope3/trunk/src/zope/viewlet/metaconfigure.py
===================================================================
--- Zope3/trunk/src/zope/viewlet/metaconfigure.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/viewlet/metaconfigure.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,18 +20,15 @@
import os
from zope.security import checker
-
from zope.configuration.exceptions import ConfigurationError
from zope.interface import Interface, classImplements
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
+from zope.publisher.interfaces.browser import IBrowserView
+from zope.component import zcml
+from zope.viewlet import viewlet, manager, interfaces
-from zope.app.component.interface import provideInterface
-from zope.app.component import metaconfigure
from zope.app.publisher.browser import viewmeta
-from zope.app.publisher.interfaces.browser import IBrowserView
-from zope.viewlet import viewlet, manager, interfaces
-
def viewletManagerDirective(
_context, name, permission,
for_=Interface, layer=IDefaultBrowserLayer, view=IBrowserView,
@@ -82,7 +79,7 @@
# Register interfaces
viewmeta._handle_for(_context, for_)
- metaconfigure.interface(_context, view)
+ zcml.interface(_context, view)
# Create a checker for the viewlet manager
checker.defineChecker(new_class, checker.Checker(required))
@@ -90,10 +87,10 @@
# register a viewlet manager
_context.action(
discriminator = ('viewletManager', for_, layer, view, name),
- callable = metaconfigure.handler,
- args = ('provideAdapter',
- (for_, layer, view), provides, name,
- new_class, _context.info),)
+ callable = zcml.handler,
+ args = ('registerAdapter',
+ new_class, (for_, layer, view), provides, name,
+ _context.info),)
def viewletDirective(
@@ -178,7 +175,7 @@
# Register the interfaces.
viewmeta._handle_for(_context, for_)
- metaconfigure.interface(_context, view)
+ zcml.interface(_context, view)
# Create the security checker for the new class
checker.defineChecker(new_class, checker.Checker(required))
@@ -186,7 +183,7 @@
# register viewlet
_context.action(
discriminator = ('viewlet', for_, layer, view, manager, name),
- callable = metaconfigure.handler,
- args = ('provideAdapter',
- (for_, layer, view, manager), interfaces.IViewlet,
- name, new_class, _context.info),)
+ callable = zcml.handler,
+ args = ('registerAdapter',
+ new_class, (for_, layer, view, manager), interfaces.IViewlet,
+ name, _context.info),)
Modified: Zope3/trunk/src/zope/viewlet/metadirectives.py
===================================================================
--- Zope3/trunk/src/zope/viewlet/metadirectives.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/viewlet/metadirectives.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,11 +19,11 @@
import zope.configuration.fields
import zope.schema
+from zope.publisher.interfaces import browser
+from zope.i18nmessageid import MessageFactory
+_ = MessageFactory('zope')
-from zope.app.i18n import ZopeMessageFactory as _
from zope.app.publisher.browser import metadirectives
-from zope.app.publisher.interfaces import browser
-
from zope.viewlet import interfaces
Modified: Zope3/trunk/src/zope/viewlet/tests.py
===================================================================
--- Zope3/trunk/src/zope/viewlet/tests.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/viewlet/tests.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -32,8 +32,8 @@
setup.placefulSetUp()
# resource namespace setup
- from zope.app.traversing.interfaces import ITraversable
- from zope.app.traversing.namespace import resource
+ from zope.traversing.interfaces import ITraversable
+ from zope.traversing.namespace import resource
ztapi.provideAdapter(None, ITraversable, resource, name="resource")
ztapi.provideView(None, None, ITraversable, "resource", resource)
Modified: Zope3/trunk/src/zope/viewlet/viewlet.py
===================================================================
--- Zope3/trunk/src/zope/viewlet/viewlet.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/viewlet/viewlet.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -20,15 +20,13 @@
import os
import sys
import zope.interface
+from zope.traversing import api
+from zope.publisher.browser import BrowserView
+from zope.viewlet import interfaces
from zope.app.pagetemplate import simpleviewclass
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
-from zope.app.publisher.browser import BrowserView
-from zope.app.traversing import api
-from zope.viewlet import interfaces
-
-
class ViewletBase(BrowserView):
"""Viewlet adapter class used in meta directive as a mixin class."""
Modified: Zope3/trunk/src/zope/wfmc/README.txt
===================================================================
--- Zope3/trunk/src/zope/wfmc/README.txt 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zope/wfmc/README.txt 2006-04-27 00:54:03 UTC (rev 67630)
@@ -102,6 +102,7 @@
>>> pd = process.ProcessDefinition('sample')
>>> zope.component.provideUtility(pd, name=pd.id)
+
>>> pd.defineActivities(
... author = process.ActivityDefinition(),
... review = process.ActivityDefinition(),
@@ -336,6 +337,7 @@
>>> pd = process.ProcessDefinition('sample', integration)
>>> zope.component.provideUtility(pd, name=pd.id)
+
>>> pd.defineActivities(
... author = process.ActivityDefinition(),
... review = process.ActivityDefinition(),
@@ -408,6 +410,7 @@
>>> pd = process.ProcessDefinition('sample', integration)
>>> zope.component.provideUtility(pd, name=pd.id)
+
>>> pd.defineActivities(
... author = process.ActivityDefinition(),
... review = process.ActivityDefinition(),
Modified: Zope3/trunk/src/zwiki/browser/wiki.py
===================================================================
--- Zope3/trunk/src/zwiki/browser/wiki.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/browser/wiki.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,11 +16,11 @@
$Id$
"""
from datetime import datetime
+
+import zope.component
from zope.proxy import removeAllProxies
-
-from zope.app import zapi
-from zope.app.dublincore.interfaces import ICMFDublinCore
-from zope.app.traversing.api import getName, getPath
+from zope.traversing.api import getName, getPath
+from zope.dublincore.interfaces import ICMFDublinCore
from zope.app.container.browser.adding import Adding
from zwiki.interfaces import IWikiPageHierarchy
@@ -33,7 +33,7 @@
if self.request.get('frontpage'):
page = removeAllProxies(
- zapi.createObject('zwiki.WikiPage'))
+ zope.component.createObject('zwiki.WikiPage'))
page.type = u'zope.source.rest'
page.source = u'This is the FrontPage of the Wiki.'
dc = ICMFDublinCore(page)
Modified: Zope3/trunk/src/zwiki/browser/wikipage.py
===================================================================
--- Zope3/trunk/src/zwiki/browser/wikipage.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/browser/wikipage.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,13 +18,12 @@
import re
from urllib import quote
+from zope.component import createObject, getMultiAdapter
from zope.proxy import removeAllProxies
-from zope.app.publisher.browser import BrowserView
-
-from zope.app import zapi
+from zope.traversing.api import getParent, getName
+from zope.publisher.browser import BrowserView
+from zope.dublincore.interfaces import ICMFDublinCore
from zope.app.form.browser.submit import Update
-from zope.app.dublincore.interfaces import ICMFDublinCore
-from zope.app.traversing.api import getParent, getName
from zwiki.interfaces import IWikiPageHierarchy, IMailSubscriptions
@@ -125,8 +124,8 @@
def render(self):
"""Render the wiki page source."""
- source = zapi.createObject(self.context.type, self.context.source)
- view = zapi.getMultiAdapter((removeAllProxies(source), self.request))
+ source = createObject(self.context.type, self.context.source)
+ view = getMultiAdapter((removeAllProxies(source), self.request))
html = view.render()
html = self.renderWikiLinks(html)
return html
@@ -135,8 +134,8 @@
result = []
for name, comment in self.context.items():
dc = DublinCoreViews(comment, self.request)
- source = zapi.createObject(comment.type, comment.source)
- view = zapi.getMultiAdapter(
+ source = createObject(comment.type, comment.source)
+ view = getMultiAdapter(
(removeAllProxies(source), self.request))
result.append({
'name': name,
Modified: Zope3/trunk/src/zwiki/comment.py
===================================================================
--- Zope3/trunk/src/zwiki/comment.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/comment.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -21,9 +21,9 @@
from zope.interface import implements
from zope.schema.vocabulary import getVocabularyRegistry
+from zope.dublincore.interfaces import ICMFDublinCore
from zope.app.container.contained import Contained
-from zope.app.dublincore.interfaces import ICMFDublinCore
-from zope.app.filerepresentation.interfaces import IReadFile, IWriteFile
+from zope.filerepresentation.interfaces import IReadFile, IWriteFile
from zwiki.interfaces import IComment
from zwiki.interfaces import IWikiPageContained
@@ -148,18 +148,18 @@
self.context = context
def read(self):
- """See zope.app.filerepresentation.interfaces.IReadFile"""
+ """See zope.filerepresentation.interfaces.IReadFile"""
text = 'Title: %s\n' %self.context.title
text += 'Type: %s\n\n' %self.context.type
text += self.context.source
return text
def size(self):
- """See zope.app.filerepresentation.interfaces.IReadFile"""
+ """See zope.filerepresentation.interfaces.IReadFile"""
return len(self.read())
def write(self, data):
- """See zope.app.filerepresentation.interfaces.IWriteFile"""
+ """See zope.filerepresentation.interfaces.IWriteFile"""
if data.startswith('Title: '):
title, data = data.split('\n', 1)
self.context.title = unicode(title[7:])
Modified: Zope3/trunk/src/zwiki/configure.zcml
===================================================================
--- Zope3/trunk/src/zwiki/configure.zcml 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/configure.zcml 2006-04-27 00:54:03 UTC (rev 67630)
@@ -89,7 +89,7 @@
<class class=".wiki.Wiki">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
+ interface="zope.annotation.interfaces.IAttributeAnnotatable" />
<factory
id="zwiki.Wiki"
@@ -144,7 +144,7 @@
<class class=".wikipage.WikiPage">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
+ interface="zope.annotation.interfaces.IAttributeAnnotatable" />
<factory
id="zwiki.WikiPage"
@@ -189,7 +189,7 @@
<class class=".comment.Comment">
<implements
- interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
+ interface="zope.annotation.interfaces.IAttributeAnnotatable" />
<factory
id="zwiki.Comment"
@@ -206,14 +206,14 @@
<adapter
for=".interfaces.IComment"
- provides="zope.app.filerepresentation.interfaces.IReadFile"
+ provides="zope.filerepresentation.interfaces.IReadFile"
factory=".comment.CommentFile"
permission="zwiki.ViewWikiPage"
/>
<adapter
for=".interfaces.IComment"
- provides="zope.app.filerepresentation.interfaces.IWriteFile"
+ provides="zope.filerepresentation.interfaces.IWriteFile"
factory=".comment.CommentFile"
permission="zwiki.CommentWikiPage"
/>
@@ -229,7 +229,7 @@
<adapter
factory=".traversal.WikiPageTraversable"
- provides="zope.app.traversing.interfaces.ITraversable"
+ provides="zope.traversing.interfaces.ITraversable"
for=".interfaces.IWikiPage"
trusted="true"
/>
@@ -238,21 +238,21 @@
<!-- WikiPage FTP configurations -->
<adapter
for=".interfaces.IWikiPage"
- provides="zope.app.filerepresentation.interfaces.IReadDirectory"
+ provides="zope.filerepresentation.interfaces.IReadDirectory"
factory=".wikipage.Directory"
permission="zwiki.ViewWikiPage"
/>
<adapter
for=".interfaces.IWikiPage"
- provides="zope.app.filerepresentation.interfaces.IWriteDirectory"
+ provides="zope.filerepresentation.interfaces.IWriteDirectory"
factory=".wikipage.Directory"
permission="zwiki.CommentWikiPage"
/>
<adapter
for=".interfaces.IWikiPage"
- provides="zope.app.filerepresentation.interfaces.IFileFactory"
+ provides="zope.filerepresentation.interfaces.IFileFactory"
factory="zwiki.comment.CommentFileFactory"
permission="zope.ManageContent"
/>
Modified: Zope3/trunk/src/zwiki/interfaces.py
===================================================================
--- Zope3/trunk/src/zwiki/interfaces.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/interfaces.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -19,11 +19,11 @@
"""
from zope.interface import Interface
from zope.schema import TextLine, List, SourceText, Choice
+from zope.component.interfaces import IObjectEvent
from zope.app.container.interfaces import IContained
from zope.app.container.interfaces import IContainer
from zope.app.container.constraints import contains, containers
-from zope.app.event.interfaces import IObjectEvent
from zwiki import ZWikiMessageFactory as _
Modified: Zope3/trunk/src/zwiki/tests/test_docstrings.py
===================================================================
--- Zope3/trunk/src/zwiki/tests/test_docstrings.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/tests/test_docstrings.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,15 +16,15 @@
$Id$
"""
import unittest
+import zope.component
from zope.schema.vocabulary import SimpleVocabulary
from zope.schema.vocabulary import VocabularyRegistry, _clear
from zope.schema.vocabulary import getVocabularyRegistry
from zope.schema.vocabulary import setVocabularyRegistry
from zope.testing.doctestunit import DocTestSuite
+from zope.dublincore.interfaces import ICMFDublinCore
-from zope.app import zapi
-from zope.app.dublincore.interfaces import ICMFDublinCore
-from zope.app.testing import placelesssetup, ztapi
+from zope.app.testing import placelesssetup
from zwiki.interfaces import IComment
@@ -48,7 +48,7 @@
def setUp(test):
placelesssetup.setUp()
- ztapi.provideAdapter(IComment, ICMFDublinCore, DCStub)
+ zope.component.provideAdapter(DCStub, (IComment,), ICMFDublinCore)
_clear()
registry = VocabularyRegistry()
Modified: Zope3/trunk/src/zwiki/tests/test_traversable.py
===================================================================
--- Zope3/trunk/src/zwiki/tests/test_traversable.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/tests/test_traversable.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -16,14 +16,14 @@
$Id$
"""
import unittest, sys
-from zope.app.traversing.interfaces import TraversalError
+from zope.traversing.interfaces import TraversalError
from zope.testing.cleanup import CleanUp
from zwiki.wiki import Wiki
from zwiki.wikipage import WikiPage
from zwiki.traversal import WikiPageTraversable
-from zope.app.site.tests.placefulsetup import PlacefulSetup
+from zope.app.component.testing import PlacefulSetup
class TestTraversable(PlacefulSetup, CleanUp, unittest.TestCase):
Modified: Zope3/trunk/src/zwiki/tests/test_traverser.py
===================================================================
--- Zope3/trunk/src/zwiki/tests/test_traverser.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/tests/test_traverser.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -17,19 +17,17 @@
"""
import unittest, sys
-from zope.component.tests.request import Request
-from zope.interface import Interface, classImplements
+from zope.interface import Interface, classImplements, directlyProvides
from zope.publisher.interfaces import NotFound
from zope.proxy import removeAllProxies
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.location.interfaces import ILocation
+from zope.location.traversing import LocationPhysicallyLocatable
+from zope.annotation.attribute import AttributeAnnotations
+from zope.annotation.interfaces import IAnnotations, IAttributeAnnotatable
-from zope.app import zapi
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.annotation.interfaces import IAnnotations, IAttributeAnnotatable
-from zope.app.location.interfaces import ILocation
-from zope.app.location.traversing import LocationPhysicallyLocatable
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.traversing.interfaces import IPhysicallyLocatable
from zwiki.interfaces import IWikiPage, IWikiPageHierarchy
from zwiki.wiki import Wiki
@@ -39,7 +37,11 @@
class I(Interface):
pass
-class Request(Request):
+class Request(object):
+
+ def __init__(self, type):
+ directlyProvides(self, type)
+
def getEffectiveURL(self):
return ''
Modified: Zope3/trunk/src/zwiki/tests/test_wikimail.py
===================================================================
--- Zope3/trunk/src/zwiki/tests/test_wikimail.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/tests/test_wikimail.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,20 +15,20 @@
$Id$
"""
+import unittest
import email
from email.Header import decode_header
-import unittest
-
from zope.event import subscribers
from zope.interface import classImplements, implements
+from zope.annotation.interfaces import IAnnotations, IAttributeAnnotatable
+from zope.annotation.attribute import AttributeAnnotations
+from zope.lifecycleevent import ObjectModifiedEvent
+from zope.sendmail.interfaces import IMailDelivery
+
from zope.app.testing import ztapi
from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.site.tests.placefulsetup import PlacefulSetup
-from zope.app.annotation.interfaces import IAnnotations, IAttributeAnnotatable
-from zope.app.event.objectevent import ObjectModifiedEvent
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.mail.interfaces import IMailDelivery
+from zope.app.component.testing import PlacefulSetup
from zwiki.interfaces import IWikiPage, IWiki, IMailSubscriptions
from zwiki.interfaces import IWikiPageEditEvent
Modified: Zope3/trunk/src/zwiki/tests/test_wikipagehierarchy.py
===================================================================
--- Zope3/trunk/src/zwiki/tests/test_wikipagehierarchy.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/tests/test_wikipagehierarchy.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -18,16 +18,15 @@
import unittest
from zope.interface import implements, classImplements
+from zope.traversing.interfaces import IPhysicallyLocatable
+from zope.location.interfaces import ILocation
+from zope.location.traversing import LocationPhysicallyLocatable
+from zope.annotation.interfaces import IAnnotations, IAttributeAnnotatable
+from zope.annotation.attribute import AttributeAnnotations
+
from zope.app.testing import ztapi
+from zope.app.component.testing import PlacefulSetup
-from zope.app.annotation.interfaces import IAnnotations, IAttributeAnnotatable
-from zope.app.traversing.interfaces import IPhysicallyLocatable
-from zope.app.location.interfaces import ILocation
-
-from zope.app.site.tests.placefulsetup import PlacefulSetup
-from zope.app.annotation.attribute import AttributeAnnotations
-from zope.app.location.traversing import LocationPhysicallyLocatable
-
from zwiki.interfaces import IWikiPage, IWikiPageHierarchy
from zwiki.wikipage import WikiPage, WikiPageHierarchyAdapter
from zwiki.wiki import Wiki
Modified: Zope3/trunk/src/zwiki/traversal.py
===================================================================
--- Zope3/trunk/src/zwiki/traversal.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/traversal.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -15,14 +15,12 @@
"""
from zope.interface import implements
from zope.proxy import removeAllProxies
-from zope.publisher.interfaces import IPublishTraverse
-from zope.publisher.interfaces import NotFound
-from zope.app.traversing.interfaces import TraversalError
+from zope.publisher.interfaces import IPublishTraverse, NotFound
+from zope.traversing.interfaces import TraversalError, ITraversable
+from zope.traversing.api import getParent
+from zope.traversing.namespace import UnexpectedParameters
from zope.app import zapi
-from zope.app.traversing.api import getParent
-from zope.app.traversing.namespace import UnexpectedParameters
-from zope.app.traversing.interfaces import ITraversable
from zwiki.interfaces import IWikiPage, IWikiPageHierarchy
Modified: Zope3/trunk/src/zwiki/wikipage.py
===================================================================
--- Zope3/trunk/src/zwiki/wikipage.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/src/zwiki/wikipage.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -25,19 +25,19 @@
from zope.interface import implements
from zope.event import notify
from zope.schema.vocabulary import getVocabularyRegistry
+from zope.annotation.interfaces import IAnnotations
+from zope.component.interfaces import ObjectEvent
+from zope.filerepresentation.interfaces import IReadFile
+from zope.filerepresentation.interfaces import IWriteFile
+from zope.filerepresentation.interfaces import IReadDirectory
+from zope.filerepresentation.interfaces import IWriteDirectory
+from zope.sendmail.interfaces import IMailDelivery
from zope.app import zapi
from zope.app.container.btree import BTreeContainer
from zope.app.container.contained import Contained
-from zope.app.filerepresentation.interfaces import IReadFile
-from zope.app.filerepresentation.interfaces import IWriteFile
-from zope.app.filerepresentation.interfaces import IReadDirectory
-from zope.app.filerepresentation.interfaces import IWriteDirectory
-from zope.app.annotation.interfaces import IAnnotations
-from zope.app.event.objectevent import ObjectEvent
from zope.app.container.interfaces import \
IObjectAddedEvent, IObjectRemovedEvent
-from zope.app.mail.interfaces import IMailDelivery
from zwiki.interfaces import IWiki, IWikiPage
from zwiki.interfaces import IWikiContained, IWikiPageContained
@@ -270,17 +270,17 @@
self.context = context
def read(self):
- """See zope.app.filerepresentation.interfaces.IReadFile"""
+ """See zope.filerepresentation.interfaces.IReadFile"""
text = u'Source Type: %s\n\n' %self.context.type
text += self.context.source
return text
def size(self):
- """See zope.app.filerepresentation.interfaces.IReadFile"""
+ """See zope.filerepresentation.interfaces.IReadFile"""
return len(self.read())
def write(self, data):
- """See zope.app.filerepresentation.interfaces.IWriteFile"""
+ """See zope.filerepresentation.interfaces.IWriteFile"""
if data.startswith('Type: '):
type, data = data.split('\n\n', 1)
type = type[6:]
Copied: Zope3/trunk/to-do.txt (from rev 67629, Zope3/branches/jim-adapter/to-do.txt)
Modified: Zope3/trunk/utilities/runurl.py
===================================================================
--- Zope3/trunk/utilities/runurl.py 2006-04-26 23:44:19 UTC (rev 67629)
+++ Zope3/trunk/utilities/runurl.py 2006-04-27 00:54:03 UTC (rev 67630)
@@ -47,11 +47,6 @@
Run the profiler saving the profile data to the given file name
- --hotshot file
-
- Run the hotshot profiler saving the profile data to the given
- file name
-
-w
--warmup
@@ -62,9 +57,9 @@
Output this usage information.
- --build
+ --bias float
- Run from a build directory
+ The profiler bias. The default is 0.0.
$Id$
"""
@@ -86,15 +81,17 @@
args,
'b:r:p:d:c:hi:w',
['basic=', 'run=', 'profile=', 'database=', 'config=', 'help',
- 'input=', 'warmup', 'build', 'hotshot='])
+ 'input=', 'warmup', 'bias='])
except getopt.GetoptError:
print __doc__ % {'script': script}
raise
- basic = run = warm = profilef = database = config = hotshotf = None
+ basic = run = warm = profilef = database = config = None
stdin = ''
src = 'src'
+ bias = 0.0
+ warm = 0
for name, value in options:
if name in ('-b', '--basic'):
basic = value
@@ -102,13 +99,6 @@
run = int(value)
elif name in ('-p', '--profile'):
profilef = value
- elif name in ('--hotshot', ):
- hotshotf = value
- elif name in ('--build', ):
- from distutils.util import get_platform
- PLAT_SPEC = "%s-%s" % (get_platform(), sys.version[0:3])
- src = os.path.join("build", "lib.%s" % PLAT_SPEC)
-
elif name in ('-d', '--database'):
database = value
elif name in ('-c', '--config'):
@@ -116,7 +106,9 @@
elif name in ('-i', '--input'):
input = value
elif name in ('-w', '--warmup'):
- warm= True
+ warm += 1
+ elif name in ('--bias', ):
+ bias = float(value)
elif name in ('-h', '--help'):
print __doc__ % {'script': script}
sys.exit(0)
@@ -139,27 +131,21 @@
debugger = Debugger(database, config)
if warm:
- _mainrun(debugger, path, basic, 1, stdin, env)
+ _mainrun(debugger, path, basic, warm, stdin, env)
- if profilef or hotshotf:
+ if profilef:
cmd = "_mainrun(debugger, path, basic, run, stdin, env, True)"
- if profilef:
- import profile
- profile.run(cmd, profilef)
- if hotshotf:
- import hotshot
- p = hotshot.Profile(hotshotf)
- p.runctx(cmd, globals(), locals())
- p.close()
- del p
-
- print 'Writing', hotshotf
- from hotshot.stats import StatsLoader
- p = StatsLoader(hotshotf).load()
- import marshal
- marshal.dump(p.stats, open(hotshotf, 'w'))
- print 'Wrote', hotshotf
-
+ import time
+ import profile
+ profiler = profile.Profile(time.time, bias)
+ try:
+ profiler.run(cmd)
+ except SystemExit:
+ pass
+ if profilef == '-':
+ profiler.print_stats()
+ else:
+ profiler.dump_stats(profilef)
else:
_mainrun(debugger, path, basic, run, stdin, env)
More information about the Zope3-Checkins
mailing list