[Zope-Perl] Beta 3, Book etc.

Gisle Aas gisle@ActiveState.com
20 Nov 2000 21:05:30 -0800


Michel Pelletier <michel@digicool.com> writes:

> Perl methods don't seem to be synchronized with the latest version of
> python methods in that:
> 
>   1. 'self' is passed as an argument instead of a magic variable binding
> 
>   2. There are no magic variable bindings (context, etc...)

Correct.

> This syncing may not be desireable, I don't know.  For now, the book
> documents the 'self' first argument method but you (collectivly) may
> want to consider changing the behavior to sync with Py meths. 

The behaviour of perl methods should change to be compatible with
python methods (eventually).

> I remember sending you a recent cvs checkout of py methods to see the new
> behavior, did you get that?

Yes, I got that one.

> I can send you another if you'd like.

I would actually like to see a written spec on how this is supposed to
work.  Perhaps your book could be just that :-)

>                                         For behavior of the new
> methods and an explanation of the binding etc, see chapter 8 of the
> book:
> 
> http://www.zope.org/Members/michel/ZB/ScriptingZope.html

Some bugs spotted in that chapter:

The example of calling a method from perl should be:

   $context->updateInfo(*color   => 'brown', 
                        *pattern => 'spotted');

(note the '*' to signal keywords).  The alternative interface to
passing keyword arguemnts is:

    $context->updateInfo(Python::KW(color   => 'brown', 
                                    pattern => 'spotted));

The fig 8-2 perl code needs all "." replaced with "->", i.e:

    $context->Zoo->Diet->LargeAnimals->hippo->feed;

The code that shows "Method Parameters" should not include all those
shift statements, i.e. the code is simply:

    $context->processName($name);
    $context->processAge($age);
    return $context->responseMessage;

but for External Perl Methods they are needed, but then I would write it
as:

    my($context, $name, $age) = @_;
    $context->processName($name);
    #...

Just after this code sample you say: "In the above example there is a
subtle problem.  You are probably expecting an integer,..."  This is a
bit misleading since perl does not care whether data some piece of
data is a string or a number.

Perhaps just rephrasing as "In the above Pythod example ..."

And $context does not really work in current perl methods.
Only $self works.

> Next, we are renaming python methods by running a poll this week.  I
> don't know if perl methods are going to fall under the same renaming
> policy.  What do you all think?

To me it is kind of obvous that perl methods ought to follow the name
scheme, just s/python/perl/ in what you eventually decide.

> Next, we don't know if we should provide installation istructions in the
> book or not for perl methods.  Right now it is a bit painful and it
> might be better to just provide a link to installtion documentation.  if
> this is the case, we need to write that documentation and figure out the
> cannoical URL for it.

I would not include something like that in a book.  It is surely
something that will change.  I hope to get the 'pyperl' stuff into
ActivePerl/ActivePython at some point and that should take care of
most of the painfulness.  But this also depends on having a Zope that
is happy together with Python 2.0.

Regards,
Gisle