[Zope-DB] sqlvar tag for text

Alex Cowan alex@funcom.com
Mon, 24 Feb 2003 22:50:49 +0100

The idea is cut to extra steps

if I'm passing a variable from a form almost directly into an SQL Method its
simpler to have a tag to handle it (rather than send it through extra python
scripts that aren't really needed). Maybe its only me that uses zope in this
way (don't you love flexibility!). For me this cuts and extra step before
putting it into the db.

So I get text in the database like:
"Text here

Text here"

and not:

"Text here Text here"


----- Original Message -----
From: "Charlie Clark" <charlie@begeistert.org>
To: <zope-db@zope.org>
Sent: Monday, February 24, 2003 10:12 PM
Subject: Re: [Zope-DB] sqlvar tag for text

> On 2003-02-24 at 21:48:10 [+0100], Alex Cowan wrote:
> > Ah alright, I'll explain a little ;)
> >
> > Its for when you want to enter text into a database but not as a string.
> > Normally you'd have a problem if there are any ' or ", so you need to
> > either have a small python script to parse the text before you put it
> > into the db or something else to do it.
> no problem with either """ this is "text" """ or """ this is 'text' """
> The ZopeDA does the quoting for you. This is apparently no so nice to
> implement and another reason for a general overhaul of the ZopeDAs but it
> works in userland.
> > PHP has addslashes, python doesn't seem to have anything (that I can
> > find) except using string.replace to do it, but its far easier to have a
> > dtml-tag to do it.
> Python doesn't have this because it doesn't need it! You can have raw
> strings if you want (quite nice for regular expressions).
> eat_this = r"\"
> print eat_this
> '\'
> Anybody got a link to the wonderful Dilbert comic about Python?
> <glowering_horribly>
> php is evil, very bad, nearly perl
> </glowering_horribly>
> and DTML should be getting less tags instead of more!!! Go ZPT,
> PythonScripts + ExternalMethods!!!
> > sqlvar only has string or int (basically), which is great for strings
> > converting the text to a string isn't always the best thing (since it
> > loses any formatting). So the tag does it without making it a string.
> It's gonna be a string in the database. It just needs quoting properly and
> then you don't have to worry.
> Charlie
> _______________________________________________
> Zope-DB mailing list
> Zope-DB@zope.org
> http://mail.zope.org/mailman/listinfo/zope-db