FAQ
Hello,

I have a simple page that finishes with this :

[$ if (1) $]
<form name="edituser" id="edituser">
<table>
<td>identity</td>
<td><input type="text" name="displayname" id="displayname" value="[+ 1 +]" /></td>
</table>
</form>
[$ else $]
<p>User not found</p>
[$ endif $]

But I get *both* results (the form *and* the "user not found" message).


Also, sometimes the input's value shows as "1", sometimes it's "<[+>1"
And it changes randomly between the 2 values when I refresh the page.

So it has to come from what's before that part (although I'd prefer embperl to detect
the problem, it's very confusing).


So, before this part, I have a call to a function :
%x = $ldap->getuser(
uid => $fdat{uid},
attributes => join(',',@attrs)
);

If I comment it out, the problem disappears.


So the problem comes from this function. Ok.


I am starting to write objects and I don't fully understand how it works (when is
the package recompiled is one question).

I made a package inside which I create my objects :

package omicoldap;

use utf8;
use strict;
use Net::LDAP;
use Net::LDAP::Util qw(ldap_error_name ldap_error_text);

package omicoldapcnx;

use Net::LDAP;
sub new {
my $class = shift;
my $self = {
_serveradr => shift,
};
bless $self,$class;
return $self;
}

sub DESTROY {
my $self = shift;
$self->{_connexion}->unbind;
}

sub connect {
my $self = shift;
# do things
}

sub listusers {
my ($self,%params) = @_;
# do things
}

sub getuser {
my ($self,%params) = @_;
# do things
}

1;


Am I doing things the right way ? Or should I rather remove the initial
"package omicoldap" part and "use omicoldapcnx" directly ?
I did this because I wanted to have a "use" different from the class (so
I could store several classes in the same source code).

BTW, is there a way to use embperl's "warn" mechanism or equivalent from within the
package so I can write messages to apache's logs for debugging purpose ?

Anyway, I still wonder about the very strange behaviour described at the beginning.

Sorry for being so long, I wanted to give as much details as possible.

Thanks for your help,

JC

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org

Search Discussions

  • Jean-Christophe Boggio at Mar 9, 2012 at 1:39 pm
    Hours of "debugging" later, no real success.
    (Many thanks to those who gave hints via private emails)

    1) Modified my package so there's only one package/one object in the source.
    2) Renamed the getuser() function so it's called MYgetuser
    3) Calling code looks like this :

    [-
    sub BEGIN {
    my $script = $0;
    $script =~ s/^(.*)\/.*?$/$1/;
    push @INC,$script;
    push @INC,"$script/..";
    }
    use omicoldapcnx;

    $req = shift;
    $escmode = 0;

    print OUT "1";
    $typeetab = "anything";
    print OUT "2";
    my $a=omicoldapcnx->new($udat{adrldap},$udat{rne},$typeetab);
    print OUT "3";
    if ($a) {
    if ($a->connect) {
    print OUT "4";
    %x = $a->getuser();
    print OUT "5";
    }
    else {
    print OUT "Connect error: ".$a->{_lasterror}."<br />";
    }
    }
    else {
    print OUT "New error: ".$a->{_lasterror}."<br />";
    }
    -]

    - Cat is
    [$ if 1 $]
    Alive
    [$ else $]
    Dead
    [$ endif $]

    I get "1234- Cat is Alive Dead"


    So what I "understand" (so to say) :
    - embperl works normally until "%x = $a->getuser();"
    - embperl does not find the "getuser" function (it's been renamed)
    - embperl "gives up", does not finish the [- ... -] block
    - embperl treats all subsequent [$ ... $] blocks as comments and prints everything inbetween.

    There is *no* error in /var/log/apache2/error.log
    Lots of (unusable by me) stuff in EMBPERL_LOG depending on EMBPERL_DEBUG value.


    A few more informations to help debugging :
    - Module Apache2::Reload activated and working (checked with debug mode that my package is recompiled)
    - apache2-mpm-prefork 2.2.16-6+squeeze4
    - libembperl-perl 2.3.0-1
    - Running on Debian 6.0.4
    - Linux miaou 2.6.32-5-686 #1 SMP Mon Jan 16 16:04:25 UTC 2012 i686 GNU/Linux


    I will stop trying to work with objects because I have no time/knowledge to go deeper.

    I keep this code if someone (Gerald ?) wants to dig.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
    For additional commands, e-mail: embperl-help@perl.apache.org
  • Gerald Richter at Mar 9, 2012 at 10:24 pm
    Hi,

    If you are sure that is not a problem of your module, then I would:

    - move "sub BEGIN { }" and the "use ..." to a startup.pl file which call on server startup (PerlRequire in httpd.conf)

    - If this doesn't help, try without the print OUT (use warn for debugging, which log into apache error log).

    What do you mean by getuser is renamed?

    Gerald
    -----Original Message-----
    From: Jean-Christophe Boggio
    Sent: Friday, March 09, 2012 2:39 PM
    To: embperl@perl.apache.org
    Subject: Re: Schrödinger syndrome

    Hours of "debugging" later, no real success.
    (Many thanks to those who gave hints via private emails)

    1) Modified my package so there's only one package/one object in the
    source.
    2) Renamed the getuser() function so it's called MYgetuser
    3) Calling code looks like this :

    [-
    sub BEGIN {
    my $script = $0;
    $script =~ s/^(.*)\/.*?$/$1/;
    push @INC,$script;
    push @INC,"$script/..";
    }
    use omicoldapcnx;

    $req = shift;
    $escmode = 0;

    print OUT "1";
    $typeetab = "anything";
    print OUT "2";
    my $a=omicoldapcnx->new($udat{adrldap},$udat{rne},$typeetab);
    print OUT "3";
    if ($a) {
    if ($a->connect) {
    print OUT "4";
    %x = $a->getuser();
    print OUT "5";
    }
    else {
    print OUT "Connect error: ".$a->{_lasterror}."<br />";
    }
    }
    else {
    print OUT "New error: ".$a->{_lasterror}."<br />";
    }
    -]

    - Cat is
    [$ if 1 $]
    Alive
    [$ else $]
    Dead
    [$ endif $]

    I get "1234- Cat is Alive Dead"


    So what I "understand" (so to say) :
    - embperl works normally until "%x = $a->getuser();"
    - embperl does not find the "getuser" function (it's been renamed)
    - embperl "gives up", does not finish the [- ... -] block
    - embperl treats all subsequent [$ ... $] blocks as comments and prints
    everything inbetween.

    There is *no* error in /var/log/apache2/error.log Lots of (unusable by me)
    stuff in EMBPERL_LOG depending on EMBPERL_DEBUG value.


    A few more informations to help debugging :
    - Module Apache2::Reload activated and working (checked with debug mode
    that my package is recompiled)
    - apache2-mpm-prefork 2.2.16-6+squeeze4
    - libembperl-perl 2.3.0-1
    - Running on Debian 6.0.4
    - Linux miaou 2.6.32-5-686 #1 SMP Mon Jan 16 16:04:25 UTC 2012 i686
    GNU/Linux


    I will stop trying to work with objects because I have no time/knowledge to
    go deeper.

    I keep this code if someone (Gerald ?) wants to dig.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
    For additional commands, e-mail: embperl-help@perl.apache.org


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
    For additional commands, e-mail: embperl-help@perl.apache.org
  • Jean-Christophe Boggio at Mar 11, 2012 at 11:26 am
    Gerald,

    Le 09/03/2012 23:23, richter@ecos.de a écrit :
    If you are sure that is not a problem of your module, then I would:
    I'm sure it *is* a problem with my module.
    - move "sub BEGIN { }" and the "use ..." to a startup.pl file which call on server startup (PerlRequire in httpd.conf)
    I don't want to go this way because I'm still building the module (and don't want to restart
    Apache after every change).
    - If this doesn't help, try without the print OUT (use warn for debugging, which log into apache error log).
    Well, at the time I was doing all my tests, neither print OUT nor warn did work from within the module.
    I am pretty sure I was messing with the return parameters of my function and that was completely messing
    things in the module.

    I restarted from scratch, verifying every call and variable and now it seems very stable.
    What do you mean by getuser is renamed?
    At some time, I did rename the function in my code but that change was not visible to Embperl, it was still
    using the old implementation. I must have scrambled some cache, I don't know.

    Thanks for your input,

    Have a nice day,

    JC

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
    For additional commands, e-mail: embperl-help@perl.apache.org
  • Gerald Richter at Mar 11, 2012 at 5:06 pm
    Hi,

    if you change some sort of things in your module, you have to restart Apache, especially when do things like renaming methods, because Perl does a lot of magic cacheing and automatic reload like Embperl and Apache::Reload does, will not work in such situations.

    Gerald

    -----Original Message-----
    From: Jean-Christophe Boggio
    Sent: Sunday, March 11, 2012 12:26 PM
    To: Gerald Richter - ECOS
    Cc: embperl@perl.apache.org
    Subject: Re: Schrödinger syndrome

    Gerald,

    Le 09/03/2012 23:23, richter@ecos.de a écrit :
    If you are sure that is not a problem of your module, then I would:
    I'm sure it *is* a problem with my module.
    - move "sub BEGIN { }" and the "use ..." to a startup.pl file which
    call on server startup (PerlRequire in httpd.conf)
    I don't want to go this way because I'm still building the module (and don't
    want to restart Apache after every change).
    - If this doesn't help, try without the print OUT (use warn for debugging,
    which log into apache error log).

    Well, at the time I was doing all my tests, neither print OUT nor warn did
    work from within the module.
    I am pretty sure I was messing with the return parameters of my function
    and that was completely messing things in the module.

    I restarted from scratch, verifying every call and variable and now it seems
    very stable.
    What do you mean by getuser is renamed?
    At some time, I did rename the function in my code but that change was not
    visible to Embperl, it was still using the old implementation. I must have
    scrambled some cache, I don't know.

    Thanks for your input,

    Have a nice day,

    JC

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
    For additional commands, e-mail: embperl-help@perl.apache.org


    ---------------------------------------------------------------------
    To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
    For additional commands, e-mail: embperl-help@perl.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupembperl @
categoriesmodperl, perl
postedMar 8, '12 at 4:37p
activeMar 11, '12 at 5:06p
posts5
users2
websiteperl.apache.org

People

Translate

site design / logo © 2018 Grokbase