Hi,

Luiz had already pointed out how to solve the problem with Embperl::Object,
I just want to add a few annotations


>
> Here's the initialization code:
>
>      use lib "$ENV{DOCUMENT_ROOT}/data/";
>      use lib "$ENV{DOCUMENT_ROOT}/data/SWC";
>      use SWC::Calendar;
>      use SWC::Commons;
>      use SWC::HashChain;
>

I would move this in a startup.pl file that is executed on server startup.
This is more memory efficient and you have one central place to set it up.

>
> Question #1. In that case, I used [! !].  Does that seem correct?
>

Yes, code inside [! !] is only executed once

> Question #2. Is there anyway to avoid the $ENV{DOCUMENT_ROOT} in
> specifying the inputfile?
>

You can either give a relative path, or use the EMBPERL_PATH config
directive to setup a search path.

PerlSetEnv EMBPERL_PATH  /path/to/lib

and then call it without any path element

Execute({inputfile => "IMH.epl", import => 1});


>
> Question #3. Any reason not to put that in a [! !]?
>

No

> Question #4. Any way to have a function that auto-executes on import?
> I can't just execute the file because then the routines aren't
> imported.  (Hmm, maybe I'm answering my own question here, I just put
> the initialization code in [! !] in the imported file and it seemed
> to work!)
>

Yes, [! !] is executed also on import

> Question #5. Is there a way to call the routines in an executed
> module by name, without having done an import?
>

In 1.3 not, in 2.0 you can

In 1.3 you have to write

      Execute({inputfile => "$ENV{DOCUMENT_ROOT}/data/IMH.epl", import  =>
0});
      Execute("$ENV{DOCUMENT_ROOT}/data/IMH.epl#Init');

in 2.0 the second statement is enough, but this will only call Init and
compile the code in IMH.epl, it will _not_ import any functions in your
current document. If you want to import function you need import => 1 and
both lines in 1.3 and 2.0.

BTW the second line is the same as

      Execute({inputfile => "$ENV{DOCUMENT_ROOT}/data/IMH.epl", sub =>
'Init'});

> Then I tried to simplify more.
>
> [-
>      Execute({inputfile => "$ENV{DOCUMENT_ROOT}/data/IMH.epl", import
> => 1, sub => 'Init'});
> -]
>
> This gets me into a very odd loop on my database which in retrospect
> may have a different cause, but also if I put the same code in my
> EmbperlObject template I get a rather different error.
> Call to unknown Embperl macro Init
>

You cannot use sub and import in the same call to Execute

> Question #6. Exactly how am I supposed to use 'sub =>' or am I
> looking at the wrong thing?
>

sub => will call the given [$sub xxx $]  in your page, but you can't use it
when import is given.

>
> I think I've got it down to this.
>
> Create a .epl file of library functions.  Put the initialization code
> in it in [! !] brackets.  Then load it from each page with
>
> [! Execute({inputfile => "$ENV{DOCUMENT_ROOT}/data/IMH.epl", import => 1})
!]
>
> Does that seem right?
>

Yes

> Finally one unrelated question.  I have a page which does some
> queries in the body.  For various reasons I'd rather not do them in
> the header of the page, but I want to set the page *title* to
> something from the database. I can do this in EmbperlObject using
> member functions called in the parent template, but I'm not using
> EmbperlObject in this case.  Is there any to do this with a regular
> page?

No

> I suspect I'm going to just have to use EmbperlObject.

Yes

Gerald


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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to