Re: mod_perl IDE

2004-05-18 Thread Brent 'Dax' Royal-Gordon
Waldo_Tumanut/MO/[EMAIL PROTECTED] wrote:
What would you recommend for Windows-based integrated development 
environment for non-heavy-programmers such as DBAs and data analysts? 
Target server platforms are Windows and AIX.
If you already have a Visual Studio license, I'm partial to 
ActiveState's VisualPerl plugin.  Includes syntax highlighting, debugger 
integration, and all sorts of other shinies.

--
Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker
Oceania has always been at war with Eastasia.
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [mp2] Custom directives

2004-05-14 Thread Brent &#x27;Dax&#x27; Royal-Gordon
Stas Bekman wrote:
a=SERVER_CREATE();
b=SERVER_CREATE();
RegulateDatabase(a, ...);
global_init(b);
global_init(c);
I have no idea where 'c' is coming from--like I said, I've 
instrumented {SERVER,DIR}_{CREATE,MERGE}, which I think should cover 
everything.
PostConfig is called twice, because of the server startup:
http://perl.apache.org/docs/2.0/user/handlers/server.html#Startup_Phases_Demonstration_Module 
Right...I figured I could probably handle that by setting a flag 
variable somewhere, or something of the sort.

Why are the PostConfig handlers being given config objects with 
different addresses, though?

...hmm.  It looks like they're being handed different server objects:
global_init server: Apache::Server=SCALAR(0x8caded0)
global_init server: Apache::Server=SCALAR(0x8c059e0)
Okay, this is starting to beg a question: why is PostConfig called 
twice?  What does each call represent?  Why is it only called once for 
an 'apachectl -k restart'?

And perhaps the question I should've asked to start with: if I need to 
fork off one background process for the entire Apache server, what 
handler should I do so in?

--
Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker
Oceania has always been at war with Eastasia.

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [mp2] Custom directives

2004-05-14 Thread Brent &#x27;Dax&#x27; Royal-Gordon
Stas Bekman wrote:
I still didn't have a chance to look at it in details, but could it be 
the issue with merging not performing a deep copy?
http://perl.apache.org/docs/2.0/user/config/custom.html#Merging_Entries_Whose_Values_Are_References 
I don't think so--the only operation I do on that array is @{$arrayref} 
to flatten it out into a DBI argument list.  (i.e. I never mutate it, 
which is where deep copying is important.)

If not, I'll look tomorrow on a fresh head, unless someone beats me to it.
I instrumented SERVER_CREATE, DIR_CREATE, SERVER_MERGE, DIR_MERGE, 
RegulateDatabase, and global_init to print the value of $self to the log:

SERVER_CREATE: Apache::Regulate=HASH(0x831a330)
SERVER_CREATE: Apache::Regulate=HASH(0x831a450)
RegulateDatabase: Apache::Regulate=HASH(0x831a330)
global_init: Apache::Regulate=HASH(0x831a450)
global_init: Apache::Regulate=HASH(0x8105190)
So what we're seeing is:

a=SERVER_CREATE();
b=SERVER_CREATE();
RegulateDatabase(a, ...);
global_init(b);
global_init(c);
I have no idea where 'c' is coming from--like I said, I've instrumented 
{SERVER,DIR}_{CREATE,MERGE}, which I think should cover everything.

--
Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker
Oceania has always been at war with Eastasia.

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: [mp2] Custom directives

2004-05-14 Thread Brent &#x27;Dax&#x27; Royal-Gordon
Stas Bekman wrote:
Even with a line in my httpd.conf like:
PerlLoadModule Apache::Regulate
RegulateDatabase 'dbi:mysql:apache' apache [redacted]
Please try:


# start perl early

PerlLoadModule Apache::Regulate
RegulateDatabase 'dbi:mysql:apache' apache [redacted]
Doesn't seem to have helped.  Before and after adding those lines to 
httpd.conf, a Data::Dumper call in global_init gives:

$VAR1 = bless( {
 'on' => 0,
 'Database' => [
 'DBI:mysql:apache',
 'apache',
 'password'
   ],
 'dead' => 0,
 'ChunkSize' => '8000',
 'TotalQuota' => '1966080',
 'TotalBuffer' => 4
   }, 'Apache::Regulate' );
Which is precisely the default configuration.

For what it's worth, I ended up having to modify my output filter 
function to use this to load the full configuration:

my %conf=(
%{Apache::Module->get_config(__PACKAGE__, $f->r->server)},
    %{Apache::Module->get_config(__PACKAGE__, $f->r->server,
$f->r->per_dir_config)}
);
Might a similar mixing be necessary in global_init?

--
Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker
Oceania has always been at war with Eastasia.

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


[mp2] Custom directives

2004-05-13 Thread Brent &#x27;Dax&#x27; Royal-Gordon
Hello,
I'm writing a pure-Perl Apache 2 module that installs a few custom 
directives.  Four of the directives are only useful in the server root 
(i.e. outside of any VirtualHost, Directory, etc. directives), but three 
others make sense within containers.

The directives seem to parse correctly, but when I try to access the 
configuration structure from a PostConfigHandler or ChildInitHandler, 
the resulting structure contains the default configuration, as if the 
directives had never been parsed at all.  (I want a PostConfigHandler 
because I need to fork off a single background process for the entire 
server, and that seems like the easiest way to do so.)

At the very least, I'm looking for a good example of a module that does 
something like this, but if someone can help me with the specific 
problem I'm having, that'd be even better.

Some (possibly) relevant bits of code follow...

our @APACHE_MODULE_COMMANDS=(
{
name => 'RegulateDatabase',
args_how => Apache::TAKE123,
req_override => Apache::RSRC_CONF,
errmsg => 'RegulateDatabase connectionstring [username
[password]]'
},
...
);
sub SERVER_CREATE {
return bless {
Database=> ['DBI:mysql:Regulate'],
...
}, shift;
}
sub DIR_CREATE {
return bless {
...
}, shift;
}
sub SERVER_MERGE {
my($base, $add)[EMAIL PROTECTED];
return bless { %$add, %$base }, ref $base;
}
sub DIR_MERGE {
my($base, $add)[EMAIL PROTECTED];
return bless { %$add, %$base }, ref $base;
}
sub RegulateDatabase {
my($self, $params, @args)=(@_);
$self->[EMAIL PROTECTED];
}
sub global_init #:PostConfigHandler
{
my(undef, undef, undef, $s)[EMAIL PROTECTED];
my $conf=Apache::Module->get_config(__PACKAGE__, $s);
...
my $dbh=DBI->connect(@{$conf->{Database}}, {RaiseError=>1}) or
die $DBI::errstr;
}
Even with a line in my httpd.conf like:
PerlLoadModule Apache::Regulate
RegulateDatabase 'dbi:mysql:apache' apache [redacted]
global_init() dies with this error:
DBI connect('Regulate','HASH(0x8a377ec)',...) failed: Access denied
for user: '@localhost' to database 'Regulate'
Which leads me to believe that either the information isn't being 
recorded for some reason, or I'm looking at the wrong $conf structure.

Any help, even just a pointer to a module that does something like this, 
would be much appreciated.  In the mean time, I guess I'll hardwire the 
values I want and continue testing...

--
Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker
Oceania has always been at war with Eastasia.

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: DBI and Apache::DBI

2004-05-12 Thread Brent &#x27;Dax&#x27; Royal-Gordon
I S wrote:
Sorry for being unclear.  I mean Apache subdirectory
under site_perl directory.  I can seee Registry.pm
under .../site_perl/5.8.3/sun4-solaris/Apache
directory. (Apache::Registry)  I would expect DBI in
the same directory but it is not there.   I figured
that out after it gave me an error that it can't find
Apache::DBI.
Try .../site_perl/Apache and .../site_perl/5.8.3/Apache.  Also, if you 
originally installed mod_perl with an older version of Perl, check its 
folders.

--
Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker
Oceania has always been at war with Eastasia.

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html