[Zope3-dev] PythonScript in Zope3?
Barry Pederson
bp@barryp.org
Mon, 24 Feb 2003 13:56:47 -0600
Steve Alexander wrote:
> What I mean is, why would you want to have a 'print "hello world"'
> statement in a persistent module?
>
> Persistent modules aren't scripts. They aren't meant to be run. In Zope,
> you don't expect to see the effects of what you have done appear on
> standard-output.
>
> Printing 'hello world' in a print statement in a module is not an
> appropriate 'hello world' program for a persistent module.
Good point, I had gone a bit far around the bend in frustration, and
forgot the extra bit in Zope2 where you do a "return printed" which sort
of turns the "script" into a "function" that returns a value.
But still, the main point was that I was looking for a working example
for using TTW Python for simple logic perhaps in association with a ZPT.
But it's looking like those features aren't quite here yet.
> You'll need to get hold of the module, as described here:
>
> http://www.zope.org/Wikis/DevSite/Projects/ZPT/ModuleAccessInTALES
>
> So,
>
> <div tal:define="mymod nocall modules/mystuff/mymod">
> <p tal:contents="mymod/myfunc" />
> </div>
>
>
>> 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?
>
>
> I haven't tried much of this. What I describe above should work.
> If I get time, I'll try it out later.
> If you try it out and tell me where you get stuck, I'll try to help you.
I tried to see what modules were available from within a ZPT, using this
snippet:
<div tal:repeat="m python:modules.keys()">
<span tal:replace="m">module name</span>
</div>
But don't see the persistent module I defined.
I was reading through Jim's wiki document on TTW Site Development:
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/ThroughTheWebSiteDevelopment
which has a section on persistent modules, and mentions:
---------
Persistent modules can be exported to the containing site and all of
it's subsites by creating a module configuration. A module configuration
registers a module and also specified which names are accessible from
the module and, for each name, the permission required to access the name.
---------
The description of how persistent modules will work sounds very good,
but the bit about "creating a module configuration" to specify which
names are accessible...and permissions... doesn't seem to be implemented
yet.
>> 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.
>
> I can't argue with that.
>
> You are already improving the situation by trying these things, and
> asking these questions.
>
> You can improve it more if you have time to write how-to documentation
> based on your experiences.
Fair enough.
Barry