NameError (global name 'namespace' is not defined)
This may be a version problem, or it may not. I wrote a fairly straightforward Zope application in Zope 2-3-1 on Linux. (That instance of Zope has been working just fine for months and hey, it wasn't broke so I didn't fix it. The Linux box has been up for 132 days and I like the fact that I only have to fuss with Zope, if anything at all.) I created a simple product and associated folder (with a slew of Folders, DTML Documents, python scripts, and DTML Methods. Then I exported them and shipped both the product and the site off to a client who had downloaded and installed Zope 2-3-4 for Windows. The client got into the Zope management screen (after a little hand-holding, but he didn't read any documentation, so I can't complain). I talked him through the processes of unzip/untar the product, and loading the particular site. Now the client can pull up a browser and accurately read index_html of the main folder. However, when he tries to read any of the DTML Documents, Folders, etc. he gets: Zope Error Error Type: NameError Error Value: global name 'namespace' is not defined Is this problem between different versions of Zope? namespace is pretty fundamental. I don't see how it could have worked fine under 2-3-1 and not under 2-4-3. Thanks in advance for any help. Ron
Okay, here is a little more diagnostic information. The 'namespace' that Zope is complaining about is in the following code: found = 0 # flag to indicate that the object was/wasn't found... contents = [] # the return list... # Run through the objects in the current (context) folder to see if there is a match (with given_title)... for obj in context.objectValues('Image'): if found == 0: if given_title == obj.title: url = obj.absolute_url title = obj.title contents.append(namespace(url=url, title=title)[0]) found = 1 # Set flag on success... # If you can't find it in the context, then check the container... for obj in container.objectValues('Image'): if found == 0: if given_title == obj.title: url = obj.absolute_url title = obj.title contents.append(namespace(url=url, title=title)[0]) found = 1 # Set flag on success... # Return indicative values if the desired object was not found... if found == 0: contents.append(namespace(url='', title='')[0]) vars = namespace(contents=contents) return vars ------------- As I said before, the above code works just fine in Zope 2-3-1. However, it fails (gets the NameError) in both versions 2-4-2 and 2-4-3. Is this because Zope went to python 2.x instead of 1.5? Do I have to rewrite my code? Do I have to tell my client to get 2-3-1? Any hints would be greatly appreciated. Thanks, Ron complaw@hal-pc.org wrote:
This may be a version problem, or it may not.
I wrote a fairly straightforward Zope application in Zope 2-3-1 on Linux. (That instance of Zope has been working just fine for months and hey, it wasn't broke so I didn't fix it. The Linux box has been up for 132 days and I like the fact that I only have to fuss with Zope, if anything at all.)
I created a simple product and associated folder (with a slew of Folders, DTML Documents, python scripts, and DTML Methods. Then I exported them and shipped both the product and the site off to a client who had downloaded and installed Zope 2-3-4 for Windows.
The client got into the Zope management screen (after a little hand-holding, but he didn't read any documentation, so I can't complain). I talked him through the processes of unzip/untar the product, and loading the particular site.
Now the client can pull up a browser and accurately read index_html of the main folder. However, when he tries to read any of the DTML Documents, Folders, etc. he gets:
Zope Error
Error Type: NameError Error Value: global name 'namespace' is not defined
Is this problem between different versions of Zope? namespace is pretty fundamental. I don't see how it could have worked fine under 2-3-1 and not under 2-4-3.
Thanks in advance for any help.
Ron
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Ronald L. Chichester writes:
Okay, here is a little more diagnostic information. The 'namespace' that Zope is complaining about is in the following code: ... vars = namespace(contents=contents)
-------------
As I said before, the above code works just fine in Zope 2-3-1. However, it fails (gets the NameError) in both versions 2-4-2 and 2-4-3. Is this because Zope went to python 2.x instead of 1.5? No and yes.
Python 2.1 made it possible to rewrite Zope's security subsystem to get it much clearer and more efficient. "namespace" is a "TemplateDict" method ("TemplateDict" is the class name for Zope's DTML namespace). It is valid only with a namespace object. As in a Python Script, there is no such natural object, the "namespace" (and other true namespace methods, such as e.g. "render") have probably been removed... Dieter
participants (3)
-
complaw@hal-pc.org -
Dieter Maurer -
Ronald L. Chichester