TAL and empty sql-list

Jonas Nielsen <[email protected]>
Newsgroups gmane.comp.web.zope.database
Message-ID <[email protected]>
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]).

So what is a smart solution to this ? I've tried putting a repeat 
statement around this, and tried defining a variable called projectExist 
using len on the function. This however makes the page template very 
complex when calling another sql method such as:

<div 
tal:python:here.membersInSectionAndProject(section=sectionList[0].section, 
 
                                project=projectList[0].project)" />

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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.