You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Nicolas Parody <in...@nicodev.com> on 2001/04/29 22:44:54 UTC

EmbperlObject Execute Order

Hi,

I have been using the EmbperlObject Feature of Embperl and have to say that I love it. However I suddenly arrived at a problem that I didn't have before when using vanilla cgi.
I have most of my code in a seperate file and just call the appropriate function in whichever file is called by 'Execute("*")'. I also have a status bar (login status etc..) on top of each document that is inserted via 'Execute("status.epl")' in 'base.epl'.
The problem is that status.epl is called before Execute("*") and so doesn't reflect the actual status. For example the code that logs people in is in the 'login_confirm.epl' that is called with 'Execute("*")'.

Is there a way to force Embperl to execute the * portion first? How have others solved this problem?

Thanks,

Nico

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


Re: EmbperlObject Execute Order

Posted by Nicolas Parody <in...@nicodev.com>.
Thanks for the quick reply.
But unfortunately after looking at the example I still do not know how i could solve my problem. Maybe I didn't describe it very well.
I am calling a module function in login.html that checks user name and password and sets the global $user_id. Problem is that the status.html is executed before login.html and is therefore displaying an old value. I do not understand how I could solve this by using method calls.

Nico
 
>>
>> Is there a way to force Embperl to execute the * portion first? How have others solved this problem?
>>
> 
>You can use method calls to solve this problem. Look at the example in the EMbperlObject documenation:
> 
>http://perl.apache.org/embperl/EmbperlObject.pod.5.html#Example_for_using_method_calls
> 
>This example shows different things. The piece that apply to your problem, is how the title is build. The actual file defines a method title, that could be call _before_ the Execute ('*')
> 
>Hope this helps
> 
>Gerald

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


Re: EmbperlObject Execute Order

Posted by Gerald Richter <ri...@ecos.de>.
>
> The above works perfectly however it doesn't work in my project since I
have all my functions in a seperate file.
> I tried doing this in my page:
>
> [- $subs = $param[0] -]
> [! sub getstatus { return $subs->status } !]
>
> But unfortunately I get the following error message: 'Can't call method
"status" on an undefined value at....'
>

Yes, because $subs will not be defined at the time you call your subroutine.

One possibility is to change it to

[! sub getstatus { return $_[1]->status } !]

and call it like

[- $r -> getstatus ($subs) -]

or you can add your subs object to the request data, so you don't have to
pass it everytime as argument:


[! sub getstatus { return $_[0]->{subs}->status } !]

and call it like

[-
$r -> {subs} = $subs ;
$r -> getstatus  ;
-]

> Is there some other way I can separate my functions from the individual
pages and get an accurate status. Or am I going in the totally wrong
direction and should I instead do things with plain Embperl instead of
EmbperlObject????
>

It depends on what you want to do. From what I hear so far, I think
EmbperlObject is alright for you.

> Is there really no way to force Embperl to Execute the (*) part first?

The Execute order defines where in your output the resulting HTML is places.
So Executeing (*) first changes your output.

> Surely this would make sense for most applications and would make things a
lot simpler. Also it would make it easier to port from plain CGI?

And how do you define where the output goes ?

Suggestions are always welcome to improve Embperl

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


Re: EmbperlObject Execute Order

Posted by Nicolas Parody <in...@nicodev.com>.
On Wed, May 02, 2001 at 05:33:46AM +0200, Gerald Richter wrote:
> 
> 
> Your files (that are invoked via Execute ('*') ), defines a method, for
> example getstatus, this method returns what ever information is needed, your
> status page now can call this method, also the actual file isn't executed so
> far:
> 
> status.epl:
> 
> [-
> $r = shift ; # get EMbperl request object
> $status = $r -> getstatus ; # retrived status of current page
> -]
> 
> in your page:
> 
> [!
> sub getstatus
>     {
>     return "What ever you want" ;
>     }
> !]
> 

The above works perfectly however it doesn't work in my project since I have all my functions in a seperate file.
I tried doing this in my page:

[- $subs = $param[0] -]
[! sub getstatus { return $subs->status } !]

But unfortunately I get the following error message: 'Can't call method "status" on an undefined value at....'

Is there some other way I can separate my functions from the individual pages and get an accurate status. Or am I going in the totally wrong direction and should I instead do things with plain Embperl instead of EmbperlObject????

Thanks for any suggestions,

Nico

> 
> 
> > Nico
> >
> > >>
> > >> Is there a way to force Embperl to execute the * portion first? How
> have others solved this problem?
> > >>
> > >
> > >You can use method calls to solve this problem. Look at the example in
> the EMbperlObject documenation:
> > >
> >
> >http://perl.apache.org/embperl/EmbperlObject.pod.5.html#Example_for_using_m
> ethod_calls
> > >
> > >This example shows different things. The piece that apply to your
> problem, is how the title is build. The actual file defines a method title,
> that could be call _before_ the Execute ('*')
> > >
> > >Hope this helps
> > >
> > >Gerald
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
> 

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


Re: EmbperlObject Execute Order

Posted by Nicolas Parody <in...@nicodev.com>.
Is there really no way to force Embperl to Execute the (*) part first?
Surely this would make sense for most applications and would make things a lot simpler. Also it would make it easier to port from plain CGI?

Nico

On Wed, May 02, 2001 at 05:33:46AM +0200, Gerald Richter wrote:
> 
> 
> > Thanks for the quick reply.
> > But unfortunately after looking at the example I still do not know how i
> could solve my problem. Maybe I didn't describe it very well.
> > I am calling a module function in login.html that checks user name and
> password and sets the global $user_id. Problem is that the status.html is
> executed before login.html and is therefore displaying an old value. I do
> not understand how I could solve this by using method calls.
> >
> 
> Your files (that are invoked via Execute ('*') ), defines a method, for
> example getstatus, this method returns what ever information is needed, your
> status page now can call this method, also the actual file isn't executed so
> far:
> 
> status.epl:
> 
> [-
> $r = shift ; # get EMbperl request object
> $status = $r -> getstatus ; # retrived status of current page
> -]
> 
> in your page:
> 
> [!
> sub getstatus
>     {
>     return "What ever you want" ;
>     }
> !]
> 
> You may define a default implementation, in your base template, that is
> called when the actual page doesn't define a getstatus method:
> 
> [!
> sub getstatus
>     {
>     return "unknown" ;
>     }
> !]
> 
> Is this more clear now, or is this not what you need ?
> 
> 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
> -------------------------------------------------------------
> 
> 
> > Nico
> >
> > >>
> > >> Is there a way to force Embperl to execute the * portion first? How
> have others solved this problem?
> > >>
> > >
> > >You can use method calls to solve this problem. Look at the example in
> the EMbperlObject documenation:
> > >
> >
> >http://perl.apache.org/embperl/EmbperlObject.pod.5.html#Example_for_using_m
> ethod_calls
> > >
> > >This example shows different things. The piece that apply to your
> problem, is how the title is build. The actual file defines a method title,
> that could be call _before_ the Execute ('*')
> > >
> > >Hope this helps
> > >
> > >Gerald
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
> 

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


Re: EmbperlObject Execute Order

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

> Thanks for the quick reply.
> But unfortunately after looking at the example I still do not know how i
could solve my problem. Maybe I didn't describe it very well.
> I am calling a module function in login.html that checks user name and
password and sets the global $user_id. Problem is that the status.html is
executed before login.html and is therefore displaying an old value. I do
not understand how I could solve this by using method calls.
>

Your files (that are invoked via Execute ('*') ), defines a method, for
example getstatus, this method returns what ever information is needed, your
status page now can call this method, also the actual file isn't executed so
far:

status.epl:

[-
$r = shift ; # get EMbperl request object
$status = $r -> getstatus ; # retrived status of current page
-]

in your page:

[!
sub getstatus
    {
    return "What ever you want" ;
    }
!]

You may define a default implementation, in your base template, that is
called when the actual page doesn't define a getstatus method:

[!
sub getstatus
    {
    return "unknown" ;
    }
!]

Is this more clear now, or is this not what you need ?

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
-------------------------------------------------------------


> Nico
>
> >>
> >> Is there a way to force Embperl to execute the * portion first? How
have others solved this problem?
> >>
> >
> >You can use method calls to solve this problem. Look at the example in
the EMbperlObject documenation:
> >
>
>http://perl.apache.org/embperl/EmbperlObject.pod.5.html#Example_for_using_m
ethod_calls
> >
> >This example shows different things. The piece that apply to your
problem, is how the title is build. The actual file defines a method title,
that could be call _before_ the Execute ('*')
> >
> >Hope this helps
> >
> >Gerald
>
>


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


Re: EmbperlObject Execute Order

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

>
> Is there a way to force Embperl to execute the * portion first? How have
others solved this problem?
>

You can use method calls to solve this problem. Look at the example in the
EMbperlObject documenation:

http://perl.apache.org/embperl/EmbperlObject.pod.5.html#Example_for_using_me
thod_calls

This example shows different things. The piece that apply to your problem,
is how the title is build. The actual file defines a method title, that
could be call _before_ the Execute ('*')

Hope this helps

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


Re: Help needed with make test error

Posted by Gerald Richter <ri...@ecos.de>.
> EmbperlObject/sub/epopage2.htm ...
> Error in Line 6
> Is:     > <h1>head from foo</h1><
> Should: > <h1>another head from sub</h1><

That is strange, never seen this before. Could you send me test/tmp/test.log
file (via private email) ?

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


Help needed with make test error

Posted by Gary Nielson <gn...@charlotte.infi.net>.
Hi,

I am trying to install HTML-Embperl-1.3.1 on a Redhat 5.2 machine running
perl version 5.004_04. I installed File-Spec-0.82, and it appears that I
have all the other modules that INSTALL.pod says are optional. 

When I run make test, I get the following error. Can anyone help me
figure out how to get around this?:

Testing Execute function...

div.htm from file...          ok
div.htm from memory...        ok
div.htm to memory...          ok
div.htm from/to memory...     ok
error.htm to memory...        ok
EmbperlObject/epopage1.htm ...ok
EmbperlObject/sub/epopage2.htm ...
Error in Line 6
Is:     > <h1>head from foo</h1><
Should: > <h1>another head from sub</h1><
Input:          EmbperlObject/sub/epopage2.htm
Output:         test/tmp/out.htm
Compared to:    test/cmp/epopage2.htm
Log:            test/tmp/test.log
Testparameter:
  cgi = 0
  offline = 0

 ERRORS detected! NOT all test have been passed successfully

make: *** [test_dynamic] Error 6


-- 
Gary Nielson
gary@garynielson.com





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