Re: Server returns nothing (solved)

2003-02-13 Thread Viljo Marrandi
Hello,

My code checks $tt-error() and it didn't show anything. But I found the
problem, it still was perl and it was very, very stupid mistake. In that
weird module I defined:

DBIx::Recordset::Fetchsizewarn = 0;

while the correct is:

$DBIx::Recordset::Fetchsizewarn = 0;

Only one missing $ ! Can anyone explain why server acted so weirdly
beacuse of this error? Why it didn't show anything at all in error_log? At
least next time I know...

Best regards,
Viljo

On Wed, 12 Feb 2003 [EMAIL PROTECTED] wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Then it's probably a template error, check $tth-error()'s value,
 after the process()ing. also you might wanna try the template toolkit
 mailing list?

 wildguess You are trying tt's USE directive, and that module isn't
 returning a true value from new() on given occasions, which throws an
 error (plugin failed), so nothing being sent at all. /wildguess

 On Wed, 12 Feb 2003 16:58:14 +0200 (EET), Viljo Marrandi wrote:
 Hello,

 - --
 cheers,
 [EMAIL PROTECTED] - wa1800z@DALnetCAiRC - #32741432
 KeyID 0xDE9EB50B - D0D87CA98916CBB258AC 77FB91E0DA95DE9EB50B
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.2.1 (FreeBSD)

 iD8DBQE+SmtckeDald6etQsRAh1CAJ9K3jlTictgvsdouOaWJyXJ/o0BdgCggbjo
 l5Tnf8wbPHF2md6wLXOAEXc=
 =+H6d
 -END PGP SIGNATURE-




Re: Server returns nothing (solved)

2003-02-13 Thread Viljo Marrandi
Hello,

Yes, use strict; was in all modules, this makes it even more interesting,
doesn't it?

Viljo


On Thu, 13 Feb 2003, Ged Haywood wrote:

 Hi there,

 On Thu, 13 Feb 2003, Viljo Marrandi wrote:

  My code checks $tt-error() and it didn't show anything. But I found the
  problem, it still was perl and it was very, very stupid mistake. In that
  weird module I defined:
 
  DBIx::Recordset::Fetchsizewarn = 0;
 
  while the correct is:
 
  $DBIx::Recordset::Fetchsizewarn = 0;
 
  Only one missing $ ! Can anyone explain why server acted so weirdly
  beacuse of this error? Why it didn't show anything at all in error_log?

 Did you

 use strict;

 ?

 73,
 Ged.





Re: Server returns nothing (solved)

2003-02-13 Thread Viljo Marrandi

Yes, even warnings was used.

Viljo


On Fri, 14 Feb 2003, Stas Bekman wrote:

 Viljo Marrandi wrote:
  Hello,
 
  Yes, use strict; was in all modules, this makes it even more interesting,
  doesn't it?

 use warnings; ?



 __
 Stas BekmanJAm_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




Server returns nothing

2003-02-12 Thread Viljo Marrandi
Hello,

I have a mod_perl + Template-Toolkit driven web-site with some 20+ perl
modules. Apache is 1.3.26, mod_perl is 1.26 and TT is 2.08.

Problem is, sometimes happens that I get absolutely no response from
server, browser just says that 'Document contains no data' and even
server accesslog doesn't show anything. All requests go to some kind of
black hole. I can get rid of it, by not using one module. And
interesting thing is that when I start to use it again, server responds
normally.

I've checked this module as much as I could, but to me it seems like every
other normal module. I have no idea what could cause this. I used
diagnostics and warnings and got rid of all warnings.

If I used diagnostics first and it showed some warnings, then I saw that
server tried to show (compile, however you should say that) this page for
serveral times (maybe browser tried to fetch it many times...). And all I
saw was just errors from diagnostics, all loggings messages I have in code
were ignores.

Has anyone seen something like this before and can direct me on this
debugging task? What should I try next? There are no syntactical errors,
only logical, seems to me.

Thanks in advance,
Viljo




Weird error on logging

2002-12-06 Thread Viljo Marrandi
Hello list,

I have following configuration: Apache 1.3.26, Perl 5.6.1 and mod_perl
1.26. And I get one very absurd error (for me at least).

I have following line in my code that prints out one data structure:

$self-{log}-notice( DEBUG: permissions:  . Dumper( $all_permissions ) );

$self-{log} is Apache's log object created in calling module and then
blessed into current module, which is security checker.

Now the problem with line above is, that when it's in code the page just
doesn't work - it somehow gets into loop and starts to do the whole
request phase again and again, until browser shows 'Page not found error'.
When I comment this line out it just works perfectly, or even if I dump
the keys of this hash. And interesting is that this hash nothing comples
nor does it have circular references etc. Here's how it looks like:

$data = {
  'categories' = {
'263' = {
   'publish' = '1',
   'languages' = [
'eng',
'est',
'lat',
'lit'
  ],
   'write' = '1'
 },
'264' = {
   'publish' = '1',
   'languages' = [
'eng',
'est',
'lat',
'lit'
  ],
   'write' = '1'
 },
 },
  'modules' = {
 '9' = {
  'publish' = '1',
  'languages' = [],
  'write' = '1'
}
   }
};

Can anyone shed light into this dark matter, how in the world can one data
structure cause this kind of thing? Has anyone seen this before?

Thanks in advance,
Viljo



Weird error on logging

2002-12-06 Thread Viljo Marrandi
Hello list,

I have following configuration: Apache 1.3.26, Perl 5.6.1 and mod_perl
1.26. And I get one very absurd error (for me at least).

I have following line in my code that prints out one data structure:

$self-{log}-notice( DEBUG: permissions:  . Dumper( $all_permissions ) );

$self-{log} is Apache's log object created in calling module and then
blessed into current module, which is security checker.

Now the problem with line above is, that when it's in code the page just
doesn't work - it somehow gets into loop and starts to do the whole
request phase again and again, until browser shows 'Page not found error'.
When I comment this line out it just works perfectly, or even if I dump
the keys of this hash. And interesting is that this hash nothing comples
nor does it have circular references etc. Here's how it looks like:

$data = {
  'categories' = {
'263' = {
   'publish' = '1',
   'languages' = [
'eng',
'est',
'lat',
'lit'
  ],
   'write' = '1'
 },
'264' = {
   'publish' = '1',
   'languages' = [
'eng',
'est',
'lat',
'lit'
  ],
   'write' = '1'
 },
 },
  'modules' = {
 '9' = {
  'publish' = '1',
  'languages' = [],
  'write' = '1'
}
   }
};

Can anyone shed light into this dark matter, how in the world can one data
structure cause this kind of thing? Has anyone seen this before?

Thanks in advance,
Viljo



Exporter variables get lost

2002-06-07 Thread Viljo Marrandi

Hello,

I'm working on mod_perl project which has many different modules. One is
so-called 'main' modules which loads other when needed. Until now
everything worked just fine, but now one module just says that he doesn't
know the variable I've exported.

And interesting is, that when I comment out either
$sub_first-do_something(); or other three lines about Sub::Second then it
works just fine.

Error it get looks like this:

 Can't call method notice on an undefined value at
/usr/local/lib/perl/5.6.1/Sub/First.pm line 25.

First.pm and Second.pm use Export.pm exactly same way. So, it this some
mod_perl specific feature to just eat up some variables, or what?

Here are cut-down versions of my modules:

Site.pm:
-
package Site;

use strict;
use Apache::Log;

sub handler {
   my $r = shift;
   use vars qw( $log );
   $log = $r-log();

   if ( $some_case eq 'true' ) {
  use Sub::First qw( $log );
  my $sub_first = new Sub::First;

  $sub_first-do_something();

  if ( $some_other_case eq 'yes' ) {
 use Sub::Second qw( $log );
 my $sub_second = new Sub::Second;

# if I comment out $sub_first-do_something then it works...

 $sub_first-do_something();
 $sub_second-do_something_else();
  }
   }
}
1;

---
package Sub::First;

use strict;
use Apache::Log;

BEGIN {
   use Exporter();

   Sub::First::ISA   = qw( Exporter );
   Sub::First::EXPORT= qw();
   Sub::First::EXPORT_OK = qw( $log );

}

use vars qw( $log );

sub new {
   my $class = $_[0];
   my $objref = { };

   bless ( $objref, $class );
   return $objref;
}

sub do_somehing {
   $log-notice(Now this here doesn\'t work);
}

1;

--

Rgds,
Viljo




[OT] Refs don't work, like I want

2002-05-17 Thread Viljo Marrandi

Hello,

Sorry about non mod_perl question, but as I'm subscribed to this list and
I know I can get help from here, I ask my question here.

Can anyone tell me, what's wrong with this piece of code:

$vars-{'key2'} = value of second key;
$vars = {
xxx = AAA,
yyy = BBB,
zzz = CCC,
};
$vars-{'key1'} = value of first key;

foreach $a ( keys %{$vars} ) {
   print $a = $vars-{$a}\n;
}


Problem is, that value of key2 is lost after I set values to xxx, yyy and
zzz, but key1 is ok. I searched through perlref, perldsc manpages, but
didn't find anything similar (maybe that's the problem?).

Any help is welcome.

Rgds,
Viljo




Many requests per page

2002-05-02 Thread Viljo Marrandi

Hello,

I'm using Apache 1.3.22, mod_perl 1.25 and Template-Toolkit 2.06.

How can I make my system so, that my perl handler is not called for each
image, css and script the page has? Apache conf has following lines:

  Location /
 SetHandler  perl-script
 PerlHandler My::Site
 PerlSendHeader  On
  /Location

I tried to check $r-content_type in FixupHandler (if content is img/gif
or whatever, I could tell Apache not to call My::Site), but it was empty,
so I couldn't use it to check what client requested. One solution
that I could think of, was to make Apache conf use File *.html directive
instead of Location, but I'd like to avoid this, if possible (it's a long
story ;).

And I can't put all static files to other VirtualHost, because this site
is going to use Secure HTTP and all files must come from one place, or the
client must answer to every image that it's ok to load it from another
place.

Thanks in advance.

Rgds,
Viljo




Re: Many requests per page

2002-05-02 Thread Viljo Marrandi

Hello again,

 * Viljo Marrandi [EMAIL PROTECTED] [2002-05-02 08:57]:
  How can I make my system so, that my perl handler is not called for
  each image, css and script the page has?

[-- snip --]

 return DECLINED if $r-content_type  $r-content_type !~ m|^text/|i;

I tried that, but no luck - $r-content_type is just plain empty, don't
know why. Maybe i can somehow debug or track this content_type and figure
out, why it's empty? First lines in My::Site look like this:

package My::Site;

use strict;
use other_modules;

sub handler {
   my $r = shift;

   return DECLINED if $r-content_type  $r-content_type !~ m|^html/|i;

...

In regexp i changed 'text' to 'html', because css's are text/css type.




Re: Many requests per page

2002-05-02 Thread Viljo Marrandi

 Can you not limit your perl-script to a single folder, so that you can set:

 Alias /scripts/  /path/to/scripts/

 Location /scripts
 SetHandler  perl-script
 PerlHandler My::Site
 PerlSendHeader  On
 /Location

Unfortunately I can't do this, my handler must handle all / requests
too. Though I'm not very sure about this, but if I tried to Alias only
images then it wouldn't work, becayse My::Site was / handler.

 The way I figure this, is that https://mysite.com/scripts/* act the same way
 as everything used to, and you can load your images from
 https://mysite.com/images/* without complaints about crossing the
 secure/nonsecure boundry...

Hmm, but maybe it's possible to set up Apache so, that My::Site handles
/ and doesn't care about, let say, about /imgs?


Rgds,
Viljo




Weird (unwanted) text on page

2002-02-25 Thread Viljo Marrandi

Hello,

I've made one site using Embperl (but I think it's not Embperl problem)
for image selling agency. Some time ago their HDD crashed and I had to
restore whole site from older code, which I had. Before it worked just
fine, but now it's not. If I look the page with IE it's OK, but if I use
Netscape it shows at the bottom of page weird error. Dunno where it
comes. And interesting is, that IE doesn't show this error even in HTML
source.

You can check it out at http://www.focus.ee

And at least as weird problem is with Mac's (though I don't have a mac
to test it, but clients complain). The whole page is screwed up, tables
are broken, cookies won't get stored (send?) etc etc. 

Anyone seen this before?

Rgds,
Viljo



Apache::AuthTicket problem

2002-01-15 Thread Viljo Marrandi

Hello,

I'm trying to get this AuthTicket stuff to work, but somehow I can't
manage it. Problem it, that when I try to access a site that has this
stuff defined:

 Location /foo
 AuthType Apache::AuthTicket
 AuthName Foo
 PerlAuthenHandler Apache::AuthTicket-authenticate
 PerlAuthzHandler Apache::AuthTicket-authorize
 require valid-user  
 /Location

Then in errorlog I get these messages:

Can't locate object method authenticate via package
Apache::AuthTicket.
[Tue Jan 15 11:39:59 2002] [error] Can't locate authenticate.pm in @INC
(@INC contains: /usr/libdata/perl/5.00503/mach /usr/libdata/perl/5.00503
/usr/local/lib/perl5/site_perl/5.005/i386-freebsd
/usr/local/lib/perl5/site_perl/5.005 . /usr/local/apache/
/usr/local/apache/lib/perl) at (eval 23) line 3.

AuthTicket.pm is in @INC path. But if I searched for authenticate and
authorize methods I couldn't find them anywhere. Maybe I must install
some more packages to get it working (Apache::AuthCookie is installed)?

Thnx in advance,
Viljo



Ticket systems

2002-01-14 Thread Viljo Marrandi

Hello,

I'm on a mission ta make a web-site that uses cookies for user log-in
and log-out. First I'd like to know which one you suggest - Ticket
system from Eagle book or Apache::AuthTicket. I know that
Apache::AuthTicket is based on Eagle book's version, but it seems little
more advanced.

And now second problem. Has anyone modified one of these modules so,
that when user first enters the site he will get a cookie immediately
(with random generated ID) and can walk around there. And if he logs in
then the cookie gets modified accordingly (saying that user is logged
in).

Here's the situation. I must make a site for insurance company. User can
browse the site and see which offers he can get, if he wants to make a
deal only then he must log in. But all the data that is calculated must
be stored in dbase waiting for user to log in, so system can then, err,
bind this temporary data with current user. But of course user can log
in anytime he wants - even between different calculation steps.

Any ideas are welcome.

Rgds,
Viljo



Tips tricks needed :)

2001-12-19 Thread Viljo Marrandi

Hello,

We're going to make a web-site for insurance company (err, more like
portal for several companies) and the problem is that ( I think ) it's
going to be our biggest and most complex site we've ever done AND we're
going to use some new stuff we've never used. So I'd be very happy if
you can give me some points what to look at, what are real no-no's and
what are go-go's.

1. We're going to switch from mysql to postgresql, because we need
transactions, triggers and all other stuff that mysql doesn't support.
What could be possible problems going from mysql to postgres, if any?

2. We will use Template-Toolkit and Apache/mod_perl. Problem is that 2
out of 3 people have never used TT or programmed mod_perl and OO Perl.
Only I've made sites this way, they've used Embperl til now. How can I
make this switch for them a little easier? I know I must spend a lot of
time teaching them, but may-be there are some kinda switchover tutorials
or something?

3. Authorization. Is cookie based auth most reasonable or are there some
other ways too? .htaccess will not do, I think, because all data is in
the same directory and authorized access/login is needed only on some
parts of site. Which data should I send with cookie? Only some random
key which is also stored in dbase and this key is used to find real data
from dbase? (I guess I must read again this thread about cookies).

4. How is most reasonable to store(and use too) complex formulas and
coefficients? Problem is that there are 4 companies and each of them has
different way to calculate same thing eg. insurance for travelling, car
insurance etc. Unfortunately they are all quite different, because every
company uses even different things to calculate final result. So if we
use different formula for every company and insurance type we end up
with ~50 formulas and none understands afterwards which is which. Are
there any guidelines to generalize formulas? Ok, let's say we even
somehow make these formulas general enough to use, but where shall the
calculation take place? Postgres stored procs or in perl code/module (i
think this) or even in TT? Constans will be in db.

5. Any other things to look out when creating large site and/or running
it over SSL and/or using above described configuration?

P.S. I hope that in about few months I can write about this project to
success stories ;-)

Thanks for your attention,
Viljo



form upload limit

2001-12-13 Thread Viljo Marrandi

Hello,

I didn't find anywhere in Net how much is browser form upload limit
(with POST) and how much is Apache's default form data access(input)
limit. If anyone knows where I can find this data i'd be grateful.

I tested this form upload with large text and in my case only 64K went
thru (ended up in MySQL). I saw in Apache homepage, that I could define
POST_MAX like this:

   my $apr = Apache::Request-new($r, POST_MAX = 1024);

Err, is this 1024 bytes or kbytes?

(OT - Perl basics question) Right now I define $apr this way:

$apr = Apache::Request-new( $r-is_main ? $r : $r-main );

Now how I tell $apr that its POST_MAX = 1024?

Rgds,
Viljo



array's first element is empty

2001-11-26 Thread Viljo Marrandi

Hello,

Not sure if this is mod_perl related, but i hope someone can help me
anyway. When i do DBI queries from mod_perl handler and put all returned
results in array then array's first element is empty, I wonder why? I
don't like to shift off first element every time i return the result.
Has anyone seen this before and what could cause this?

Rgds,
Viljo



Re: weird update problem

2001-11-13 Thread Viljo Marrandi

Ahh... like usually, problem is solved after the mail is sent. Problem
was, that code that moved things was after the code which told which
file to include... so thats why i saw it next time.

Thnx anyway :)

Viljo Marrandi wrote:
 
 Hello,
 
 I have one website which is running on Apache/mod_perl and
 Template-Toolkit. There is one piece of code which moves categories
 up'n'down. Now the problem is, that when I submit page with parametres
 it doesn't show that category has moved, but actually it has. I can see
 the change only after I 'hard-refresh' the page again - eg. Shift +
 refresh under IE.
 
 But what's interesting is that the same code works just fine in another
 section of same page. ..
 
 All information is stored in MySQL tables and I use standard DBI in
 mod_perl modules to manipulate it.
 
 All ideas are welcome, I'm kinda... lost in this problem.
 
 Rgds,
 Viljo



CGI.pm problem

2001-10-30 Thread Viljo Marrandi

Hello,

When I try to make a CGI object in my Apache/mod_perl handler a la $q =
CGI-new(); The server just don't reply. Actually it works just fine
until I try to submit a form, then it just hangs and Apache doesn't send
anything back. If I remove this object creation line, then I can submit
my form (but then its no use, i can't use the data). What could be the
problem?

Rgds,
Viljo



array problem

2001-09-20 Thread Viljo Marrandi

Hello,

In apache/mod_perl handler i use recursive function to parse a tree and
find it's root (umm, uppermost ID). If script goes one level up it pushes
it's ID to array, after it's finisthed I pop last ID from array.  Now
first time it runs it works just fine, but after that array contains only
first ID that was pushed there. What could cause this? To make it little
clearer I add table and script. So, first time @maks_id is 18 17 16 1 and
$temp_id = 1, but later array it just 18 and id is 18 too, I don't like
it :(. Oh, and if someone has any good ideas how to improve this tree
parsing algorithm then i'd be happy to hear about it :).


table:

mysql  SELECT categ_id, parent FROM categories;
+++
|   categ_id | parent |
+++
|  1 |  0 |
| 16 |  1 |
| 17 | 16 |
| 18 | 17 |
+++

program:

sub maksimum {
   my ( $dbh, $kat ) = @_;
   my $counter = 0;
   my @maks_id = [ ];

   my $query = qq{ SELECT categ_id, parent, nimetus FROM categories };
   my $sth = $dbh-prepare_cached( $query ) or die $log-notice($dbh-errstr);
   $sth-execute;
   my $info = $sth-fetchall_arrayref;
   $sth-finish;

   foreach $counter (0 .. $#{$info}) {
  if($info-[$counter][0] == $kat) {
 push @maks_id, $info-[$counter][0];
 print_it($info-[$counter][1]);
  }
   }

   sub print_it {
  my $counter2 = 0;
  my $counter3 = 0;

  foreach $counter2 (0 .. $#{$info}) {
 if($info-[$counter2][0] == $_[0]) {
push @maks_id, $info-[$counter2][0];
foreach $counter3 (0 .. $#{$info}) {
   if($info-[$counter3][0] == $info-[$counter2][1]) {
  print_it($info-[$counter3][0]);
   }
}
 }
  }
   }
   my $temp_id = pop @maks_id;
   return $temp_id;
}


-
- Viljo Marrandi-
- programmer/admin  -
- Inspiral Network  -
- www.inspiral.net  -
-




Re: handler question

2001-07-04 Thread Viljo Marrandi

 It depends on what you are trying to accomplish, of course, but
 for most purposes, yeah, splitting r-uri on '/' will give a
 useful list of directories. If you are using these as actual
 filenames, and ignoring r-filaname, however, beware of requests
 like:
 
   http://foo.bar.baz/my_hander/../../../../../../../etc/passwd
 
 which might be trying to get you to send your /etc/passwd. If you
 are using the URI to dispatch the request to a particular Perl
 module, take a look at Apache::Dispatch.

Hmm, i think i souldn't worry about any of these problems, because i use 
this for Template-Toolkit and these splitted directories will be only 
parameters for one template file. So no matter what request is, always 
is read only one file (index.ttml in this case). But hey, thanks for the 
hints :)

Rgds,
Viljo




handler question

2001-07-03 Thread Viljo Marrandi

Hello,

Is it possible, if yes then how, to set handler recursively for one 
directory? Now my handler is defined:

Directory /my_server
SetHandler perl-script
PerlHandler MyServ::MyHandler
/Directory

But if i try to access /my_server/some/other/dir then apache gives error 
because this directory doesn't exist, which is ok, because i want these 
some/other/dir to become parameters for my handler (not directories 
where files are), but how to make that apache won't check if directory 
exists or not. One possibility is to make these directories and in 
httpd.conf define same handler for all them but this ain't good.

Rgds,
Viljo




Re: handler question

2001-07-03 Thread Viljo Marrandi

 Use a Location rather than Directory directive. Use the absolute
 URI relative to the server as the second part (e.g.,
 http://www.foo.bar/baz would look like Location /baz).


Hey, that's what i needed. Thanks :)

 If sounds like you want to use r-path_info in your application,
 so you *can't* create these directories, or they will become part
 of r-filename, not r-path_info.


Actually i thought about r-uri. It returns everything after servername 
and if i split it using '/' as separator i think i'm almost there ;o). 
Or are there any reasons i shouldn't use r-uri?


Rgds,
Viljo




$r-path_info()

2001-07-02 Thread Viljo Marrandi

Hello,

I hope this is the right place to ask this question. I'm using 
Template-Toolkit under Apache/mod_perl and created my own handler for 
it. There is such line in this handler:

my $temp_file = $r-path_info();

When i send this $temp_file to log it works fine:

my $log = $r-log();
$log-notice($temp_file, $r-filename);

But if i try to modify it (eg. $temp_file =~ tr/a-z/A-Z/;) it doesn't do 
nothing. It's still same as in the beginning. What am i doing wrong? It 
should be a regular string so i should be able to modify it...

And if I send $temp_file as variable to process it into template it's empty:

my $vars = {
   filename = $temp_file,}

$template-process($file, $vars, $r)

Any help would be great.

Rgds,
Viljo