Re: [Zope] Python formatting question

2005-07-21 Thread Jonathan


- Original Message - 
From: [EMAIL PROTECTED]

To: zope@zope.org
Sent: Thursday, July 21, 2005 12:14 PM
Subject: [Zope] Python formatting question



In a Python script, how can I break up a SQL statement over more than
one line?  For example, to transform

#generate the sql statement
sql=DELETE FROM tblUsers WHERE user_name LIKE '%'

to:

#generate the sql statement
sql=DELETE FROM tblUsers
  WHERE user_name LIKE '%'

...does not work. Is there a way to break lines?


in python you can continue a logical line over several physical lines by 
placing a '\' character in the last position of the line you want continued.



jh 



___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Python formatting question

2005-07-21 Thread Andreas Jung



--On 21. Juli 2005 10:14:32 -0600 [EMAIL PROTECTED] wrote:


In a Python script, how can I break up a SQL statement over more than
one line?  For example, to transform

# generate the sql statement
sql=DELETE FROM tblUsers WHERE user_name LIKE '%'

to:

# generate the sql statement
sql=DELETE FROM tblUsers
   WHERE user_name LIKE '%'

...does not work. Is there a way to break lines?



Why don't you use ZSQL methods?

-aj


pgpxOlZurYg9l.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Python formatting question

2005-07-21 Thread J Cameron Cooper

[EMAIL PROTECTED] wrote:

In a Python script, how can I break up a SQL statement over more than 
one line?  For example, to transform


#generate the sql statement
sql=DELETE FROM tblUsers WHERE user_name LIKE '%'

to:

#generate the sql statement
sql=DELETE FROM tblUsersWHERE user_name LIKE '%'

...does not work. Is there a way to break lines?

Any example would be appreciated.



Python allows you to you triple-quotes to include line breaks in the
string::

 sql=DELETE FROM tblUsers
WHERE user_name LIKE '%'

Take a look at the python.org tutorial or diveintopython.org.

--jcc


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Python formatting question

2005-07-21 Thread hpinson
Perfect. Thanks for the great tips.  I had looked at the various 
tutorials, but had not made the connection with 

 Why don't you use Z SQL methods?
I do, but sometimes it is more convient to do SQL through python. I 
also find that ZSQL encourages SQL duplication, especially among 
multiple developers. With a python script, the SQL calls can be 
stored as a single central library

Thanks again!

Harlow Pinson
Indepth Learning
Email: [EMAIL PROTECTED] 
Web: http://www.indepthl.com
Voice: 505-994-2135
FAX: 208-475-7678

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Python formatting question

2005-07-21 Thread Andreas Jung



--On 21. Juli 2005 10:53:41 -0600 [EMAIL PROTECTED] wrote:




Why don't you use Z SQL methods?

I do, but sometimes it is more convient to do SQL through python. I
also find that ZSQL encourages SQL duplication, especially among
multiple developers. With a python script, the SQL calls can be
stored as a single central library



*shivering*

-aj

pgp30lHlGvC9m.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Python formatting question

2005-07-21 Thread Peter Bengtsson
 
  Why don't you use Z SQL methods?
  I do, but sometimes it is more convient to do SQL through python. I
  also find that ZSQL encourages SQL duplication, especially among
  multiple developers. With a python script, the SQL calls can be
  stored as a single central library
 
 
 *shivering*
 

I agree with Andreas. ZSQLs are a good thing. If you mix python code
and sql code you're likely to run into problems sooner or later.
Bare in mind that ZSQLs aren't just a method to store the sql
statement, they also have caching and other nifty functions such as
parameter handling.

Let me guess... you write your HTML in python code strings? :)


-- 
Peter Bengtsson, 
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )