Template or XML?
Hello, all! We have a 4 year experience in developing web sites for our customers. Most of these web sites must present information stored in some relational database (MySQL or Oracle), and we create a special web interface for managing the data stored in the database. We cannot use standard modules like DB::Editor, because we need to provide a simple and easy-to-use interface for end user. We used to create such interface using Apache::ASP, but that was incovenient because we could not reuse code for different projects, and it required a programmer and a usability specialist to work togather on such interface which took up to 70% of the entire project. Now we use Template Toolkit 2, it is more convenient as we can define templates with common objects. Some of these objects perform tasks related to database, for example, updating or fetching data from the database, other kind of objects are those that define presentation of the document. So, we can reuse such objects, but it is not very convenient. The main template mostly consists of a lot of [% INCLUDE ... %] statements, and we want to use some simplier syntax for this, like XML. We tried to use XML, but the main problem with XML is that we cannot insert even a simple logic constructions, like IF of FOREACH, as with Template. At this time, for this configuration file we use a special XML-like syntax (it is not really an XML, it is translated into TT2 with a our parser). Here is an example of such page: autorization_check mysql_connect database=musica edit sql=update banned_ip set ip=? where ip=? params=ip old_ip delete sql=delete from musica.banned where banned_ip = ? params=old_ip add sql=insert into musica.banned (banned_ip) values (?) params=ip rows=fetch sql=select banned_ip from banned order by banned_ip page name=musica.mustdie.ru title=Innards of musica subtitle=Banned IP add_table rowth value=Ban new IP:inp name=ip type=text size=15/row /add_table edit_table edit_titleth value=Banned IP hint=Banned IP/edit_title FOREACH c=rows row inp name=ip type=text value=c.banned_ip size=15 inp name=old_ip type=hidden value=c.banned_ip /row /FOREACH edit_titleth value=Banned IP hint=Banned IP/edit_title /edit_table /page -- which is actually translated into [% PROCESS autorization_check %] [% mysql_connect({database=musica}) %] etc... Our questions are: 1. Are there any mod-perl packages created for similar tasks? 2. Can constructions similar to FOREACH c=rows ... /FOREACH (which is now translated into [% FOREACH ... %] template blocks) be implemented with standard XML parser? - Best regards, Alexander Efimov. programmer of WebZavod (http://www.webzavod.ru)
Re: Persistent Database connections to Oracle
On Thu, 13 Sep 2001, Medi Montaseri wrote: I have a related question How do I confirm that I indeed have a persistent database connection... I have modified my httpd.conf via PerlRequire /path/startup.pl with debuging at level 2...I see the following in my httpd error_log [Thu Sep 13 22:11:34 2001] [notice] Apache/1.3.12 (Unix) (Red Hat/Linux) mod_ssl/2.6.6 OpenSSL/0.9.5a mod_perl/1.24 configured -- resuming normal operations 5653 Apache::DBI PerlChildInitHandler 5654 Apache::DBI PerlChildInitHandler 5655 Apache::DBI PerlChildInitHandler 5656 Apache::DBI PerlChildInitHandler 5660 Apache::DBI PerlChildInitHandler 5658 Apache::DBI PerlChildInitHandler 5657 Apache::DBI PerlChildInitHandler 5659 Apache::DBI PerlChildInitHandler But when I check my sessions on my Informix, I don't see any sessions owned by the owner of the httpd process... By the way, my method of checking my Informix sessions is onstat -g ses Just in case I'm doing this part wrong In case you don't see Apache::DBI reporting that it reuses connections, you don't have the persistance. That's the whole point of debug statements. But did you actually generated some requests? The above messages are from the server startup and doesn't help at all. Stas Bekman wrote: On Thu, 13 Sep 2001, Flavio D' Amore wrote: Hi! How can i configure the startup.pl in order to use a global symbol such as $lda = Apache::DBI-connect_on_init(... including a persistent database connection to Oracle that's could be shared by other perl scripts? http://perl.apache.org/guide/databases.html _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/ -- - Medi Montaseri [EMAIL PROTECTED] Unix Distributed Systems EngineerHTTP://www.CyberShell.com CyberShell Engineering - _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
keeping perl in memory
Blank This question does and doesn't have to do with mod_perl. I wish to keep perl binary (nothing related to apache) in memory so that each time a specific script is invoked there is no cost of perl startup time. The script gets executed many times (intercepts corporate, virtual domain email). Regards, Mire -- perl -Mstrict -e 'print pack(h*, d69627560496e616d656e236f6d6),\n' OPTIMISED FOR HUMAN OPTICAL NERVE BEST VIEWED WITH A MONITOR grin
Re: keeping perl in memory
Hi there, On Fri, 14 Sep 2001, Miroslav Madzarevic wrote: This question does and doesn't have to do with mod_perl. I wish to keep perl binary (nothing related to apache) in memory See the Guide: http://perl.apache.org/guide And read about Apache::Registry. 73, Ged.
Re: keeping perl in memory
I don't wan't anything related to Apache (no Apache, not even Apache::Registry or anything else, I'm a mod perl, Mason programmer so I'm familiar with them). I just wanted to have perl binary persistent in memory (_like_ in mod_perl) so that perl doesn't have to be loaded #!/usr/local/bin/perl on each _shell_ request and there could be many of requests (once per email). But I found a solution with Matt Sergeant's help in using POE or some other daemon and communicating with it. This way I have perl in some sort of persistance. It's not a true replacement but it will do. If there is another list to wich I should direct questions like these please direct me. Rgds, mire - Original Message - From: Ged Haywood [EMAIL PROTECTED] To: Miroslav Madzarevic [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, 14 September, 2001 14:55 Subject: Re: keeping perl in memory This question does and doesn't have to do with mod_perl. I wish to keep perl binary (nothing related to apache) in memory See the Guide: http://perl.apache.org/guide And read about Apache::Registry.
Re: Template or XML?
On Friday 14 September 2001 11:40, Alexandr Efimov wrote: We tried to use XML, but the main problem with XML is that we cannot insert even a simple logic constructions, like IF of FOREACH, as with Template. Yes you can, but of course you need a dedicated processor. XML is just a syntax :-) One thing you could use for this is XSP, available as part of AxKit (it's useful enough that I'd like to see it split out, but it looks like no one has the time to work on that right now). I don't know of anyone that's defined a control structures taglib, but of course you can always use XSP Core to do that. In fact it is rarely needed as in the general case for example for loops, you'd simply output what it is you want to loop over as the output of XSP, and then XSLT will take care of converting that to whatever output you want, most of the time taking care of the looping transparently (at whatever degree of depth and/or recursivity). At this time, for this configuration file we use a special XML-like syntax (it is not really an XML, it is translated into TT2 with a our parser). If you are considering switching to XML (even if it is in a very distant future) then I'd recommend still using valid XML rather than an XML-like syntax. It may be useless now, but if you're thinking of changing it'll make the change trivial. Our questions are: 1. Are there any mod-perl packages created for similar tasks? There's AxKit, and I think that other packages can do that too (Apache::PageKit ?). 2. Can constructions similar to FOREACH c=rows ... /FOREACH (which is now translated into [% FOREACH ... %] template blocks) be implemented with standard XML parser? By the parser itself, no, its job is simply to parse, nothing more. You could however rather trivially create a SAX processor, and XSP taglib, etc that would do that job. -- ___ Robin Berjon [EMAIL PROTECTED] -- CTO k n o w s c a p e : // venture knowledge agency www.knowscape.com --- An eye for an eye will make the whole world blind. -- Mahatma Gandhi
Re: keeping perl in memory
Miroslav Madzarevic wrote: I don't wan't anything related to Apache (no Apache, not even Apache::Registry or anything else, I'm a mod perl, Mason programmer so I'm familiar with them). I just wanted to have perl binary persistent in memory (_like_ in mod_perl) so that perl doesn't have to be loaded #!/usr/local/bin/perl on each _shell_ request and there could be many of requests (once per email). http://sourceforge.net/projects/speedycgi/ If there is another list to wich I should direct questions like these please direct me. The newsgroup comp.lang.perl.misc is most appropriate forum for general Perl questions. Also, comp.lang.perl.modules is for discussing use of Perl modules. If you don't have access to a Usenet (NNTP) server you can use the web interface at http://groups.google.com
Persistent Database connections
Hi, Im very near to the solution of my problem, but there's still a thing that's not working properly. Before running my perl script (f1.pl) i see five httpd@hostname sessions in Oracle V$session but at the moment in which i run f1.pl there appear a seventh session alone such f1.pl@hostname. The mechanism of persistent connections seems to be not workinkg properly. What goes wrong? Thanks a lot in advance --- Fl@vio D' Amore DATAMAT S.p.A. Via Laurentina 760 00143 Rome - Italy DATASIM - Product Support Phone: +39-06-50.27.4350 case.zip
Template or XML?
Hello, All! Yes. AxKit's XSP module does this. Your SQL can be generated with the AxKit::XSP::ESQL module, and then you can loop over the results in your XSLT stylesheet using either xsl:foreach or (better still) using a template. Actually using AxKit::XSP::ESQL module seems to be much more complicated compared to calling a function in Template Toolkit, for example, it is inconvenient to write code like this: -- sql:execute-query sql:driverSybase/sql:driver sql:dburldatabase=mydb/sql:dburl sql:usernamematt/sql:username sql:passwordmillionaire/sql:password sql:querySELECT MessageId, Subject FROM Messages/sql:query /sql:execute-query - in Template, it would be something like [% data=fetch({sql=SELECT MessageId, Subject FROM Messages}) %] and we can connect to database only once, probably before processing a Template. Also, logic seems to be easier to implement with Template than with AxKit. So, we tried to set up Apache so that files will be processed with Template Toolkit first, and the result will be an XML to be processed by AxKit. But that didn't work, with the following error message in log: Can't locate object method filter_register via package Apache at /usr/local/lib/site_perl/Apache/RegistryFilter.pm line 13. How can I configure Apache so that Template output will be processed by AxKit? We have also heard something about OpenInteract, which is based on Template Toolkit - may be it would be simplier to use it? - Best regards, Alexander Efimov. programmer of WebZavod (http://www.webzavod.ru)
Re: Pre-announce Apache::ConfigParser
Hi! I swore there was yet a third candidate in this realm, but I didn't see it on brief inspection. I am currently sort of working (haven't touched for some time) on something called Apache::FakeEnv which should be something like a subclass of Apache::FakeRequest, but which includes access to stuff defined in Apache Config Files. I am now using Config::General to parse the config file, which works, but as Config::General doesn't handle eg. PerlSetVar in the way I need it, I have to do some dirty tricks to use the data structure returned from Config::General A feature I would really like to see (or implement myself in some combined verions of the various Config parsers) is a way to take a parsed config and an URL and to get all values that apply to this URL eg: Location /test/ PerlSetVar foo bar PerlSetVar baz bla /Location LocationMatch something PerlSetVar foo NotBar /LocationMatch $conf-requested_uri('http://host/test/somehting/'); print $conf-dir_config('foo'); # prints 'NotBar' print $conf-dir_config('baz'); # prints 'bla' So, if there will be an Unified Apache Config Parsing Module, I would like to implement this feature (if it's not allready there ...) domm
Re: Template or XML?
On Friday 14 September 2001 18:16, Alexandr Efimov wrote: Yes. AxKit's XSP module does this. Your SQL can be generated with the AxKit::XSP::ESQL module, and then you can loop over the results in your XSLT stylesheet using either xsl:foreach or (better still) using a template. Actually using AxKit::XSP::ESQL module seems to be much more complicated compared to calling a function in Template Toolkit, for example, it is inconvenient to write code like this: -- sql:execute-query sql:driverSybase/sql:driver sql:dburldatabase=mydb/sql:dburl sql:usernamematt/sql:username sql:passwordmillionaire/sql:password sql:querySELECT MessageId, Subject FROM Messages/sql:query /sql:execute-query - in Template, it would be something like [% data=fetch({sql=SELECT MessageId, Subject FROM Messages}) %] and we can connect to database only once, probably before processing a Template. Also, logic seems to be easier to implement with Template than with AxKit. Your examples are not equivalent ! To begin with, your connection params are unlikely to be in the same place as the query, otherwise you'd have to include them everytime you want to use the connection, which would be painful. For this, you can use either entities or XInclude. The example would be more like: sql:execute-query connect_params; sql:querySELECT MessageId, Subject FROM Messages/sql:query /sql:execute-query But this is still useless (as is your TT example), and not really equivalent. A more exact equivalent would be: xsp:logic my $data = Foo::fetch({sql=SELECT MessageId, Subject FROM Messages}); /xsp:logic AxKit::XSP::ESQL is great if you need to generate XML records from SQL. It has many helpers to do that in a great variety of ways. However if all you need is a little SQL here (ie if you're using less than 10% of what it does) then the verbosity does clearly become an overhead. I personally do use it for simplistic SQL queries, including updates that don't influence the output, but only when I'm already using it for larger operations within the same site (by larger I mean that have to generate XML records). So, we tried to set up Apache so that files will be processed with Template Toolkit first, and the result will be an XML to be processed by AxKit. But that didn't work, with the following error message in log: Can't locate object method filter_register via package Apache at /usr/local/lib/site_perl/Apache/RegistryFilter.pm line 13. How can I configure Apache so that Template output will be processed by AxKit? I'm not sure, I never tried this. However if you're looking for performance I wouldn't do that. Piping two independent modperl toolkits into one another is likely to give you serious performance hits. I'd recommend either finding your solution on the TT side, or switching completely to AxKit. Using both is a bit weird. Note that there are other ways than XSP to generate dynamic data in AxKit, I only mentionned it because it is the one I use (for the big advantage that it is XML throughout). We have also heard something about OpenInteract, which is based on Template Toolkit - may be it would be simplier to use it? This depends on where exactly your problem(s) lies. -- ___ Robin Berjon [EMAIL PROTECTED] -- CTO k n o w s c a p e : // venture knowledge agency www.knowscape.com --- An eye for an eye will make the whole world blind. -- Mahatma Gandhi
Environment variable $ENV{MOD_PERL}
Hi, im reading on mod_perl and Relational Databases (http://apache.org/guide/databases.html), Introduction, that persistent database connections needs to have set $ENV{MOD_PERL} in order to execute CGI perl script via mod_perl and not via normal CGI. What's the right value for that variable and where i've to set it (httpd.conf or Unix environment?)? By and thanks in advance --- Fl@vio D' Amore DATAMAT S.p.A. Via Laurentina 760 00143 Rome - Italy DATASIM - Product Support Phone: +39-06-50.27.4350
Re: Environment variable $ENV{MOD_PERL}
On Friday 14 September 2001 17:53, Flavio D' Amore wrote: im reading on mod_perl and Relational Databases (http://apache.org/guide/databases.html), Introduction, that persistent database connections needs to have set $ENV{MOD_PERL} in order to execute CGI perl script via mod_perl and not via normal CGI. What's the right value for that variable and where i've to set it (httpd.conf or Unix environment?)? mod_perl will take care for you to set it and to set it properly. That's the way to know that you're running under mod_perl. -- ___ Robin Berjon [EMAIL PROTECTED] -- CTO k n o w s c a p e : // venture knowledge agency www.knowscape.com --- An eye for an eye will make the whole world blind. -- Mahatma Gandhi
Re: Environment variable $ENV{MOD_PERL}
On Fri, 14 Sep 2001, Flavio D' Amore wrote: Hi, im reading on mod_perl and Relational Databases (http://apache.org/guide/databases.html), Introduction, that persistent database connections needs to have set $ENV{MOD_PERL} in order to execute CGI perl script via mod_perl and not via normal CGI. What's the right value for that variable and where i've to set it (httpd.conf or Unix environment?)? mod_perl does this for you. You shouldn't mess with it yourself. Hmm, may be you don't run under mod_perl even if you think you are? _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: Template or XML?
Alexandr Efimov wrote: Hello, all! We have a 4 year experience in developing web sites for our customers. Most of these web sites must present information stored in some relational database (MySQL or Oracle), and we create a special web interface for managing the data stored in the database. We cannot use standard modules like DB::Editor, because we need to provide a simple and easy-to-use interface for end user. We used to create such interface using Apache::ASP, but that was incovenient because we could not reuse code for different projects, and it required a programmer and a usability specialist to work togather on such interface You ever look at XMLSubs in Apache::ASP? It should promote code reuse like you are going for. You just need to install your XMLSubs module in each of your projects. Also, if you decomp much of your generic application logic into some real object, you can init this object, say $App, in Script_OnStart, and have it available in all scripts just like $Server, $Session, etc. use vars qw($App $Form); sub Script_OnStart { my $dbh = DBI-connect(...); $App = My::App-new(dbh = $dbh, ...); $Form = $Request-Form; } The you can reference $App in all scripts includes, just like %= $App-print_something % since all scripts includes are compiled into the same package as global.asa. For support of the code you mentioned like: edit sql=update banned_ip set ip=? where ip=? params=ip old_ip delete sql=delete from musica.banned where banned_ip = ? params=old_ip add sql=insert into musica.banned (banned_ip) values (?) params=ip You can define PerlSetVar XMLSubsMatch edit|delete|add Then in global.asa, you can define you subs like so: # assuming edit() represents a widget db function sub edit { my($args, $html) = @_; my @params = split(/\s+/, $args-{params}); if($Form-{'edit'}) { $App-{dbh}-do($args-{sql}, undef, map { $Form-{$_} } @params); } print input type=submit name=edit value=Edit; } Because these XMLSubs don't have their own namespace you would not be able to decomp them into their own perl package, but you could put them in a perl module without a package, and then use/require/do them from global.asa to import. I only suggest this for code reuse between projects. You could also have them in a package, and them import the functions, but you might have to reference vars like $main::App, which you would have to init in global.asa. Its very easy to not use good coding practice with Apache::ASP, but you can use like any other full embedded perl environment for good code reuse. One more thing ... XMLSubs are limited to parsing out only the XML attributes body, so things like FOREACH are harder to implement, however a recent feature makes it possible, as you can now $Response-Include() scripts data on the fly, not just file names, so: XMLSubs FOREACH|rows|row|inp rows name=myrows action=fetch sql=select banned_ip from banned order by banned_ip ... FOREACH c=myrows row inp name=ip type=text value=c.banned_ip size=15 inp name=old_ip type=hidden value=c.banned_ip /row /FOREACH sub rows { my $args = shift; my @rows; my $sth = $App-{dbh}-prepare($args-{sql}); while(my $row = $sth-fetchrow_hashref) { push(@rows, $row); } $App-{rows}{$args-{name}} = $rows; } sub FOREACH { my($args, $script) = @_; my $rows = $App-{rows}{$args-{c}}; for my $row (@$rows) { $App-{currrow} = $row; $Response-Include(\$script); } } sub inp { my $args = shift; my $row = $App-{currrow}; print input name=$args-{name} value=$row-{$args-{name}} ...; } Just as example of how you might achieve what you are going for with Apache::ASP. I know you used it before, but the application environment has grown considerably over time, now in its 4th year of development. --Josh _ Joshua Chamas Chamas Enterprises Inc. NodeWorks Founder Huntington Beach, CA USA http://www.nodeworks.com1-714-625-4051
How to build apache/mod_perl/mod_ssl
Hi, I have the sources of: apache 1.3.20 openssl-0.9.6b openssl-engine-0.9.6b mod_ssl-2.8.4-1.3.20 mod_perl-1.26 How do I build them? I have tried ./configure --help in all but it seems they are all inter-reliant on each other and it seems impossible to build apache and enable mod_perl and mod_ssl, or I have no idea how to do it. I'm using Red Hat Linux 7.1 on an Intel x86 (Celeron). Thanks heaps. James
Re: How to build apache/mod_perl/mod_ssl
If you're on RedHat 7.1, the easiest way is to go to ftp://ftp.redhat.com/pub/redhat/linux/rawhide/i386/RedHat/RPMS/ and just download and install the packages. They don't have a current version of mod_perl though. You may have the also update your glibc to 2.2.4. Blair [EMAIL PROTECTED] wrote: Hi, I have the sources of: apache 1.3.20 openssl-0.9.6b openssl-engine-0.9.6b mod_ssl-2.8.4-1.3.20 mod_perl-1.26 How do I build them? I have tried ./configure --help in all but it seems they are all inter-reliant on each other and it seems impossible to build apache and enable mod_perl and mod_ssl, or I have no idea how to do it. I'm using Red Hat Linux 7.1 on an Intel x86 (Celeron). Thanks heaps. James
RE: How to build apache/mod_perl/mod_ssl
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, September 14, 2001 2:22 PM To: [EMAIL PROTECTED] Subject: How to build apache/mod_perl/mod_ssl Hi, I have the sources of: apache 1.3.20 openssl-0.9.6b openssl-engine-0.9.6b mod_ssl-2.8.4-1.3.20 mod_perl-1.26 see INSTALL.simple.mod_ssl in the mod_perl sources for some hints... HTH --Geoff
RE: How to build apache/mod_perl/mod_ssl
Or you can check out the mod_perl guide, specifically: http://perl.apache.org/guide/install.html#mod_perl_and_mod_ssl_openssl_ If you haven't seen the guide before, take some time to go through it. It's an excellent resource. -Fry -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, September 14, 2001 11:22 AM To: [EMAIL PROTECTED] Subject: How to build apache/mod_perl/mod_ssl Hi, I have the sources of: apache 1.3.20 openssl-0.9.6b openssl-engine-0.9.6b mod_ssl-2.8.4-1.3.20 mod_perl-1.26 How do I build them? I have tried ./configure --help in all but it seems they are all inter-reliant on each other and it seems impossible to build apache and enable mod_perl and mod_ssl, or I have no idea how to do it. I'm using Red Hat Linux 7.1 on an Intel x86 (Celeron). Thanks heaps. James
Updating $r-connection-aborted before $r-print() ?
Hey, In my own experience it seems that I can only get $r-connection-aborted updated if I first do a $r-print(). Is there any way to get aborted to update without $r-print? The scenario is that developer would like to know the aborted status before any part of the script runs, where browser requests might queue up on a busy server for 3+ seconds before the scripts run, hit the STOP button reload. Unfortunately, to have to print() or send headers before an aborted check means that the headers have already been sent out, which is limiting. Thanks, Josh _ Joshua Chamas Chamas Enterprises Inc. NodeWorks Founder Huntington Beach, CA USA http://www.nodeworks.com1-714-625-4051
RE: Updating $r-connection-aborted before $r-print() ?
-Original Message- From: Joshua Chamas [mailto:[EMAIL PROTECTED]] Sent: Friday, September 14, 2001 3:21 PM To: Mod Perl Subject: Updating $r-connection-aborted before $r-print() ? Hey, In my own experience it seems that I can only get $r-connection-aborted updated if I first do a $r-print(). Is there any way to get aborted to update without $r-print? my $fileno = $r-connection-fileno; $s = IO::Select-new($fileno); die aborted if grep { m/$fileno/ } $s-can_read(1); HTH --Geoff
Re: Apache::LogFile
This problem went away when I downgraded to Apache 1.3.17, mod_perl 1.25, and mod_ssl 2.80. I would really like to use the up-to date versions if I can... can someone provide me with a clue to what has changed? -Bryan Bryan T. Schmidt wrote: Howdy folks... got a wierd one here, although I bet someone knows what to do about it. I am running Apache 1.3.20, mod_perl 1.26, and mod_ssl (most recent version that works with Apache 1.3.20). The following happens with Perl 5.005_03 and 5.6.1. In my httpd.conf, I have : # mod_perl stuff... # PerlRequire conf/startup.pl PerlFreshRestartOn PerlModule Apache::LogFile PerlLogFile logs/PTW-access.log PTW::access PerlLogFile logs/PTW-error.log PTW::error PerlLogFile logs/PTW-debug.log PTW::debug PerlLogFile logs/PTW-security.log PTW::security Location /PTW-Server/FileFilter SetHandler perl-script PerlHandler PTW::FileFilter /Location So I have FileFilter.pm, which does some things, and is working quite happily. On 4 of my other servers, I have this exact same configuration with Apache 1.3.14 and mod_perl of similar vintage. My problem is that my PerlHandler's (like PTW::FileFilter) cannot write to the log files. I have been using statements like: print PTW::error (you had a big old error); For some reason, with the updated config, this no longer works, and my Apache error_log says: Invalid command 'PerlLogFile' perhaps misspelled yadi yada. Any clues why this would be any different in newer versions? Also, I tried changing PerlModule Apache::LogFile to PerlRequire Apache::LogFile, which results in Apache barfing saying that there is no such animal in @INC. I have verified that it is infact in the @INC path, so why can Apache not see it? Lastly, the very odd thing to me, is that something is successfully creating the logs/PTW-access.log etc. If it can create them, how come I cant write to them? Something is screwy, and I clearly do not have a good grasp on what is going on. Can someone please help me a bit? Thanks! -Bryan -- Bryan T. Schmidt Systems/Network Administrator Profitool Inc. [EMAIL PROTECTED]
RE: Apache::LogFile
-Original Message- From: Bryan T. Schmidt [mailto:[EMAIL PROTECTED]] Sent: Friday, September 14, 2001 3:32 PM To: [EMAIL PROTECTED] Subject: Re: Apache::LogFile This problem went away when I downgraded to Apache 1.3.17, mod_perl 1.25, and mod_ssl 2.80. I would really like to use the up-to date versions if I can... can someone provide me with a clue to what has changed? the only thing I can think of is that directive handlers used to work via use Apache::LogFile; in a startup.pl and now they don't. is your PerlModule Apache::LogFile the first occurence of Apache::LogFile? if you are pre-loading it in a startup.pl you might try taking it out... HTH --Geoff
Re: Environment variable $ENV{MOD_PERL}
These documents are very confusingon one hand the document the other caller mentioned does explicitly talk about two conditions should exists. Note A AND B. And then we hear that that is not really true...And even Apache::DBI.pm itslef does not talk about it and there is no way that I know of that one can tell, if we do indeed have a persistant connection or have simply required some dumb packages... We appreciate the technology such package authors bring to us...but please regard the documentation part as important as other parts... We are doing out best to keep the Perl and open source flag up, but we can not read source code all day long, our Microsoftish developers are way ahead of us with their fancy IDEs On Sat, 15 Sep 2001, Stas Bekman wrote: On Fri, 14 Sep 2001, Flavio D' Amore wrote: Hi, im reading on mod_perl and Relational Databases (http://apache.org/guide/databases.html), Introduction, that persistent database connections needs to have set $ENV{MOD_PERL} in order to execute CGI perl script via mod_perl and not via normal CGI. What's the right value for that variable and where i've to set it (httpd.conf or Unix environment?)? mod_perl does this for you. You shouldn't mess with it yourself. Hmm, may be you don't run under mod_perl even if you think you are? _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/ -- - Medi Montaseri [EMAIL PROTECTED] Unix Distributed Systems EngineerHTTP://www.CyberShell.com CyberShell Engineering -
Re:Environment variable $ENV{MOD_PERL}
On Friday, September 14, 2001, Medi Montaseri wrote the following about Environment variable $ENV{MOD_PERL} MM and there is no way that I know of that one can tell, if we do MM indeed have a persistant connection or have simply required some MM dumb packages... logging into the database and monitoring connections in use seems to me to be one way to do it ... Best Regards, Mike Miller [EMAIL PROTECTED]
Re: Environment variable $ENV{MOD_PERL}
Hello, MMAnd even Apache::DBI.pm itslef does not talk about it and there is no MMway that I know of that one can tell, if we do indeed have a persistant MMconnection or have simply required some dumb packages... The documentation mentions that you can use Apache::Status to check on statistics about Apache::DBI. This is directly from perldoc Apache::DBI. Three clicks into the mod_perl guide gives you this: http://perl.apache.org/guide/databases.html#Debugging_Apache_DBI Which is about how to turn on debugging information from Apache::DBI. Do these things not work for you? If so, tell us and we can perhaps help you further. By the way, you will likely receive more polite and helpful replies if you do not persist in calling technology that many of us rely on for production sites dumb. MMWe appreciate the technology such package authors bring to us...but MMplease regard the documentation part as important as other parts... We MMare doing out best to keep the Perl and open source flag up, but we can MMnot read source code all day long, our Microsoftish developers are way MMahead of us with their fancy IDEs Use what works for you and your situation. You shouldn't be using Perl and open source software if you really want to be using a Microsoft language and its related IDE. That being said, point out the relevant documentation pieces that are missing--I think you just missed what you needed in this case--to the authors and this list! Then we can all help fill in the pieces. Humbly, Andrew -- Andrew Ho http://www.tellme.com/ [EMAIL PROTECTED] Engineer [EMAIL PROTECTED] Voice 650-930-9062 Tellme Networks, Inc. 1-800-555-TELLFax 650-930-9101 --
Re: DBI connections build up..
Your script uses an END block to disconnect. If you use Apache::Registry, that will not be run until the server is shut down. With Apache::DBI, you should get one connection per Apache process, and they'll stay open. If you are changing the login parameters (i.e. different user each time), you can't use Apache::DBI because you'll get a huge build-up of connections. really? when did that change? As much as I know, Apache::Registry scripts always run END blocks. http://perl.apache.org/guide/porting.html#END_blocks Right, my mistake. I was thinking about BEGIN blocks and Registry vs. PerlRun. - Perrin
Re: DBI connections build up..
Your script uses an END block to disconnect. If you use Apache::Registry, that will not be run until the server is shut down. With Apache::DBI, you should get one connection per Apache process, and they'll stay open. If you are changing the login parameters (i.e. different user each time), you can't use Apache::DBI because you'll get a huge build-up of connections. really? when did that change? As much as I know, Apache::Registry scripts always run END blocks. http://perl.apache.org/guide/porting.html#END_blocks Right, my mistake. I was thinking about BEGIN blocks and Registry vs. PerlRun. - Perrin
Re: Template or XML?
We have also heard something about OpenInteract, which is based on Template Toolkit - may be it would be simplier to use it? It does sound like a possible good choice for your purposes, since it combines a basic application structure with Template Toolkit integration and an object/relational mapping tool (SPOPS) for data management. Personally, the way I would do this is to write the config stuff you're doing in XML as straight Perl data structures (nested hashes and arrays). I would do all of the database processing in standard Perl modules, and only use TT to display results and editing forms. If your TT templates seem messy, it may be because you're trying to do too much application logic in them. It's best to avoid things like the DBI plugin and do all the real work before you run the template. - Perrin
Re: Template or XML?
We have also heard something about OpenInteract, which is based on Template Toolkit - may be it would be simplier to use it? It does sound like a possible good choice for your purposes, since it combines a basic application structure with Template Toolkit integration and an object/relational mapping tool (SPOPS) for data management. Personally, the way I would do this is to write the config stuff you're doing in XML as straight Perl data structures (nested hashes and arrays). I would do all of the database processing in standard Perl modules, and only use TT to display results and editing forms. If your TT templates seem messy, it may be because you're trying to do too much application logic in them. It's best to avoid things like the DBI plugin and do all the real work before you run the template. - Perrin
Setting headers
Hello, I am using template toolkit to generate dynamic content and I was wondering if there is any way to set a cookie after returning OK. Here is what I mean. 1-There are two scripts that check for access privileges of a user. One sets two cookies and the other (mine) sets three cookies. 2- My script checks for all the cookies and if it does not find the third one it should set it. But the catch is here: package some_package; # apache packages use vars qw($r); sub handler{ $r = Apache::Request-new(shift); #code here $object-{is_allowed_todo} = \is_allowed_todo; $template = Template-new(); $remplate-process($file,$object); return OK; } sub is_allowed_todo { my ($args) = shfit; # args are the arguments that I get from my .html file # [% is_allowed_todo('A HREF=' %] my $status = __PACKAGE__-SUPER::is_allowed_todo($r); if ($status) { # do this } else { # do that } } 1; # The SUPER package some_other; sub is_allowed_todo { my $r = shift; my $cookies = Apache::Cookie-new($r)-parse(); my @webaccess = $cookies-{'webaccess'} ? $cookies-{'webaccess'}-value() : (); unless ($webaccess[MIS_APPS::RHS::Constants::ONE()]); { my $user= $cookies-{'webuname'}-value(); my $job = $cookies-{'webjob'}-value(); ($code,$status,$dept) = get_userinfo($user,$job); Apache::Cookie-new( $r, -name = 'webaccess', -value = { 'department' = $dept, 'access' = $status, }, -domain = '.rhythm.com', -expires= '+24h', -path = '/' )-bake; } return $status; } But my problem is that I have already returned OK in my handler. How can I set another cookie when I have already opened the data stream to the client browser? I hope I have been clear... :) Any comments will be greatly appreciated. -r
Re: Persistent Database connections
Before running my perl script (f1.pl) i see five httpd@hostname sessions in Oracle V$session but at the moment in which i run f1.pl there appear a seventh session alone such f1.pl@hostname. The mechanism of persistent connections seems to be not workinkg properly. What is it that makes you think it's not working properly? You should get one connection for each httpd process, and then no more. - Perrin
Auth vs Authz handler
I'm working on the Apache::AuthExpire module. Considering the difficulties of getting two browsers to behave the same way, I was thinking that I should probably implement a login page, once the initial authentication phase is finished. Basically, user logs in, then if no timestamp is available (stored in a file), then the initial login also starts the timer. If a timestamp is available, and the user is idle for more than 15 minutes, the user is greeted with an html page asking for password again. My question is this: should I implement this as an authen handler, which it is now, or as an authz handler, which I think would give me more flexibility. Also, how do I get something renamed or reclassified, if I decide that I should move it from the Authen phase to the Authz phase? Thanks, JJ -- J. J. Horner H*,6d6174686c696e40326a6e6574776f726b732e636f6d *** H*,6a6a686f726e65724062656c6c736f7574682e6e6574 Freedom is an all-or-nothing proposition: either we are completely free, or we are subjects of a tyrannical system. If we lose one freedom in a thousand, we become completely subjugated. PGP signature
Re: Environment variable $ENV{MOD_PERL}
On Fri, 14 Sep 2001, Medi Montaseri wrote: These documents are very confusingon one hand the document the other caller mentioned does explicitly talk about two conditions should exists. Note A AND B. And then we hear that that is not really true...And even Apache::DBI.pm itslef does not talk about it and there is no way that I know of that one can tell, if we do indeed have a persistant connection or have simply required some dumb packages... We appreciate the technology such package authors bring to us...but please regard the documentation part as important as other parts... We are doing out best to keep the Perl and open source flag up, but we can not read source code all day long, our Microsoftish developers are way ahead of us with their fancy IDEs As Andrew said, you just need to learn how to find your way around. I believe it's still easier than trying to get somebody on the support call to explain it to you. The cool thing is that once you know your way around, you don't need anybody else to help yourself. I admit that the initial overhead may be longer but it's only in the beginning. Back to your problem. What I've suggested is that may be you aren not running mod_perl at all [read: you run mod_cgi]! Try to put into your startup.pl: die not running under mod_perl unless $ENV{MOD_PERL}; On Sat, 15 Sep 2001, Stas Bekman wrote: On Fri, 14 Sep 2001, Flavio D' Amore wrote: Hi, im reading on mod_perl and Relational Databases (http://apache.org/guide/databases.html), Introduction, that persistent database connections needs to have set $ENV{MOD_PERL} in order to execute CGI perl script via mod_perl and not via normal CGI. What's the right value for that variable and where i've to set it (httpd.conf or Unix environment?)? mod_perl does this for you. You shouldn't mess with it yourself. Hmm, may be you don't run under mod_perl even if you think you are? _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/ -- - Medi Montaseri [EMAIL PROTECTED] Unix Distributed Systems EngineerHTTP://www.CyberShell.com CyberShell Engineering - _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: Setting headers
On Fri, 14 Sep 2001, Rasoul Hajikhani wrote: Hello, I am using template toolkit to generate dynamic content and I was wondering if there is any way to set a cookie after returning OK. Here is what I mean. 1-There are two scripts that check for access privileges of a user. One sets two cookies and the other (mine) sets three cookies. 2- My script checks for all the cookies and if it does not find the third one it should set it. But the catch is here: The problem is that you don't show where is_allowed_todo gets called. I guess in the template as in your comment. The solution is very simple. Change is_allowed_todo to change status in $object or elsewhere. Now change the handler to do; my $status = exists $object-{status} ? $object-{status} : OK; return $status; does that solve your problem? You return your status as the last thing in the handler, after the template was processed, I don't see how can you have this problem Even better solution would be to run is_allowed_todo from your code and not template! Run is_allowed_todo, get the status and pass it to your template as a variable. One should avoid running code from the templates, as they are designed for presentation not application logic. package some_package; # apache packages use vars qw($r); sub handler{ $r = Apache::Request-new(shift); #code here $object-{is_allowed_todo} = \is_allowed_todo; $template = Template-new(); $remplate-process($file,$object); return OK; } sub is_allowed_todo { my ($args) = shfit; # args are the arguments that I get from my .html file # [% is_allowed_todo('A HREF=' %] my $status = __PACKAGE__-SUPER::is_allowed_todo($r); if ($status) { # do this } else { # do that } } 1; # The SUPER package some_other; sub is_allowed_todo { my $r = shift; my $cookies = Apache::Cookie-new($r)-parse(); my @webaccess = $cookies-{'webaccess'} ? $cookies-{'webaccess'}-value() : (); unless ($webaccess[MIS_APPS::RHS::Constants::ONE()]); { my $user= $cookies-{'webuname'}-value(); my $job = $cookies-{'webjob'}-value(); ($code,$status,$dept) = get_userinfo($user,$job); Apache::Cookie-new( $r, -name = 'webaccess', -value = { 'department' = $dept, 'access' = $status, }, -domain = '.rhythm.com', -expires= '+24h', -path = '/' )-bake; } return $status; } But my problem is that I have already returned OK in my handler. How can I set another cookie when I have already opened the data stream to the client browser? I hope I have been clear... :) Any comments will be greatly appreciated. -r _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://eXtropia.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/