Skip to content

Commit

Permalink
Fixed deprecation warnings for use of Globals. Avoid a dependency on …
Browse files Browse the repository at this point in the history
…zope.app.apidoc by copying over the getViews method - this removes the dependency on many zope.app packages.
  • Loading branch information
hannosch committed Jan 14, 2009
1 parent e5f1075 commit d7b6de5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ CHANGES
five.customerize 0.4 (unreleased)
---------------------------------

Fixed deprecation warnings for use of Globals.

Specify all package dependencies.

Added missing dependencies on zope.app.apidoc.
Avoid a dependency on zope.app.apidoc by copying over the getViews method.

five.customerize 0.3 (2008/07/07)
---------------------------------
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
'zope.testing',
'zope.traversing',
'zope.viewlet',
'zope.app.apidoc',
'zope.app.component',
'zope.app.container',
'zope.app.pagetemplate',
Expand Down
17 changes: 16 additions & 1 deletion src/five/customerize/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,34 @@
from Products.Five.browser import BrowserView

from zope.interface import providedBy, Interface
from zope.component import getGlobalSiteManager
from zope.component import getMultiAdapter, getSiteManager
from zope.component import getUtility, queryUtility
from zope.dottedname.resolve import resolve
from zope.interface.interfaces import IInterface
from zope.schema.interfaces import IVocabularyFactory
from zope.publisher.interfaces import IRequest
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.traversing.browser import absoluteURL
from zope.app.apidoc.presentation import getViews

from five.customerize.zpt import TTWViewTemplate
from five.customerize.interfaces import IViewTemplateContainer


# This method was copied from zope.app.apidoc.presentation
def getViews(iface, type=IRequest):
"""Get all view registrations for a particular interface."""
gsm = getGlobalSiteManager()
for reg in gsm.registeredAdapters():
if (len(reg.required) > 0 and
reg.required[-1] is not None and
reg.required[-1].isOrExtends(type)):

for required_iface in reg.required[:-1]:
if required_iface is None or iface.isOrExtends(required_iface):
yield reg


def mangleAbsoluteFilename(filename):
"""
Mangle an absolute filename when the file happens to be in a
Expand Down
2 changes: 1 addition & 1 deletion src/five/customerize/customerize.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ available to the customized local view. We create one of these views
... return 'baz'
>>> from Products.Five.browser.metaconfigure import makeClassForTemplate
>>> from Products.Five.security import getSecurityInfo, protectClass
>>> from Globals import InitializeClass
>>> from App.class_init import InitializeClass
>>> cdict = getSecurityInfo(TestView)
>>> cdict['__name__'] = 'simpleview.html'
>>> viewclass = makeClassForTemplate('testviewtemplate.pt', globals=globals(),
Expand Down

0 comments on commit d7b6de5

Please sign in to comment.