Gerald Richter dijo [Mon, Dec 11, 2006 at 05:25:58AM +0100]:
> Embperl::exit is the right thing to do, but normaly you should not see this
> message, because it's internaly catched by Embperl.
>
> From where do you call this code in your module?
Ok, seems I'll have to explain my probably twisted logic :)
First of all, the application is an Embperl::Object app, using the
following Apache configuration:
<Location /smb>
PerlSetVar SMBGATE_INSTANCE smbgate
PerlSetVar SMBGATE_YAMLCONF /etc/smbgate.yaml
EMBPERL_OBJECT_APP base.pm
EMBPERL_APPNAME smbgate
EMBPERL_OBJECT_FALLBACK index.html
EMBPERL_ESCMODE 0
EMBPERL_OPTIONS 16
EMBPERL_DEBUG 0
SetHandler perl-script
PerlHandler Embperl::Object
Options ExecCGI FollowSymLinks
RewriteEngine On
RewriteRule /file/(.*) file?file=$1
RewriteRule /dir/(.*) ?dir=$1
</Location>
Now, I tried to split the application into logic modules, so from
base.pm I include (use) some modules, among which is
SmbGate::Embperl::WebClient. I am attaching the module as it is now -
of course, it lacks any documentation, but should be just
readable. Now, what triggers this message? For example, when calling
logout.html, which is:
[$ var $dummy $]
[- # Just clear the user session information to leave cleanly, inform
# the user he has logged out, and redirect to the login screen
delete $udat{login};
delete $udat{passwd};
$epreq->{warnings}->add_msg('Su sesión ha finalizado');
$epreq->{webclient}->redirect('login.html');
-]
(of course, $epreq->{webclient} is an instantiated
SmbGate::Embperl::WebClient, invoked at base.pm's init)
You will notice I'm using $epreq to hold my various objects so they
are available along the way - I lack a better way of doing this, you
might also point me out to another way of doing this :)
Thanks,
--
Gunnar Wolf - [EMAIL PROTECTED] - (+52-55)5623-0154 / 1451-2244
PGP key 1024D/8BB527AF 2001-10-23
Fingerprint: 0C79 D2D1 2C4E 9CE4 5973 F800 D80E F35A 8BB5 27AF
use strict;
use warnings;
=head1 NAME
SmbGate::Embperl::Webclient -
=head1 SYNOPSIS
=head1 REQUIRES
=head1 SEE ALSO
=head1 AUTHOR
Gunnar Wolf, [EMAIL PROTECTED]
Instituto de Investigaciones Económicas, UNAM
=head1 COPYRIGHT
Copyright 2006 Gunnar Wolf
This library is free software, you can redistribute it and/or modify it
under the terms of the GPL version 2 or later.
=cut
package SmbGate::Embperl::WebClient;
sub new {
my ($class, $self);
$class = shift;
$self = {epreq => shift, headers => shift, udat => shift};
return bless $self, $class;
}
sub redirect {
# Redirect the request to a new page inside the system (preceded by
# $epreq->{conf}{base_url}) - and stop processing before doing any
# further harm
my ($self, $to);
$self = shift;
$to = $self->{epreq}->{conf}->base_url . '/' . shift;
$to =~ s!/+!/!g;
$self->{headers}{Location} = $to;
exit(301);
}
sub content_type {
my ($self, $type);
$self = shift;
$type = shift;
$self->{headers}{'Content-Type'} = $type;
}
sub set_header {
my ($self, $header, $data);
$self = shift;
$header = shift;
$data = shift;
$self->{headers}{$header} = $data;
}
sub user_agent {
return $ENV{HTTP_USER_AGENT};
}
sub set_debug {
my $self = shift;
###### PENDING: Who has rights to set debug?
# # Only an administrative user may set the debug flag
# return undef unless (defined $self->{epreq}{person} and
# $self->{epreq}{person}->get_admin_tasks);
$self->{udat}{debug} = 1;
}
sub unset_debug {
my $self = shift;
# If debug is turned on, just let anybody switch it off.
$self->{udat}{debug} = 0;
}
1;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]