Do.pm


NAME

Communiware::DE::Do - Dynamic element Do


SYNOPSIS

   <:Do time action parameters...:>


DESCRIPTION

Dynamic element Do specifies that some procedure code should be executed in given stage of processing of the request.

Code specified should be Perl module name or ModuleName::function. If function name omitted then handler assumed.

Communiware::Postprocess:: would be prepended to the ModuleName.

Dependless of time first argument of called function is context object and all the other arguments are arguments of Do DE.

TIME SPECIFICATIONS

immediate
Code is executed when execution control in containing template reaches this Do DE. If fact immediate Do translated into corresponding function call with given parameters. Return value of this function is appended to template's output.

First argument of immedite Do is context of created document.

postrequest
After request have been completely processed and output send to user. Could be used to perform logging in the database and simular activities.

prepost
This time specification can be used only in the posting context. Code will be executed just after result of form submission are recieved by server, before any posting-time actions are performed.

It is guaranteed to be performed before any items would be created or updated, and not to rolled back if posting fails.

preedit
Available only in posting context. Performed before actual item creation or updating is performed. Could be used to perform complex context manipulation. Performed in the context of transaction.

postedit
Available only in posting context.

Performed after item creation or updating in the context of same transaction only if posting haven't failed already. It replaces old postprocessor syntax, eliminating its quoting weirdness

Note that external processes, spawned from this kind of procedural code wouldn't see results of current transaction.

postpost
Performed after entire posting form is processed and transaction has been commited (and only if posting was successful). It is possible to spawn external process from such code, which has to have access to result of current posting

CODE INTERFACE

Procedure, called from Do dynamic element recieves following arugumets

context to operate on
an instace of Communiware::Context, which contain all attriubutes of current context.

arguments, specified in template
Rest of arguments in Do dynamic element is passed to procedure. Usual argument substitution is performed on them before passing.

Procedure is able to modify passed context as specified in the Communiware::Context documintation.

In case of error, procedure should throw an exeption using die internal command. If this <:Do:> is posting-time operation (prepost, preedit, postedit or postpost) then entire posting operation would be rolled back (unless it is already commited, i.e. on postpost stage), no redirects, specified in the Post dynamic element performed, and message specified as parameter of die command would be plased in the ERROR attribute of global context. Module name and line number would be stripped out from this message just as last symbol of it was ``\n'' unless DEBUG cookie is set to truth value.

16 октябрь 2007 13:44