[Zope] underscore '_' in python script

Tino Wildenhain tino@wildenhain.de
Fri, 08 Nov 2002 01:06:24 +0100


Hi Alfredo,

--On Freitag, 8. November 2002 00:08 +0800 "Alfredo P. Ricafort" 
<alpot@mylinuxsite.com> wrote:

> Hi Chris,
>
> Thanks for your reply.
>
> What I'm not so clear here is what you meant by 'disk-based Python
> Product'.  My understanding is that you cannot call a user defined
> python script unless you define it as 'Script (Python)'. Also, if you
> follow the link, it appears that it is a 'Script (Python)' because it is
> being called from a DTML method.

Actually 'Script (Python)' Objects are methods of the container
just like a DTML method is. Its only a name. You can define
simple functions in them, its just like in python if you define
inner functions in a method (for example you cannot reference such
functions from outside of the 'Script (Python)' object.

Image this object like this: (only oversimplified example to show the idea!)

class Folder():
    def __init__(self,...):
        ...

    def yourPythonScript(self,args...):
        context=self
        container=context.aq_parent # out of my head. May be wrong but
                                    # for the sake of example
        here starts your Python Code in your Python Script.


HTH
Tino Wildenhain

>
> AL
>
> On Thu, 2002-11-07 at 19:11, Chris Withers wrote:
>> Alfredo P. Ricafort wrote:
>> >
>> > In this location,
>> > http://www.zope.org/Members/anthony/tree-coding-tricks, there is a
>> > sample python script.  If I try to load it in my Zope installation (ver
>> > 2.6), it complains because a class and a method starts with "_".  But
>> > in python, the class initialization method __init__ starts "_".
>> >
>> > So how do you define a class that requires an initialization method in
>> > a Zope?
>>
>> if you're trying to use Script (Python)'s to play around with this,
>> don't,  they're not designed for it ;-)
>>
>> You probably want to look at writing a disk-based Python Product in
>> which you  can do anything you want.
>>
>> cheers,
>>
>> Chris
>>
>>
>> _______________________________________________
>> Zope maillist  -  Zope@zope.org
>> http://lists.zope.org/mailman/listinfo/zope
>> **   No cross posts or HTML encoding!  **
>> (Related lists -
>>  http://lists.zope.org/mailman/listinfo/zope-announce
>>  http://lists.zope.org/mailman/listinfo/zope-dev )
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )