import ZGadflyDA.gadfly: Ext Method or Python Script?
Hi, I would like to learn about using Gadfly, on a very little application. I put this in a "Python Script": from Products.ZGadflyDA import gadfly connection = gadfly.gadfly("rktmb_db", "demo") cursor = connection.cursor() cursor.execute("select * from pointage") for x in cursor.fetchall(): print x return printed In a page template, I call that script. I try to view the page template, then I am prompted for login and password (zope HTTP prompt), and my Zope manager login/pass is refused (re-prompted). If I cancel logging in, I get "unauthorized" because I am "not authorized to use ZGadflyDA in this context". So, must I only use external methods (duh!)? Or should I release some permission to make it OK? I am running Zope 2.9. Thank you.
--On 27. Dezember 2007 01:59:10 +0100 Rakotomandimby Mihamina <mihamina.rakotomandimby@etu.univ-orleans.fr> wrote:
Hi, I would like to learn about using Gadfly, on a very little application.
Consider using a *real* database. Gadfly is a toy and it will be removed in Zope 2.11. And of course you're right: it is a well known fact that PythonScript are restricted on imports and doing other stuff. That's why we have *trusted codde* in form of external methods, Zope products and browser views. In addition: your code does not make much sense from the architectural point of view. Zope has a DB abstraction layer with ZSQL methods. If you do execute SQL code directly this way, be doomed. Please read the RDBMS of "The Zope Book 2.7 edition" (use Google). Andreas
Andreas Jung wrote:
I would like to learn about using Gadfly, on a very little application. Consider using a *real* database. Gadfly is a toy and it will be removed in Zope 2.11.
Okay.
And of course you're right: it is a well known fact that PythonScript are restricted on imports and doing other stuff. That's why we have *trusted code* in form of external methods, Zope products
Okay. I tried on Gadfly in order to test my SQL statements. But are Product's *.py files (those in the "Products" FS directory) also restricted that way?
In addition: your code does not make much sense from the architectural point of view. Zope has a DB abstraction layer with ZSQL methods.
I really want to use ZPT+Python on the thing I am developping. Is there any hint to have: "ZQSL Methods" -> "Python Sscript" -> "ZPT" Thank you for all. I am going to have a look at the ZOpe book, as you said.
--On 27. Dezember 2007 11:54:27 +0100 Rakotomandimby Mihamina <mihamina.rakotomandimby@etu.univ-orleans.fr> wrote:
Okay. I tried on Gadfly in order to test my SQL statements. But are Product's *.py files (those in the "Products" FS directory) also restricted that way?
You don't need that (and you don't want that). Use a DA and ZSQL methods. Andreas
participants (2)
-
Andreas Jung -
Rakotomandimby Mihamina