Re: [Zope-DB] Retrieving Data from Z SQL in Python
Christer Fernstrom wrote: Hello, I have a very simple Z SQL method that works fine when I test run it. But when I call it from a Python script (see below) and attempt to print the result, I get the following error: Error Type: TypeError Error Value: cannot concatenate 'str' and 'ImplicitAcquirerWrapper' objects -- Python script - # Import a standard function, and get the HTML request and response objects. ##from Products.PythonScripts.standard import html_quote request = container.REQUEST RESPONSE = request.RESPONSE data = context.getChunk1() for data_row in data: print "data-row="+data_row return printed You need to iterate over the columns in the row: data = context.getChunk1() for data_row in data: print "data-row=" for item in data_row: print item + ' ' return printed It is more normal to fetch one result row at a time: for data_row in context.getChunk1(): # and handle the results by column name print data_row.FirstName print ' ' print data_row.Surname ... return printed HTH Cliff ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
Re: [Zope-DB] Python Script / ZSQL
Answer below Infor Gates wrote: Hello Zopist I am new and try to learn python script with ZSQL in Zope. I have read the Zope Book. However, most of them are in DTML and very few on python script. I have a little knowledge on Zope and SQL but am lost in trying to see the whole picture of zope/pythonscript/zsql. I have a simple database record of person details. I used a simple insertZSQL statement: INSERT INTO person ( p_givenname, p_familyname, p_datebirth, p_sex ) VALUES ( ); In DTML script: How can I do something similar in python script? context.REQUEST.set('p_givenname','Ian') ... But note that if the input data is originating in a form then it is already in the REQUEST and you do not need to use set. Cliff Can anyone point me to an example? Very much appreciated. Thank you. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
Re: [Zope-DB] Creating a hyperlink using results from query
Martin Jennings wrote: Firstly, thank you to those who answered by query on the empty result set, it set me on the way to finding a solution. Not sure if this is the right list to ask on, but here is the question. I have got information from a ZSQL request in a result set and I want to use one of the values as a parameter in a hyperlink, how do I do this? I.e. my link How do I write the code for this? It depends on how you are calling the ZSQL Method, and whether you are returning one result or many. In DTML it could be like this: You can shorten to &dtml-FieldName; - but I thin you should get the idea. Python uses for result in context.nameOfZSQLMethod(): return 'Link Text' % \ result.FieldName HTH Cliff Thank you in advance, and once again, sorry if this is not the correct list. Martin Jennings ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
Re: [Zope-DB] Null characters & booleans
Watch out if you need to use fields longer than 4000 characters - Oracle CLOBs return handles rather than contents, as in MySQL Text fields for example. So you need extra coding in your presentation later. Also, watch out for Database X returning result.FieldName whilst Database Y returns result.FIELDNAME. I don't suppose I need to mention DateTime fields! I suspect you might be better off having some database specific code rather than trying to patch the ZSQL Method code. Cliff Andrew Veitch wrote: We're doing a lot with relational databases and Zope at the moment. We are trying to get our code to work with as many different relational backends as possible with a minimal amount of rewriting. The first issue we've got is chr(0) appearing in input strings. Using Postres/Psycopg if we do: and variable contains a chr(0) then it will fail. Obviously we can get round this by variable.replace(chr(0), '') on every variable before it goes in to the ZSQL method but that's not ideal. Would it be sensible to look at patching sqlvar or is this just a problem specific to Postgres? The second issue we've got is with Booleans. It is quite annoying to have to do: to insert Booleans. Also I think that some databases expect their Booleans to be other than 'true' and 'false' so introducing a Boolean quoting type would push this logic down to the DA rather than complicating the application. We'd be willing to provide patches for both these issues if there's interest and agreement it's a sensible way to go. A ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
Re: [Zope-DB] Connection to Oracle DB
Umashankar Rao wrote: But how to define my database connection parameters like username/passwd and SID? You need an entry in tnsnames.ora that looks like this: YOURID = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = address.of.your.server)(PORT = )) ) (CONNECT_DATA = (SID = yourid) ) ) is the actual port number the database is using. Can you please give me the navigation from http://localhost:8080/manage ??? Is it the right adaptor i downloaded?/ You should see Z Oracle Database Connection in the Add list (if the installation was successful). If so... Your connection string should look like this: username/[EMAIL PROTECTED] HTH Cliff ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db
Re: [Zope-DB] Another problem with Zope-Mysql
Don't know what the equivalent for Windows is, but on *ix you can start Zope in the foreground and see what the startup sequence messages have to say. Also, try looking in the logs. If Zope fails to start there should be an error report somewhere. Cliff David wrote: Hi, so I also tried Mysql because i thought there'd be more support. I followed the instructions given here http://www.pastrytech.com/willy/zopemysql.html but it did not work for me. I am using more recent versions of the platform: OS: Windows XP Professional Zope 2.7.4 Mysql 4.1 and the latest adaptors: MySQL-python.exe-1.2.0.win32-py2.4.zip ZMySQLDA-2.0.8.tar.gz Zope just failed to start. I would really appreciate your help on this. Thanks, David. ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db ___ Zope-DB mailing list Zope-DB@zope.org http://mail.zope.org/mailman/listinfo/zope-db