Geoffrey Young wrote:

Stas Bekman wrote:


Philippe M. Chiasson wrote:


Following this discussion:
http://marc.theaimsgroup.com/?t=107100040400003&r=1&w=2

I've made a few adjustements and cleanups.

The following patch adds ModPerl::Util::file2package() to build a safe
package from a pathname or filename.


Do you think we should really expose it in the public API?
package2filename is clear and generic, but file2package does a few
assumptions that might not be suitable to users. Do you think it'll
really speed up registry? If not I'd keep it as an internal util function.


I haven't looked inside the cooker recently, so I really don't remember how
it all works...

but if we use package2file and/or file2package in registry someplace, then
there's the potential that users will want to subclass registry and will
thus require either function to emulate core.

as I said, I'm not sure how we use either at the moment - bringing it up
just in case :)

They have that function. As you can see it doesn't do the same as Phillipe's one.


#########################################################################
# func: make_namespace
# dflt: make_namespace
# desc: prepares the namespace
# args: $self - registry blessed object
# rtrn: the namespace
# efct: initializes the field: PACKAGE
#########################################################################

sub make_namespace {
    my $self = shift;

my $package = $self->namespace_from;

    # Escape everything into valid perl identifiers
    $package =~ s/([^A-Za-z0-9_])/sprintf("_%2x", unpack("C", $1))/eg;

    # make sure that the sub-package doesn't start with a digit
    $package =~ s/^(\d)/_$1/;

    # prepend root
    $package = $self->namespace_root() . "::$package";

$self->{PACKAGE} = $package;

    return $package;
}

Again I'm fine with exposing package2file since it's deterministic. But not
with file2package. In fact we shouldn't expose any of these, they have very little to do with mod_perl. The problem with exposing any functions is that you can't change them later. So if we don't have to expose them, let's not do it.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


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



Reply via email to