Embperl - building dynamic websites with Perl


Embperl's Objects
[ << Prev: Parameters ] [ Content ]

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.



threadtop
 

Method:

 

$application -> thread [read only]

 

Since:

 

2.0b6

Returns a reference to a object which hold per threads information. There is only one such object per thread.



curr_reqtop
 

Method:

 

$application -> curr_req [read only]

 

Since:

 

2.0b6

Returns a reference to the current request object i.e. the object of the request currently running.



configtop
 

Method:

 

$application -> config [read only]

 

Since:

 

2.0b6

Returns a reference to the configuration object of the application. See section Configuration.



user_sessiontop
 

Method:

 

$application -> user_session [read only]

 

Since:

 

2.0b6

Returns a reference to the user session object.



state_sessiontop
 

Method:

 

$application -> state_session [read only]

 

Since:

 

2.0b6

Returns a reference to the state session object.



app_sessiontop
 

Method:

 

$application -> app_session [read only]

 

Since:

 

2.0b6

Returns a reference to the application session object.



udattop
 

Method:

 

$application -> udat [read only]

 

Since:

 

2.0b6

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.



sdattop
 

Method:

 

$application -> sdat [read only]

 

Since:

 

2.0b6

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.



mdattop
 

Method:

 

$application -> mdat [read only]

 

Since:

 

2.0b6

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.



errors_counttop
 

Method:

 

$application -> errors_count

 

Since:

 

2.0b6

Contains the number of errors since last time send per mail. See also mail_errors_to.



errors_last_timetop
 

Method:

 

$application -> errors_last_time

 

Since:

 

2.0b6

Time when the last error has occurred. See also mail_errors_to.



errors_last_send_timetop
 

Method:

 

$application -> errors_last_send_time

 

Since:

 

2.0b6

Time when the last mail with error messages was sent. See also mail_errors_to.



apache_reqtop
 

Method:

 

$request -> apache_req [read only]

 

Since:

 

2.0b6

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.



configtop
 

Method:

 

$request -> config [read only]

 

Since:

 

2.0b6

Returns a reference to the configuration object of the request. See section Configuration.



paramtop
 

Method:

 

$request -> param [read only]

 

Since:

 

2.0b6

Returns a reference to the parameter object of the request. See section Parameters.



componenttop
 

Method:

 

$request -> component [read only]

 

Since:

 

2.0b6

Returns a reference to the object of component currently running. See component methods below.



apptop
 

Method:

 

$request -> app [read only]

 

Since:

 

2.0b6

Returns a reference to the object of application to which the current request belongs. See application methods above.



threadtop
 

Method:

 

$request -> thread [read only]

 

Since:

 

2.0b6

Returns a reference to a object which hold per threads information. There is only one such object per thread.



request_counttop
 

Method:

 

$request -> request_count [read only]

 

Since:

 

2.0b6

Returns the number of request handled so far by this child process.



request_timetop
 

Method:

 

$request -> request_time [read only]

 

Since:

 

2.0b6

Start time of the current request.



session_mgnttop
 

Method:

 

$request -> session_mgnt [read only]

 

Since:

 

2.0b6

Set to true if session management is available.



session_idtop
 

Method:

 

$request -> session_id [read only]

 

Since:

 

2.0b6

Combined id of current user and state session.



session_state_idtop
 

Method:

 

$request -> session_state_id [read only]

 

Since:

 

2.0b6

Id of the current state session as received by the browser, this means this method returns undef for a new session.



session_user_idtop
 

Method:

 

$request -> session_user_id [read only]

 

Since:

 

2.0b6

Id of the current user session as received by the browser, this means this method returns undef for a new session.



cookie_expirestop
 

Method:

 

$request -> cookie_expires

 

Since:

 

2.1.1

Can be used to retrieve the actual expiration date that Embperl uses for the cookie with the session id.



had_exittop
 

Method:

 

$request -> had_exit [read only]

 

Since:

 

2.0b6

True if exit was called in one of the components processed so far.



log_file_start_postop
 

Method:

 

$request -> log_file_start_pos [read only]

 

Since:

 

2.0b6

File possition of the log file at the time when the request has started.



errortop
 

Method:

 

$request -> error

 

Since:

 

2.0b6

True if there were any error during the request.



errorstop
 

Method:

 

$request -> errors

 

Since:

 

2.0b6

Reference to an array which holds all error messages occurred so far.



errdat1top
 

Method:

 

$request -> errdat1

 

Since:

 

2.0b6

Additional information passed to the error handler when an error is reported.



errdat2top
 

Method:

 

$request -> errdat2

 

Since:

 

2.0b6

Additional information passed to the error handler when an error is reported.



lastwarntop
 

Method:

 

$request -> lastwarn

 

Since:

 

2.0b6

Last warning message.



errobjtop
 

Method:

 

$request -> errobj

 

Since:

 

2.0rc3

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.



cleanup_varstop
 

Method:

 

$request -> cleanup_vars

 

Since:

 

2.0b6

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.



cleanup_packagestop
 

Method:

 

$request -> cleanup_packages

 

Since:

 

2.0b6

Reference to a hash which contains all packages that must be cleaned up after the request.



initial_cwdtop
 

Method:

 

$request -> initial_cwd [read only]

 

Since:

 

2.0b6

Working directory when the request started.



messagestop
 

Method:

 

$request -> messages

 

Since:

 

2.0b6

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.



default_messagestop
 

Method:

 

$request -> default_messages

 

Since:

 

2.0b6

Reference to an array with default messages. Messages will be taken from this array if nothing can be found in the messages array.



configtop
 

Method:

 

$component -> config [read only]

 

Since:

 

2.0b6

Returns an reference to the configuration object of the component.



paramtop
 

Method:

 

$component -> param [read only]

 

Since:

 

2.0b6

Returns an reference to the parameter object of the component.



req_runningtop
 

Method:

 

$component -> req_running [read only]

 

Since:

 

2.0b6

True if Embperl is inside of the execution of the request.



sub_reqtop
 

Method:

 

$component -> sub_req [read only]

 

Since:

 

2.0b6

True is this is not the outermost Embperl component, i.e. this component is called from within another component.



inside_subtop
 

Method:

 

$component -> inside_sub [read only]

 

Since:

 

2.0b6

True is we are inside a Embperl subroutine ([$ sub $] ... [$ endsub $])



had_exittop
 

Method:

 

$component -> had_exit [read only]

 

Since:

 

2.0b6

True if the exit was called during the excution of the component.



path_ndxtop
 

Method:

 

$component -> path_ndx [read only]

 

Since:

 

2.0b6

Tells Embperl how much parts of the path should be ignored when searching through the path.



cwdtop
 

Method:

 

$component -> cwd [read only]

 

Since:

 

2.0b6

Directory of the source file of the component.



sourcefiletop
 

Method:

 

$component -> sourcefile [read only]

 

Since:

 

2.0b6

Source file of the component.



syntaxtop
 

Method:

 

$component -> syntax

 

Since:

 

2.0b6

Syntax of the component



prevtop
 

Method:

 

$component -> prev [read only]

 

Since:

 

2.0b6

Previous component, e.g. the component which called this component.



import_stashtop
 

Method:

 

$component -> import_stash [read only]

 

Since:

 

2.0b6

While importing a component this is set to the stash to which symbols are imported. undef during normal execution.



exportstop
 

Method:

 

$component -> exports

 

Since:

 

2.0b6

Symbols that should be exported by this component.



curr_packagetop
 

Method:

 

$component -> curr_package [read only]

 

Since:

 

2.0b6

Name of the package the component is executed in.



codetop
 

Method:

 

$component -> code

 

Since:

 

2.0b6

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.


[ << Prev: Parameters ] [ Content ]


© 1997-2023 Gerald Richter / actevy