[Zope3-dev] PythonScript in Zope3?

Barry Pederson bp@barryp.org
Wed, 19 Feb 2003 14:04:31 -0600


Steve Alexander wrote:
> 
> Add a folder called 'foo'. Inside the folder, add a python script called 
> 'index.html'.

Zope3 doesn't offer python script as a choice of things you can add to a 
content folder - that's what got me started on this whole thing in the first 
place, finding out what the new equivalent is.



>>  * Can the sourcecode be as simple as: "print 'hello world'", or does
>>    there need to be a function defined.
> 
> 
> Yes (but I don't know why you'd want to print anything like this).

Geez, a "hello world" sample is supposed to be trivial, to get you over 
whatever initial hurdles there are to using a new system.  It's hard to 
contemplate doing more worthwhile things, if you can't do simple stuff first.



> If you define a persistent module, and the module name is mystuff.mymod, 
> then you can call a function called 'myfunc' that is inside 
> mystuff.mymod by writing this in a page template:
> 
>   <div tal:define="result mystuff/mymod/myfunc" />
> 
> or perhaps this:
> 
>   <div tal:define="result python:mystuff.mymod.myfunc()" />

Nope, doesn't seem to work, get a NameError: name 'mystuff' is not defined.

Has any of this been actually tried? or is it more of a hypothetical "this is 
how I imagine it probably works?"  or are there more steps?

That's mainly what I'm asking to find out..what are the 17..no 18..18 easy 
steps to getting a 'hello world' example running from whatever replaces 
python scripts :)

(or is the whole thing just not functional yet?)


> You can set up a local views service, configure a view for IFolder, and 
> provide a template and possibly a class for that (if you want).
> 
> You can redefine the default view of IFolder to be your new view.
> 
> This is appropriate if you want to change the default view of all 
> folders in your site.
> This is not appropriate if you want to put an index.html page in a 
> single particular folder.

Yeah, I'd love to see that sort of thing working, changing the default view 
of something, but again it's not obvious what needs to go into the "configure 
a view" form.  I've tried various things, but mostly get:

   AttributeError: GlobalViewService instance has no attribute
    'queryConfigurationsFor'

The big frustration with learning Zope3 right now is constantly reading that 
you "can" do something, but specific detailed reproducible examples of "how" 
to do something aren't easily come by.

	Barry