[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/ Move
applySkin from zope.app.publisher.browser to zope.publisher.browser.
Philipp von Weitershausen
philikon at philikon.de
Tue Apr 4 13:26:11 EDT 2006
Log message for revision 66417:
Move applySkin from zope.app.publisher.browser to zope.publisher.browser.
Changed:
U Zope3/branches/jim-adapter/src/zope/app/apidoc/apidoc.py
U Zope3/branches/jim-adapter/src/zope/app/apidoc/browser/preference.py
U Zope3/branches/jim-adapter/src/zope/app/demo/skinpref/skin.py
U Zope3/branches/jim-adapter/src/zope/app/publisher/browser/__init__.py
U Zope3/branches/jim-adapter/src/zope/app/traversing/namespace.py
U Zope3/branches/jim-adapter/src/zope/publisher/browser.py
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/apidoc.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/apidoc.py 2006-04-04 17:19:50 UTC (rev 66416)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/apidoc.py 2006-04-04 17:26:10 UTC (rev 66417)
@@ -18,14 +18,14 @@
__docformat__ = 'restructuredtext'
from zope.interface import implements
+from zope.publisher.browser import applySkin
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 interfaces import IDocumentationModule
-from utilities import ReadContainerBase
+from zope.app.apidoc.interfaces import IDocumentationModule
+from zope.app.apidoc.utilities import ReadContainerBase
class APIDocumentation(ReadContainerBase):
"""Represent the complete API Documentation.
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/browser/preference.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/browser/preference.py 2006-04-04 17:19:50 UTC (rev 66416)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/browser/preference.py 2006-04-04 17:26:10 UTC (rev 66417)
@@ -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/branches/jim-adapter/src/zope/app/demo/skinpref/skin.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/demo/skinpref/skin.py 2006-04-04 17:19:50 UTC (rev 66416)
+++ Zope3/branches/jim-adapter/src/zope/app/demo/skinpref/skin.py 2006-04-04 17:26:10 UTC (rev 66417)
@@ -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/branches/jim-adapter/src/zope/app/publisher/browser/__init__.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/publisher/browser/__init__.py 2006-04-04 17:19:50 UTC (rev 66416)
+++ Zope3/branches/jim-adapter/src/zope/app/publisher/browser/__init__.py 2006-04-04 17:26:10 UTC (rev 66417)
@@ -19,16 +19,14 @@
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
-
key = "zope.app.publisher.browser.IUserPreferredLanguages"
class BrowserView(Location):
@@ -101,40 +99,6 @@
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.
Modified: Zope3/branches/jim-adapter/src/zope/app/traversing/namespace.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/traversing/namespace.py 2006-04-04 17:19:50 UTC (rev 66416)
+++ Zope3/branches/jim-adapter/src/zope/app/traversing/namespace.py 2006-04-04 17:26:10 UTC (rev 66417)
@@ -23,9 +23,9 @@
from zope.component.interfaces import ComponentLookupError
from zope.interface import providedBy, directlyProvides, directlyProvidedBy
from zope.publisher.interfaces.browser import IBrowserSkinType
+from zope.publisher.browser import applySkin
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
Modified: Zope3/branches/jim-adapter/src/zope/publisher/browser.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/publisher/browser.py 2006-04-04 17:19:50 UTC (rev 66416)
+++ Zope3/branches/jim-adapter/src/zope/publisher/browser.py 2006-04-04 17:26:10 UTC (rev 66417)
@@ -25,17 +25,17 @@
from cgi import FieldStorage
import zope.component
-from zope.interface import implements, directlyProvides, providedBy
+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.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 IBrowserSkinType
from zope.publisher.http import HTTPRequest, HTTPResponse
-
__ArrayTypes = (ListType, TupleType)
start_of_header_search=re.compile('(<head[^>]*>)', re.I).search
@@ -890,3 +890,36 @@
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)
More information about the Zope3-Checkins
mailing list