You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Cameron McBride <ca...@cwru.edu> on 2002/04/16 08:51:06 UTC

Embperl Object Inheritance

Now that I got an idea about configuration, lets move on to usage.  
(thanks!!)

What I had in mind for Embperl (using the Embperl::Object stuff) was an
inheritance tree for the request object.  But I want my base.epl to be
in the middle: 
(the order is via my understanding of precedence, most -> least)

  REQUESTED PAGE  -->    base.epl    --> defaults.epl
 (the .html file)    

So, the requested page could change what it likes, base.epl is used as the
template for the html formatting (most of the request objects features
are used here) and the defaults.epl is where site defaults and constants
are stored.

I was not able to achieve this.  I tried several methods, described
below.

1. Importing the code via 'Execute':
    (in base.epl)
    Execute({inputfile=>'defaults.epl', import=>1);

   Never got this to work at all, it just seems to silently fail -- and
   the subroutines never became part of the namespace of the file.  

2. Adding to the ISA array via 'Execute':   
    (in base.epl)
    Execute ({isa=>'defaults.epl'});
   
   Now, base.epl (being the EMBPERL_OBJECT_BASE) does not seem to like
   having an 'isa' assignment in it.  I get some error in embperl.log
   about the ISA being corrupted.  

   I was able to correctly use this directive outside of a base.epl
   file, and it works as expected (ie as documented).

3. Just plain 'Execute'ing the code:
    (in base.epl)
    Execute ('defaults.epl');

   I didn't really expect this to work, but I thought what the hell.
   I did learn that the only files to contribute to the requested object
   namespace are the REQUESTED PAGE and the EMBPERL_OBJECT_BASE.  
   (not matter how many 'Execute's are in the base.epl) Is this correct? 

What I was able to do, albeit in a different way -- was to incorporate
the 'defaults.epl' as a separate object -- to be called when needed.  So
any file that wanted to use 'defaults', would do the following:
  [- $default = Execute({object=>'defaults.epl'}); -]

And it would now have these available via the $defaults object.   

This is acceptable, but I still think it would be better to implement my
original idea.  Is it possible to import code (with commands in
'base.epl') into the request object namespace?  The only way I have been
able to do this is by explicit declaration within the 'base.epl' file.

Am I missing something?

If there are any readers that have a better idea for an implementation,
or comments on mine -- input is welcome!

Cameron

PS -- this was all done using my test environment (in case that matters):  
Embperl: 2.0b5 / 2.0b7 (some under 1.3.4)
Perl:    5.6.0 (mod_perl 1.26)
Apache:  1.3.22
Configs: (analogous to previous posts - see them for details)


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Embperl Object Inheritance

Posted by Cameron McBride <ca...@cwru.edu>.
Hallo,

> > What I had in mind for Embperl (using the Embperl::Object stuff) was an
> > inheritance tree for the request object.  But I want my base.epl to be
> > in the middle:
> > (the order is via my understanding of precedence, most -> least)
> >
> >   REQUESTED PAGE  -->    base.epl    --> defaults.epl
> >  (the .html file)
> >
> >...
> > 2. Adding to the ISA array via 'Execute':
> >     (in base.epl)
> >     Execute ({isa=>'defaults.epl'});
> >
> 
> That's the correct way to go.

Good -- thanks for the clarification.

> >    Now, base.epl (being the EMBPERL_OBJECT_BASE) does not seem to like
> >    having an 'isa' assignment in it.  I get some error in embperl.log
> >    about the ISA being corrupted.
> >
> I assume you test this with b5 (or 1.3.x), because the error message isn't
> anymore in b7
> 
> This is only a warning. Does your code work?

Hmmmm, funny that -- it DOES work!

I am not sure what I did when it was nonfunctional, but it does seem to be 
working like expected (both in 2.0b5, 2.0b7).  I think I am doing the exact 
same thing.  Perhaps I had a syntax error and then saw the warning...
which led me to believe that was the cause.  

Thanks for helping me catch my own mistake...  ::sigh::

Cameron



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Embperl Object Inheritance

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

great that it works now! Please answer to the list also, other people may
have the same problem and are happy when they find the answer in the mailing
list archives....

Gerald

> Hallo,
>
> > > What I had in mind for Embperl (using the Embperl::Object stuff) was
an
> > > inheritance tree for the request object.  But I want my base.epl to be
> > > in the middle:
> > > (the order is via my understanding of precedence, most -> least)
> > >
> > >   REQUESTED PAGE  -->    base.epl    --> defaults.epl
> > >  (the .html file)
> > >
> > >...
> > > 2. Adding to the ISA array via 'Execute':
> > >     (in base.epl)
> > >     Execute ({isa=>'defaults.epl'});
> > >
> >
> > That's the correct way to go.
>
> Good -- thanks for the clarification.
>
> > >    Now, base.epl (being the EMBPERL_OBJECT_BASE) does not seem to like
> > >    having an 'isa' assignment in it.  I get some error in embperl.log
> > >    about the ISA being corrupted.
> > >
> > I assume you test this with b5 (or 1.3.x), because the error message
isn't
> > anymore in b7
> >
> > This is only a warning. Does your code work?
>
> Hmmmm, funny that -- it DOES work!
>
> I am not sure what I did when it was nonfunctional, but it does seem to be
> working like expected (both in 2.0b5, 2.0b7).  I think I am doing the
exact
> same thing.  Perhaps I had a syntax error and then saw the warning...
> which led me to believe that was the cause.
>
> Thanks for helping me catch my own mistake...  ::sigh::
>
> Cameron
>
>
>


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Embperl Object Inheritance

Posted by Gerald Richter <ri...@ecos.de>.
>
> What I had in mind for Embperl (using the Embperl::Object stuff) was an
> inheritance tree for the request object.  But I want my base.epl to be
> in the middle:
> (the order is via my understanding of precedence, most -> least)
>
>   REQUESTED PAGE  -->    base.epl    --> defaults.epl
>  (the .html file)
>
>...
> 2. Adding to the ISA array via 'Execute':
>     (in base.epl)
>     Execute ({isa=>'defaults.epl'});
>

That's the correct way to go.

>    Now, base.epl (being the EMBPERL_OBJECT_BASE) does not seem to like
>    having an 'isa' assignment in it.  I get some error in embperl.log
>    about the ISA being corrupted.
>
I assume you test this with b5 (or 1.3.x), because the error message isn't
anymore in b7

This is only a warning. Does your code work?

print out the @ISA array after the Execute, it should contain your module
(an numbered package name) and HTML::Embperl::Req. Does it?

Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org