Re: [Zope] SQL delimiter?

2001-01-18 Thread Jose Soares

You need to insert the following line between two SQL statements.
dtml-var sql_delimiter
Remember you can't use it with more than one SELECT.
sql_delimiter is usefull only to separate more than one
INSERT, UPDATE, DELETE.

Jos


Andy McKay wrote:

 Ive looked through the docs and Im sure I saw once (but cant see it now),
 some sort of delimiter between SQL statements allowing me to put multiple
 SQL statements in one SQLMethod. Was I imagining that?
 --
   Andy McKay.

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


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




[Zope] Error, Exceptions.SystemError: unknown opcode

2000-12-27 Thread Jose Soares

Hi all,

I'm trying to insert data into a MySQL table using a SQL Method
without success.
Zope return me the following message:
"Error, Exceptions.SystemError: unknown opcode"

Any ideas?


Thanks
José





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




Re: [Zope] multiple selects are not allowed

2000-12-13 Thread Jose Soares

from ZSQL Methods User's Guide, last row on pag. 22:

"Note that no more than one SQL select statement may be used in a single SQL
Database Method."



Diny van Gool wrote:

 Hi,

 I want to execute multiple SQL statements in one SQL-Method. In the
 mailinglist archives i found the answer but when i try it i get an error:

 Error, exceptions.ValueError: multiple selects are not allowed

 I used a simple Z SQL Method query (Zope 2.2.2) just to try:

 select *
 from GENEESM_DIER

 dtml-var sql_delimiter

 select *
 from TOED_WIJZE

 What am i doing wrong?

 Diny

 DIVA, Faculty of Veterinary Medicine
 Utrecht University,  The Netherlands
 http://www.vet.uu.nl

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


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




Re: [Zope] Last day of Month

2000-12-13 Thread Jose Soares

Use an External Method like this one.

# Perché non usare un metodo esterno?
from DateTime import Date
def lastDay(year,month):
try:
last = Date(year,month+1,1)-1
return last.day
except:
return 31


José

Eric Walstad wrote:

 Hi Paolo,
 I have a Python Metho... er  Python Script that I use that tells me the days
 in each month.  You pass in a Zope DateTime object as a parameter and it
 returns the days in that month:

 Parameters: ZopeDateTime
 Code:
 -8-- Start Snip --8-
 if ZopeDateTime.isLeapYear():
 intDaysInFebruary = 29
 else:
 intDaysInFebruary = 28

 strMonthName=ZopeDateTime.Month()

 dicDaysPerMonth =
 {'January':31,'February':intDaysInFebruary,'March':31,'April':30,'May':31,'J
 une':30,'July':31,'August':31,'September':30,'October':31,'November':30,'Dec
 ember':31}

 return dicDaysPerMonth.get(strMonthName, 0)
 -8-- End Snip --8-

 Hope that helps.

 Eric.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Paolo
 Quaglia
 Sent: Tuesday, December 12, 2000 4:05 AM
 To: [EMAIL PROTECTED]
 Subject: [Zope] Last day of Month

 Hi everibody
 Is there some tricky way to know the last day of the month of a DateTime
 object?
 for ex: if my DateTime object is 12/12/2000  is there a method or a
 function that return the last day of the month? (in this example 31)

 Thanks a lot
 Paolo Quaglia
 Information Technology Coordinator
 Sitek S.p.A.
 [EMAIL PROTECTED]

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


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




Re: [Zope] Patch to avoid hypenation variables and more

2000-12-11 Thread Jose Soares



Tino Wildenhain wrote:

 Hi,

 anybody had time for testing? May be we could have it in the next
 zope release. Any comments, remarks? How about an alternatively or
 extra "name"-attribute wich defaults to "sequence" ?

 Another issue: what about an alias for dtml-var called something
 like: dtml-print dtml-output or dtml-out ? Just for the
 ones that lern zope. Since I often see the missunderstood meaning
 of dtml-var in such constructs like: dtml-var "somelist[dtml-var
 indexvar]"
 you know what I mean? I think it would be more obvious, if the
 tag would usually be called dtml-out or something.


Yes. I vote for dtml-print  some_var



 Regards
 Tino

 Tino Wildenhain schrieb:
 
  Michel Pelletier schrieb:
  
 
The second problem is if you put one in-tag into another.
You have to use dtml-let oder REQUEST.set() with variables
of the outher in-tag to be able to reference them in the inner
loop. The code becomes very ugly this way. So my idea was to
give the in-tag an optional argument, called "prefix" to
prefix all the sequence-variables with a custom identifier.
So you can write:
   
dtml-in some_sequence prefix="outer_"
   dtml-in some_other_sequence
 dtml-var outer_sequence_item:dtml-var sequence_item
   /dtml-in the inner sequence
/dtml-in the outer sequence
   
What do you think about this?
  
   It's cool.  Your patches are big and therefore, naturally, are a bit
   worrisome to us in terms of checking them into the core.  Do you have a
   set of test DTML scripts that verify your patch?  Say, a set of scripts
   that verifies backwards compatibity, and a set of scripts that verifies
   the new functionality?  I would suggest even investigating "ZUnit" and
   creating DTML unit tests.  Then we would *really* love you.  ;)
  
  Have to find this ZUnit... ;)
  Ok, I made some further tests and improvements. There was a mistake
  (ok, it comes from variables spilled randomly over DT_In.py and
  DT_InSV.py ;)
  with the prefix. In some cases it wasnt there as supposed.
 
  Now all the prefix-handling should be ok. I've made an yet simple
  test-suite, all available thru
  http://www.zope.org/Members/tino/
  (See "Patch for dtml-in" there)
 
  Note: the prefix prepends only the in-tags own variables. Any attribute
  coming from the sequence is untouched. This is also true for statistic
  variables and the magic "mapping" symbol.
 
  While it could easy be implemented, I think prefixing all attributes is
  not such a good idea. If you are ilterating over database queries you
  can rename the attributes there.
 

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


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




Re: [Zope] New user - couple of questions

2000-12-06 Thread Jose Soares



Paolo Quaglia wrote:
Hi
to all,I'm
a new Zope user/developer ... Zope has impressed me very much!Ihave
a couple of questions.I
want to build a new intranet site for my company using Zope, but:1.
How can I import and use Python modulesFor
example I want to use the function sleep(secs) that resides in the
time module.I
wrote this code:import
timedef hello(self):
sleep(10)
return "I'm Back!!"



Better if you write this function like
this:
import time
def hello(self):
 time.sleep(10)
 return
"I'm Back!!"
1. give it a name, say pippo.py
2. then go back to your zope and add
an External Method
3. put id=pluto
4. function name=hello
5. python module=pippo
6. save it
If you want to try it create a DTML
Document for example and put in it the the following command:
dtml-var pluto>
and then view the DTML Document,
after a while i.e. 10 secs you will
see the message: I'm Back!!

but
when I call the external method bounded with the hello function an error
occours!!1st.
Have I to install the time module?
- if yes where can I found it and where can I install it?2nd.
How do I have to call the sleep function?2.
I want to build an application that use the database transection to update
rows.I
use SQL server that support DB transactions.where
can I build SQL transactions with Zope?do
I have to build a ZSQL method with multiple SQL calls? .. for example:...
If I am not mistaken,
zope works all the time in transaction mode, then you don't need to
expecify
transactions at all.

begin
transactiondtml-var
sql_delimiter>update
t_cliente set primaetichinterna = 'mia'dtml-var
sql_delimiter>commitAm
I sure that the transaction will work (if another user use the same method
at the same time)?How
can I test if a transaction has been committed or aborted?Thanks
VERY MUCH in advancePaolo
QuagliaSitek Spa
ItalyPaolo
Quaglia
Information Technology Coordinator
Sitek S.p.A.
[EMAIL PROTECTED]
Ciao
Jos Soares - Italy



Re: [Zope] how to get the created table names

2000-11-24 Thread Jose Soares

There isn't a SQL standard command to show the tables in the database.
Thus evry database has a different command to do such job.
For example:

DBMaker:
  to show TABLES:  select  *  from SYSTABLE
  to show COLUMNS: SELECT  COLUMN_NAME,TYPE_NAME,PRECISION  FROM
SYSCOLUMN  WHERE  TABLE_NAME='table_name'
MySQL:
  to show TABLES:  SHOW TABLES
  to show COLUMNS: DESC table_name
PostreSQL:
  to show TABLES:  select tablename from pg_tables where tablename not
like 'pg_%'
  to show COLUMNS: SELECT a.attname, t.typname, CASE WHEN a.attlen  0
THEN attlen ELSE a.atttypmod END as length FROM pg_class c, pg_attribute
a, pg_type t WHERE c.relname = 'table_name' AND a.attnum  0 AND
a.attrelid = c.oid AND a.atttypid = t.oid


I wrote a couple of ZSQL Methods to emulate a generic ISQL
to query a database using the SQL language
which shows the names of every table in the database
and every column name, type and length of every table.
If you want I can send you it.


José

subrahmanyan kalathur wrote:

 hi,

 I would like to know the names of the created table in zsql method.
 Kindly give me the tag for displaying the table names.( if exists.)

 thanks
 bye
 yours,

 K.H.Subrahmanyan

 ( [EMAIL PROTECTED] )

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


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




Re: [Zope] How to access column names in DTML Methods

2000-11-14 Thread Jose Soares

Great!
Thank you very much Curtis.


Curtis Maloney wrote:

 On Tue, 14 Nov 2000, Jose Soares wrote:
  Hi all,
 
  I'm trying to display the column names of a Record object without success.
  I'm able to access column data using sequence-item but I don't know
  how to display column names.
 
 

 Here is some code I use in a production site:

 dtml-let Fields="sqlQuery().names()"
   dtml-in Fields
 do your loop stuff here
   /dtml-in
 /dtml-let

 I only used the dtml-let because I use the list twice... so;

 dtml-in "sqlQuery().names()"
   blah
 /dtml-in

 should work fine (not testsed.)  I believe there is some more detail in what
 exactly is in an SQL return object (try the ZQR :)

 
  Thanks for any help
  José
 

 Have a better one,
 Curtis Maloney

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


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




[Zope] How to access column names in DTML Methods

2000-11-13 Thread Jose Soares

Hi all,

I'm trying to display the column names of a Record object without success.
I'm able to access column data using sequence-item but I don't know
how to display column names.


dtml-var standard_html_header
dtml-in "desc(cmd=cmd_sql)" size=50 start=query_start
   dtml-if sequence-start
  dtml-if previous-sequence
A HREF="dtml-var URLdtml-var sequence-queryquery_start=dtml-var
previous-sequence-start-number"(Previous dtml-var previous-sequence-size
results)/A
  /dtml-if previous-sequence
  TABLE
TRTH?HEADER/TH/TR
   /dtml-if sequence-start
TR
  dtml-in sequence-item
TD BGCOLOR="WHITE"dtml-var sequence-item null="NULL"/TD
  /dtml-in
/TR
   dtml-if sequence-end
  /TABLE
  dtml-if next-sequence
 A HREF="dtml-var URLdtml-var sequence-queryquery_start=dtml-var
next-sequence-start-number" (Next dtml-var next-sequence-size results)/A

  /dtml-if next-sequence
   /dtml-if sequence-end
dtml-else
  There was no data matching this dtml-var title_or_id query.
/dtml-in
dtml-var standard_html_footer

Thanks for any help
José



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