Re: TAL and empty sql-list

"Jimmy small" <[email protected]>
Newsgroups gmane.comp.web.zope.database
Message-ID <[email protected]>
sorry for the double post --
A python script would be your best bet.  You would be able to use that
in other areas of your site in that case.

On 3/21/06, Charlie Clark <[email protected]> wrote:
>
> 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
> [email protected]
> http://mail.zope.org/mailman/listinfo/zope-db
>

_______________________________________________
Zope-DB mailing list
[email protected]
http://mail.zope.org/mailman/listinfo/zope-db
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.