On 2006-03-20 at 12:01:55 [+0100], Jonas Nielsen <[EMAIL PROTECTED]> 
wrote:
> I have an sql statement that given a username it returns a project.
> 
> So my first question is: Is it possible to let the statement return a
> string instead of a list. i.e. 'project' instead of ['project'] ?
> 
> So, if call it from a page template, I can use
> 
> <div tal:content="python:here.project(uname=username)[0].project" />
> 
> But if the project method returns an empty list, this statement will
> fail (because of [0]).
 
> if I'm using, say, the Python Database API I would just call fetchone()
> on the cursor object. It is that functionality I am looking for.

Yes, it's very frustrating.

You've got two choices: either use a tal:repeat around your content which 
is not only more code but as you point out not always helpful. You can also 
use a Python statement or PythonScript to help you out:

<block tal:define="result python:here.project(uname=username)[0].project or 
''"></block>

Charlie
_______________________________________________
Zope-DB mailing list
Zope-DB@zope.org
http://mail.zope.org/mailman/listinfo/zope-db

Reply via email to