[Zope-dev] Login Manager/Latest Zope -possible bug

Luca Mearelli luca@lineanet.net
Mon, 23 Oct 2000 16:38:53 +0200


This is a multi-part message in MIME format.
--------------0EE9B87296E8A1E8974158FF
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello,

I had a strange problem when trying out LoginManager v0.8.8b1 with the latest cvs Checkout (as of Oct.23),
 here is the traceback trying to add a LoginManager (The form didn't show up):

Error Type: NameError
Error Value: path
...
Traceback (innermost last):
  File /usr/local/tmp/Zope2/lib/python/ZPublisher/Publish.py, line 222, in publish_module
  File /usr/local/tmp/Zope2/lib/python/ZPublisher/Publish.py, line 187, in publish
  File /usr/local/tmp/Zope2/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook
  File /usr/local/tmp/Zope2/lib/python/ZPublisher/Publish.py, line 171, in publish
  File /usr/local/tmp/Zope2/lib/python/ZPublisher/mapply.py, line 160, in mapply
    (Object: addLoginManager)
  File /usr/local/tmp/Zope2/lib/python/ZPublisher/Publish.py, line 112, in call_object
    (Object: addLoginManager)
  File /usr/local/tmp/Zope2/lib/python/App/special_dtml.py, line 120, in __call__
    (Object: addLoginManager)
    (Info: /usr/local/tmp/Zope2/lib/python/Products/LoginManager/addLoginManager.dtml)
  File /usr/local/tmp/Zope2/lib/python/DocumentTemplate/DT_String.py, line 528, in __call__
    (Object: addLoginManager)
  File /usr/local/tmp/Zope2/lib/python/DocumentTemplate/DT_In.py, line 633, in renderwob
    (Object: UserSourcesMetaTypes(this()))
  File /usr/local/tmp/Zope2/lib/python/DocumentTemplate/DT_Util.py, line 331, in eval
    (Object: UserSourcesMetaTypes(this()))
    (Info: UserSourcesMetaTypes)
  File /usr/local/tmp/Zope2/lib/python/ZPublisher/HTTPRequest.py, line 772, in __getitem__
NameError: (see above)

after looking at the LM code I found that the manage_addLoginManagerForm is defined 
in LoginManager.py:
...
manage_addLoginManagerForm = HTMLFile('addLoginManager', globals(),
    UserSourcesMetaTypes = PlugInFinder(LoginManager.UserSourcesGroup),
    LoginMethodsMetaTypes = PlugInFinder(LoginManager.LoginMethodsGroup))
...


At first I thought it could have been a LM problem, removing UserSourcesMetaTypes(this()) let
the form appear, but when I focused on the UserSourcesMetaTypes work, and how the user sources
PlugIns get installed I found nothing (It was actually my first test with LM & ZPatterns), moreover
there was no mention of such problems by anyone else on the Mailing Lists.

Then I tried to it on a Zope 2.2.0 (released) and it worked fine adding the LM.
So it should have been something with my Zope CVS checkout, when looked at the HTTPRequest.py
file at the line shown in the Traceback, i found a possible error with "__getitem__"
When it tries to return the value of UserSourcesMetaTypes, it enters the "if key[:1]=='U':" at line 760
since UserSourcesMetaTypes starts with 'U', but match is empty, therefore path is not initialized
and at the line 772 we have the NameError.
Putting the lines 772-774 inside the "if match is not None:" fixed the problem (I included a diff for this),
is it the right way to go, is it enough? I think so but I have a small knowledge of Zope internals so 
I'm not completely sure i.e. if we want to match only the env.variables starting with "URL" why not even change
the  "if key[:1]=='U':" into "if key[:3]=='URL':"?

Thanks
   Luca Mearelli
--------------0EE9B87296E8A1E8974158FF
Content-Type: text/plain; charset=us-ascii;
 name="HTTPRequest.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="HTTPRequest.patch"

*** HTTPRequest.py	Mon Oct 23 15:32:09 2000
--- HTTPRequest.py.OLD	Mon Oct 23 14:55:51 2000
***************
*** 769,777 ****
                      path = [''] + path[:n]
                  else:
                      path = [other['SERVER_URL']] + path[:n]
!         	other[key] = URL = join(path, '/')
!         	self._urls = self._urls + (key,)
!         	return URL
  
          if isCGI_NAME(key) or key[:5] == 'HTTP_':
              environ=self.environ
--- 769,777 ----
                      path = [''] + path[:n]
                  else:
                      path = [other['SERVER_URL']] + path[:n]
!             other[key] = URL = join(path, '/')
!             self._urls = self._urls + (key,)
!             return URL
  
          if isCGI_NAME(key) or key[:5] == 'HTTP_':
              environ=self.environ

--------------0EE9B87296E8A1E8974158FF--