[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL - AbsoluteURL.py:1.1.2.5 config.zcml:1.1.2.5
Jim Fulton
jim@zope.com
Fri, 7 Jun 2002 10:41:51 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL
In directory cvs.zope.org:/tmp/cvs-serv12187/lib/python/Zope/App/ZopePublication/AbsoluteURL
Modified Files:
Tag: Zope-3x-branch
AbsoluteURL.py config.zcml
Log Message:
Merging in Zope3InWonderland-branch, which implemented the following
proposals (see
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/OldProposals):
- RenameAllowToRequire
- GroupClassRelatedDirectivesInClassDirective
- ViewInterfaceAndSimplification
- ConsistentUseOfSpacesAsDelimitersInZCMLAttributes
- TwoArgumentViewConstructors
- ImplementsInZCML
- SimpleViewCreationInZCML
- RemoveGetView
- ReplaceProtectWithAllow
- ViewMethodsAsViews
- MergeProtectionAndComponentDefinitions
There were also various security fixes resulting of better integration
of security with components.
=== Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/AbsoluteURL.py 1.1.2.4 => 1.1.2.5 ===
$Id$
"""
-from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
+from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.Proxy.ContextWrapper import getWrapperContainer, getWrapperData
-from Zope.ComponentArchitecture import getRequestView
+from Zope.ComponentArchitecture import getView
-class AbsoluteURL:
+from Interface import Interface
- __implements__ = IBrowserPublisher
+class IAbsoluteURL(Interface):
- def __init__(self, context):
- self.__context = context
+ def __str__():
+ """Get a human-readable string representation
+ """
- def setViewRequest(self, request):
- self.__request = request
+ def __repr__():
+ """Get a string representation
+ """
+
+
+class AbsoluteURL(BrowserView):
def __str__(self):
- context = self.__context
+ context = self.context
dict = getWrapperData(context)
name = dict and dict.get('name') or None
container = getWrapperContainer(context)
if name is None or container is None:
raise TypeError, 'Not enough context information to get a URL'
- return "%s/%s" % (getRequestView(container, 'absolute_url', self.__request),
+ return "%s/%s" % (getView(container, 'absolute_url', self.request),
name)
__call__ = __str__
-class SiteAbsoluteURL:
-
- __implements__ = IBrowserPublisher
-
- def __init__(self, context):
- self.__context = context
-
- def setViewRequest(self, request):
- self.__request = request
+class SiteAbsoluteURL(BrowserView):
def __str__(self):
- return self.__request.getApplicationURL()
+ return self.request.getApplicationURL()
__call__ = __str__
=== Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/config.zcml 1.1.2.4 => 1.1.2.5 ===
>
-<security:protectClass
- class='.AbsoluteURL.'
- permission_id='Zope.Public'
-/>
-
-<browser:view
- name="absolute_url"
- factory=".AbsoluteURL."
-/>
-
-<security:protectClass
- class='.AbsoluteURL.SiteAbsoluteURL'
- permission_id='Zope.Public'
-/>
-
-<browser:view
- for="Zope.App.OFS.Content.Folder.RootFolder.IRootFolder"
- name="absolute_url"
- factory=".AbsoluteURL.SiteAbsoluteURL"
-/>
+ <browser:view
+ name="absolute_url"
+ factory=".AbsoluteURL."
+ permission='Zope.Public'
+ allowed_interface=".AbsoluteURL.IAbsoluteURL"
+ />
+
+ <browser:view
+ for="Zope.App.OFS.Content.Folder.RootFolder.IRootFolder"
+ name="absolute_url"
+ factory=".AbsoluteURL.SiteAbsoluteURL"
+ permission='Zope.Public'
+ allowed_interface=".AbsoluteURL.IAbsoluteURL"
+ />
</zopeConfigure>