[Zope-CMF] Localizer in CMF/Plone problem

Greg Ward gward@python.net
Mon, 17 Feb 2003 10:08:29 -0500

On 16 February 2003, Roger Oberholtzer said:
> However, I cannot access it. Zope complains:
> 2003-02-16T22:51:15 ERROR(200) BeforeTraverse Error while invoking hook:
> "portal_localizer" Traceback (innermost last):  
> File /home/httpd/Zope/lib/python/ZPublisher/BeforeTraverse.py,
> line 134, in __call__  File
> /home/httpd/Zope/lib/python/Products/CMFLocalizer/LocalizerTool.py,
> line 227, in __call__    (Object: portal_localizer)  File
> /home/httpd/Zope/lib/python/Products/CMFLocalizer/LocalizerTool.py,
> line 85, in _get_first_lang    (Object: portal_localizer)  File
> /home/httpd/Zope/lib/python/Products/Localizer/Accept.py,
> line 184, in __getitem
> __
> AttributeError: 'int' object has no attribute 'split'

I don't know much about Zope or CMF or Localizer (although I am
learning), but I know a Python exception when I see one.  That error
happens when the programmer thought he was doing this:

  x = "hello there"
  chunks = x.split(" ")

but accidentally did this:

  x = 37
  chunks = x.split(" ")   # exception raised here -- 37 has no 'split' attr

(Usually the assignment and error are separated by a function call: that
is, some bit of code is passing an int where it's supposed to pass a

IOW, it's entirely likely that this is a bug in one of the bits of
Python code you're dealing with.  In particular, the exact function
where the exception is being raised is probably not the problem, more
likely, the code that's *calling* that function is the problem.

> I thought I was making great progress. But this I do not understand. I see
> this in Zope's log all through the time I am making the item. There is no
> complaint to the Zope interface. 

That's weird.  I also see occasional exceptions in the log that do *not*
cause 5xx errors to the web client, which is really disturbing.

> I see in Accept.py, on line 184, the split call is called with two
> arguments, and everywhere else in the file it has 1. Is this the problem?

No.  The string 'split()' method can be called with zero, one, or two
arguments.  See the Python docs for details.

Greg Ward <gward@python.net>                         http://www.gerg.ca/
Ban the bomb -- save the world for conventional warfare.