[Zope] queries and tiny tables and python methods... oh my!

Timothy Wilson wilson@visi.com
Fri, 30 Jun 2000 09:08:58 -0500 (CDT)


On Fri, 30 Jun 2000, Rik Hoekstra wrote:

> > The problem is hooking them all together. Passing the query to a
> > PythonMethod is throwing up the following error:
> > 
> > Error Type: TypeError
> > Error Value: argument l: expected read-only character buffer, instance found
> 
> The error means you're trying to split up a string, but the argument is
> no string, but an instance (a Python Object). In many cases this is
> caused by an omission of parenthesis, like so 
> 
> called_object instead of called_object()

OK, that makes sense.

> in which case the object is referenced instead of called and nothing is
> returned (of course). I did not find the culprit in your description,
> though. 

> I do not quite get what part you want to parse. Is it 'SB_B208'?
> accessing this in python is a bit strange due to the returned value. You
> get to the 'SB_B208'part in the following way:
> 
> whateverreturnstheresult(<someargument>)[0][0][0], meaning (in this
> case):

I was trying to walk the fine line between providing too much detail and not
enough. Briefly, 'SB_B208' is an example of the type of string I'm trying to
parse. I do a string.split('l', '_') (where 'l' is the argument to the
string-splitting Python method) and get ['SB', 'B208']. 'SB' is one of the
two-letter codes that gets lookup up in the Tiny Table and 'B208' is an
office number. Together, these two strings represent a person's location in
our LDAP directory.

I don't understand where the weird tuple in the traceback is coming from.

> > Here's the code for parseLocation ('l' is the argument):
> > 
> > x = string.split(l, '_')
> > return x[0]
> 
> I may be reading badly, but can you explain what the l is (or is
> supposed to be)? Is it the tuple in the traceback?

'l' is passed to the Pyton Method. Examples would be: FH_123, SB_A231,
DO_111, etc.

> > (BTW, changing it to x = string.split(`l`, '_') eliminates the error, but
> > nothing is rendered.
> > 
> > qry_person is an ZLDAP filter method that takes one argument (uid). The
> > original dtml to display this mess looks like:
> > 
> > <dtml-call "REQUEST.set('user_id', user_id)">
> > <dtml-in "qry_person(uid = user_id)"><br>
> >   <dtml-in "buildingCodes(parseLocation(l))">
> >     <dtml-var building><br>  # 'building' comes from the Tiny Table
> >   </dtml-in>
> > </dtml-in>

Anyone see where the problem lies?

-Tim

--
Tim Wilson      | Visit Sibley online:         | Check out:
Henry Sibley HS | http://www.isd197.k12.mn.us/ | http://www.zope.org/
W. St. Paul, MN |                              | http://slashdot.org/
wilson@visi.com |   <dtml-var pithy_quote>     | http://linux.com/