cvs commit: modperl-2.0/src/modules/perl modperl_perl_includes.h

2002-05-29 Thread dougm

dougm   02/05/29 18:23:28

  Modified:src/modules/perl modperl_perl_includes.h
  Log:
  define environ on darwin if needed
  
  Revision  ChangesPath
  1.13  +5 -0  modperl-2.0/src/modules/perl/modperl_perl_includes.h
  
  Index: modperl_perl_includes.h
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_perl_includes.h,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- modperl_perl_includes.h   23 May 2002 22:40:47 -  1.12
  +++ modperl_perl_includes.h   30 May 2002 01:23:28 -  1.13
   -63,4 +63,9 
   #   define PERL_MAGIC_tied 'P'
   #endif
   
  +#if defined(__APPLE__)  !defined(PERL_CORE)  !defined(environ)
  +#   include crt_externs.h
  +#   define environ (*_NSGetEnviron())
  +#endif
  +
   #endif /* MODPERL_PERL_INCLUDES_H */
  
  
  



cvs commit: modperl-2.0/lib/Apache Build.pm

2002-05-29 Thread dougm

dougm   02/05/29 18:52:55

  Modified:lib/Apache Build.pm
  Log:
  darwin does not like ranlib on mod_perl.so
  
  Revision  ChangesPath
  1.95  +9 -4  modperl-2.0/lib/Apache/Build.pm
  
  Index: Build.pm
  ===
  RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v
  retrieving revision 1.94
  retrieving revision 1.95
  diff -u -r1.94 -r1.95
  --- Build.pm  29 May 2002 03:26:40 -  1.94
  +++ Build.pm  30 May 2002 01:52:55 -  1.95
   -20,6 +20,7 
   use constant HAS_ITHREADS =
   $Config{useithreads}  ($Config{useithreads} eq 'define');
   
  +use constant DARWIN = $^O eq 'darwin';
   use constant WIN32 = $^O eq 'MSWin32';
   use constant MSVC  = WIN32()  ($Config{cc} eq 'cl');
   
   -863,10 +864,14 
   
   sub dynamic_link_default {
   my $self = shift;
  -return $self-dynamic_link_header_default . 'EOF';
  - -o $
  - $(MODPERL_RANLIB) $
  -EOF
  +
  +my $link = $self-dynamic_link_header_default . \t . '-o $';
  +
  +my $ranlib = \t . '$(MODPERL_RANLIB) $';
  +
  +$link .= \n . $ranlib unless DARWIN;
  +
  +$link;
   }
   
   sub dynamic_link_MSWin32 {
  
  
  



cvs commit: modperl-2.0/xs/tables/current/ModPerl FunctionTable.pm

2002-05-29 Thread dougm

dougm   02/05/29 19:33:49

  Modified:src/modules/perl modperl_filter.c modperl_filter.h
   xs/APR/Bucket APR__Bucket.h
   xs/Apache/RequestIO Apache__RequestIO.h
   xs/tables/current/ModPerl FunctionTable.pm
  Log:
  use apr_size_t rather than apr_ssize_t for apr_bucket_read
  (gets rid of some warnings on darwin)
  
  Revision  ChangesPath
  1.35  +10 -10modperl-2.0/src/modules/perl/modperl_filter.c
  
  Index: modperl_filter.c
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- modperl_filter.c  6 Apr 2002 01:19:15 -   1.34
  +++ modperl_filter.c  30 May 2002 02:33:48 -  1.35
   -3,7 +3,7 
   /* simple buffer api */
   
   MP_INLINE apr_status_t modperl_wbucket_pass(modperl_wbucket_t *wb,
  -const char *buf, apr_ssize_t len)
  +const char *buf, apr_size_t len)
   {
   apr_bucket_alloc_t *ba = (*wb-filters)-c-bucket_alloc;
   apr_bucket_brigade *bb;
   -52,9 +52,9 
   
   MP_INLINE apr_status_t modperl_wbucket_write(modperl_wbucket_t *wb,
const char *buf,
  - apr_ssize_t *wlen)
  + apr_size_t *wlen)
   {
  -apr_ssize_t len = *wlen;
  +apr_size_t len = *wlen;
   *wlen = 0;
   
   if ((len + wb-outcnt)  sizeof(wb-outbuf)) {
   -226,13 +226,13 
   return 0;
   }
   
  -MP_INLINE apr_ssize_t modperl_output_filter_read(pTHX_
  - modperl_filter_t *filter,
  - SV *buffer,
  - apr_ssize_t wanted)
  +MP_INLINE apr_size_t modperl_output_filter_read(pTHX_
  +modperl_filter_t *filter,
  +SV *buffer,
  +apr_size_t wanted)
   {
   int num_buckets = 0;
  -apr_ssize_t len = 0;
  +apr_size_t len = 0;
   
   (void)SvUPGRADE(buffer, SVt_PV);
   SvPOK_only(buffer);
   -268,7 +268,7 
   
   while (1) {
   const char *buf;
  -apr_ssize_t buf_len;
  +apr_size_t buf_len;
   
   if (!get_bucket(filter)) {
   break;
   -361,7 +361,7 
   
   MP_INLINE apr_status_t modperl_output_filter_write(modperl_filter_t *filter,
  const char *buf,
  -   apr_ssize_t *len)
  +   apr_size_t *len)
   {
   return modperl_wbucket_write(filter-wbucket, buf, len);
   }
  
  
  
  1.14  +7 -7  modperl-2.0/src/modules/perl/modperl_filter.h
  
  Index: modperl_filter.h
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- modperl_filter.h  6 Apr 2002 01:19:15 -   1.13
  +++ modperl_filter.h  30 May 2002 02:33:48 -  1.14
   -12,13 +12,13 
   
   /* simple buffer api */
   MP_INLINE apr_status_t modperl_wbucket_pass(modperl_wbucket_t *b,
  -const char *buf, apr_ssize_t len);
  +const char *buf, apr_size_t len);
   
   MP_INLINE apr_status_t modperl_wbucket_flush(modperl_wbucket_t *b);
   
   MP_INLINE apr_status_t modperl_wbucket_write(modperl_wbucket_t *b,
const char *buf,
  - apr_ssize_t *wlen);
  + apr_size_t *wlen);
   
   /* generic filter routines */
   
   -43,14 +43,14 
   
   MP_INLINE apr_status_t modperl_output_filter_flush(modperl_filter_t *filter);
   
  -MP_INLINE apr_ssize_t modperl_output_filter_read(pTHX_
  - modperl_filter_t *filter,
  - SV *buffer,
  - apr_ssize_t wanted);
  +MP_INLINE apr_size_t modperl_output_filter_read(pTHX_
  +modperl_filter_t *filter,
  +SV *buffer,
  +apr_size_t wanted);
   
   MP_INLINE apr_status_t modperl_output_filter_write(modperl_filter_t *filter,
  const char *buf,
  -   apr_ssize_t *len);
  +  

cvs commit: modperl-2.0/lib/Apache compat.pm

2002-05-29 Thread dougm

dougm   02/05/29 20:54:08

  Modified:lib/Apache compat.pm
  Log:
  prevent inclusion of Apache::Table
  
  Revision  ChangesPath
  1.56  +2 -0  modperl-2.0/lib/Apache/compat.pm
  
  Index: compat.pm
  ===
  RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- compat.pm 25 May 2002 17:49:03 -  1.55
  +++ compat.pm 30 May 2002 03:54:08 -  1.56
   -43,6 +43,8 
   $INC{'Apache/Constants.pm'} = __FILE__;
   
   $INC{'Apache/File.pm'} = __FILE__;
  +
  +$INC{'Apache/Table.pm'} = __FILE__;
   }
   
   sub request {
  
  
  



cvs commit: modperl-2.0/t/response/TestApache compat2.pm

2002-05-29 Thread dougm

dougm   02/05/29 21:05:07

  Modified:lib/Apache compat.pm
   t/response/TestApache compat2.pm
  Log:
  add compat for Apache::Table-new
  
  Revision  ChangesPath
  1.57  +8 -0  modperl-2.0/lib/Apache/compat.pm
  
  Index: compat.pm
  ===
  RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- compat.pm 30 May 2002 03:54:08 -  1.56
  +++ compat.pm 30 May 2002 04:05:06 -  1.57
   -472,5 +472,13 
   APR::URI-parse($r-pool, $uri);
   }
   
  +package Apache::Table;
  +
  +sub new {
  +my($class, $r, $nelts) = _;
  +$nelts ||= 10;
  +APR::Table::make($r-pool, $nelts);
  +}
  +
   1;
   __END__
  
  
  
  1.14  +6 -1  modperl-2.0/t/response/TestApache/compat2.pm
  
  Index: compat2.pm
  ===
  RCS file: /home/cvs/modperl-2.0/t/response/TestApache/compat2.pm,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- compat2.pm25 May 2002 17:49:03 -  1.13
  +++ compat2.pm30 May 2002 04:05:06 -  1.14
   -24,7 +24,7 
   sub handler {
   my $r = shift;
   
  -plan $r, tests = 44;
  +plan $r, tests = 45;
   
   $r-send_http_header('text/plain');
   
   -225,6 +225,11 
   my $ptime = Apache::Util::parsedate($fmtdate);
   
   ok t_cmp($time, $ptime, Apache::Util::parsedate);
  +
  +my $t = Apache::Table-new($r);
  +my $t_class = ref $t;
  +
  +ok t_cmp('APR::Table', $t_class, Apache::Table-new);
   
   #note these are not actually part of the tests
   #since i think on platforms where crypt is not supported,
  
  
  



cvs commit: modperl-2.0/lib/Apache Build.pm

2002-05-29 Thread dougm

dougm   02/05/29 23:00:49

  Modified:lib/Apache Build.pm
  Log:
  prevent possible fatal warning seen in 5.6.0/darwin in MM-init_others
  
  Revision  ChangesPath
  1.96  +4 -1  modperl-2.0/lib/Apache/Build.pm
  
  Index: Build.pm
  ===
  RCS file: /home/cvs/modperl-2.0/lib/Apache/Build.pm,v
  retrieving revision 1.95
  retrieving revision 1.96
  diff -u -r1.95 -r1.96
  --- Build.pm  30 May 2002 01:52:55 -  1.95
  +++ Build.pm  30 May 2002 06:00:49 -  1.96
   -824,6 +824,9 
   $$val =~ s/\(($mm_replace)\)/(MODPERL_\U$perl_config_pm_alias{$1})/g;
   }
   
  +#help prevent warnings
  +my mm_init_vars = (BASEEXT = '');
  +
   sub make_tools {
   my($self, $fh) = _;
   
   -832,7 +835,7 
   }
   
   require ExtUtils::MakeMaker;
  -my $mm = bless {}, 'MM';
  +my $mm = bless { mm_init_vars }, 'MM';
   $mm-init_others;
   
   for (qw(rm_f mv ld ar cp test_f)) {
  
  
  



Re: [RFC] Dynamic image generator handler

2002-05-29 Thread Gerald Richter

Hi,

I am a little bit late for this thread, but anyway...


 I looked at Apache::ImageMagick last night however, and although it
 seems pretty usefull, it doesn't really address what I want to do with
 my module.


I read your original RFC and as far as I see you can do everything you have
requested with Apache::ImageMagick. What are you missing? Beside the fact
that your benchmark shows that ImageMagick is slower then GD (but
ImageMagick also handle a lot more picture formats then GD, for example I
use it to convert TIFF input files to jpeg)

What about the idea from Ed, to have one module, where you can drop in
different backends?

Would this be an idea to extent Apache::ImageMagick, so that it can use
other grapical libraries?

Gerald


-
Gerald Richterecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:   Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: [EMAIL PROTECTED] Voice:+49 6133 925131
WWW:http://www.ecos.de  Fax:  +49 6133 925152
-




dso

2002-05-29 Thread Arnold van Kampen


Hi

Some messages ago, someone still mentioned that modperl had been
 - compiled in -, 
when describing his configuration, that he was having trouble with.

Does this mean it is still better to compile it in instead of
using mod_perl as a dso?



Arnold




Re: Invoke PHP scripts?

2002-05-29 Thread Thomas Klausner

Hi!

On Tue, May 28, 2002 at 09:48:14PM -0600, Ryan Thompson wrote:
 I'm developing a large-ish web site in which I would like to use a
 combination of mod_perl (90%) and PHP (10%). I have run into a
 roadblock trying to include the output of a PHP script from a mod_perl
 script.
As far as I know this is rather impossible with mod_perl 1.x

You can chain different perl handlers (but only perl handlers) using
Apache::Filter, or you could let your mod_perl application issue a real http
request (using LWP), parse the output, and then do what you want with it.

Apache 2.0 (and mod_perl 2.0) (both in BETA) can do what you want unsing
Filters.



-- 
 D_OMM  +  http://domm.zsi.at -+
 O_xyderkes |   neu:  Arbeitsplatz   |   
 M_echanen  | http://domm.zsi.at/d/d162.html |
 M_asteuei  ++





MVC advice..?

2002-05-29 Thread Rafiq Ismail (ADMIN)

Hi,

I'm building an MVC architecture site and have hit a design issue.  I have
varoius Control subclasses which relate to different templates with
different behaviour.  Now my problem is that I have to assign which
Subclass I want to instantiate, based on the script and params.  I my last
effort I went for a Shared datastructure holding (script, control module
pairs) which then allowed one to be dynamically eval 'use..''ed in the
main content handler.  I found that clunky.  I'm building from scratch
again and am thinking of just firing up a template and allowing the
control to be loaded INTO the view as a template toolkit plugin.  What I
hate about this is that I'm surrendering my View layer.

Is there a neat way of dynamically loading in the appropriate control
subclass?  Something proven and widely used.

Cheers,

Fiq

__  __   _ __  __
|  \/  | ___   __| | ___ _ __ _ __ |  \/  | __ _ _ __
| |\/| |/ _ \ / _` |/ _ \ '__| '_ \| |\/| |/ _` | '_ \
| |  | | (_) | (_| |  __/ |  | | | | |  | | (_| | | | |
|_|  |_|\___/ \__,_|\___|_|  |_| |_|_|  |_|\__,_|_| |_|
a pathetic example of his organic heritage
- Bad Religion






Re: Invoke PHP scripts?

2002-05-29 Thread Andrew McNaughton



On Wed, 29 May 2002, Thomas Klausner wrote:

 Hi!

 On Tue, May 28, 2002 at 09:48:14PM -0600, Ryan Thompson wrote:
  I'm developing a large-ish web site in which I would like to use a
  combination of mod_perl (90%) and PHP (10%). I have run into a
  roadblock trying to include the output of a PHP script from a mod_perl
  script.
 As far as I know this is rather impossible with mod_perl 1.x

 You can chain different perl handlers (but only perl handlers) using
 Apache::Filter, or you could let your mod_perl application issue a real http
 request (using LWP), parse the output, and then do what you want with it.

It's possible to lock up your server under heavy load if it's calling
itself via HTTP.  between that and mysql handles I prefer to have separate
apache engines for php and modperl.

Andrew




Re: mod-perl_2.0

2002-05-29 Thread Per Einar Ellefsen

At 00:25 29.05.2002, Kent, Mr. John wrote:
Now my question.  In the older version,(126) mod-perl created a larger
(heavy)
webserver.  I could then add a startup.pl file to its http.conf file
which used Apache::Registry to load perl and my modules.

I don't see how this works in the new version of mod-perl, because
I don't see a larger version of the httpd server anywhere.

When I did the install it just seemed to load into the Perl 5.6.1 libraries.

We'll need some more information about your build process... Normally, you 
specify the Apache Prefix (or the location of apxs) when running perl 
Makefile.PL. Then, you run make for mod_perl, ./configure and make for 
Apache 2.0, make test for mod_perl and I guess finally make install on both 
parts.

You should see the mod_perl 2 installation documents: 
http://perl.apache.org/release/docs/2.0/user/index.html

Did notice in the overview
The details of these optimizations from the most part are hidden from
 mod_perl users, the exception being that some will only be turned on
 with configuration directives. A few of which include:
 *   Inlined Apache::*.xs calls

But not sure how to use it.

This isn't really related to your question.. Look through the 
documentation, but for the most part these optimizations happen without you 
noticing.


-- 
Per Einar Ellefsen
[EMAIL PROTECTED]





Re: dso

2002-05-29 Thread Per Einar Ellefsen

At 11:41 29.05.2002, Arnold van Kampen wrote:

Hi

Some messages ago, someone still mentioned that modperl had been
  - compiled in -,
when describing his configuration, that he was having trouble with.

Does this mean it is still better to compile it in instead of
using mod_perl as a dso?

If you're having problems, it's often known to be the quick answer to try. 
If you're not having trouble, keep using DSO happily!


-- 
Per Einar Ellefsen
[EMAIL PROTECTED]





RE: dso

2002-05-29 Thread Joe Breeden

I have to agree with this statement. We have a server farm with 15 apache servers 
running mod_perl as a DSO (not counting the several development and QC servers) with 
no problems. IMHO mod_perl as a DSO probably had problems in the beginning, but I 
couldn't confirm that without some research and I'm too lazy to do it, and as a result 
people now recommend compiling mod_perl into httpd. So I would say if DSO works for 
you use it, if not don't use it. 

 -Original Message-
 From: Per Einar Ellefsen [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, May 29, 2002 6:54 AM
 To: Arnold van Kampen
 Cc: [EMAIL PROTECTED]
 Subject: Re: dso
 
 
 At 11:41 29.05.2002, Arnold van Kampen wrote:
 
 Hi
 
 Some messages ago, someone still mentioned that modperl had been
   - compiled in -,
 when describing his configuration, that he was having trouble with.
 
 Does this mean it is still better to compile it in instead of
 using mod_perl as a dso?
 
 If you're having problems, it's often known to be the quick 
 answer to try. 
 If you're not having trouble, keep using DSO happily!
 
 
 -- 
 Per Einar Ellefsen
 [EMAIL PROTECTED]
 
 
 



RE: MVC advice..?

2002-05-29 Thread Aaron Ross

 Is there a neat way of dynamically loading in the appropriate control
 subclass?  Something proven and widely used.

For what it's worth, I use the eval trick too.  Although it may seem a
little clunky, I believe it is proven and widely used.  The DBI.pm
module uses code like this to load in the DBD drivers:

my $driver_class = DBD::$driver;
eval package DBI::_firesafe; require $driver_class;

I'm not sure this answers your MVC questions, but maybe it will make you
feel more comfortable with your solution.

hth, aaron






Re: Configuring mod_perl on Debian

2002-05-29 Thread Stas Bekman

Ian D. Stewart wrote:
 On 2002.05.27 12:57 Andrew McNaughton wrote:
 

 Sounds to me like you're not setting your content-type correctly for
 some
 reason.  Have a look at the headers being sent out.  It's either not
 sending this header, or it's sending something the browser doesn't
 know
 what to do with.
 
 
 This is the content of test.pl
 
 BEGIN-SCRIPT
 -- 
 #!/usr/bin/perl
 
 # your httpd.conf should have something like this:
 
 # Alias /perl/  /real/path/to/perl-scripts/
 
 # Location /perl
 # SetHandler  perl-script
 # PerlHandler Apache::Registry
 # PerlSendHeader On
 # Options +ExecCGI
 # /Location
 
 print Content-type: text/html\n\n;
 
 print bDate: , scalar localtime, /bbr\n;
 
 print %ENV: br\n, map { $_ = $ENV{$_} br\n } keys %ENV;
 -- 
 END-SCRIPT
 
 Based on this, I would expect the content to be set to text/html and the 
 page to be displayed to be a listing of the current environment.
 
 Galeon identifies the content type as application/x-perl.  This would 
 seem to indicate to me that Apache is serving the script directly 
 instead of executing the script and serving the output.  According to 
 the mod_perl Guide, the ExecCGI option (which I have set for Location 
 /perl) is supposed to avoid this situation.

issue a request from the command line and look at the saved response. 
Use lwp's GET, or 'lynx -dump' or any other favorite downloading utility.

__
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




Re: back-tracking

2002-05-29 Thread Stas Bekman

Lucas M. Saud wrote:
 hi,
 
 i'm writting a module to highlighting of Perl syntactical structures, but the 
current code is very slow... :(
 
 i need some help to implementing a method of back-tracking or one way to revising 
a token that has already been formatted without reformatting the entire string? it's 
possible?
 
 if anyone interess, contact-me and i will send the source code...

I fail to see what this has to do with the mod_perl list :( This kind of 
questions is *not* welcome here.

__
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




PerlWarn/AxKit - insecure dependency

2002-05-29 Thread Arnold van Kampen



Hi

I have been going through the code example on www.perl.com
(XSP, Taglibs and Pipelines)

I  noticed I get a problem with 
PerlWarn On
PerlTaintCheck On
in httpd.conf.
So, when I turn PerlWarn Off and PerlTaintCheck Off it works.

Main error message:
[AxKit] [Error] Insecure dependency in eval while running with -T switch
at /usr/lib/perl5/site_perl/5.6.1/i586-linux/Apache/AxKit/Language/XSP.pm
line 109.
 
For testing I used these
lynx -source localhost/axkit/weather1.xsp?zip=15206 | xmllint --format -
lynx -source localhost/axkit/weather1.xsp?zip=15206 




Arnold


I am using 
Apache 1.3.23 
mod_perl 1.26
AxKit 1.52
linux 2.4.10 i686 (SuSE) 


Below are 
- config files
- code example files
- error message


CONFIG FILES

# startup.pl

#!/usr/bin/perl

use lib qw(/usr/local/apache/lib/modperl);
#use lib qw(/home/kampen/lib/modperl);

use Apache::Constants;
use Apache::Registry;
use Apache::RegistryLoader;
use DBI;
use CGI qw(:all);


use DirHandle;
use strict;


$Apache::Registry::NameWithVirtualHost = 0;


my $rl = Apache::RegistryLoader-new;
my $dh = DirHandle-new(/usr/local/apache/perl) or die $!;

foreach my $file ($dh-read) {
next unless $file =~ /\.(pl|cgi)$/;

#print $STDOUT pre-loading $file\n;


$rl-handler(/perl/$file,/usr/local/apache/perl/$file);
}


1;
__END__


# perl.conf

PerlRequire conf/startup.pl

PerlInitHandler Apache::Reload
PerlSetVar ReloadAll Off
PerlSetVar ReloadTouchFile /tmp/reload_modules
#PerlWarn On
#PerlTaintCheck On

PerlModule  AxKit
Alias /axkit/   /usr/local/apache/axkit/
Location /axkit
SetHandler  perl-script
PerlHandler AxKit
   
AxDebugLevel 10
AxCacheDir  /tmp/axkit_cache
AxStackTraceOn   
AxGzipOutputOff

AxAddXSPTaglib AxKit::XSP::Util
AxAddXSPTaglib AxKit::XSP::Param
AxAddXSPTaglib MyTaglibs::WeatherTaglib

AxAddStyleMap application/x-xsp Apache::AxKit::Language::XSP
AxAddStyleMap application/x-xpathscript Apache::AxKit::Language::XPathScript
AxAddStyleMap text/xsl  Apache::AxKit::Language::Sablot

/Location


Location /axkit_articles/weather
SetHandler  perl-script
PerlHandler MyTaglibs::WeatherTaglibs
/Location

Location /bla
SetHandler  perl-script
PerlHandler Test::Test
/Location


PerlModule  Apache::PerlSections

perl
push Alias, [ qw(/perl/ /usr/local/apache/perl/) ];

$Location{/perl/} = { SetHandler  =  perl-script,
PerlHandler =  Apache::Registry,
Options =  +ExecCGI,
PerlSendHeader  =  On,
PerlSetupEnv=  On
};

$PerlSetVar = Filter On if Apache-module('Apache::Filter');

print STDERR Apache::PerlSections-dump;

/perl




##
CODE SAMPLES

weather1.xsp:

?xml-stylesheet href=NULL type=application/x-xsp?
?xml-stylesheet href=weather.xsl type=text/xsl?
?xml-stylesheet href=as_html.xsl type=text/xsl?


xsp:page language=Perl
xmlns:xsp=http://www.apache.org/1999/XSP/Core;
xmlns:util=http://apache.org/xsp/util/v1;
xmlns:param=http://axkit.org/NS/xsp/param/v1;
xmlns:weather=http://olddog.acon.nl/axkit_articles/weather/;

data
titlea name=title/Mijn weer rapportage/title
time
  util:time format=%H:%M:%S: /
/time
weather
weather:report
weather:zipparam:zip//weather:zip
/weather:report
/weather
/data
/xsp:page

weather.xsl:
---
xsl:stylesheet 
  version=1.0
  xmlns:xsl=http://www.w3.org/1999/XSL/Transform;

xsl:template match=/data/time
timeHi! It's xsl:value-of select=/data/time //time
/xsl:template
xsl:template match=/data/weather
weatherThe weather in
xsl:value-of select=/data/weather/city /,
xsl:value-of select=/data/weather/state/ is
xsl:value-of select=/data/weather/cond / and
xsl:value-of select=/data/weather/temp /F
(courtesy of a href={/data/weather/url}The
Weather Channel/a).
  /weather
/xsl:template
xsl:template match=*|node()
!-- Copy the rest of the doc verbatim --
xsl:copy
xsl:apply-templates select=*|node()/
/xsl:copy
/xsl:template
/xsl:stylesheet



as_html.xsl
---
xsl:stylesheet 
xmlns:xsl=http://www.w3.org/1999/XSL/Transform;
version=1.0

xsl:output method=html /

xsl:template match=/
html
head
titlexsl:value-of select=/data/title //title
/head
body
h1xsl:copy-of select=/data/title/node()   //h1
pxsl:copy-of select=/data/time/node()//p
pxsl:copy-of select=/data/weather/node() //p
/body
/html
/xsl:template

/xsl:stylesheet



Re: PerlWarn/AxKit - insecure dependency

2002-05-29 Thread Per Einar Ellefsen

At 16:00 29.05.2002, Arnold van Kampen wrote:


Hi

I have been going through the code example on www.perl.com
(XSP, Taglibs and Pipelines)

I  noticed I get a problem with
PerlWarn On
PerlTaintCheck On
in httpd.conf.
So, when I turn PerlWarn Off and PerlTaintCheck Off it works.

Main error message:
[AxKit] [Error] Insecure dependency in eval while running with -T switch
at /usr/lib/perl5/site_perl/5.6.1/i586-linux/Apache/AxKit/Language/XSP.pm
line 109.

This is AxKit and not mod_perl's fault. AxKit doesn't seem to be taint 
safe. You might want to get them to change it (unlikely, it'd be a pretty 
long job :) or turn off PerlTaintCheck.

-- 
Per Einar Ellefsen
[EMAIL PROTECTED]





Re: MVC advice..?

2002-05-29 Thread F . Xavier Noria

On Wed, 29 May 2002 09:22:00 -0400
Aaron Ross [EMAIL PROTECTED] wrote:

:  Is there a neat way of dynamically loading in the appropriate control
:  subclass?  Something proven and widely used.
: 
: For what it's worth, I use the eval trick too.  Although it may seem a
: little clunky, I believe it is proven and widely used.  The DBI.pm
: module uses code like this to load in the DBD drivers:
: 
: my $driver_class = DBD::$driver;
: eval package DBI::_firesafe; require $driver_class;

I wonder, why do you program such a central module that dynamic? Why
do you chose that approach instead of this one?

 package Dispatcher;

 use Controller1;
 # ...
 use ControllerN;

 sub handler {
 my $r = Apache::Request-new(shift);
 my $ctl = $r-param('ctl');

 return Controller1::handler($r) if $ctl = 'login';
 # ...
 return ControllerN::handler($r) if $ctl = 'show_cart';
 return SERVER_ERROR;
 }

-- fxn



Re: MVC advice..?

2002-05-29 Thread Perrin Harkins

Rafiq Ismail (ADMIN) wrote:
 Now my problem is that I have to assign which
 Subclass I want to instantiate, based on the script and params.

So, you're asking how to map URLs to perl modules?  Is there some reason 
you aren't simply using httpd.conf or Apache::Dispatch?  In my last MVC 
design, we had all of our controllers inherit from one base controller 
that held all of the common code.  Then we could just map from URLs to 
the specific controllers that handled them:

Location /mycontroller
   SetHandler  perl-script
   PerlHandler My::Controller
/Location

 I my last
 effort I went for a Shared datastructure holding (script, control module
 pairs) which then allowed one to be dynamically eval 'use..''ed in the
 main content handler.  I found that clunky.

There's no good reason to do an eval 'use'.  Use require instead, and 
import if you need to (but most people don't).

 I'm building from scratch
 again and am thinking of just firing up a template and allowing the
 control to be loaded INTO the view as a template toolkit plugin.  What I
 hate about this is that I'm surrendering my View layer.

I agree, that's a bad idea and certainly not MVC.

- Perrin




Re: Carp interaction with mod_perl

2002-05-29 Thread Stas Bekman

Christian Gilmore wrote:
 How does the Carp module interact with mod_perl? Is there a built-in catch
 for croak or does it actually kill the child process, for instance?

seems not to have any effect, i.e. it doesn't kill the process

__
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




Re: Referencing Directives

2002-05-29 Thread Ian D. Stewart

On 2002.05.28 01:23 Per Einar Ellefsen wrote:

 
 Or... maybe you could try using Apache class methods inside Perl 
 sections (like document_root) -- however I think that'd be pretty 
 shaky.

Hmm...something to tinker with as time permits...


Thanx,
Ian



Re: MVC advice..?

2002-05-29 Thread Rafiq Ismail (ADMIN)

Ello,

On 29 May 2002, Randal L. Schwartz wrote:

  Rafiq == Rafiq Ismail (ADMIN) [EMAIL PROTECTED]
writes:
 Rafiq Is there a neat way of dynamically loading in the appropriate
control
 Rafiq subclass?  Something proven and widely used.

 Load the file with a require, and then just call the appropriate
 constructor using an indirect call:

 require My/Prefix/$type; # presuming $type has no colons
 $myClass = My::Prefix::$type;
 my $handler = $myClass-new(@parms);

 This works even in use strict.

Thanks.  This is pretty much the handler which I'd previously written,
with the the exception of s/use/require/.  I'll probably either go with
Apache::Dispatch, using the DispatchRequire option, or write something
custom.


On Wed, 29 May 2002, Perrin Harkins wrote:
 So, you're asking how to map URLs to perl modules?  Is there some reason
 you aren't simply using httpd.conf or Apache::Dispatch?  In my last MVC

I just took a look at Apache::Dispatch and I get he impression that if I
were to use it then I would have to either PerlModule 'all' my subclasses
beforehand, or alternateively use the DispatchRequire option anyway.  I'm
already using StatINC so I'm going to have to do a toss between code which
I've already written and converging to the Apache::Dispatch interface.

I'm not so keen on loading all the inheriting classes into memory
beforehand, nor setting up multiple handlers for each location.  It's a
fairly large site and my main concern was to do with how I should store
the correspondence from uri to object.


 design, we had all of our controllers inherit from one base controller
 that held all of the common code.

I could just map from URLs to the specific control subclasses and then use
Dispatch to require them - I'd already started on writing a mapping from
path names to relative namespaces.  I was still 'eval/use'ing the
Modules though.

How does StatINC behave with 'required' packages?

Hmm.. it's make your mind up time. ;)


Thanks for the tips.
Cheers,

Fiq

__
__  __   _ __  __
|  \/  | ___   __| | ___ _ __ _ __ |  \/  | __ _ _ __
| |\/| |/ _ \ / _` |/ _ \ '__| '_ \| |\/| |/ _` | '_ \
| |  | | (_) | (_| |  __/ |  | | | | |  | | (_| | | | |
|_|  |_|\___/ \__,_|\___|_|  |_| |_|_|  |_|\__,_|_| |_|
a pathetic example of his organic heritage
- Bad Religion




separating C from V in MVC

2002-05-29 Thread Ray Zimmerman

We're developing a pretty complex web app using mod_perl and Mason 
and I'd like to use some form of MVC structure to keep things 
manageable.

I'm looking for some pointers on MVC in this context. Specifically, M 
is easy ... use Perl objects, but how are others implementing the 
Controllers and Views in order to keep them separate?

If I understand correctly, the Mason component that generates the 
page the user sees would be considered the View. But where is the 
Controller? I assume that, conceptually, the Controller is the code 
that responds to a given web request and decides which view to 
display. This is code I would normally have put in the %init 
section of the display component (with a possible redirect to another 
component based on application logic). This sounds like C and V are 
not separated as they should be.

What's the right way to do it?  (None of this TMTOWTDO stuff now, I 
want the RIGHT way :-)   ... and do I have the concepts right?

-- 
  Ray Zimmerman  / e-mail: [EMAIL PROTECTED] / 428-B Phillips Hall
   Sr Research  /   phone: (607) 255-9645  /  Cornell University
Associate  /  FAX: (815) 377-3932 /   Ithaca, NY  14853



Re: Patch to mod_perl 1.26: error-notes support

2002-05-29 Thread Doug MacEachern

On Tue, 28 May 2002, Geoffrey Young wrote:

 
 
 Doug MacEachern wrote:
 
  thanks, i've applied a variation of your patch to cvs and will be in 1.27
  if anybody wants to work up a similar patch for Apache::PerlRun, that'd be 
  nice too.
  
 
 this seems to work ok as PerlRun and RegistryNG.

looks good, +1.  thanks.




Re: DBI modperl_2 Segmentation fault

2002-05-29 Thread Doug MacEachern

On Fri, 24 May 2002, Udlei Nattis wrote:

 hi
 
 i updating modperl-2.0-cvs and problem persist
 now i change DynaLoader in DBI.pm to XSLoader but problem persist :(

you shouldn't need to change DBI.pm
the output of perl build/config.pl (normally should use t/REPORT) might 
help.  and your DBI version.




Re: separating C from V in MVC

2002-05-29 Thread Perrin Harkins

Ray Zimmerman wrote:
 If I understand correctly, the Mason component that generates the page 
 the user sees would be considered the View. But where is the Controller?

I wrote a little about this in my templating guide, and there has been 
discussion on the Mason list.  A common approach is to use Mason's 
autohandlers as controllers, but you could really use any component. 
Just have it do some work in perl, gather some data, and then pass it 
off to a view component that generates the HTML.

 This is code I
 would normally have put in the %init section of the display component 
 (with a possible redirect to another component based on application 
 logic). This sounds like C and V are not separated as they should be.

That's a standard way to do it in Mason, but not an MVC way.  To make it 
more MVC, you need to have separate components for C and V, with V just 
receiving data and displaying it in HTML.

- Perrin





Re: MVC advice..?

2002-05-29 Thread Perrin Harkins

Dave Rolsky wrote:
 On Wed, 29 May 2002, Perrin Harkins wrote:
 
 
There's no good reason to do an eval 'use'.  Use require instead, and
import if you need to (but most people don't).
 
 
 Actually, there is.  This code:
 
   my $module = 'Foo::Bar';
   require $module;
 
 is not the same as this:
 
   require Foo::Bar;
 
 If require is given a string, it looks for a filename _matching_ that
 string.  If it's given a bareword, it converts '::' to filesystem path
 separators first.

Then do an eval 'require Foo::Bar', but eval 'use Foo::Bar' doesn't make 
sense.

- Perrin




Re: MVC advice..?

2002-05-29 Thread Perrin Harkins

Rafiq Ismail (ADMIN) wrote:
 I'm not so keen on loading all the inheriting classes into memory
 beforehand

You really should do that, because it will save overall memory by 
increasing the amount of memory that's shared.  All modules should be 
loaded during startup in the parent process.

 It's a
 fairly large site and my main concern was to do with how I should store
 the correspondence from uri to object.

The httpd.conf format seems about as simple as you can get to me.  It's 
pretty unusual for a site to have dozens of controllers, and it usually 
indicates a design problem.  Apache::Dispatch is fine too.

 How does StatINC behave with 'required' packages?

Require and use are very similar and both add the loaded module to %INC. 
  Read 'perldoc -f use' for the exact differences.

- Perrin




Re: MVC advice..?

2002-05-29 Thread Dave Rolsky

On Wed, 29 May 2002, Perrin Harkins wrote:

 There's no good reason to do an eval 'use'.  Use require instead, and
 import if you need to (but most people don't).

Actually, there is.  This code:

  my $module = 'Foo::Bar';
  require $module;

is not the same as this:

  require Foo::Bar;

If require is given a string, it looks for a filename _matching_ that
string.  If it's given a bareword, it converts '::' to filesystem path
separators first.


-dave

/*==
www.urth.org
we await the New Sun
==*/




Re: Reloading Modules

2002-05-29 Thread Stas Bekman

Ted Prah wrote:
 Hi again,
 
 I'm having trouble seeing module changes when I reload
 a script that uses it.  

That's because Reload.pm doesn't re-exports the symbols when reloading 
the module and test.pl doesn't call import() because it sees the module 
in %INC, therefore it still sees the old sub till the moment it gets 
recompiled. Below you will find a complete analysis.

 I'm using Apache::Reload and my test
 script/module is as follows:
 
 
 test.pl
 
 #!/usr/local/bin/perl
 use strict;
 use warnings;
 
 use My::Test qw(:subs);
 
 print Content-type: text/plain\r\n\r\n;
 test1();
 
 
 
 Test.pm
 
 package My::Test;
 use strict;
 use warnings;
 
 BEGIN {
 use Exporter ();
 
 our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
 
 @ISA   = qw(Exporter);
 @EXPORT= qw();
 @EXPORT_OK = qw();
 
 %EXPORT_TAGS = (
 subs = [qw(test1)],
);
 
 Exporter::export_ok_tags('subs');
 
 }
 
 sub test1 { print In test1 func\n; }
 
 1;
 

adjust the test.pl to do:

test1(); print \test1, \n;
#test2(); print \test2, \n;

and My::Test.pm to:

...
warn test1:, \test1, \n;
#warn test2:, \test2, \n;
sub test1 { print In test1 func\n; }
#sub test2 { print In test2 func\n; }
...

The first time you run the script you will see:

output:
In test1 func
CODE(0x85ad38c)

error_log:
test1:CODE(0x85ad38c)

you can see that both test1 and My::Test::test1 point to the same sub.

 When I modify sub test1, and I reload - no changes appear
 in the browser.  The following gets printed to error_log:
 Subroutine test1 redefined at /export/home/httpd/cgi-bin/My/Test.pm line 22.

output:
In test1 func
CODE(0x85ad38c)

error_log:
test1:CODE(0x84ee110)

as you see the test1 is not the same as My::Test::test1

 When I touch test.pl - the changes appear.  The following gets printed
 to error_log:
 Subroutine test1 redefined at /export/home/httpd/cgi-bin/My/test.pl line 5

output:
In test11 func
CODE(0x84ee110)

now it points to the recent My::Test::test1

In that way you can debug any mysteries in Perl code.

Now, how to solve this problem. For example comment out
 require $key;

in Reload.pm

that way, test.pl will see that My::Test is not in %INC, and require it 
+ call its import() method.

Tell if this worked and we may adjust Reload.pm to have a special mode 
where it makes Perl forget about modified modules and let the code that 
loaded them in first place do the loading (and therefore the importing).

 Finally, if I add a new subroutine test2 to Test.pm, export it, and
 update the test.pl script to call test2, the script fails with an
 Internal
 Server Error.  The following gets printed to error_log:
 test2 is not exported by the My::Test module at
 /export/home/httpd/cgi-bin/My/test.pl line 5
 [Wed May 22 15:26:12 2002] [error] Can't continue after import errors at
 
 /export/home/httpd/cgi-bin/My/test.pl line 5
 BEGIN failed--compilation aborted at /export/home/httpd/cgi-bin/
 My/test.pl line 5.
 
 Then, when I restart the server, the script runs fine.

Hmm, this one is different. Seems like a bug in Exporter.

if you remove Reload.pm from the setup, so it won't confuse you and 
adjust the code to do:

do My/Test.pm;
My::Test-import(':subs');

you will see that it fails as well. This code acts like Reload.pm, but 
always reloads the module. So it's not Reload.pm's fault.

Is anybody else  familiar with this Exporter's (mis)behavior?

The solution that I see is to use something like this:

package My::Test;

use strict;
use warnings;

sub import {
 my $package = shift;

 no strict 'refs';
 for (@_) {
 *{ (caller)[0] . ::$_ } = \{$_};
 }
}

sub test1 { print In test1 func\n; }
sub test2 { print In test2 func\n; }

1;

If somebody else can see the problem with Exporter may be we need to run 
it through p5p.

__
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




Fwd: ApacheCon session submissions: deadline is this Friday!

2002-05-29 Thread Stas Bekman



 Original Message 
Subject: ApacheCon session submissions: deadline is this Friday!
Date: Tue, 28 May 2002 13:15:57 -0400
From: Rodent of Unusual Size [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
Organization: The Apache Software Foundation
To: ASF members [EMAIL PROTECTED]

Please make sure that all the appropriate project lists get
a copy..
-- 
#ken 
P-)}

Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
Author, developer, opinionist  http://Apache-Server.Com/

Millennium hand and shrimp!

-- 


__
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

---BeginMessage---

-BEGIN PGP SIGNED MESSAGE-

Greetings!

Just a reminder: this Friday is the deadline for presentation
proposals for the ApacheCon 2002 US conference in Las Vegas
in November 2002..

To submit a proposal, visit URL:http://ApacheCon.Com/html/cfp.html.
If you're not sure about a topic, or how well it might be received,
you can ask other ApacheCon attendees by posting a message on the
conference discussion list (see the Web page with the list details at
URL:http://ApacheCon.Com/html/lists.html).

Similarly, if you plan (or want) to attend the conference and want
to request a particular topic, join the discussion list and say so.
Not only will the planners then know, but you might trigger someone
into proposing your ideal session!
- -- 
#kenP-)}

Ken Coar, Sanagendamgagwedweinini  http://Golux.Com/coar/
Author, developer, opinionist  http://Apache-Server.Com/

Millennium hand and shrimp!

-BEGIN PGP SIGNATURE-
Version: PGPfreeware 6.5.8 for non-commercial use http://www.pgp.com

iQCVAwUBPPO5sprNPMCpn3XdAQEsDAP/QCP8kv5WtiKCj+5Maof2qkwrJ8/LBkVi
4gJvuEgZQda2m2HzUfcAr7+mtSEEV3p8aispEes/bDCVLKWyPbnbc5PCTeLhN99c
SXbjtTNzZf7lQeb36M/QLlrHgnP8ovUqln3w2P3AGETnl1gbiPnpA52cXW/L3vRH
tZr55PXOY3I=
=kib0
-END PGP SIGNATURE-



---End Message---


Re: Reloading Modules

2002-05-29 Thread Ted Prah

Thanks for the input Stats.  I found your debugging methodology
to be very informative and especially useful in a mod_perl environment.

I tried your suggestion of commenting out
 require $key;
in Reload.pm, but it did not work for me.  I'd be happy to try
any other suggestions you might have.

Your code to work around Exporter worked fine.  However,
I think I'll stick with using Exporter so that I can make use
of the export tags.

Thanks again!

Ted


Stas Bekman wrote:

 Ted Prah wrote:
  Hi again,
 
  I'm having trouble seeing module changes when I reload
  a script that uses it.

 That's because Reload.pm doesn't re-exports the symbols when reloading
 the module and test.pl doesn't call import() because it sees the module
 in %INC, therefore it still sees the old sub till the moment it gets
 recompiled. Below you will find a complete analysis.

  I'm using Apache::Reload and my test
  script/module is as follows:
 
 
  test.pl
  
  #!/usr/local/bin/perl
  use strict;
  use warnings;
 
  use My::Test qw(:subs);
 
  print Content-type: text/plain\r\n\r\n;
  test1();
  
 
 
  Test.pm
  
  package My::Test;
  use strict;
  use warnings;
 
  BEGIN {
  use Exporter ();
 
  our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
 
  @ISA   = qw(Exporter);
  @EXPORT= qw();
  @EXPORT_OK = qw();
 
  %EXPORT_TAGS = (
  subs = [qw(test1)],
 );
 
  Exporter::export_ok_tags('subs');
 
  }
 
  sub test1 { print In test1 func\n; }
 
  1;
  

 adjust the test.pl to do:

 test1(); print \test1, \n;
 #test2(); print \test2, \n;

 and My::Test.pm to:

 ...
 warn test1:, \test1, \n;
 #warn test2:, \test2, \n;
 sub test1 { print In test1 func\n; }
 #sub test2 { print In test2 func\n; }
 ...

 The first time you run the script you will see:

 output:
 In test1 func
 CODE(0x85ad38c)

 error_log:
 test1:CODE(0x85ad38c)

 you can see that both test1 and My::Test::test1 point to the same sub.

  When I modify sub test1, and I reload - no changes appear
  in the browser.  The following gets printed to error_log:
  Subroutine test1 redefined at /export/home/httpd/cgi-bin/My/Test.pm line 22.

 output:
 In test1 func
 CODE(0x85ad38c)

 error_log:
 test1:CODE(0x84ee110)

 as you see the test1 is not the same as My::Test::test1

  When I touch test.pl - the changes appear.  The following gets printed
  to error_log:
  Subroutine test1 redefined at /export/home/httpd/cgi-bin/My/test.pl line 5

 output:
 In test11 func
 CODE(0x84ee110)

 now it points to the recent My::Test::test1

 In that way you can debug any mysteries in Perl code.

 Now, how to solve this problem. For example comment out
  require $key;

 in Reload.pm

 that way, test.pl will see that My::Test is not in %INC, and require it
 + call its import() method.

 Tell if this worked and we may adjust Reload.pm to have a special mode
 where it makes Perl forget about modified modules and let the code that
 loaded them in first place do the loading (and therefore the importing).

  Finally, if I add a new subroutine test2 to Test.pm, export it, and
  update the test.pl script to call test2, the script fails with an
  Internal
  Server Error.  The following gets printed to error_log:
  test2 is not exported by the My::Test module at
  /export/home/httpd/cgi-bin/My/test.pl line 5
  [Wed May 22 15:26:12 2002] [error] Can't continue after import errors at
 
  /export/home/httpd/cgi-bin/My/test.pl line 5
  BEGIN failed--compilation aborted at /export/home/httpd/cgi-bin/
  My/test.pl line 5.
 
  Then, when I restart the server, the script runs fine.

 Hmm, this one is different. Seems like a bug in Exporter.

 if you remove Reload.pm from the setup, so it won't confuse you and
 adjust the code to do:

 do My/Test.pm;
 My::Test-import(':subs');

 you will see that it fails as well. This code acts like Reload.pm, but
 always reloads the module. So it's not Reload.pm's fault.

 Is anybody else  familiar with this Exporter's (mis)behavior?

 The solution that I see is to use something like this:

 package My::Test;

 use strict;
 use warnings;

 sub import {
  my $package = shift;

  no strict 'refs';
  for (@_) {
  *{ (caller)[0] . ::$_ } = \{$_};
  }
 }

 sub test1 { print In test1 func\n; }
 sub test2 { print In test2 func\n; }

 1;

 If somebody else can see the problem with Exporter may be we need to run
 it through p5p.

 __
 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






Re: Persistent Net::Telnet Objects

2002-05-29 Thread Perrin Harkins

French, Shawn wrote:
 Although this is working right now, I don't know enough [ anything? :) ]
 about Apache or mod_perl to be sure that this will work in the future.

I can't see how it could be working now, unless it is actually creating 
a new Telnet object on every request.  Your %sessionHash is not shared 
between processes and you have no control over which process will handle 
any request.  You're probably opening new telnet connections from each 
apache process.

 What
 I am really concerned about is that the telnetObj will only be accessible
 from scripts run by the same child process as that which created and saved
 it.

That won't work, since you can't control which process will handle 
requests from the client.

 Is there a better way to do this?

You could write a web server in Perl, which would run a separate 
persistent process for each client on a different port.  Randal wrote a 
column about that: http://www.stonehenge.com/merlyn/WebTechniques/col23.html

You could also use this technique to make a sort of telnet server, and 
hide that server behind Apache/mod_perl, i.e. clients talk to mod_perl 
which talks to the telnet server.

Of course the simplest approach would be to just let each Apache process 
open telnet sessions as needed.

- Perrin







RE: Persistent Net::Telnet Objects

2002-05-29 Thread mod_perl

Maybe you can tell us more about the project (e.g. why 
telnet ?) so there will come many bad advices ? :-)

Peter Bi
 
 Perrin wrote:
  I can't see how it could be working now
 
 That makes two of us!
 
  You're probably opening new telnet connections from each apache process.
 
 I know that I am not since they are continuing to log to the same dump file,
 and my code (as stated in previous message) simply goes to the hash and
 takes the object.
 
  That won't work, since you can't control which process will handle 
  requests from the client.
 
 OK, is there a way to make sure that there is just one process? This site is
 not for milions of users, only 10 - 20.
 
 I'm sure that others have had to keep persistent sockets and/or filehandles
 on their server, and I really don't see how my problem is any different...
 
 Please, can anybody help me?
 Shawn



Re: Persistent Net::Telnet Objects

2002-05-29 Thread Rob Mueller (fastmail)

Our project needed persistent socket connections open as well. There is
supposed to be a standard mechanism to pass file descriptors between unix
processes, though it's bugginess level depends on your OS. There is a perl
module for this called Socket::PassAccessRights. So what you can do is
create a daemon process that just hangs round holding socket connections
open, like a socket cache basically, and passing them back and forth between
Apache processes based on some session ID or user ID or the like.

Your daemon ends up looking something like this (with lots more error
checking of course)

my %sockmap;
while (1) {
  my $clientsock = $listen-accept();
  chomp(my $sessionid = $clientsock);
  my $cachesock = ($sockmap{$sessionid} ||= opennewsock());
  Socket::PassAccessRights::sendfd(fileno($clientsock), fileno($cachesock));
  $clientsock-close();
}

And in your mod_perl code you do something like:

  my $serversock = IO::Socket::INET-new(Server = 'localhost', Port =
SOCKETPOOLPORT);
  print $serversock $sessionid, \n;
  my $Fd = Socket::PassAccessRights::recvfd(fileno($serversock));
  open(my $realsocket, =$Fd);
  fcntl($realsocket, F_SETFD, 0);
  my $ofh = select($realsocket); $| = 1; select ($ofh);

If you do some experimenting, you'll get something that works, you'll also
find lots of cases that don't.

Rob

- Original Message -
From: French, Shawn [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, May 30, 2002 3:53 AM
Subject: Persistent Net::Telnet Objects


 Vitals:
 Apache/1.3.20 (Win32) mod_perl/1.25_01-dev mod_ssl/2.8.4 OpenSSL/0.9.6a on
 Windows 2000 with PHP 4.21

 I am working on a project that requires me to have two telnet objects per
 user session opened, and accessible throughout the user's session. I have
 looked at Apache::Session and many other solutions but my problem is that
to
 keep a Net::Telnet object, I need to keep open sockets and filehandles, so
I
 cannot serialize the object and store it in a database or file.

 Currently I have similar code working flawlessly:
 ###
 # startup.pl - called when apache starts (ie. PerlRequire
 d:/Apache/conf/startup.pl)
 ##
 use MySite::Session;

 ###
 # Session.pm
 ##
 @EXPORT = qw( %sessionHash );
 our %sessionHash;

 ###
 # init_session.pl - called IN MOD_PERL when a new session is requested
 ##
 use MySite::Session;
 $sessionHash{$session_id . _telnetObj} = Net::Telnet-new();

 ###
 # dostuff.pl - called IN MOD_PERL many time throughout the session
 ##
 use MySite::Session;
 my telnetObj = $sessionHash{$session_id . _telnetObj};
 bless (\$telnetObj, Net::Telnet);

 Although this is working right now, I don't know enough [ anything? :) ]
 about Apache or mod_perl to be sure that this will work in the future.
What
 I am really concerned about is that the telnetObj will only be accessible
 from scripts run by the same child process as that which created and saved
 it.

 Is there a better way to do this?

 Thanks,
 Shawn French






Re: Reloading Modules

2002-05-29 Thread Stas Bekman

Ted Prah wrote:
 Thanks for the input Stats.  I found your debugging methodology
 to be very informative and especially useful in a mod_perl environment.
 
 I tried your suggestion of commenting out
  require $key;
 in Reload.pm, but it did not work for me.  I'd be happy to try
 any other suggestions you might have.

But did you debug whether the module was reloaded from test.pl with the 
modified Reload.pm? If so was the import() called? If not, try to have 
it as a separate call:

require My::Test;
My::Test-import(':subs');

 Your code to work around Exporter worked fine.  However,
 I think I'll stick with using Exporter so that I can make use
 of the export tags.

But it doesn't seem to work? You can easily extend the import() function 
I've suggested to suppport tags.

__
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




Re: Invoke PHP scripts?

2002-05-29 Thread Stas Bekman

Ryan Thompson wrote:
 Thomas Klausner wrote to [EMAIL PROTECTED]:
 
 
Hi!

On Tue, May 28, 2002 at 09:48:14PM -0600, Ryan Thompson wrote:


I'm developing a large-ish web site in which I would like to use a
combination of mod_perl (90%) and PHP (10%). I have run into a
roadblock trying to include the output of a PHP script from a
mod_perl script.

How about using notes()?
http://perl.apache.org/release/docs/1.0/guide/snippets.html#Passing_Notes_Between_mod_perl_and_other__non_Perl__Apache_Modules


__
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




Re: Persistant references [was] Persistent Net::Telnet Objects

2002-05-29 Thread Ryan Parr

I never do give enough info on the first e-mail. Thank you for bearing with
me...

What I mean is, if a request comes in for a certain form I would like to be
able to do something like this:

my $form = load_form($r);
$c{$session_id}-{handler} = $form-{handler}; # -- this being a code
ref...
$r-send_http_header;
print $form;

Then when the user completes the form and resubmits:

my $handler = $c{$session_id}-{handler};
$r-send_http_header;
print $handler-($r);

This is definately simplified, but the idea is there. I would like to be
able to store anything that can be referenced and have it be available to
all processes. I would like to be able to dynamically create anonymous
subroutine handlers based on input and have them be active until the form is
submitted, at which time they are used to process the form then discarded.

Is this something that can be accomplished? The global hash using Perl
aliasing
(http://thingy.kcilink.com/modperlguide/perl/Using_the_Perl_Aliasing_Feature
_.html) works beautifully, until of course the form is submitted to another
httpd process, and I'm hoping to not have to limit myself to just one child.

Obviously this can't be serialized, but there has to be *some* way to do
this...

-- Ryan


- Original Message -
From: Ryan Parr [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, May 29, 2002 9:16 PM
Subject: Persistant references [was] Persistent Net::Telnet Objects


 Along these same lines I'm seeking a way to store a code reference into a
 global hash that is shared among all processes. For example:

 my $session_id = get_session_from_cookie($r);
 my $handler = $c{$session_id}-{handler};

 $r-send_http_header;
 print $handler-($r);
 return OK;

 Has anyone performed this kind of magical tidbit before? Is there some
main
 process repository that I can access?

 -- Ryan


 - Original Message -
 From: Rob Mueller (fastmail) [EMAIL PROTECTED]
 To: French, Shawn [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Wednesday, May 29, 2002 5:35 PM
 Subject: Re: Persistent Net::Telnet Objects


  Our project needed persistent socket connections open as well. There is
  supposed to be a standard mechanism to pass file descriptors between
unix
  processes, though it's bugginess level depends on your OS. There is a
perl
  module for this called Socket::PassAccessRights. So what you can do is
  create a daemon process that just hangs round holding socket connections
  open, like a socket cache basically, and passing them back and forth
 between
  Apache processes based on some session ID or user ID or the like.
 
  Your daemon ends up looking something like this (with lots more error
  checking of course)
 
  my %sockmap;
  while (1) {
my $clientsock = $listen-accept();
chomp(my $sessionid = $clientsock);
my $cachesock = ($sockmap{$sessionid} ||= opennewsock());
Socket::PassAccessRights::sendfd(fileno($clientsock),
 fileno($cachesock));
$clientsock-close();
  }
 
  And in your mod_perl code you do something like:
 
my $serversock = IO::Socket::INET-new(Server = 'localhost', Port =
  SOCKETPOOLPORT);
print $serversock $sessionid, \n;
my $Fd = Socket::PassAccessRights::recvfd(fileno($serversock));
open(my $realsocket, =$Fd);
fcntl($realsocket, F_SETFD, 0);
my $ofh = select($realsocket); $| = 1; select ($ofh);
 
  If you do some experimenting, you'll get something that works, you'll
also
  find lots of cases that don't.
 
  Rob
 
  - Original Message -
  From: French, Shawn [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Thursday, May 30, 2002 3:53 AM
  Subject: Persistent Net::Telnet Objects
 
 
   Vitals:
   Apache/1.3.20 (Win32) mod_perl/1.25_01-dev mod_ssl/2.8.4
OpenSSL/0.9.6a
 on
   Windows 2000 with PHP 4.21
  
   I am working on a project that requires me to have two telnet objects
 per
   user session opened, and accessible throughout the user's session. I
 have
   looked at Apache::Session and many other solutions but my problem is
 that
  to
   keep a Net::Telnet object, I need to keep open sockets and
filehandles,
 so
  I
   cannot serialize the object and store it in a database or file.
  
   Currently I have similar code working flawlessly:
   ###
   # startup.pl - called when apache starts (ie. PerlRequire
   d:/Apache/conf/startup.pl)
   ##
   use MySite::Session;
  
   ###
   # Session.pm
   ##
   @EXPORT = qw( %sessionHash );
   our %sessionHash;
  
   ###
   # init_session.pl - called IN MOD_PERL when a new session is
requested
   ##
   use MySite::Session;
   $sessionHash{$session_id . _telnetObj} = Net::Telnet-new();
  
   ###
   # dostuff.pl - called IN MOD_PERL many time throughout the session
   ##
   use MySite::Session;
   my telnetObj = $sessionHash{$session_id . _telnetObj};
   bless (\$telnetObj, Net::Telnet);
  
   Although this is working right now, I don't know enough [ anything?
:) ]
   about Apache or mod_perl to be sure that this will work in the future.
  What
   I am really concerned 

Re: Persistant references [was] Persistent Net::Telnet Objects

2002-05-29 Thread Garth Winter Webb

You could just pass around a string rather than a subref:

my $handler = 'sub { my $arg = @_; do_something(); }';

vs

my $handler = sub { my $arg = @_; do_something(); };

When you want to call it later on you do it like:

eval($handler)-('foo');

vs

$handler-('foo');

Garth

On Wed, 2002-05-29 at 22:17, Ryan Parr wrote:
 I never do give enough info on the first e-mail. Thank you for bearing with
 me...
 
 What I mean is, if a request comes in for a certain form I would like to be
 able to do something like this:
 
 my $form = load_form($r);
 $c{$session_id}-{handler} = $form-{handler}; # -- this being a code
 ref...
 $r-send_http_header;
 print $form;
 
 Then when the user completes the form and resubmits:
 
 my $handler = $c{$session_id}-{handler};
 $r-send_http_header;
 print $handler-($r);
 
 This is definately simplified, but the idea is there. I would like to be
 able to store anything that can be referenced and have it be available to
 all processes. I would like to be able to dynamically create anonymous
 subroutine handlers based on input and have them be active until the form is
 submitted, at which time they are used to process the form then discarded.
 
 Is this something that can be accomplished? The global hash using Perl
 aliasing
 (http://thingy.kcilink.com/modperlguide/perl/Using_the_Perl_Aliasing_Feature
 _.html) works beautifully, until of course the form is submitted to another
 httpd process, and I'm hoping to not have to limit myself to just one child.
 
 Obviously this can't be serialized, but there has to be *some* way to do
 this...
 
 -- Ryan
 
 
 - Original Message -
 From: Ryan Parr [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, May 29, 2002 9:16 PM
 Subject: Persistant references [was] Persistent Net::Telnet Objects
 
 
  Along these same lines I'm seeking a way to store a code reference into a
  global hash that is shared among all processes. For example:
 
  my $session_id = get_session_from_cookie($r);
  my $handler = $c{$session_id}-{handler};
 
  $r-send_http_header;
  print $handler-($r);
  return OK;
 
  Has anyone performed this kind of magical tidbit before? Is there some
 main
  process repository that I can access?
 
  -- Ryan
 
 
  - Original Message -
  From: Rob Mueller (fastmail) [EMAIL PROTECTED]
  To: French, Shawn [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Sent: Wednesday, May 29, 2002 5:35 PM
  Subject: Re: Persistent Net::Telnet Objects
 
 
   Our project needed persistent socket connections open as well. There is
   supposed to be a standard mechanism to pass file descriptors between
 unix
   processes, though it's bugginess level depends on your OS. There is a
 perl
   module for this called Socket::PassAccessRights. So what you can do is
   create a daemon process that just hangs round holding socket connections
   open, like a socket cache basically, and passing them back and forth
  between
   Apache processes based on some session ID or user ID or the like.
  
   Your daemon ends up looking something like this (with lots more error
   checking of course)
  
   my %sockmap;
   while (1) {
 my $clientsock = $listen-accept();
 chomp(my $sessionid = $clientsock);
 my $cachesock = ($sockmap{$sessionid} ||= opennewsock());
 Socket::PassAccessRights::sendfd(fileno($clientsock),
  fileno($cachesock));
 $clientsock-close();
   }
  
   And in your mod_perl code you do something like:
  
 my $serversock = IO::Socket::INET-new(Server = 'localhost', Port =
   SOCKETPOOLPORT);
 print $serversock $sessionid, \n;
 my $Fd = Socket::PassAccessRights::recvfd(fileno($serversock));
 open(my $realsocket, =$Fd);
 fcntl($realsocket, F_SETFD, 0);
 my $ofh = select($realsocket); $| = 1; select ($ofh);
  
   If you do some experimenting, you'll get something that works, you'll
 also
   find lots of cases that don't.
  
   Rob
  
   - Original Message -
   From: French, Shawn [EMAIL PROTECTED]
   To: [EMAIL PROTECTED]
   Sent: Thursday, May 30, 2002 3:53 AM
   Subject: Persistent Net::Telnet Objects
  
  
Vitals:
Apache/1.3.20 (Win32) mod_perl/1.25_01-dev mod_ssl/2.8.4
 OpenSSL/0.9.6a
  on
Windows 2000 with PHP 4.21
   
I am working on a project that requires me to have two telnet objects
  per
user session opened, and accessible throughout the user's session. I
  have
looked at Apache::Session and many other solutions but my problem is
  that
   to
keep a Net::Telnet object, I need to keep open sockets and
 filehandles,
  so
   I
cannot serialize the object and store it in a database or file.
   
Currently I have similar code working flawlessly:
###
# startup.pl - called when apache starts (ie. PerlRequire
d:/Apache/conf/startup.pl)
##
use MySite::Session;
   
###
# Session.pm
##
@EXPORT = qw( %sessionHash );
our %sessionHash;
   
###
# init_session.pl - called IN MOD_PERL when a new session is
 

cvs commit: modperl/lib/Apache PerlRun.pm

2002-05-29 Thread geoff

geoff   02/05/29 09:52:17

  Modified:lib/Apache PerlRun.pm
  Log:
  PerlRun/RegistryNG errors are now saved in $r-notes('error-notes')
  Submitted by: geoff
  Reviewed by: dougm
  
  Revision  ChangesPath
  1.39  +9 -2  modperl/lib/Apache/PerlRun.pm
  
  Index: PerlRun.pm
  ===
  RCS file: /home/cvs/modperl/lib/Apache/PerlRun.pm,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- PerlRun.pm25 Mar 2002 01:59:02 -  1.38
  +++ PerlRun.pm29 May 2002 16:52:17 -  1.39
   -28,6 +28,12 
   return bless {r=$r}, $class;
   }
   
  +sub xlog_error {
  +my($r, $msg) = _;
  +$r-log_error($msg);
  +$r-notes('error-notes', $msg);
  +}
  +
   sub can_compile {
   my($pr) = _;
   my $r = $pr-{r};
   -52,7 +58,7 
$pr-{'mtime'} = -M _;
return wantarray ? (OK, $pr-{'mtime'}) : OK;
   }
  -$r-log_error($filename not found or unable to stat);
  +xlog_error($r, $filename not found or unable to stat);
   return NOT_FOUND;
   }
   
   -139,7 +145,7 
   }
   
   if($errsv) {
  - $r-log_error($errsv);
  + xlog_error($r, $errsv);
return SERVER_ERROR;
   }
   
   -211,6 +217,7 
   my $pr = shift;
   if ($ and substr($,0,4) ne  at ) {
$pr-{r}-log_error(PerlRun: `$');
  + $pr-{r}-notes('error-notes', $);
$@{$pr-{r}-uri} = $;
$ = ''; #XXX fix me, if we don't do this Apache::exit() breaks 
return SERVER_ERROR;
  
  
  



cvs commit: modperl Changes

2002-05-29 Thread geoff

geoff   02/05/29 09:56:04

  Modified:.Changes
  Log:
  expand $r-notes('error-notes') to cover PerlRun and RegistryNG
  
  Revision  ChangesPath
  1.647 +2 -1  modperl/Changes
  
  Index: Changes
  ===
  RCS file: /home/cvs/modperl/Changes,v
  retrieving revision 1.646
  retrieving revision 1.647
  diff -u -r1.646 -r1.647
  --- Changes   29 May 2002 16:25:40 -  1.646
  +++ Changes   29 May 2002 16:56:04 -  1.647
  @@ -14,7 +14,8 @@
   thanks to Lyle Brooks for the spot
   [Stephen Clouse [EMAIL PROTECTED]]
   
  -Apache::Registry errors are now saved in $r-notes('error-notes')
  +Apache::Registry/PerlRun/RegistryNG errors are now saved 
  +in $r-notes('error-notes')
   [Jesse Erlbaum [EMAIL PROTECTED]]
   
   fix Win32 build problems with spaces in shell arguments