[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL - AbsoluteURL.py:1.1.2.1 __init__.py:1.1.2.1 config.zcml:1.1.2.1
Jim Fulton
jim@zope.com
Tue, 9 Apr 2002 12:00:22 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL
In directory cvs.zope.org:/tmp/cvs-serv2326/lib/python/Zope/App/ZopePublication/AbsoluteURL
Added Files:
Tag: Zope-3x-branch
AbsoluteURL.py __init__.py config.zcml
Log Message:
added AbsoluteURL view
=== Added File Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/AbsoluteURL.py ===
##############################################################################
#
# 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.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
#
##############################################################################
"""
Revision information:
$Id: AbsoluteURL.py,v 1.1.2.1 2002/04/09 16:00:20 jim Exp $
"""
from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
from Zope.ContextWrapper import getinnercontext, getdict
from Zope.ComponentArchitecture import getRequestView
class AbsoluteURL:
__implements__ = IBrowserPublisher
def __init__(self, context):
self.__context = context
def setViewRequest(self, request):
self.__request = request
def __str__(self):
context = self.__context
dict = getdict(context)
name = dict and dict.get('name') or None
container = getinnercontext(context)
if name is None or container is None:
import pdb; pdb.set_trace()
raise TypeError, 'Not enough context information to get a URL'
return "%s/%s" % (getRequestView(container, 'url', self.__request),
name)
__call__ = __str__
class SiteAbsoluteURL:
__implements__ = IBrowserPublisher
def __init__(self, context):
self.__context = context
def setViewRequest(self, request):
self.__request = request
def __str__(self):
return self.__request.getApplicationURL()
__call__ = __str__
=== Added File Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/__init__.py ===
=== Added File Zope3/lib/python/Zope/App/ZopePublication/AbsoluteURL/config.zcml ===
<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
xmlns:security='http://namespaces.zope.org/security'
xmlns:browser='http://namespaces.zope.org/browser'
>
<security:protectClass
name='.AbsoluteURL.'
permission_id='Zope.Public'
/>
<browser:view
name="url"
factory=".AbsoluteURL."
/>
<security:protectClass
name='.AbsoluteURL.SiteAbsoluteURL'
permission_id='Zope.Public'
/>
<browser:view
for="Zope.App.OFS.Folder.RootFolder.IRootFolder"
name="url"
factory=".AbsoluteURL.SiteAbsoluteURL"
/>
</zopeConfigure>