Next: Modules to load Previous: Writing the converter Contents: Contents |
Different to usual Perl scripts, each PerlPoint converter should declare its own namespace, which is by convention PerlPoint::Converter::<converter name>
.
# declare script package package PerlPoint::Converter::pp2sdf; |
The background of this convention is the way Active Contents is implemented. Active Contents means PerlPoint source parts made from embedded Perl. To make document source sharing as secure as possible, and configurable to PerlPoint users, this embedded Perl can be evaluated in a compartment provided by the Safe
module.
Safe
executes passed code in a special namespace, to suppress access to "unsafed" code parts. It is arranged that the executed code itself sees this namespace as main
. So the embedded code uses main
, which is in fact the special compartment namespace different to main
.
OK. That's no problem. But unfortunately not all code can be executed by Safe
. It is different to use sort
and to load modules, for example. That's why current versions of the frameset allow to execute Active Contents by eval()
alternatively.
Now, if a document author writes Active Contents, he's not necessarily aware of how this embedded code will be executed. He doesn't know about Safe
and eval()
, so PerlPoint has to arrange that the code can be executed both ways. Because it cannot modify Safe
, it has to deal with eval()
, so it makes it working in main
. This means that embedded user code will access main
, and that's why main
should not be used by a converter itself.
Next: Modules to load Previous: Writing the converter Contents: Contents |