Thanks Dylan, Derek, Peter & Tim for your help on how to access URL parameter and on the best approach to take on my project. It helped a lot! I was able to call my routine, pass the parameters to it, and get a result back. I felt like I was almost there...then I hit a snag. I had a routine that was producing an HTML representation of my Income Statement. I worked it over so that it just returned the data in a list of line objects. When I hooked that into Zope and tried to run it, I got the Zope Logon screen. I traced it down to my use of the mx.ODBC module that I'm using to pull in the data. If I take it out, I no longer get the login screen. I figured that executing an external module was not allowed under my (only) login so I set about the task of finding where to change the permissions to allow my module to execute. I haven't been able to figure it out! I know that somewhere, there's a place where you can tell Zope that your module is safe but nothing I tired worked. The Zope Book talks about "executable content". I went to the security settings of my IncomeStatementScript object but I didn't see any permissions related to allowing modules to execute. In /Control_Panel/Products/PythonScripts on the README tab, it describes a method of adding an __init__.py module to a folder in the package directory with and example of "allow_module(base64) allow_module(re) allow_module(DateTime.DateTime)". I tried moving my object to a folder in packages and adding the __init__.py file with "allow_module(ISLines)" but it choked on the allow_module routine. I tried various things to get allow_module to work but nothing did. I'm thinking that maybe it's an older way of doing things that doesn't work anymore. I found a big list of permissions on the DEFINE PERMISSIONS tab of /Control_Panel/Products/PythonScripts. That is a bizarre screen! It has a list of object permissions followed by combo boxes each of which is set to disabled. I intuitively thought that you would set the permission from disabled to enabled if you wanted to activate it. Nope. If you pull down the combo box, you see the entire list of permissions. I'm not getting that screen at all. What would happen if you set the "Access Transient Objects" box from "(disabled)" to "Add RAM Cache Managers"? I tried making my module an external method but it also choked on the import mx.ODBC line. As a side question, the external method asks for a routine and function name. I'm trying to execute a class. It has functions in it but it's not a single function. Are external modules ONLY for specific functions? Do they work with Python classes at all? I tend to get wordy so I guess the simplest question is how do I get Zope to allow me to execute my ISLines.py module?
On Mon, 2003-12-01 at 08:27, Goldthwaite, Joe wrote: [much snipping]
I tried making my module an external method but it also choked on the import mx.ODBC line.
I don't think Zope is your issue here. If you can't import in an external method, *nothing* you can do in Zope is likely to fix the problem If you can get a shell on this machine, fire up the correct version of Python and try this import manually. You may have a permissions problem or some other issue with how the module is installed. It's also possible you may be importing the module incorrectly. Once you've figured out *that* problem, an external method should work fine or you may wish to code up this functionality as a Product. HTH, Dylan
Good point! I guess because I got the Zope login, I figured it was a security setting and went down that path. I went to the WebSite/lib directory and fired up the Python interpreter and typed "import mx.ODBC" and got the import error "No module named mx.ODBC". I guess this is one of the problems of trying to debug using Visual Studio and Active Python and then run under Zope which uses Python 2.1.3. Now that you mention it, the version of mx.ODBC I have installed is for Python 2.3. I'll download and install the 2.1 version. -----Original Message----- From: Dylan Reinhardt [mailto:zope@dylanreinhardt.com] Sent: Monday, December 01, 2003 9:43 AM To: joe@goldthwaites.com Cc: Zope Users Subject: Re: [Zope] Security? On Mon, 2003-12-01 at 08:27, Goldthwaite, Joe wrote: [much snipping]
I tried making my module an external method but it also choked on the import mx.ODBC line.
I don't think Zope is your issue here. If you can't import in an external method, *nothing* you can do in Zope is likely to fix the problem If you can get a shell on this machine, fire up the correct version of Python and try this import manually. You may have a permissions problem or some other issue with how the module is installed. It's also possible you may be importing the module incorrectly. Once you've figured out *that* problem, an external method should work fine or you may wish to code up this functionality as a Product. HTH, Dylan
Well, I don't know if it's progress but I think my questions are getting more specific. I downloaded the mx.ODBC routines for Python 2.1.3. I can now start the python interpreter in the WebSite\bin directory and type "import mx.ODBC" without getting an error. I next tried to create a limited python script; from Products.EIS import ISLines c = ISLines() return "c" I'm just returning the literal "c" on purpose because my page template can't handle the ISLines yet. In my Income Statement ZPT I have this line; <p tal:replace="python:here.IncomeStatementScript()"></p> When I try to display the ZPT, I get the Zope logon dialog box. I only have one login and it doesn't' work so I just hit cancel and get "Your are not allowed to access EIS in this context". (I had placed the ISLines.py file in my Products/EIS directory.) After that, I decided to try external modules. I added this wrapper function to my ISLines.py module; def GetISLines(): c = ISLines() return "c" Again, I put the literal "c" there to make sure I was calling things correctly. I moved the ISLines.py file to the Extensions directory and created a GetISLines external method referencing the new function in Zope root folder. I tested it and got the "c" back. Next, I put this line in my IncomeStatment ZPT; <p tal:replace="python:here.GetISLines()"></p> When I test it, I get the "c" back. Interestingly, there was also pause of about the amount of time it takes to run ISLines and build the Income Statement lines. I thought I was almost there. The next step was to return the actual object and print out the number of lines returned. I modified the 'return "c"' line to 'return c'. Now when I run it, I get "<? ISLines instance at 014879EC>" so I know I'm now returning my object. Finally I try to reference my list if lines by printing the length like this; <p tal:replace="python:len(here.GetISLines().DefLines)"></p> Deflines is a list of income statement line objects. I go to refresh and I get the Logon dialog again! #$%@ &@#% &^@$!!!! Sorry, I don't usually use that kind of language but I seem to be shooting at the wrong target. It's no wonder I can't hit anything.
These Unauthorized errors (login boxes) are caused by trying to access objects from untrusted code that do not have any Zope security assertions on them. TTW code (Python Scripts, DTML and Page Templates), including skins on the file system exposed through FS directory views, are untrusted code. They execute using a restricted Python interpreter which prevents access to arbitrary Python objects and modules that might represent a security hole (and allow you to compromise the server). There are two solutions to your problem: 1. Use trusted code, which includes external methods and zope product modules and have them return simple types (strings, ints, etc) or simple containers (lists, dicts, tuples) containing simple types up to the template that is renderign the page. Simple types are deemed safe for untrusted code by default (along with some others, like DateTime objects). 2. Put security assertions on the objects used by untrusted code. This usually requires you to subclass the objects, but not always. See the Zope developers guide for details. In most cases #1 is sufficient unless there are many places where it is desireable for untrusted code to have access to the objects directly in which case use #2. hth, -Casey On Mon, 1 Dec 2003 13:45:01 -0700 "Goldthwaite, Joe" <joe@goldthwaites.com> wrote:
Well, I don't know if it's progress but I think my questions are getting more specific.
I downloaded the mx.ODBC routines for Python 2.1.3. I can now start the python interpreter in the WebSite\bin directory and type "import mx.ODBC" without getting an error.
I next tried to create a limited python script;
from Products.EIS import ISLines c = ISLines() return "c"
I'm just returning the literal "c" on purpose because my page template can't handle the ISLines yet. In my Income Statement ZPT I have this line;
<p tal:replace="python:here.IncomeStatementScript()"></p>
When I try to display the ZPT, I get the Zope logon dialog box. I only have one login and it doesn't' work so I just hit cancel and get "Your are not allowed to access EIS in this context". (I had placed the ISLines.py file in my Products/EIS directory.)
After that, I decided to try external modules. I added this wrapper function to my ISLines.py module;
def GetISLines(): c = ISLines() return "c"
Again, I put the literal "c" there to make sure I was calling things correctly. I moved the ISLines.py file to the Extensions directory and created a GetISLines external method referencing the new function in Zope root folder. I tested it and got the "c" back. Next, I put this line in my IncomeStatment ZPT;
<p tal:replace="python:here.GetISLines()"></p>
When I test it, I get the "c" back. Interestingly, there was also pause of about the amount of time it takes to run ISLines and build the Income Statement lines. I thought I was almost there. The next step was to return the actual object and print out the number of lines returned. I modified the 'return "c"' line to 'return c'. Now when I run it, I get "<? ISLines instance at 014879EC>" so I know I'm now returning my object. Finally I try to reference my list if lines by printing the length like this;
<p tal:replace="python:len(here.GetISLines().DefLines)"></p>
Deflines is a list of income statement line objects. I go to refresh and I get the Logon dialog again! #$%@ &@#% &^@$!!!! Sorry, I don't usually use that kind of language but I seem to be shooting at the wrong target. It's no wonder I can't hit anything.
_______________________________________________ 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 )
Thanks Casey, The DefLines attribute of the ISLines object was a simple list. I changed the return from "return c" to "return c.DefLines" and then modified this; <p tal:replace="python:len(here.GetISLines().DefLines)"></p> to this; <p tal:replace="python:len(here.GetISLines())"></p> And it returned I got my 75 line count in the Income Statement. I'll try creating a loop that displays the lines on the page. I had gone through the developer guide chapter on security but it's not making much sense yet. I'm going to see if I can access my line objects and I'll revisit the assertions if it doesn't work. (The line object has a method that returns a year to date number and I suspect I'll get the unauthorized method when I try to access it). Thanks again - and thanks to everyone else who answered with help. -----Original Message----- From: Casey Duncan [mailto:casey@zope.com] Sent: Monday, December 01, 2003 2:13 PM To: joe@goldthwaites.com Cc: zope@zope.org Subject: Re: [Zope] Security? These Unauthorized errors (login boxes) are caused by trying to access objects from untrusted code that do not have any Zope security assertions on them. TTW code (Python Scripts, DTML and Page Templates), including skins on the file system exposed through FS directory views, are untrusted code. They execute using a restricted Python interpreter which prevents access to arbitrary Python objects and modules that might represent a security hole (and allow you to compromise the server). There are two solutions to your problem: 1. Use trusted code, which includes external methods and zope product modules and have them return simple types (strings, ints, etc) or simple containers (lists, dicts, tuples) containing simple types up to the template that is renderign the page. Simple types are deemed safe for untrusted code by default (along with some others, like DateTime objects). 2. Put security assertions on the objects used by untrusted code. This usually requires you to subclass the objects, but not always. See the Zope developers guide for details. In most cases #1 is sufficient unless there are many places where it is desireable for untrusted code to have access to the objects directly in which case use #2. hth, -Casey On Mon, 1 Dec 2003 13:45:01 -0700 "Goldthwaite, Joe" <joe@goldthwaites.com> wrote:
Well, I don't know if it's progress but I think my questions are getting more specific.
I downloaded the mx.ODBC routines for Python 2.1.3. I can now start the python interpreter in the WebSite\bin directory and type "import mx.ODBC" without getting an error.
I next tried to create a limited python script;
from Products.EIS import ISLines c = ISLines() return "c"
I'm just returning the literal "c" on purpose because my page template can't handle the ISLines yet. In my Income Statement ZPT I have this line;
<p tal:replace="python:here.IncomeStatementScript()"></p>
When I try to display the ZPT, I get the Zope logon dialog box. I only have one login and it doesn't' work so I just hit cancel and get "Your are not allowed to access EIS in this context". (I had placed the ISLines.py file in my Products/EIS directory.)
After that, I decided to try external modules. I added this wrapper function to my ISLines.py module;
def GetISLines(): c = ISLines() return "c"
Again, I put the literal "c" there to make sure I was calling things correctly. I moved the ISLines.py file to the Extensions directory and created a GetISLines external method referencing the new function in Zope root folder. I tested it and got the "c" back. Next, I put this line in my IncomeStatment ZPT;
<p tal:replace="python:here.GetISLines()"></p>
When I test it, I get the "c" back. Interestingly, there was also pause of about the amount of time it takes to run ISLines and build the Income Statement lines. I thought I was almost there. The next step was to return the actual object and print out the number of lines returned. I modified the 'return "c"' line to 'return c'. Now when I run it, I get "<? ISLines instance at 014879EC>" so I know I'm now returning my object. Finally I try to reference my list if lines by printing the length like this;
<p tal:replace="python:len(here.GetISLines().DefLines)"></p>
Deflines is a list of income statement line objects. I go to refresh and I get the Logon dialog again! #$%@ &@#% &^@$!!!! Sorry, I don't usually use that kind of language but I seem to be shooting at the wrong target. It's no wonder I can't hit anything.
_______________________________________________ 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 )
Well, it didn't work. As soon as I tried to create a loop and access the .desc property of the ISLine objects, I got this message; Error Type: Unauthorized Error Value: You are not allowed to access desc in this context I guess I don't understand how or why I'm hitting this. I've already run the module that does the dangerous thing - accessing the database. All I'm getting back is a list of objects but I can't even reference the desc attribute which is just a string. I'd like to just disable the security stuff until I get things working. I don't really have time to fight with it right now. When I do put it in, it will be based on the SQL server security not on Zope's. I went to the developer guide and tried their example. I put this at the top; from AccessControl import ClassSecurityInfo After the class definition line before the first (__init__) function, I put these lines; security = ClassSecurityInfo() security.declarePublic('DefLines') I saved and reloaded everything but I still get the logon dialog. I must be close but it's just not working. I really don't understand. The work is done. All I'm trying to do is access the resulting data in the ZPT. Here are the offending lines; <tr tal:repeat="item here/GetISLines"> # The GetISLines is an external module that returns a list <td tal:content=item/desc">desc</td> # this should display the line description for each line </tr> That's it but for some unknown security reason, it blows up. P.S. I've also gone through my three other Zope books but haven't been able to find the answer. I don't mean to complain but it seems every time I think I've got it, I get whacked. I really do appreciate the help though :). -----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org]On Behalf Of Goldthwaite, Joe Sent: Monday, December 01, 2003 2:39 PM To: zope@zope.org Subject: RE: [Zope] Security? Thanks Casey, The DefLines attribute of the ISLines object was a simple list. I changed the return from "return c" to "return c.DefLines" and then modified this; <p tal:replace="python:len(here.GetISLines().DefLines)"></p> to this; <p tal:replace="python:len(here.GetISLines())"></p> And it returned I got my 75 line count in the Income Statement. I'll try creating a loop that displays the lines on the page. I had gone through the developer guide chapter on security but it's not making much sense yet. I'm going to see if I can access my line objects and I'll revisit the assertions if it doesn't work. (The line object has a method that returns a year to date number and I suspect I'll get the unauthorized method when I try to access it). Thanks again - and thanks to everyone else who answered with help. -----Original Message----- From: Casey Duncan [mailto:casey@zope.com] Sent: Monday, December 01, 2003 2:13 PM To: joe@goldthwaites.com Cc: zope@zope.org Subject: Re: [Zope] Security? These Unauthorized errors (login boxes) are caused by trying to access objects from untrusted code that do not have any Zope security assertions on them. TTW code (Python Scripts, DTML and Page Templates), including skins on the file system exposed through FS directory views, are untrusted code. They execute using a restricted Python interpreter which prevents access to arbitrary Python objects and modules that might represent a security hole (and allow you to compromise the server). There are two solutions to your problem: 1. Use trusted code, which includes external methods and zope product modules and have them return simple types (strings, ints, etc) or simple containers (lists, dicts, tuples) containing simple types up to the template that is renderign the page. Simple types are deemed safe for untrusted code by default (along with some others, like DateTime objects). 2. Put security assertions on the objects used by untrusted code. This usually requires you to subclass the objects, but not always. See the Zope developers guide for details. In most cases #1 is sufficient unless there are many places where it is desireable for untrusted code to have access to the objects directly in which case use #2. hth, -Casey On Mon, 1 Dec 2003 13:45:01 -0700 "Goldthwaite, Joe" <joe@goldthwaites.com> wrote:
Well, I don't know if it's progress but I think my questions are getting more specific.
I downloaded the mx.ODBC routines for Python 2.1.3. I can now start the python interpreter in the WebSite\bin directory and type "import mx.ODBC" without getting an error.
I next tried to create a limited python script;
from Products.EIS import ISLines c = ISLines() return "c"
I'm just returning the literal "c" on purpose because my page template can't handle the ISLines yet. In my Income Statement ZPT I have this line;
<p tal:replace="python:here.IncomeStatementScript()"></p>
When I try to display the ZPT, I get the Zope logon dialog box. I only have one login and it doesn't' work so I just hit cancel and get "Your are not allowed to access EIS in this context". (I had placed the ISLines.py file in my Products/EIS directory.)
After that, I decided to try external modules. I added this wrapper function to my ISLines.py module;
def GetISLines(): c = ISLines() return "c"
Again, I put the literal "c" there to make sure I was calling things correctly. I moved the ISLines.py file to the Extensions directory and created a GetISLines external method referencing the new function in Zope root folder. I tested it and got the "c" back. Next, I put this line in my IncomeStatment ZPT;
<p tal:replace="python:here.GetISLines()"></p>
When I test it, I get the "c" back. Interestingly, there was also pause of about the amount of time it takes to run ISLines and build the Income Statement lines. I thought I was almost there. The next step was to return the actual object and print out the number of lines returned. I modified the 'return "c"' line to 'return c'. Now when I run it, I get "<? ISLines instance at 014879EC>" so I know I'm now returning my object. Finally I try to reference my list if lines by printing the length like this;
<p tal:replace="python:len(here.GetISLines().DefLines)"></p>
Deflines is a list of income statement line objects. I go to refresh and I get the Logon dialog again! #$%@ &@#% &^@$!!!! Sorry, I don't usually use that kind of language but I seem to be shooting at the wrong target. It's no wonder I can't hit anything.
_______________________________________________ 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 )
_______________________________________________ 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 )
On Mon, 2003-12-01 at 14:24, Goldthwaite, Joe wrote:
Well, it didn't work. As soon as I tried to create a loop and access the .desc property of the ISLine objects, I got this message;
Error Type: Unauthorized Error Value: You are not allowed to access desc in this context
You're doing the same thing again... using custom objects in a restricted environment. Do *all* the heavy lifting in your external method... IMO, templates shouldn't have to do practically any logic at all. It's usually pretty easy to do this in Python, often just something like: --- return [(item['id'], item['desc']) for item in item_list] --- Then all your template has to do is iterate over a list of tuples. HTH, Dylan
Hi Dylan, I know I'm doing the same thing but it's something I really want to do. I guess I could return the list of tuples but wouldn't I then have to refer to the fields by number instead of name? That seems like a step backwards. I've got this nice object with named attributes and I shouldn't have to throw that out for security. I tend to be a purest and have always tried to keep efficiency in mind when writing applications. I really have to get past that. When I think about all the overhead a web application has to go through to do the same job as my old green screen application, I shiver. By the way, that return line was slick. I didn't know Python could convert a item into a list in a single line like that. You learn something new every day. Thanks again -----Original Message----- From: Dylan Reinhardt [mailto:zope@dylanreinhardt.com] Sent: Monday, December 01, 2003 4:15 PM To: joe@goldthwaites.com Cc: Zope Users Subject: RE: [Zope] Security? On Mon, 2003-12-01 at 14:24, Goldthwaite, Joe wrote:
Well, it didn't work. As soon as I tried to create a loop and access the .desc property of the ISLine objects, I got this message;
Error Type: Unauthorized Error Value: You are not allowed to access desc in this context
You're doing the same thing again... using custom objects in a restricted environment. Do *all* the heavy lifting in your external method... IMO, templates shouldn't have to do practically any logic at all. It's usually pretty easy to do this in Python, often just something like: --- return [(item['id'], item['desc']) for item in item_list] --- Then all your template has to do is iterate over a list of tuples. HTH, Dylan
<snip>
I know I'm doing the same thing but it's something I really want to do. I guess I could return the list of tuples but wouldn't I then have to refer to the fields by number instead of name? That seems like a step backwards. I've got this nice object with named attributes and I shouldn't have to throw that out for security. I tend to be a purest and have always tried to keep efficiency in mind when writing applications. I really have to get past that. When I think about all the overhead a web application has to go through to do the same job as my old green screen application, I shiver.
Why don't you return a dictionary if you want to refer to the fields by name? The following example code creates a dictionary and then populates it (without having to hardcode the field/property names): <dtml-with "propertysheets.YourPropertySheetName"> <dtml-call "REQUEST.set('pids', [])"> <dtml-in propertyIds> <dtml-call "pids.append(_['sequence-item'])"> </dtml-in> </dtml-with> <dtml-with YourDataFolder> <dtml-with "_.getitem(recid)"> <dtml-in "_.range(_.len(pids))"> <dtml-call "REQUEST.set(pids[_['sequence-item']], _[pids[_['sequence-item']]])"> </dtml-in> </dtml-with> </dtml-with> HTH Jonathan
On Tue, 2003-12-02 at 10:07, Goldthwaite, Joe wrote:
Hi Dylan,
I know I'm doing the same thing but it's something I really want to do. I guess I could return the list of tuples but wouldn't I then have to refer to the fields by number instead of name?
You could return a dictionary... but that's not the real issue.
I've got this nice object with named attributes and I shouldn't have to throw that out for security. I tend to be a purest and have always tried to keep efficiency in mind when writing applications.
I'm all for efficiency. Longer term, I'd look toward coding this up as a product. In the meantime, the code snip someone else offered should do the trick.
I really have to get past that. When I think about all the overhead a web application has to go through to do the same job as my old green screen application, I shiver.
It isn't necessarily *that* much more... it's still nothing compared to a semi-trivial GUI app. Web apps are still just text in, text out.
By the way, that return line was slick. I didn't know Python could convert a item into a list in a single line like that. You learn something new every day.
That's a "list comprehension," one of Python's niftier tricks. Definitely worth reading up on a little, they're very handy. Dylan
At 1/12/2003 14:38, you wrote:
I'm going to see if I can access my line objects and I'll revisit the assertions if it doesn't work. (The line object has a method that returns a year to date number and I suspect I'll get the unauthorized method when I try to access it).
Try the VerboseSecurity product. It helps a lot in debugging security problems. Gabriel Genellina Softlab SRL
On Mon, 2003-12-01 at 12:45, Goldthwaite, Joe wrote:
I modified the 'return "c"' line to 'return c'. Now when I run it, I get "<? ISLines instance at 014879EC>" so I know I'm now returning my object.
Excellent, you're almost there.
Finally I try to reference my list if lines by printing the length like this;
<p tal:replace="python:len(here.GetISLines().DefLines)"></p>
What you want to do is pass your external method enough parameters that it can just hand back a string, list, or other vanilla Python object. Return c.DefLines from your external method instead of c.
Sorry, I don't usually use that kind of language but I seem to be shooting at the wrong target. It's no wonder I can't hit anything.
You're very close now... I'm sure you'll have it soon. HTH, Dylan
On Mon, 1 Dec 2003, Goldthwaite, Joe wrote: [...]
I had a routine that was producing an HTML representation of my Income Statement. I worked it over so that it just returned the data in a list of line objects. When I hooked that into Zope and tried to run it, I got the Zope Logon screen. I traced it down to my use of the mx.ODBC module that I'm using to pull in the data. If I take it out, I no longer get the login screen.
I suspect that you have a security/permissions problem. Take a look at the Security tab of the Zope root and ensure you (that is, your user) has permission to access databases, etc. I assume you have installed and are using the appropriate database adaptor in Zope. (If you are accessing the database via your external method you need to remember that the permissions need to reflect the user Zope is running as.)
I guess I should have added this. I'm logging on as jgold which has the role of Manager. The security settings for the root folder are all checked for the manager column. -----Original Message----- From: Dennis Allison [mailto:allison@sumeru.stanford.EDU] Sent: Monday, December 01, 2003 9:57 AM To: Goldthwaite, Joe Cc: zope@zope.org Subject: Re: [Zope] Security? On Mon, 1 Dec 2003, Goldthwaite, Joe wrote: [...]
I had a routine that was producing an HTML representation of my Income Statement. I worked it over so that it just returned the data in a list of line objects. When I hooked that into Zope and tried to run it, I got the Zope Logon screen. I traced it down to my use of the mx.ODBC module that I'm using to pull in the data. If I take it out, I no longer get the login screen.
I suspect that you have a security/permissions problem. Take a look at the Security tab of the Zope root and ensure you (that is, your user) has permission to access databases, etc. I assume you have installed and are using the appropriate database adaptor in Zope. (If you are accessing the database via your external method you need to remember that the permissions need to reflect the user Zope is running as.)
Goldthwaite, Joe wrote: [snip]
I tried making my module an external method but it also choked on the import mx.ODBC line. As a side question, the external method asks for a routine and function name. I'm trying to execute a class. It has functions in it but it's not a single function. Are external modules ONLY for specific functions? Do they work with Python classes at all?
Of course. You just have to wrap your classes up in a function. Arbitrary sample -- say we've got a python file 'HelloModule.py' containing: class HelloSayer: def greet(self): return 'hello' def wrapper(self): h = HelloSayer() return h.greet() In this example, your External Method would probably be called 'greet' (arbitrary, really), the function name should be 'wrapper', and the module name should be eg. 'HelloModule' hth, peter.
participants (7)
-
Casey Duncan -
Dennis Allison -
Dylan Reinhardt -
Gabriel Genellina -
Goldthwaite, Joe -
Peter Sabaini -
Small Business Services