Config(3pm) | User Contributed Perl Documentation | Config(3pm) |
Embperl::Config - Embperl configuration and calling
Embperl can operate in one of four modes:
To use Embperl under mod_perl you must have installed Apache and mod_perl on your system. Then you add some directives to your httpd.conf to load Embperl and add "Embperl" as the "PerlHandler". The following directives will cause all file with extetion epl to be handled by Embperl:
PerlModule Embperl AddType text/html .epl <Files *.epl> SetHandler perl-script PerlHandler Embperl Options ExecCGI </files>
Another possibility is to have all files under a special location processed by Embperl:
PerlModule Embperl Alias /embperl /path/to/embperl/eg <Location /embperl/x> SetHandler perl-script PerlHandler Embperl Options ExecCGI </Location>
In this setup you should make sure that non Embperl files like images doesn't served from this directory.
For mod_perl 2.0 you need addtionaly to load the dynamic object library of Embperl. This is necessary so Embperl is loaded early enough to register the configuration directives with Apache. After installing, search underneath your Perl site directory for the library. On Unix it is mostly called Embperl.so on Windows it is called "Embperl.dll". Now add the following line to your httpd.conf before any of the Embperl configuration directives, but after mod_perl.so is loaded:
LoadModule embperl_module /path/to/perl/site/lib/Embperl/Embperl.so
To use Embperl::Object you use the "Embperl::Object" as "PerlHandler":
<Location /foo> Embperl_AppName unique-name Embperl_Object_Base base.htm Embperl_UriMatch "\.htm.?|\.epl$" SetHandler perl-script PerlHandler Embperl::Object Options ExecCGI </Location>
Addtionaly you can setup other parameters for Embperl::Object. If you do so inside a container (like "<Location", <Directory>, <Files>>) you need to set "Embperl_AppName" to a unique-name (the actual value doesn't matter). The "Embperl_UriMatch" makes sure that only files of the requested type are served by Embperl::Object, while all others are served by Apache as usual.
For more information see: "perldoc Embperl::Object".
Embperl accepts a lot of configuration directives to customize it's behaviour. See the next section for a description.
NOTE: If mod_perl is statically linked into Apache you can not use ClearModuleList in your httpd.conf
Preloading pages
To optimize memory usage you can preload your pages during the initialization. If you do so they will get loaded into the parent process and the memory will be shared by all child processes.
To let Embperl preload your files, you have to supply all the filename into the key preloadfiles of the hash %initparam, before you load Embperl.
Example:
BEGIN { $Embperl::initparam{preloadfiles} = [ '/path/to/foo.epl', '/path/to/bar.epl', { inputfile => "/path/to/other.epl", input_escmode => 7 }, ] ; } use Embperl ;
As you see for the third file, it is also possible to give a hashref and supply the same parameter like Execute accpets (see below).
NOTE: Preloading is not supported under Apache 1.3, when mod_perl is loaded as DSO. To use preloading under Apache 1.3 you need to compile mod_perl statically into Apache.
To use this mode you must copy embpcgi.pl to your cgi-bin directory. You can invoke it with the URL http://www.domain.xyz/cgi-bin/embpcgi.pl/url/of/your/document.
The /url/of/your/document will be passed to Embperl by the web server. Normal processing (aliasing, etc.) takes place before the URI makes it to PATH_TRANSLATED.
If you are running the Apache httpd, you can also define embpcgi.pl as a handler for a specific file extension or directory.
Example of Apache "httpd.conf":
<Directory /path/to/your/html/docs> Action text/html /cgi-bin/embperl/embpcgi.pl </Directory>
NOTE: Via CGI Scripts it maybe possible to bypass some of the Apache setup. To avoid this use Embperl_Allow to restrict access to the files, which should be processed by Embperl.
For Embperl::Object you have to use epocgi.pl instead of embpcgi.pl.
You can also run Embperl with FastCGI, in this case use embpfastcgi.pl as cgi script. You must have FCGI.pm installed.
Run Embperl from the comannd line use embpexec.pl on unix and embpexec.bat on windows:
embpexec.pl [options] htmlfile [query_string]
embpexec.bat [options] htmlfile [query_string]
Options:
"Execute" can be used to call Embperl from your own modules/scripts (for example from a Apache::Registry or CGI script) or from within another Embperl page to nest multiple Embperl pages (for example to store a common header or footer in a different file).
(See eg/x/Excute.pl for more detailed examples)
When you want to use Embperl::Object call "Embperl::Object::Execute", when you want Embperl::Mail, call "Embperl::Mail::Execute".
There are two forms you can use for calling Execute. A short form which only takes a filename and optional additional parameters or a long form which takes a hash reference as its argument.
Execute($filename, $p1, $p2, $pn) ;
This will cause Embperl to interpret the file with the name $filename and, if specified, pass any additional parameters in the array @param (just like @_ in a Perl subroutine). The above example could also be written in the long form:
Execute ({inputfile => $filename, param => [$p1, $p2, $pn]}) ;
The possible items for hash of the long form are are descriped in the configuration section and parameter section.
EXAMPLES for Execute:
# Get source from /path/to/your.html and # write output to /path/to/output' Embperl::Execute ({ inputfile => '/path/to/your.html', outputfile => '/path/to/output'}) ; # Get source from scalar and write output to stdout # Don't forget to modify mtime if $src changes $src = '<html><head><title>Page [+ $no +]</title></head>' ; Embperl::Execute ({ inputfile => 'some name', input => \$src, mtime => 1 }) ; # Get source from scalar and write output to another scalar my $src = '<html><head><title>Page [+ $no +]</title></head>' ; my $out ; Embperl::Execute ({ inputfile => 'another name', input => \$src, mtime => 1, output => \$out }) ; print $out ; # Include a common header in an Embperl page, # which is stored in /path/to/head.html [- Execute ('/path/to/head.html') -]
Starting with 2.0b2 Embperl files can debugged via the interactive debugger. The debugger shows the Embperl page source along with the correct linenumbers. You can do anything you can do inside a normal Perl program via the debugger, e.g. show variables, modify variables, single step, set breakpoints etc.
You can use the Perl interacive command line debugger via
perl -d embpexec.pl file.epl
or if you prefer a graphical debugger, try ddd (http://www.gnu.org/software/ddd/) it's a great tool, also for debugging any other perl script:
ddd --debugger 'perl -d embpexec.pl file.epl'
NOTE: embpexec.pl could be found in the Embperl source directory
If you want to debug your pages, while running under mod_perl, Apache::DB is the right thing. Apache::DB is available from CPAN.
Configuration can be setup in different ways, depending how you run Embperl. When you run under mod_perl, Embperl add a set of new configuration directives to the Apache configuration, so you can set them in your httpd.conf. When you run Embperl as CGI it takes the configuration from environment variables. For compatibility reason that can also be turned on under mod_perl, by adding "Embperl_UseEnv on" in your httpd.conf. When you call Embperl from another Perl program, by calling the "Execute" function, you can pass your configuration along with other parameters as a hash reference. If you pass "use_env =< 1" als parameter Embperl will also scan the environment for configuration information. Last but not least you can pass configuration information as options when you run Embperl via embpexec.pl from the command line. Some of the configuration options are also setable inside the page via the Empberl objects and you can read the current configuration from these objects.
You can not only pass configuration in different ways, there are also three different contexts: Application, Request and Component. A application describes a set of pages/files that belongs together and form the application. Application level configuration are the same for all files that belongs to an application. These configuration information need to be known before any request processing takes place, so they can't be modified during a request. Every application has it's own name. You can refer the configuration of an application, by simply setting the name of the application to use.
Request level configuration information applies to one request, some of them must be known before the request starts, some of them can still be modified during the request.
Configuration for components can be setup before the request, but can also be passed as argument when you call the component via "Execute".
Tells Embperl to scan the enviromemt for configuration settings.
Tells Embperl to scan the enviromemt for configuration settings which has the prefix "REDIRECT_". This is normally the case when the request is not the main request, but a subrequest.
Specifies the name for an application. The name is basically used to refer to this application elsewhere in httpd.conf without the need to setup the parameters for the apllication again.
Embperl will call the "init" method of the given class at the start of the request, but after all request parameters are setup. This give the class a chance to do any necessary computation and modify the request parameters, before the request is actualy executed. See internationalization for an example.
Set the class that performs the Embperl session handling. This gives you the possibility to implement your own session handling.
NOTE: Default until 1.3.3 was "HTML::Embperl::Session", starting with 1.3.4 it is "Apache::SessionX". To get the old session behaviour set it to "HTML::Embperl::Session".
List of arguments for Apache::Session classes Arguments that contains spaces can be quoted. Example:
EMBPERL_SESSION_ARGS "DataSource=dbi:mysql:session UserName=www 'Password=secret word'"
Space separated list of object store and lock manager (and optionally the serialization and id generating class) for Apache::Session (see "Session handling")
Selects a session configuration from the configurations you have defined when running Apache::SessionX's "Makefile.PL".
NOTE: Use either "EMBPERL_SESSION_CONFIG" or "EMBPERL_SESSION_ARGS" and "EMBPERL_SESSION_CLASSES"
Set the name that Embperl uses when it sends the cookie with the session id.
Set the domain that Embperl uses for the cookie with the session id.
Set the path that Embperl uses for the cookie with the session id.
Set the expiration date that Embperl uses for the cookie with the session id. You can specify the full date or relativ values. The following forms are all valid times:
+30s 30 seconds from now +10m ten minutes from now +1h one hour from now -1d yesterday (i.e. "ASAP!") now immediately +3M in three months +10y in ten years time Thu, 25-Apr-1999 00:40:33 GMT at the indicated time & date
Set the secure flag of cookie that Embperl uses for the session id. If set the cookie will only be transferred over a secured connection.
Gives the location of the log file. This will contain information about what Embperl is doing. The amount of information depends on the debug settings (see "EMBPERL_DEBUG" below). The log output is intended to show what your embedded Perl code is doing and to help debug it.
This is a bitmask which specifies what should be written to the log. To specify multiple debugflags, simply add the values together. You can give the value a decimal, octal (prefix 0) or hexadecimal (prefix 0x) value. You can also use the constants defined in Embperl::Constant. The following values are defined:
Inserts a link at the top of each page which can be used to view the log for the current HTML file. See also "EMBPERL_VIRTLOG".
Example:
EMBPERL_DEBUG 10477 EMBPERL_VIRTLOG /embperl/log.htm <Location /embperl/log.htm> SetHandler perl-script PerlHandler Embperl Options ExecCGI </Location>
Debug value pass to Net::SMTP.
Specifies which host the mail related functions of Embperl uses as SMTP server.
Specifies which host/domain all mailrealted function uses in the HELO/EHLO command. A reasonable default is normally chosen by Net::SMTP, but depending on your installation it may necessary to set it manualy.
Specifies the email address that is used as sender all mailrelted function.
If set all errors will be send to the email address given.
Do not mail more then <num> errors. Set to 0 for no limit.
Reset error counter if for <sec> seconds no error has occurred.
Mail errors of <sec> seconds regardless of the error counter.
Name of the base page that Embperl::Objects searches for.
Filename of the application object that Embperl::Object searches for. The file should contain the Perl code for the application object. There must be no package name given (as the package is set by Embperl::Object) inside the file, but the @ISA should point to Embperl::App. If set this file is searched through the same search path as any content file. After a successful load the init method is called with the Embperl request object as parameter. The init method can change the parameters inside the request object to influence the current request.
Additional directories where Embperl::Object searches for pages.
This search through the searchpath is always performed if in a call to Execute no path for the file is given.
In httpd.conf or as environment variable directories are separated by ";" (on Unix ":" works also). The parameter for "Execute" and the application object method expects/returns an array reference. This path is always appended to the searchpath.
Additional directories where Embperl::Object searches for files for the initial request.
If a file is requested, but cannot be found at the given location, the directories given in the this path are additionally searched for the file. This applies only to the initial filename given to Embperl::Object and not to files called via Execute.
In httpd.conf or as environment variable directories are separated by ";" (on Unix ":" works also). The parameter for "Execute" and the application object method expects/returns an array reference.
Example:
if you say
Embperl_Object_Reqpath /a:/b:/c
and you request
/x/index.epl
it will try
/x/index.epl /a/index.epl /b/index.epl /c/index.epl
and take the first one that is found.
Directory where Embperl::Object stops searching for the base page.
If the requested file is not found by Embperl::Object, the file given by "EMBPERL_OBJECT_FALLBACK" is displayed instead. If "EMBPERL_OBJECT_FALLBACK" isn't set a staus 404, NOT_FOUND is returned as usual. If the fileame given in "EMBPERL_OBJECT_FALLBACK" doesn't contain a path, it is searched thru the same directories as "EMBPERL_OBJECT_BASE".
If you specify this, the template base and the requested page inherit all methods from this class. This class must contain "Embperl::Req" in his @ISA array.
Tells Embperl to scan the enviromemt for configuration settings.
Tells Embperl to scan the enviromemt for configuration settings which has the prefix "REDIRECT_". This is normally the case when the request is not the main request, but a subrequest.
If specified, only files which match the given perl regular expression will be processed by Embperl. All other files will return FORBIDDEN. This is especially useful in a CGI environment by making the server more secure.
If specified, only files which match the given perl regular expression will be processed by Embperl, all other files will be handled by the standard Apache handler. This can be useful if you have Embperl documents and non Embperl documents (e.g. gifs) residing in the same directory.
Example: # Only files which end with .htm will processed by Embperl EMBPERL_URIMATCH \.htm$
Specifies the character that is used to separate multiple form values with the same name.
Can contain a semicolon (also colon under Unix) separated file search path. When a file is processed and the filename isn't an absolute path or does not start with ./ (or .\ under windows), Embperl searches all the specified directories for that file.
A special handling is done if the filename starts with any number of "../" i.e. refers to an upper directory. Then Embperl strips the same number of entries at the start of the searchpath as the filename contains "../". "Execute" and the method of the request object expects/returns a array ref.
See application configuration for an describtion of possible values
This bitmask specifies some options for the execution of Embperl. To specify multiple options, simply add the values together.
$errors = $req_rec -> prev -> pnotes('EMBPERL_ERRORS') ;
where $errors is a array reference. (1.3b5+)
Set the desired output format. 0 for HTML and 1 XML. If set to XML all tags that are generated by Embperl will contain a closing slash to conform to XML specs. e.g.
<input type="text" name="foo" />
NOTE: If you set output_mode to XML you should also change escmode to XML escaping.
Set the charset which to assume when escaping. This can only be set before the request starts (e.g. httpd.conf or top of the page). Setting it inside the page has undefined results.
Specifies how the id for the session data is passed between requests. Possible values are:
You may add the UDat and SDat values together to get both sorts of sessions, for example the value 0x21 will pass the id for the user session inside a cookie and the id for the state session as parameters.
Tells Embperl to scan the enviromemt for configuration settings.
Tells Embperl to scan the enviromemt for configuration settings which has the prefix "REDIRECT_". This is normally the case when the request is not the main request, but a subrequest.
The name of the package where your code will be executed. By default, Embperl generates a unique package name for every file. This ensures that variables and functions from one file do not conflict with those of another file. (Any package's variables will still be accessible with explicit package names.)
See application configuration for an describtion of possible values
This bitmask specifies some options for the execution of Embperl. To specify multiple options, simply add the values together.
$errors = $req_rec -> prev -> pnotes('EMBPERL_ERRORS') ;
where $errors is a array reference. (1.3b5+)
If this option is set Embperl will never set the UTF-8 on any data in %fdat.
Turn HTML and URL escaping on and off.
NOTE: If you want to output binary data, you must set the escmode to zero.
For convenience you can change the escmode inside a page by setting the variable $escmode.
NOTE: You can localize $escmode inside a [+ +] block, e.g. to turn escaping temporary off and output $data write
[+ do { local $escmode = 0 ; $data } +]
Tells Embperl how to handle escape sequences that are found in the source.
Add 4 to remove html tags inside of Perl code. This is helpful when an html editor insert html tags like <br> inside your Perl code.
Set EMBPERL_INPUT_ESCMODE to 7 to get the old default of Embperl < 2.0b6
Set EMBPERL_INPUT_ESCMODE to 0 to get the old behaviour when optRawInput was set.
If set to the value "utf8" the source is interpreted as utf8 encoded so you can use utf8 literals. It has the same effect as adding "use utf8" to a normal Perl script.
Give a pieces of code that is include at the very top of every file.
Example:
Embperl_Top_Include "use MY::Module;"
This will cause MY::Module to be used in every page. Note that Embperl_Top_Include must contain valid Perl code and must be ended with a semicolon.
NOTE: If you pass top_include as parameter to Execute it is only used in case the code is compiled (or recompiled) and not cached.
literal string that is appended to the cache key
Tells Embperl how to create a key for caching of the output
Function that is called every time before data is taken from the cache. If this function returns true, the data from the cache isn't used anymore, but rebuilt.
Function could be either a coderef (when passed to Execute), a name of a subroutine or a string starting with "sub " in which case it is compiled as anonymous subroutine.
NOTE: If &EXPIRES is defined inside the page, it get evaluated before the excecution of the page
function that should be called when build a cache key. The result is appended to the cache key.
Time in seconds that the output should be cached. (0 = never, -1 = forever)
NOTE: If $EXPIRES is set inside the page, it get evaluated before the excecution of the page
Cache should be expired when the given file is modified.
Used to tell Embperl which syntax to use inside a page. Embperl comes with the following syntaxes:
You can get a description for each syntax if you type
perldoc Embperl::Syntax::xxx
where 'xxx' is the name of the syntax.
You can also specify multiple syntaxes e.g.
EMBPERL_SYNTAX "Embperl SSI" Execute ({inputfile => '*', syntax => 'Embperl ASP'}) ;
The 'syntax' metacommand allows you to switch the syntax or to add or subtract syntaxes e.g.
[$ syntax + Mail $]
will add the Mail taglib so the <mail:send> tag is available after this line.
[$ syntax - Mail $]
now the <mail:send> tag is unknown again
[$ syntax SSI $]
now you can only use SSI commands inside your page.
Tells Embperl which recipe to use to process this component
Tell the xslt processor which stylsheet to use.
Tells Embperl which xslt processor to use. Current "libxslt" and "xalan" are supported by Embperl, but they must be compiled in to be available.
Parameters gives addtionaly information about the current request or the execution of the current component. So we have two sorts of parameters Request and Component parameters. Request parameters are automatically setup by Embperl with information Embperl takes from the current running environment. When Embperl is invoked via the "Execute" function, you can pass any of the parameters to Execute. Component parameters mainly reflect the parameters given to "Execute".
Gives the filename of the file that was actualy requested. Inside of the applications "init" function it can be changed to force Embperl to serve a different file.
The full unparsed_uri, includeing the query_string and the path_info.
The decoded path of the unparsed_uri.
URL of the server of the current request in the form schema://addr:port/ e.g. http://perl.apache.org/ (port is omitted if it is an default port)
The path_info, that is anything in the path after the file the is currently served.
Any parameters passed in a GET request after the question mark. The hash %fdat will contain these values in a already decoded and easy to use way. So it's normly more convenient to use %fdat instead.
The primary langange found in the browser "Accept-Language" HTTP header. This value is used for all language-dependent functions inside Embperl. You can set it change the selection of message returned by "$request -> gettext" and "[= =]".
A hashref that contains all cookies send by the browser to the server.
Holds the CGI.pm object, which is used for file upload. If no file uploaded data is send to the request, this member is undefined.
Give the name of the file that should be processed, e.g.
Execute({inputfile => 'mysource.epl'}) ;
There is a shortcut when you only need to give the input file and no other parameters. The above is will do the same as:
Execute('mysource.epl') ;
Specify a file to which the output should be written. Example:
Execute({inputfile => 'mysource.epl', outputfile => 'myoutput.htm'}) ;
This parameter is used, when you have the source already in memory. You should pass a reference to a scalar that contains the source. Addtionaly you should give the inputfile parameter, to allow Embperl caching to keep track of different in memory sources. The mtime parameter is used to tell Embperl's cache if the source has change since the last call or not. If "mtime" if "undef" or of a different value as it was during the last call, the source is considered to be changed and everything is recompiled. Example:
# Get source from scalar # Don't forget to modify mtime if $src changes $src = '<html><head><title>Page [+ $no +]</title></head>' ; Embperl::Execute ({ inputfile => 'some name', input => \$src, mtime => 1 }) ;
Gives the possibility to write the output into a scalar instead of sending it to stdout or a file. You should give a reference to a scalar. Example:
Execute({inputfile => 'mysource.epl', output => \$out}) ;
Call the given Embperl subroutine defined with "[$sub$]" inside the page. A shortcut for this is to append the name of the subroutine after the filename with a hash sign, so the following calls are doing the same thing:
Execute('mysource.epl#mysub') ; Execute({inputfile => 'mysource.epl', sub => 'mysub'}) ;
If you leave out the filename, the sub is called in the current file, so this can only be used inside a file that is already processed by Embperl.
This utilizies Apache 2.0 filters to retrieve the output of a sub-request and uses it as input for the current component. For example if you have a CGI-Script and you need to post process it via Embperl or simply want to include it's output in another Embperl/Embperl::Object document you can write:
[- Execute ({subreq => '/cgi-bin/script.cgi'}) -]
NOTE: You have to specify a URI and not a filename!
A value of one tells Embperl to define the subrountines inside the file (if not already done) and to import them as perl subroutines into the current namespace.
See [$ sub $] metacommand and section about subroutines for more info.
A value of zero tells Embperl to simply precompile all code found in the page. (With 2.0 it is not necessary anymore to do it before using the "sub" parameter on a different file).
Specifies the first linenumber of the sourcefile.
Last modification time of parameter input. If undef the code passed by input is always recompiled, else the code is only recompiled if mtime changes.
Can be used to pass parameters to the Embperl document and back. Must contain a reference to an array. Example:
Execute({inputfile => 'mysource.epl', param => [1, 2, 3]}) ; Execute({inputfile => 'mysource.epl', param => \@parameters}) ;
There is a shortcut, so the following code the aquivalent (NOTE: Don't use a array ref here):
Execute('mysource.epl', 1, 2, 3) ; Execute('mysource.epl', @parameters) ;
The array @param in the Embperl document is setup as an alias to the array. See eg/x/Excute.pl for a more detailed example.
Pass a hash reference to customly set %fdat. If "ffld" is not given, "ffld" will be set to "keys %fdat".
Pass a array reference to customly set @fdat. Does not affect %fdat.
Takes a filename and returns an hashref that is blessed into the package of the given file. That's useful, if you want to call the subs inside the given file, as methods. By using the "isa" parameter (see below) you are able to provide an inherence tree. Additionally you can use the returned hashref to store data for that object. Example:
[# the file eposubs.htm defines two subs: txt1 and txt2 #] [# first we create a new object #] [- $subs = Execute ({'object' => 'eposubs.htm'}) -] [# then we call methods inside the object #] txt1: [+ $subs -> txt1 +] <br> txt2: [+ $subs -> txt2 +] <br>
Takes a name of a file and pushes the package of that file into the @ISA array of the current file. By using this you can setup an inherence tree between Embperl documents. Is is also useful within Embperl::Object. Example:
[! Execute ({'isa' => '../eposubs.htm'}) !]
Takes a reference to an array. Upon return, the array will contain a copy of all errormessages, if any.
Takes a reference to hash which contains key/value pair that are accessible inside the stylesheet via <xsl:param>.
There are three major objects in Embperl: application, request and component. Each of these objects can be used to get information about the processing and control the execution. Each of these objects has a config sub-object, which makes the configuration accessible and, where possible, changeable at runtime. The "config" method of these three objects returns a reference to the configuration object. The methods of these configurations objects are described in the section Configuration. The request and the component object have addtionaly a parameter sub-object, which holds parameters passed to the current request/component. The "param" method of these two objects returns the parameter sub-object. The methods of these parameter objects can be found in the section Parameters. Addtionaly each of the three major objects has a set of own methods, which are described here.
Returns a reference to a object which hold per threads information. There is only one such object per thread.
Returns a reference to the current request object i.e. the object of the request currently running.
Returns a reference to the configuration object of the application. See section Configuration.
Returns a reference to the user session object.
Returns a reference to the state session object.
Returns a reference to the application session object.
Returns a reference to a hash which contains the data of the user session. This has can be used to access and modify user session data. It's the same as accessing the global %udat.
Returns a reference to a hash which contains the data of the state session. This has can be used to access and modify state session data. It's the same as accessing the global %sdat.
Returns a reference to a hash which contains the data of the application session. This has can be used to access and modify application session data. It's the same as accessing the global %mdat.
Contains the number of errors since last time send per mail. See also mail_errors_to.
Time when the last error has occurred. See also mail_errors_to.
Time when the last mail with error messages was sent. See also mail_errors_to.
Returns a reference to mod_perls Apache request object. In mod_perl 1 this is of type "Apache::" in mod_perl 2 it's a "Apache2::RequestRec".
Returns a reference to the configuration object of the request. See section Configuration.
Returns a reference to the parameter object of the request. See section Parameters.
Returns a reference to the object of component currently running. See component methods below.
Returns a reference to the object of application to which the current request belongs. See application methods above.
Returns a reference to a object which hold per threads information. There is only one such object per thread.
Returns the number of request handled so far by this child process.
Start time of the current request.
Set to true if session management is available.
Combined id of current user and state session.
Id of the current state session as received by the browser, this means this method returns "undef" for a new session.
Id of the current user session as received by the browser, this means this method returns "undef" for a new session.
Can be used to retrieve the actual expiration date that Embperl uses for the cookie with the session id.
True if exit was called in one of the components processed so far.
File possition of the log file at the time when the request has started.
True if there were any error during the request.
Reference to an array which holds all error messages occurred so far.
Additional information passed to the error handler when an error is reported.
Additional information passed to the error handler when an error is reported.
Last warning message.
The object passed to the last die, if any. This is useful when you pass an object to die inside an Execute. After the Execute you can check $epreq -> errobj, to get the object. The object is also push to the array passed to the errors parameter of Execute.
Reference to an array which is filled with references to variables that should be cleaned up after the request. You can add your own variables that needs cleanup here, but you should never remove any variables from this array.
Reference to a hash which contains all packages that must be cleaned up after the request.
Working directory when the request started.
Reference to an array of hashs of messages. This is used by Embperl to translate message into different languages. When a "[= =]" block is processed or $request -> gettext is called, Embperl searches this array. It starts from the first element in the array (each element in the array must be a hashref) and tries to lookup the text for the given symbol in hash. When it fails it goes to the next array element. This way you can setup multiple translation tables that are search for the symbol. Example:
%messages = ( 'de' => { 'addsel1' => 'Klicken Sie auf die Kategorie zu der Sie etwas hinzufügen möchten:', 'addsel2' => 'oder fügen Sie eine neue Kategorie hinzu. Bitte geben Sie die Beschreibung in so vielen Sprachen wie Ihnen möglich ein.', 'addsel3' => 'Falls Sie die Übersetzung nicht wissen, lassen Sie das entsprechende Eingabefeld leer.', 'addsel4' => 'Kategorie hinzufügen', }, 'en' => { 'addsel1' => 'Click on the category for which you want to add a new item:', 'addsel2' => 'or add new category. Please enter the description in as much languages as possible.', 'addsel3' => 'If you don\'t know the translation leave the corresponding input field empty.', 'addsel4' => 'Add category', } ) ; $lang = $request -> param -> language ; push @{$request -> messages}, $messages{$lang} ; push @{$request -> default_messages}, $messages{'en'} if ($lang ne 'en') ;
"$request -" param -> language> retrieves the language as given by the browser language-accept header (or set before in your program). Then it pushes the german or english messages hash onto the message array. Addtionaly it pushes the english messages on the default_messages array. Messages will be taken from this array if nothing can be found in the messages array.
Reference to an array with default messages. Messages will be taken from this array if nothing can be found in the messages array.
Returns an reference to the configuration object of the component.
Returns an reference to the parameter object of the component.
True if Embperl is inside of the execution of the request.
True is this is not the outermost Embperl component, i.e. this component is called from within another component.
True is we are inside a Embperl subroutine ([$ sub $] ... [$ endsub $])
True if the exit was called during the excution of the component.
Tells Embperl how much parts of the path should be ignored when searching through the path.
Directory of the source file of the component.
Source file of the component.
Syntax of the component
Previous component, e.g. the component which called this component.
While importing a component this is set to the stash to which symbols are imported. "undef" during normal execution.
Symbols that should be exported by this component.
Name of the package the component is executed in.
Only valid during compile phase. Can used to retrieve and modify the code Embperl is generating. See Embperl::Syntax for more details and Embperl::Syntax::RTF for an example.
2023-01-22 | perl v5.36.0 |