[Zope-CVS] CVS: Products/CookieCrumbler - CHANGES.txt:1.10 CookieCrumbler.py:1.18 version.txt:1.6 utils.py:NONE
Shane Hathaway
shane@zope.com
Wed, 18 Jun 2003 11:50:11 -0400
Update of /cvs-repository/Products/CookieCrumbler
In directory cvs.zope.org:/tmp/cvs-serv13933
Modified Files:
CHANGES.txt CookieCrumbler.py version.txt
Removed Files:
utils.py
Log Message:
CookieCrumblers are now folders that hold login forms.
This makes it easier to use CookieCrumblers in sites that disallow
anonymous access. You now only need to grant the "View" permission to
anonymous users in the context of the cookie crumbler.
=== Products/CookieCrumbler/CHANGES.txt 1.9 => 1.10 ===
--- Products/CookieCrumbler/CHANGES.txt:1.9 Mon Jun 16 14:15:28 2003
+++ Products/CookieCrumbler/CHANGES.txt Wed Jun 18 11:49:40 2003
@@ -1,4 +1,12 @@
+Next feature release
+
+- CookieCrumblers are now folders that hold login forms. This makes
+ it easier to use CookieCrumblers in sites that disallow anonymous
+ access. You now only need to grant the "View" permission to anonymous
+ users in the context of the cookie crumbler.
+
+
Version 1.0
- Added unit tests.
=== Products/CookieCrumbler/CookieCrumbler.py 1.17 => 1.18 ===
--- Products/CookieCrumbler/CookieCrumbler.py:1.17 Tue Jun 10 13:44:46 2003
+++ Products/CookieCrumbler/CookieCrumbler.py Wed Jun 18 11:49:40 2003
@@ -17,17 +17,17 @@
from base64 import encodestring, decodestring
from urllib import quote, unquote
+import sys
+
from Acquisition import aq_inner, aq_parent
from DateTime import DateTime
-from utils import SimpleItemWithProperties
-from AccessControl import ClassSecurityInfo, Permissions
+from AccessControl import getSecurityManager, ClassSecurityInfo, Permissions
from ZPublisher import BeforeTraverse
import Globals
from Globals import HTMLFile
from zLOG import LOG, ERROR
-import sys
-
from ZPublisher.HTTPRequest import HTTPRequest
+from OFS.Folder import Folder
# Constants.
@@ -43,7 +43,7 @@
"""Cookie crumbler should not be used for a certain request"""
-class CookieCrumbler (SimpleItemWithProperties):
+class CookieCrumbler (Folder):
'''
Reads cookies during traversal and simulates the HTTP
authentication headers.
@@ -55,6 +55,9 @@
security.declareProtected(ModifyCookieCrumblers, 'manage_changeProperties')
security.declareProtected(ViewManagementScreens, 'manage_propertiesForm')
+ # By default, anonymous users can view login/logout pages.
+ _View_Permission = ('Anonymous',)
+
_properties = ({'id':'auth_cookie', 'type': 'string', 'mode':'w',
'label':'Authentication cookie name'},
@@ -286,8 +289,7 @@
page_id = self.unauth_page
retry = ''
if page_id:
- parent = aq_parent(aq_inner(self))
- page = getattr(parent, page_id, None)
+ page = self.restrictedTraverse(page_id, None)
if page is not None:
came_from = req.get('came_from', None)
if came_from is None:
@@ -317,8 +319,7 @@
, self.defaultExpireAuthCookie )
method( resp, cookie_name=self.auth_cookie )
if self.logout_page:
- parent = aq_parent(aq_inner(self))
- page = getattr(parent, self.logout_page, None)
+ page = self.restrictedTraverse(self.logout_page, None)
if page is not None:
resp.redirect('%s?disable_cookie_login__=1'
% page.absolute_url())
@@ -340,6 +341,15 @@
nc = BeforeTraverse.NameCaller(self.getId())
BeforeTraverse.registerBeforeTraverse(container, nc, handle)
+ security.declarePublic('propertyLabel')
+ def propertyLabel(self, id):
+ """Return a label for the given property id
+ """
+ for p in self._properties:
+ if p['id'] == id:
+ return p.get('label', id)
+ return id
+
Globals.InitializeClass(CookieCrumbler)
@@ -363,21 +373,23 @@
manage_addCCForm = HTMLFile('dtml/addCC', globals())
manage_addCCForm.__name__ = 'addCC'
-def manage_addCC(self, id, create_forms=0, REQUEST=None):
+def manage_addCC(dispatcher, id, create_forms=0, REQUEST=None):
' '
ob = CookieCrumbler()
ob.id = id
- self._setObject(id, ob)
+ dispatcher._setObject(ob.getId(), ob)
+ ob = getattr(dispatcher.this(), ob.getId())
if create_forms:
import os
from OFS.DTMLMethod import addDTMLMethod
dtmldir = os.path.join(os.path.dirname(__file__), 'dtml')
- for fn in ('login_form', 'logged_in', 'logged_out'):
+ for fn in ('index_html', 'logged_in', 'logged_out', 'login_form',
+ 'standard_login_footer', 'standard_login_header'):
filename = os.path.join(dtmldir, fn + '.dtml')
f = open(filename, 'rt')
try: data = f.read()
finally: f.close()
- addDTMLMethod(self, fn, file=data)
+ addDTMLMethod(ob, fn, file=data)
if REQUEST is not None:
- return self.manage_main(self, REQUEST)
+ return dispatcher.manage_main(dispatcher, REQUEST)
=== Products/CookieCrumbler/version.txt 1.5 => 1.6 ===
--- Products/CookieCrumbler/version.txt:1.5 Mon Jun 16 14:15:28 2003
+++ Products/CookieCrumbler/version.txt Wed Jun 18 11:49:40 2003
@@ -1 +1 @@
-CookieCrumbler-1.0
+CookieCrumbler-1.0+
=== Removed File Products/CookieCrumbler/utils.py ===