Re: templating system opinions

2003-07-20 Thread Ruslan U. Zakirov
>> Barry Hoggard wrote:
>> I used to use HTML::Template for projects, but I moved to
>> Template::Toolkit because I felt the former's syntax was just too 
>> limited.  I know we want to separate code and logic, but H::T 
>> keeps me 

[skip]
JE> Jesse Erlbaum
JE>   Programmer: Get object, Get object attribute
JE>   HTML Designer: Display attribute
JE> This is no more than a philosophical difference.  HTML::Template assumes
JE> HTML designers should never do programming tasks, and implements this
JE> philosophy by not opening the "code floodgate" at all.  TT believes that
JE> there is some amount of code you want your designer to do.

[skip]

  Hello.
Absolutely agree with Jesse.
I've started with my own simple templating module, but step by step I've
come to HT.
Why HT?
1) It isn't framework, just templates. I'm trying to write my own
framework.
2) Relatively fast.
3) Separate code and design.
4) Enough simple syntax to designers.
When I was doing selection I just read comparison from
perl.apache.org. Satisfied with the choice still.

   Best regards, Ruslan.



Re: segmentation fault under mod_perl+XML::XPath

2003-07-14 Thread Ruslan U. Zakirov
Hello, Ged and other.
Thanks for long suggestion letter. I've solved my problem with mod_perl
compiled staticaly.
GH> Hi there,
GH> Haven't seen any replies, so I thought you'd like to hear from someone. :)
Thanks...
GH> On Wed, 2 Jul 2003, Ruslan U. Zakirov wrote:

>> I've tried to use XML::XPath under mod_perl 1.27 and Apache 1.3.27, but
>> got segmentation fault

GH> It's not uncommon to see XML and segfaults in the same post.  :(
GH> Have you searched the archives?
Looked at it. My problem was different.

>> Under command line and CGI it's working fine and all tests during installation of
>> XML::XPath were fine, but the same code crush apache+mod_perl.
GH> [snip]
>> Apache - with so, unique_id, no expat
>> mod_perl with everything as DSO

GH> Whenever I see segfaults in a DSO Apache I'd say try static linking if
GH> you don't know what else to try.  :)
Exactly this method is a solution.

>> Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:

GH> Did you compile this Perl yourself?  The standard advice is to compile
GH> mod_perl and Perl with the same compiler.


>> usemymalloc=n, bincompat5005=undef

GH> Highly unlikely, but maybe a malloc problem?

>> ccversion='', gccversion='2.95.3 20010315 (release) [FreeBSD]', gccosandvers=''

GH> You should be OK with that compiler, is that what you're using yourself?
GH> Hope you're not using gcc 3.x with that Perl...
I don't want to try 3.x yet.

>>   Dynamic Linking:
>> dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
>> cccdlflags='-DPIC -fpic', lddlflags='-shared  -L/usr/local/lib'

GH> Never heard of Perl (as opposed to mod_perl) dynamic linking causing a
GH> problem, so don't worry about that.  (Until later.:)

>> Backtrace:
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x80711c5 in poolCopyString ()
>> (gdb) bt
>> #0  0x80711c5 in poolCopyString ()

GH> This is the code in xmlparse.c from my 1.3.27 source tree:

GH> --
GH> static const XML_Char *poolCopyString(STRING_POOL *pool, const XML_Char *s)
GH> {
GH>   do {
GH> if (!poolAppendChar(pool, *s))
GH>   return 0;
GH>   } while (*s++);
GH>   s = pool->start;
GH>   poolFinish(pool);
GH>   return s;
GH> }
GH> --

GH> Assuming you're using the same thing...

GH> As far as I can see this must mean that your pointer s is invalid, and
GH> either the dereference *s causes a memory bound error or else the s++
GH> increment tries to increment it off the end of the stack or something.
GH> There's nothing else in that function that would be likely to cause the
GH> fault, if pool were invalid I'd expect it to happen in poolAppendChar().

GH> I have no idea why these might be but it's a bit serious of course.

GH> You're into XS territory, the sort of thing that can easily be thrown
GH> by struct alignment problems such as you might get on the less well
GH> exercised configurations - which probably includes FreeBSD - and an
GH> unsuitable combination of compilers/dso/libraries/...

GH> You shouldn't have to be delving this deeply into these packages, but
GH> if a static link or a compiler change doesn't fix it and you don't
GH> mind cranking gdb a bit further you could find out what that pointer
GH> is pointing to and if it's a valid XML_Char pointer.

GH> Hope this gets you started in the right direction, but please don't
GH> take it as authoritative as I've never used FreeBSD nor XML::XPath.
Big thanks for your reply.

GH> 73,
GH> Ged.

 Ruslan.



segmentation fault under mod_perl+XML::XPath

2003-07-05 Thread Ruslan U. Zakirov
Hello.
I've tried to use XML::XPath under mod_perl 1.27 and Apache 1.3.27, but
got segmentation fault with this peace of code:
use XML::XPath;

my $mfname='/proj/optolink/html/.meta.xml';
my $xp = XML::XPath->new(filename => $mfname);
my $ns = $xp->find('//[EMAIL PROTECTED]"yes"]');

Perl 5.8.0, Apache - with so, unique_id, no expat
mod_perl with everything as DSO

Under command line it's working fine and all tests during installation of
XML::XPath were fine, but the same code crush apache+mod_perl.
Backtrace:
Program received signal SIGSEGV, Segmentation fault.
0x80711c5 in poolCopyString ()
(gdb) bt
#0  0x80711c5 in poolCopyString ()
#1  0x806cf71 in XML_SetBase ()
#2  0x28cfcc92 in XS_XML__Parser__Expat_SetBase ()
   from
/usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd/auto/XML/Parser/Expat/Expat.so
#3  0x28c398fb in Perl_pp_entersub () from
/usr/local/libexec/apache/libperl.so
#4  0x28c33c28 in Perl_runops_standard ()
   from /usr/local/libexec/apache/libperl.so
#5  0x28bf2f36 in S_call_body () from /usr/local/libexec/apache/libperl.so
#6  0x28bf2d16 in Perl_call_sv () from
/usr/local/libexec/apache/libperl.so
#7  0x28bd3d56 in perl_call_handler ()
   from /usr/local/libexec/apache/libperl.so
#8  0x28bd359e in perl_run_stacked_handlers ()
   from /usr/local/libexec/apache/libperl.so
#9  0x28bd1d64 in perl_handler () from
/usr/local/libexec/apache/libperl.so
#10 0x8052595 in ap_invoke_handler ()
#11 0x806225c in process_request_internal ()
#12 0x80622bd in ap_process_request ()
#13 0x805b52e in child_main ()
#14 0x805b6a0 in make_child ()
#15 0x805b7bd in startup_children ()
#16 0x805bcb4 in standalone_main ()
#17 0x805c397 in main ()
#18 0x804ebe1 in _start ()

Any help would be good.
Ruslan.




segmentation fault under mod_perl+XML::XPath

2003-07-02 Thread Ruslan U. Zakirov
Hello.
I've tried to use XML::XPath under mod_perl 1.27 and Apache 1.3.27, but
got segmentation fault with this peace of code:
use XML::XPath;

my $mfname='/proj/optolink/html/.meta.xml';
my $xp = XML::XPath->new(filename => $mfname);
my $ns = $xp->find('//[EMAIL PROTECTED]"yes"]');

Under command line and CGI it's working fine and all tests during installation of
XML::XPath were fine, but the same code crush apache+mod_perl.



Apache - with so, unique_id, no expat
mod_perl with everything as DSO

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
  Platform:
osname=freebsd, osvers=4.5-stable, archname=i386-freebsd
uname='freebsd flamengo.citl.miee.ru 4.5-stable freebsd 4.5-stable #3: tue apr 23 
15:48:51 msd 2002 [EMAIL PROTECTED]:usrsrcsyscompileflamengo i386 '
config_args='-de'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
  Compiler:
cc='cc', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing 
-I/usr/local/include',
optimize='-O',
cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing 
-I/usr/local/include'
ccversion='', gccversion='2.95.3 20010315 (release) [FreeBSD]', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
  Linker and Libraries:
ld='cc', ldflags ='-Wl,-E  -L/usr/local/lib'
libpth=/usr/lib /usr/local/lib
libs=-lm -lc -lcrypt -lutil
perllibs=-lm -lc -lcrypt -lutil
libc=, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version=''
  Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-DPIC -fpic', lddlflags='-shared  -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: USE_LARGE_FILES
  Built under freebsd
  Compiled at Oct 23 2002 11:00:00
  @INC:
/usr/local/lib/perl5/5.8.0/i386-freebsd
/usr/local/lib/perl5/5.8.0
/usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd
/usr/local/lib/perl5/site_perl/5.8.0
/usr/local/lib/perl5/site_perl


Backtrace:
Program received signal SIGSEGV, Segmentation fault.
0x80711c5 in poolCopyString ()
(gdb) bt
#0  0x80711c5 in poolCopyString ()
#1  0x806cf71 in XML_SetBase ()
#2  0x28cfcc92 in XS_XML__Parser__Expat_SetBase ()
   from
/usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd/auto/XML/Parser/Expat/Expat.so
#3  0x28c398fb in Perl_pp_entersub () from
/usr/local/libexec/apache/libperl.so
#4  0x28c33c28 in Perl_runops_standard ()
   from /usr/local/libexec/apache/libperl.so
#5  0x28bf2f36 in S_call_body () from /usr/local/libexec/apache/libperl.so
#6  0x28bf2d16 in Perl_call_sv () from
/usr/local/libexec/apache/libperl.so
#7  0x28bd3d56 in perl_call_handler ()
   from /usr/local/libexec/apache/libperl.so
#8  0x28bd359e in perl_run_stacked_handlers ()
   from /usr/local/libexec/apache/libperl.so
#9  0x28bd1d64 in perl_handler () from
/usr/local/libexec/apache/libperl.so
#10 0x8052595 in ap_invoke_handler ()
#11 0x806225c in process_request_internal ()
#12 0x80622bd in ap_process_request ()
#13 0x805b52e in child_main ()
#14 0x805b6a0 in make_child ()
#15 0x805b7bd in startup_children ()
#16 0x805bcb4 in standalone_main ()
#17 0x805c397 in main ()
#18 0x804ebe1 in _start ()

Any help would be good.
Ruslan.



[OT] Perfomance tests, How?

2003-04-02 Thread Ruslan U. Zakirov
Hello All!
  I need to test my project perfomance. Is there any OpenSource
projects like WebBench and other in the Internet?
 Best regards. Ruslan.



DECLINE, ERRORs in the middle of hanlers stack

2003-03-07 Thread Ruslan U. Zakirov
Hello All!
"Stacked handlers" is a very useful technology, but as I think incomplete.
I need some suggestions.
My project split content handler in the few parts. And each handler
send part of the requested page to user, but sometimes I must stop
proccessing and return DECLINE, redirect user or return some ERROR.
Error appear in the middle of the page.
I want Apache to buffer content and send it after last handler in
chain return OK. Is it possible?
  Beforehead thanks, Ruslan.



Re: Inserting a handler in "stack of handlers".

2003-01-14 Thread Ruslan U. Zakirov

SB> Geoffrey Young wrote:
>> Ruslan U. Zakirov wrote:
>>> Hello All!
>>> Short synopsis:
>>>   How to push handler just after handler that working now?
>>> More about the problem.
>>>  I've got main handler, that forms stack of handlers from query 
>>> string
>>> by calling push_handlers(). Then each module doing his job. Some handlers
>>> needs to put another hook just after they end thier job. I do it with
>>> direct call to SomeModule::handler($r), it works for me, but it's rude
>>> back(as i think). I've tried to do the same with push_handlers, but this
>>> function push handlers only at the end of handler's list and content 
>>> appears at
>>> the bottom of page :(
>>> Any suggestion?
>>> Best regards, Ruslan.
>> you can't really do this now I don't think.  generally, the way would be
>> to use get_handlers() to get the current chain, then use set_handlers() 
>> to set it to what you want it to be (inserting logic to splice the added 
>> handler where you want it).  unfortunately, you can't call 
>> set_handlers() for the current phase, so adding another handler right 
>> after the current one runs probably isn't possible.
SB> That should probably be possible in 2.0, but it's not implemented yet.
SB> Patches are welcome.
Thanks.
Sorry, but I don't have time to look in mod_perl/Apache code.
Good product. I think it'll be better and hope that it'll be more
flexible in some cases.
 Thanks, Ruslan.




Inserting a handler in "stack of handlers".

2003-01-13 Thread Ruslan U. Zakirov
Hello All!
Short synopsis:
  How to push handler just after handler that working now?
More about the problem.
 I've got main handler, that forms stack of handlers from query string
by calling push_handlers(). Then each module doing his job. Some handlers
needs to put another hook just after they end thier job. I do it with
direct call to SomeModule::handler($r), it works for me, but it's rude
back(as i think). I've tried to do the same with push_handlers, but this
function push handlers only at the end of handler's list and content appears at
the bottom of page :(
Any suggestion?
Best regards, Ruslan.




How sub handler was called.

2002-11-22 Thread Ruslan U. Zakirov
 Hello, all!
May I understand in my handler sub how it was called?
Was it called by Apache process in stacked handlers chain or
it was called by some other module with call "MyMod::handler($r)"?
Could i do it without adding some special parametrs?
   Beforehead thanks, Ruslan.




Re: FW: mod_perl / PerlAuthenHandler question

2002-10-29 Thread Ruslan U. Zakirov
MJJ> Mitchel, Jennifer (Jem) wrote:
MJJ>  > The machine does belong to my org & my login does not have root access.  I 
will do the
MJJ>  > /perl-status?hooks as soon as I can be let onto the machine with root access.
MJJ>  >
MJJ>  > I did print out the global hash %Apache::MyConfig::Setup and here is the result
MJJ>  >
MJJ>  > Apache_Src => /web/server/apache/1.3.22-source/src SSL_BASE =>
MJJ>  >

MJJ> the hooks part of Apache::MyConfig wasn't added until mod_perl 1.25, so that
MJJ> won't help you with your version :)

MJJ> the following Apache::Registry script should do the trick:
MJJ> #!/usr/bin/perl
MJJ> use mod_perl_hooks qw(hook hooks);
shift->send_http_header('text/plain');
MJJ> foreach my $hook (mod_perl::hooks) {
MJJ>print "$hook => ", mod_perl::hook($hook) ?
MJJ>   "enabled\n"   :
MJJ>   "disabled\n";
MJJ> }

MJJ> the line shift->send_http_header('text/plain');
MJJ> is giving me the error:
MJJ> Can't call method "send_http_header" on an undefined value
Hello.
You must put this script in  or  where
SetHandler perl-script
PerlHandler Apache::Registry

or put this code in your own module in "sub handler"
and set this module as content handler in some  and request
this location from browser.




Communication between handlers

2002-10-29 Thread Ruslan U. Zakirov
Hi!
Please point me to good documentation about subj.
Is it possible to initialize some class(MyProjConfig for example)
with some params in first content handler, and then send it trought
other handlers, all it within only one request?
Thank you beforehead.
__
Sorry for my English.




Re: Get file list of the dir.

2002-10-28 Thread Ruslan U. Zakirov
Thank you for your help!
I'm terribly sorry for getting your time, It's my fault.
There was an error in my code.
I'm inattentive foolish man.
But I've known new methods of reading directory listening.
Best regards.
___
Sorry for my English.




Re: Get file list of the dir.

2002-10-28 Thread Ruslan U. Zakirov
RK> But this doesn't seem to be the problem ... What's printed in the
RK> browser? Is there anything in the error logs? Is the name of the
RK> directory to be read input from the user (if so, are you running
RK> under taint mode?), and are the permissions appropriate?
Here is my module's code...
use strict;
use Apache::Constants qw(:common);
use Apache::File ();
use IO::Dir;

sub handler {
   my $r = shift;
   return DECLINED unless $r->content_type() eq '' or $r->content_type() eq 
'text/html';

   my $file = $r->filename;
   my $tmp=substr($file,rindex($file,'/')+1,length($file)-$_-1,'');

   if (-e $r->finfo)
   {
  return DECLINED;
   }

   $r->content_type('text/plain');
   $r->send_http_header;

   my @htmls;
   my $refdir;
   opendir($refdir, "$file");
   unless ($refdir)
   {
 $r->log_error("Err in opendir($refdir,$file) : $!");
 return SERVER_ERROR;
   }
   my $filedir;
   while ($filedir = readdir($refdir))
   {
 next if (not $filedir =~/.html/);
 push(@htmls, $filedir) if (-f "$file$filedir");
   }
   closedir($refdir);

   foreach my $html(@htmls)
   {
 $html=$file.$html;

 my $fh;
 unless ($fh = Apache::File->new($file))
 {
$r->log_error("Couldn't open $file for reading: $!");
return SERVER_ERROR;
 }
 while (<$fh>)
 {
$r->print($_);
 }
 $fh->close();
   }
   return OK;
}

1;
__END__

I've attached file with browser output.
ݦ.!x..¦
index.htmlґ·imagesÒß·fotoÒñ·´ 
style.cssÒ


Get file list of the dir.

2002-10-27 Thread Ruslan U. Zakirov
I'm writing handler which generate some html from files in requested
dir if requested file does not exist.
I have a problem with getting file list of the directory.
I've tried to use IO::Dir, like this
   my @htmls;
   my $dh = new IO::Dir ($req_dir);
   if (defined $dh)
   {
 while (defined($_ = $dh->read))
 {
   if(m/(\w*?\.html)/)
   {
 unshift(@htmls,$_);
   }
 }
   }
This code successfully create array, but at the same time apache prints
something to user. And I have an abbracadabra in browser.
May be I've missed some better way of getting file names?




What module I have to choose?

2002-10-20 Thread Ruslan U. Zakirov
Hello!
I've wrote my module that uses Apache::Forward example from "Writing
Apache modules with Perl and C". Module generates site navigation bar
and insert it in content that was returned by simple CGI scripts.
I've used Apache::PerlRun in stacked handlers to run CGI scripts, like

PerlHandler MyModule Apache::PerlRun

Ok, now it's all working fine.
But Apache::Forward it's just an exaple from book, and I've tried to
search it CPAN. There is no this module. I've found at least two other
Apache::OutputChain and Apache::Filter.
I'll be glad to listen any suggestions about what module to use.
What different between them?

Beforehead thanks.




Re: What module I have to choose?

2002-10-20 Thread Ruslan U. Zakirov
GH> Congratulations!
Thank you.
GH> Install them, then try the commands
GH>  perldoc Apache::OutputChain
GH> and
GH>  perldoc Apache::Filter
GH> which will tell you about them.  You can look at the source code too.
Have done.
Each documents talking only about there own modules.
But I'm interesting in comparison of modules. May be someone have done
this and have any ideas why one module must be used instead of
another?
I'm interesting in it, because I want to port my module from using
Apache::Forward to another and now I must decide wich one.
mailto:cubic@;wr.miee.ru




Re: Can I parse content that has been returned to user by simple cgi script?

2002-10-16 Thread Ruslan U. Zakirov

AA> perldoc cgi_to_mod_perl
AA> perldoc mod_perl_traps
AA> http://perl.apache.org/docs/1.0/guide/porting.html
PEE> There aren't many problems with Apache::PerlRun, as it goes to great
PEE> lengths to be a direct equivalent to mod_cgi so that "dirty scripts" can run.
PEE> Anyway, the Guide is always here to help. See especially 
PEE> http://perl.apache.org/docs/1.0/guide/porting.html , although a lot of this 
PEE> is for Apache::Registry, which you might want to move on to later.
Thanks!
I think enough information for me and I've answers for all my
questions.
Thank you all.




  mailto:[EMAIL PROTECTED]




Re: Can I parse content that has been returned to user by simple cgi script?

2002-10-16 Thread Ruslan U. Zakirov

>>I want to upgrade my project with implementing some feature.
>>Project was writen for mod_cgi, but I would like to parse content that
>>was generated by my scripts to implement something like SSI or
>>Apache::UCase and etc.

PH> You can't do that.  However, you can run your CGI scripts under 
PH> Apache::PerlRun and then use Apache::Filter on them to do things like 
PH> SSI.  This will also make them much faster.
PH> - Perrin
Thank you!
Now I've uderstood that it's only way.
OK.
And last one, could someone point me to documents about troubleshoots
which could ocure while using Apache::PerlRun with CGI scripts that was
writen only for mod_cgi?
Thank you for help.
  mailto:[EMAIL PROTECTED]




Re: ap_rwrite()/ap_rvputs() called in PerlCleanupHandler

2002-10-15 Thread Ruslan U. Zakirov

Hello again.
May be it helps to solve your problem.
is_initial_req()

There are several instances in which an incoming URI request can
trigger one or more secondary internal requests. An internal request
is triggered when internal_redirect() is called explicitly, and it
also happens behind the scenes when lookup_file() and lookup_uri()
are called.

With the exception of the logging phase, which is run just once for
the primary request, secondary requests are run through each of the
transaction processing phases, and the appropriate handlers are
called each time. There may be times when you don't want a
particular handler running on a subrequest or internal redirect,
either to avoid performance overhead or to avoid infinite recursion.
The is_initial_req() method will return a true value if the current
request is the primary one and false if the request is the result of
a subrequest or an internal redirect.

return DECLINED unless $r->is_initial_req;

ssn> Hello,

ssn> Why is apache re-doing the request after a internal_redirect() ? ( and that too 
ssn> in the cleanup phase ??)

ssn> Please help me understand this. Any hints most appreciated :-)
  mailto:[EMAIL PROTECTED]




Re: ap_rwrite()/ap_rvputs() called in PerlCleanupHandler

2002-10-15 Thread Ruslan U. Zakirov

Hello!

internal_redirect()
 The required argument is an absolute URI path on the current server.
 The server will process the URI as if it were a whole new request,
 running the URI translation, MIME type checking, and other phases
 before invoking the appropriate content handler for the new URI.
 The content handler that eventually runs is not necessarily the same
 as the one that invoked internal_redirect().
 This method should only be called within a content handler.
That from "Writing Apache modules with Perl and C".
ssn> Hello,

ssn> Why is apache re-doing the request after a internal_redirect() ? ( and that too 
ssn> in the cleanup phase ??)

ssn> Please help me understand this. Any hints most appreciated :-)
 mailto:[EMAIL PROTECTED]




Can I parse content that has been returned to user by simple cgi script?

2002-10-15 Thread Ruslan U. Zakirov

Hello!
I want to upgrade my project with implementing some feature.
Project was writen for mod_cgi, but I would like to parse content that
was generated by my scripts to implement something like SSI or
Apache::UCase and etc.
I don't know how to set "stacked handler" after mod_cgi. May be it's
wrong way of doing this?
Could I do this?
Beforehand thank.
_
Sorry for my bad English.
 mailto:[EMAIL PROTECTED]