[Zope3-checkins] CVS: Zope3/src/zope/app/browser/userpreferences -
__init__.py:1.1.2.1 configure.zcml:1.1.2.1
Jim Fulton
jim at zope.com
Tue Sep 2 18:40:37 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/userpreferences
In directory cvs.zope.org:/tmp/cvs-serv26498/src/zope/app/browser/userpreferences
Added Files:
Tag: user-preferences-branch
__init__.py configure.zcml
Log Message:
Checking in some work (on a branch) that Staphan and I did toward
implementing user preferences. More work is needed to finish this up.
Detailed log messages need to be provided in the merge.
=== Added File Zope3/src/zope/app/browser/userpreferences/__init__.py ===
##############################################################################
#
# Copyright (c) 2003 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.
#
##############################################################################
"""User preferences view
This is a weird view redirector. It pretends to be a view of a site, but
it actually delagates to a view of the authenticated user.
$Id: __init__.py,v 1.1.2.1 2003/09/02 21:40:36 jim Exp $
"""
from zope.publisher.browser import BrowserView
from zope.publisher.interfaces.browser import IBrowserPresentation
from zope.publisher.interfaces.browser import IBrowserPublisher
import zope.interface
from zope.app import zapi
class UserPreferencesPhony(BrowserView):
zope.interface.implements(IBrowserPublisher)
def browserDefault(self, request):
"""Return the request user and index.html
>>> from zope.publisher.browser import TestRequest
>>> request = TestRequest()
>>> request.setUser('bob')
>>> prefs = UserPreferencesPhony(None, request)
>>> prefs.browserDefault(request)
('bob', 'index.html')
"""
return request.user, 'index.html'
def publishTraverse(self, request, name):
"""Traverse to a name, but really just get a view on the user
>>> import zope.app.tests.placelesssetup
>>> from zope.publisher.browser import TestRequest
>>> from zope.publisher.interfaces.browser import IBrowserPublisher
>>> from zope.interface import Interface
>>> zope.app.tests.placelesssetup.setUp()
>>> class IPrincipal(Interface):
... pass
>>> class User:
... zope.interface.implements(IPrincipal)
>>> class V(BrowserView):
... pass
>>> zapi.getService(None, 'Views').provideView(
... IPrincipal, 'xxx', IBrowserPresentation, V)
>>> request = TestRequest()
>>> request.setUser(User())
>>> prefs = UserPreferencesPhony(None, request)
>>> v = prefs.publishTraverse(request, 'xxx')
>>> v.__class__ is V
1
>>> zope.app.tests.placelesssetup.tearDown()
"""
return zapi.getView(request.user, name, request)
=== Added File Zope3/src/zope/app/browser/userpreferences/configure.zcml ===
<zope:configure
xmlns:zope="http://namespaces.zope.org/zope"
xmlns="http://namespaces.zope.org/browser"
>
<view
for="zope.app.interfaces.services.service.ISite"
name="UserPrefernces"
class=".UserPreferencesPhony"
permission="zope.Public"
allowed_interface="zope.publisher.interfaces.browser.IBrowserPublisher"
/>
</zope:configure>
More information about the Zope3-Checkins
mailing list