Re: ap_unescape_url can't escape %uXXXX
At 29 Nov 2002 02:17:31 -0500, Joe Schaefer wrote: It seems that Apache's ap_unescape_url() can't handle %u style URI-escaped Unicode string, hence Apache::Request cannot neighther, while CGI.pm can. my WinIE 5.5 / WinIE 6.0 uses this style of URI escaping when you use javascript to submit page's content. (Well, I'm talking about MovableType's bookmarklet, if you're interested) seems to indicate that this isn't a recommended practice. OTOH, IIRC the apache source claims to support utf8 extension(s) of www-urlencoded ASCII, so if people really are using such encodings, supporting %u in ap_unescape_url shouldn't hurt server performance at all. In any case, putting together a patch of ap_unescape_url along the lines of CGI::Util's utf8_chr() can't hurt :-). Yep ;-) -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: [RFC] Apache::SessionManager
Apache::SessionManager has once been discussed here. AFAIK it's not on CPAN though .. http://mathforum.org/epigone/modperl/clarcloigol At Fri, 2 Aug 2002 16:59:43 +0200, Enrico Sorcinelli wrote: After some search on CPAN I haven't found a mod_perl module that does the same thing (right?). The module is work in progress, of course, even if already I use it. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
ANNOUNCE: Apache::Session::Serialize::YAML 0.01
Just 8 lines of glue code to use YAML as a Apache::Session serialization handler. Any suuggestions welcome, Thanks. The URL http://bulknews.net/lib/archives/Apache-Session-Serialize-YAML-0.01.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MI/MIYAGAWA/Apache-Session-Serialize-YAML-0.01.tar.gz size: 1499 bytes md5: 31f6c30d707a56e2f37aca7e3a4cddf4 =head1 NAME Apache::Session::Serialize::YAML - use YAML for serialization =head1 SYNOPSIS use Apache::Session::Flex; tie %session, 'Apache::Session::Flex', $id, { Store = 'MySQL', Lock = 'Null', Generate = 'MD5', Serialize = 'YAML', }; =head1 DESCRIPTION Apache::Session::Serialize::YAML enables you to use YAML (YAML Ain't Makeup Language [tm]) for Apache::Session serialization format. YAML is a generic data serialization language for scripting languages, so this module can be a good start to share session data with Ruby, Python or PHP etc. See http://www.yaml.org/ for details of YAML. =head1 AUTHOR Tatsuhiko Miyagawa Elt[EMAIL PROTECTED]gt This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO LYAML, LApache::Session, LApache::Session::PHP =cut -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
RFC: Apache::DefaultCharset
Here's a tiny XS mod_perl module to configure AddDefaultCharset stuff from mod_perl. This is my first XS hack, thanks to mod_perl developer's cookbook. Any suggestions are welcome. http://bulknews.net/lib/archives/Apache-DefaultCharset-0.01.tar.gz =head1 NAME Apache::DefaultCharset - AddDefaultCharset configuration from mod_perl =head1 SYNOPSIS use Apache::DefaultCharset; my $charset = Apache::DefaultCharset-new($r); print default_charset_name is , $charset-name; # or print default charset is $charset; will do (overload) $charset-name('euc-jp'); # modify default_charset_name in run-time =head1 DESCRIPTION Apache::DefaultCharset is an XS wrapper for Apache Core's CAddDefaultCharset configuration. =head1 EXAMPLES =head2 Unicode Handling Suppose you develop multi-language web application, and transparently decode native encodings into Unicode string inside Perl (5.8 or over would be better). First you should add AddDefaultCharset euc-jp in your Chttpd.conf, then leave off Csend_http_header arguments just to text/html. Then you can get the current configuration with this module when you use CEncode or CText::Iconv to decode the HTTP request query into Unicode. =head2 Modification of DefaultCharset Suppose you want to add utf-8 for XML files, and Shift_JIS for HTML files as HTTP charset attribute by default (By default means that if you set Ccontent_type explicitly in content-generation phase, that will be prior to the defalut). This module enables you to write CPerlFixupHandler to configure Cadd_default_charset_name in run-time. =head1 AUTHOR Tatsuhiko Miyagawa Elt[EMAIL PROTECTED]gt This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO LApache::GuessCharset mod_perl cookbook at http://www.modperlcookbook.com/ =cut
Re: RFC: Apache::DefaultCharset
At Fri, 31 May 2002 13:58:52 +0900, Tatsuhiko Miyagawa wrote: =head1 SEE ALSO LApache::GuessCharset mod_perl cookbook at http://www.modperlcookbook.com/ s/com/org/ -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
[ANNOUNCE] Apache::GuessCharset
Apache::GuessCharset is a PerlFixupHandler to demonstrate bleeding edge perl's powerful encoding detection, thanks to Encode module. It's now going on its way to CPAN, or also on http://bulknews.net/lib/archives/ NAME Apache::GuessCharset - adds HTTP charset by guessing file's encoding SYNOPSIS PerlModule Apache::GuessCharset SetHandler perl-script PerlFixupHandler Apache::GuessCharset # how many bytes to read for guessing (default 512) PerlSetVar GuessCharsetBufferSize 1024 # list of encoding suspects PerlSetVar GuessCharsetSuspects euc-jp PerlAddVar GuessCharsetSuspects shiftjis PerlAddVar GuessCharsetSuspects 7bit-jis DESCRIPTION Apache::GuessCharset is an Apache handler which adds HTTP charset attribute by automaticaly guessing file' encodings via Encode::Guess. CONFIGURATION This module uses following configuration variables. GuessCharsetSuspects a list of encodings for Encode::Guess to check. See the Encode::Guess manpage for details. GuessCharsetBufferSize specifies how many bytes for this module to read from source file, to properly guess encodings. default is 512. AUTHOR Tatsuhiko Miyagawa [EMAIL PROTECTED] This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO the Encode::Guess manpage, the Apache::File manpage -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
[OT] Re: full-featured online database apps
At Wed, 24 Apr 2002 14:05:38 -0700, Peter Bi wrote: Well, I changed it back to HTML::Template . It takes relatively less time to work it out with graphic designers. plug I've made simple utilities (fot TT and H::T) to help perl developers having a nightmare with co-work with designers. See http://perlmonks.org/index.pl?node_id=161595 for details. /plug -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
[OT] [ANNOUNCE] mod_log_sqlite
Announcing new Apache module (written in C): mod_log_sqlite is an Apache logging module for sqlite database. It allows you to log your HTTP stats into sqlite, then you can do queries using sqlite's SQL feature (including subselects, views) to HTTP statistics. http://freshmeat.net/projects/mod_log_sqlite/ here's an excerpt from README: mod_log_sqlite - Apache logging module to sqlite INSTALL: You can install this module easily via apxs magic. % make # make install % make clean CONFIGURATION (summary): 1. install sqlite from http://www.hwaci.com/sw/sqlite/ 2. Add following lines to your httpd.conf LogSQLiteDBFile sqlite-logs/sqlite_log LogSQLiteAutoChown On CONFIGURATION (details): First you should install sqlite module manually. See http://www.hwaci.com/sw/sqlite/ for details. Then you should initialize access_log database (from 0.05, this is optional). Note that the database file and the directory should be writable by httpd running user (nobody by default). # mkdir /usr/local/apache/sqlite-logs # chown nobody:nobody /usr/local/apache/sqlite-logs % sudo -u nobody sqlite /usr/local/apache/sqlite-logs/sqlite_log create_table.sql create_table.sql is bundled with this module. Note that this module automatically creates log table if there's not one, from 0.05. You can let this moule do chown() automatically, by adding directive: LogSQLiteAutoChown On Finally, simply add the following line to your httpd.conf: LogSQLiteDBFile sqlite-logs/sqlite_log Table name is access_log by default. You can change it via LogSQLiteTable directive if you want to. LogSQLiteTable wwwlog From 0.05, this module supports separate database files per VirtualHosts, which means you can even do: VirtualHost x.x.x.x ServerName vh.example.com LogSQLiteDBFile /home/vh.example.com/logs/sqlite_log /VirtualHost That's all! Enjoy querying your access_log via VIEWs and/or sub-querys. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: [OT] [ANNOUNCE] mod_log_sqlite
At Mon, 15 Apr 2002 17:09:43 +0100 (BST), Matt Sergeant wrote: PS: Taso: you sent to [EMAIL PROTECTED], which Ask seems to have setup to redirect to the right address. Yep. I've made a mistake, which Ask kindly had outsmarted ;) -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: [OT] [ANNOUNCE] mod_log_sqlite
At Mon, 15 Apr 2002 11:32:55 -0400, Perrin Harkins wrote: The SQLite FAQ seems to suggest that SQLite isn't very good at parallel read/write situations: http://www.hwaci.com/sw/sqlite/faq.html#q6 Have you seen any problems so far? Yep, that's what I'd expected to happen. Without sqlite's timeout_handler function, there happen many errors due to database locking. But with handler there seems no problem and it just works fine in my personal website which has 10_000 hits a day. I should give it a shot with a site with more accesses, and examine how to rotate the log db file. Thanks! -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
[PATCH] Class::DBI (auto_increment in Apache::DBI)
I use Class::DBI + DBD::mysql in mod_perl Apache::DBI enabled environment. I've found SELECT LAST_INSERT_ID would *sometimes* cause vizarre result in persistent connection. It happens very rarely, but the phenomenon is gone away we stop-start the httpd. Here's a patch for Class::DBI that fix this problem (*1) (for 0.36). In evey installation of Class::DBI I've applied this patch, and the problem above never happens with it. It should be clever that Class/DBI.pm can be free from this mysql-dependent hardcode into each subclasses (Strategy Pattern, or DBIx::AnyDBD?). *1) error message is as follows: Can't call method call_hook on an undefined value at /usr/local/lib/ perl5/site_perl/5.005/Class/DBI.pm line 101. -- Tatsuhiko Miyagawa [EMAIL PROTECTED] --- DBI.pm~ Fri Nov 2 00:43:27 2001 +++ DBI.pm Fri Mar 8 00:57:17 2002 @@ -125,10 +125,7 @@ $sth-execute(values %$data); # If we still don't have a primary key, try AUTO_INCREMENT. unless( _safe_exists($data, $self-primary) ) { - $sth = $self-sql_LastInsertID; - $sth-execute; - $data-{$self-primary} = ($sth-fetch)[0]; - $sth-finish; + $data-{$self-primary} = $class-db_Main-{mysql_insertid}; } }; if($@) {
[ANNOUNCE] PHP::Session 0.06 Apache::Session::PHP
Announcing the update of PHP::Session and yet another module of nightmare. You can download 'em from http://bulknews.net/lib/archives/ and CPAN. NAME Apache::Session::PHP - glues Apache::Session with PHP::Session SYNOPSIS use Apache::Session::PHP; tie %session, 'Apache::Session::PHP', $sid, { SavePath = '/var/sessions', }; DESCRIPTION Apache::Session::PHP is an adapter of Apache::Session for PHP::Session. It uses following combination of straregies: Generate: MD5 PHP4 session also uses 32bit session-id, generated by MD5 of random string. So MD5 (default) generation would fit. Serialize: PHP uses PHP::Session::Serializer::PHP. Lock: Null PHP4 uses exclusive flock for session locking. In Apache::Session, we use Null for locking and Store module executes flock on opening the session file. Store: PHP similarto File store, but file naming scheme is slightly different. NOTE PHP does NOT have distinction between hash and array. Thus PHP::Session restores PHP *array* as Perl *hash*. Perl = PHP = Perl arrayarrayhash Thus if you store array in sessions, what'll come back is hash. AUTHOR Tatsuhiko Miyagawa [EMAIL PROTECTED] This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO the Apache::Session manpage, the PHP::Session manpage -- Tatsuhiko Miyagawa
Re: [ANNOUNCE] PHP::Session
Now PHP::Session 0.05 with save/destory implementation is going on its way to CPAN. 0.05 Mon Mar 18 16:36:27 JST 2002 * added Boolean type (ext/var.h in PHP source code) 0.04 Fri Mar 15 16:14:32 JST 2002 * added destroy() 0.03 Fri Mar 15 16:01:35 JST 2002 * added session ID validation * implemented save() At Thu, 14 Mar 2002 17:40:28 +0900, Tatsuhiko Miyagawa wrote: Announcing new module: PHP::Session. This module enables you to read / write (write is not yet implemented though) PHP4-builtin session files from Perl. Then you can share session data between PHP and Perl, without changing PHP code, which may be a hard work for us Perl hackers. This is something you'll never want to do, but imagine the cases where you should co-work with PHP coders, or take over another company's PHP code. -- Tatsuhiko Miyagawa
Re: [ANNOUNCE] PHP::Session
At Mon, 18 Mar 2002 14:06:56 -0600, Jim Smith wrote: Will there be a way to specify each of the actions as PHP allows? For example, in a project I have, we use PHP4 sessions, but they are stored in a MySQL table so they can be shared across web machines without worrying about NFS problems. You're very happy :) Then you don't have to play with this module of nightmare. Basically, it would be nice to have PHP::Sessions provide the serialization mechanism for use by Apache::Session without it worrying about how to store the information. Yes, what I'm planning now is Apache::Sesion::PHP, which gives your a way to handle PHP4 session files transparently via Apache::Session interface. -- Tatsuhiko Miyagawa
Re: [ANNOUNCE] PHP::Session
At Tue, 19 Mar 2002 06:03:56 +0900, Tatsuhiko Miyagawa wrote: Basically, it would be nice to have PHP::Sessions provide the serialization mechanism for use by Apache::Session without it worrying about how to store the information. Yes, what I'm planning now is Apache::Sesion::PHP, which gives your a way to handle PHP4 session files transparently via Apache::Session interface. Current implementation of PHP::Session is already modularized enough for you to use serialization part as a standalone code. See PHP::Session::Serializer::PHP for it. (Though its synopsis says DONT USE THIS MODULE DIRECTLY :)) -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: [ANNOUNCE] PHP::Session
At Mon, 18 Mar 2002 15:46:20 -0600, Jim Smith wrote: Will there be a way to specify each of the actions as PHP allows? For example, in a project I have, we use PHP4 sessions, but they are stored in a MySQL table so they can be shared across web machines without worrying about NFS problems. You're very happy :) Then you don't have to play with this module of nightmare. I tried to write such a module last year. PHP sessions are a bit of a nightmare to parse efficiently, afaik. I'm glad someone's gone to the trouble to try and make a usable and distributable module. Exactly, it *is* a nightmare. See my dirty duplicated source code! I guess the format is designed to be easily parsed by C, but very difficult by Perl :) -- Tatsuhiko Miyagawa
[ANNOUNCE] PHP::Session
Announcing new module: PHP::Session. This module enables you to read / write (write is not yet implemented though) PHP4-builtin session files from Perl. Then you can share session data between PHP and Perl, without changing PHP code, which may be a hard work for us Perl hackers. This is something you'll never want to do, but imagine the cases where you should co-work with PHP coders, or take over another company's PHP code. NAME PHP::Session - read / write PHP session files SYNOPSIS use PHP::Session; my $session = PHP::Session-new($id); # session id my $id = $session-id; # get/set session data my $foo = $session-get('foo'); $session-set(bar = $bar); # remove session data $session-unregister('foo'); # remove all session data $session-unset; # check if data is registered $session-is_registerd('bar'); # save session data (*UNIMPLEMENTED*) $session-save; DESCRIPTION PHP::Session provides a way to read / write PHP4 session files, with which you can make your Perl applicatiion session shared with PHP4. TODO * saving session data into file is UNIMPLEMENTED. * WDDX support, using WDDX.pm * Apache::Session::PHP AUTHOR Tatsuhiko Miyagawa [EMAIL PROTECTED] This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO the WDDX manpage, the Apache::Session manpage -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: [WOT] emacs and WEBDAV
At Thu, 14 Mar 2002 11:30:54 -0800, Rob Bloodgood wrote: DW also speaks WEBDAV natively, but emacs does not. Emacs speaks CVS Eldav: Yet another WebDAV interface for Emacsen http://www.gohome.org/eldav/ -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
[Patch] Apache::ProxyPassThru
Ask, here is a patch for Apache::ProxyPassThru, fixing the bug that multiple response headers are mungled into one (like double Set-Cookie:s) I should apply this with my own proxy modules ... :) --- ProxyPassThru.pm~ Tue Aug 21 08:06:24 2001 +++ ProxyPassThru.pmFri Mar 8 15:23:04 2002 -33,8 +33,9 #feed reponse back into our request_rec* $r-status($res-code); $r-status_line($res-status_line); +my $table = $r-headers_out; $res-scan(sub { - $r-header_out(_); + $table-add(_); }); $r-send_http_header();
Re: POST without any content - sometimes
On Sat, 16 Feb 2002 08:40:12 +0100 Anders Knuts [EMAIL PROTECTED] wrote: Yes of course it is referer, my mistake thanx The _referer_ should be my own server, since it is from where the POST originate, but in this particular case, from this IP-adress, the referer disapears sometimes... Bug (or feature) of the Brwoser? Anyway, you can't rely on Referer: header for validation of the data, as you can spoof it easily. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Cookie as session store
On Thu, 14 Feb 2002 11:35:14 -0500 Perrin Harkins [EMAIL PROTECTED] wrote: It's really a good idea to do this even when the cookie is nothing but a session ID. A standard module for this like the one Jay mentioned would definitely be nice. Apache::Cookie::Encrypted seems to be the one. http://search.cpan.org/search?dist=ApacheCookieEncrypted -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: POST without any content - sometimes
On Tue, 12 Feb 2002 20:03:22 +0100 Anders Knuts [EMAIL PROTECTED] wrote: xxx.xxx.25.50 - - [10/Feb/2002:21:15:33 +0100] POST /cgi-bin/mboard/message.pl HTTP/1.1 200 88 - Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0) xxx.xxx.25.50 - - [10/Feb/2002:21:15:36 +0100] POST /cgi-bin/mboard/message.pl HTTP/1.1 200 1683 http://www.servern.nu/main.html; Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0) The first POST is erronuos as there is no content (-) and the script won't accept it as vaild. If this log's LogFormat is combined, the field you point means HTTP Referer, not the content of the POST request. The scond POST is okay as it has content (http://www.servern.nu/main.html;). -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: mod_perl + UNIVERSAL
On Tue, 12 Feb 2002 14:15:37 +1100 Morton-Allen, Matthew [EMAIL PROTECTED] wrote: However both applications make use of the UNIERVSAL package to create universally accessible methods (to return the current database handle for example) within the application. You don't need UNIVERSAL for the purpose. Try import(). package Foo; our @ISA = qw(Exporter); our @EXPORT = qw(get_dbh); sub get_dbh { ... } package main; use Foo; # will import get_dbh() my $dbh = get_dbh; -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: performance coding project? (was: Re: When to cache)
On Fri, 25 Jan 2002 21:15:54 + (GMT) Matt Sergeant [EMAIL PROTECTED] wrote: With qmail, SMTP generally uses inetd, which is slow, or daemontools, which is faster, but still slow, and more importantly, it anyway goes: perl - SMTP - inetd - qmail-smtpd - qmail-inject. So with going direct to qmail-inject, your email skips out a boat load of processing and goes direct into the queue. Of course none of this is relevant if you're not using qmail ;-) Yet another solution: use Mail::QmailQueue, directly http://search.cpan.org/search?dist=Mail-QmailQueue -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: UI Regression Testing
On Sat, 26 Jan 2002 00:23:40 -0500 Perrin Harkins [EMAIL PROTECTED] wrote: But what about the actual data? In order to test my $product-name() method, I need to know what the product name is in the database. That's the hard part: writing the big test data script to run every time you want to run a test (and probably losing whatever data you had in that database at the time). This has been by far the biggest obstacle for me in testing, and from Gunther's post it sounds like I'm not alone. If you have any ideas about how to make this less painful, I'd be eager to hear them. You're not alone ;) here is my solution. * All datasource are maintained with separate config file * Generate config file for testing * Create database and tables for testing (called test_foo) * Insert dummy data into test_foo * Test 'em * Drop dummy data Then my test script has both client side testing and server side testing, like this. use Test::More 'no_plan'; BEGIN { do 'db_setup.pl'; } END { do 'db_teardown.pl'; } # server-side my $product = Product-create({ name = 'foo' }); # client-side my $ua = LWP::UserAgent-new; my $res = $ua-request(GET /foo/bar); like $res-content, qr/foo/; my $form = HTML::Form-parse($res-content); my $req2 = $form-click; my $res2 = $ua-request($req); like $res2-content, qr/blah/; # server-side my @p = Product-retrieve_all; is @p, 2; -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Cross-site Scripting prevention with Apache::TaintRequest
On Tue, 22 Jan 2002 19:01:48 +0100 Thomas Eibner [EMAIL PROTECTED] wrote: my $fields = { id = ['\d+', \validation_sub ], text = ['(?:\w\s)+'] }; And I feed this along with the request or cgi object to a function that checks each key for first the simple regexp to see if it's worth trying the real validation function. see also CGI::Untaint by Tony Bowden, on CPAN. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Cross-site Scripting prevention with Apache::TaintRequest
On Tue, 22 Jan 2002 09:25:15 -0800 Paul Lindner [EMAIL PROTECTED] wrote: As part of the CPANification of the code in the mod_perl Developer's cookbook, I present Apache::TaintRequest, a module that helps prevent cross-site scripting attacks by automatically html-escaping 'tainted' text sent to a web browser.. Get it at http://www.modperlcookbook.org/code.html Techniques I use depends on HTML::Template's TMPL_VAR escape=HTML stuff. But your idea to detect output from Untainted data for protection against CSS, is very neat. Nice. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
ANNOUNCE: Log::Dispatch::Config 0.12
0.12 Fri Jan 18 05:08:22 JST 2002 * No check on config mtime by default New class method: configure_and_watch() (Thanks to Hiroyuki Oyama [EMAIL PROTECTED]) - Added documenttion for subclassing/wrapping - Code clean up, revised configurator API docs The URL http://bulknews.net/lib/archives/Log-Dispatch-Config-0.12.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MI/MIYAGAWA/Log-Dispatch-Config-0.12.tar.gz size: 10899 bytes md5: 6c9c5f4c2029579fd6514dd52ee8485d -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
ANNOUNCE: Log::Dispatch::Config 0.11_02
http://bulknews.net/lib/archives/Log-Dispatch-Config-0.11_02.tar.gz 0.11_02 Fri Jan 18 05:08:22 JST 2002 * [API change] No check on config mtime by default New class method: configure_and_watch() (Thanks to Hiroyuki Oyama [EMAIL PROTECTED]) - Modified configurator API This release is a beta release. If you have trouble with this API change or something, please let me know ASAP. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Exception::Handler
On Fri, 11 Jan 2002 17:39:33 -0500 Jay Lawrence [EMAIL PROTECTED] wrote: For what it is worth - I would encourage you to check out the Error package as well. Exactly, in fact the module can nicely work with Error.pm. See t/*.t for details ;) -- Tatsuhiko Miyagawa Livin' On The EDGE, Co.,Ltd. mailto:[EMAIL PROTECTED] http://www.edge.co.jp/
Re: Exception::Handler
On Fri, 11 Jan 2002 17:34:30 -0600 (CST) Dave Rolsky [EMAIL PROTECTED] wrote: You would have: try { code; } catch FooException with { code for FooExceptions; } catch BarException with { code for BarExceptions; } otherwise { }; And the fun potential for memory leaks with nested closures. Matt has an idea for doing this with Filter module, instead of nasty closures. AFAICT, Tatsuhiko's module is designed to work with either of those types of objects transparently, but it provides an alternate mechanism for catching exceptions. Absolutely. And anything inspired by my Sig::PackageScoped module scares me, Yep. the module is greaty inspired, and in fact borrows its some code from Sig::PackageScoped! but its an interesting idea ;) -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Exception::Handler
On Sat, 12 Jan 2002 10:25:23 + (GMT) Matt Sergeant [EMAIL PROTECTED] wrote: Matt has an idea for doing this with Filter module, instead of nasty closures. Actually unfortunately I even had code, but it was on my laptop that died. Sad. I may resurrect the project in time for this year's Perl Conference, provided Tony Blair decides to instigate my vision of a 30 hour day. AFAIK Filter module can't work with eval EXPR code, thus making Apache::Registry unhappy. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
RFC: Exception::Handler
Seeing through Dave Rolsky's Exception::Class and Sig::PackageScoped has let me make the following module, called Exception::Handler. In fact I rarely use $SIG{__DIE__} for exception handling, but the concept of the module would be a bit interesting. Especially eval { }; if ($@-isa('FooException')) { # ... } elsif ($@-isa('BarException')) { # ... } else { # ... } code like this can be greatly simplified. Any suggestions welcome, escpecially from gurus of exception, Matt and Dave ;) See t/*.t for typical usage. http://bulknews.net/lib/archives/Exception-Handler-0.01.tar.gz NAME Exception::Handler - Hierarchical exception handling SYNOPSIS use Exception::Class 'MyException', 'AnotherException' = { isa = 'MyException' }, 'YetAnotherException' = { isa = 'AnotherException' }, 'FooBarException'; use Exception::Handler MyException = \my_handler, AnotherException = \another_handler, __DEFAULT__ = \default_handler; eval { MyException-throw }; # my_handler() eval { AnotherException-throw; };# another_handler() eval { YetAnotherException-throw; }; # another_handler() : hierarchical eval { FooBarException-throw; }; # default_handler() sub my_handler { my $exception = shift; # ... } sub another_handler { } sub default_handler { } DESCRIPTION Exception::Handler allows you to handle exception with various subs each of which registered for an appropriate class of exception. This module can nicely work with Dave Rolsky's Exception::Class and Grahamm Barr's Error module. TODO * Lexical handler, which may be done via local. AUTHOR Tatsuhiko Miyagawa [EMAIL PROTECTED] This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO Exception::Class, Sig::PackageScoped -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: [Poop-group] ANNOUNCE: Class::Trigger 0.03
On Tue, 25 Dec 2001 16:03:21 -0500 Michael G Schwern [EMAIL PROTECTED] wrote: Class::Trigger is a mixin class to invoke triggers (or hooks) in arbitrary point, which can be registered from outside the class. Useful for extending your own framework like Class::DBI. (In fact, this module first implementation is extracted out from Class::DBI 0.35) Are you aware of the perl-aspects project and the Aspect module? Yep. I've found it very interesting. Very similar to Class::Trigger by the look of it, but its not nearly as explicit. Its not necessary for foo() to actually say triggers go *here*, you just add them. This may not be what you want. You might also find Sub::Uplevel or Hook::LexWrap useful if you want the trigger's caller() to be the same as foo() itself. Exactly. But the difference would be: * Class::Trigger is easy to learn. * Class::Trigger doesn't require 5.6 or over. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Cache::Cache locking
On Sun, 23 Dec 2001 04:23:47 +0900 Tatsuhiko Miyagawa [EMAIL PROTECTED] wrote: Apache::Singleton::Server got me thinking about Cache::Cache and locking again. if i'm going to have a server-global object, i am going to need to protect against multiple processes updating it simultaneously, right? Right. Which makes me remember current Apache::Singleton::Server is complete broken :( it doesn't update changed attribute to shared data in IPC ... would fix. Apache::Singleton 0.04 is now going to CPAN, without Server subclass, which was broken, and in fact I don't need for my production environment ;) If you want Server implementation (with sufficient speed and robust locking), I'm always open to patches! 0.04 Sun Dec 23 21:20:04 JST 2001 - Fixed docs - pulled off Server subclass: it was completely broken The URL http://bulknews.net/lib/archives/Apache-Singleton-0.04.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MI/MIYAGAWA/Apache-Singleton-0.04.tar.gz size: 2675 bytes md5: 3865399d4d8a9b970fd71e2f048de8e3 -- Tatsuhiko
[ANNOUNCE] Apache::Singleton 0.02 (Re: Tips tricks needed :))
On Thu, 20 Dec 2001 11:51:30 -0500 Perrin Harkins [EMAIL PROTECTED] wrote: Like this? (using register_cleanup instead of pnotes) Better to use pnotes. I started out doing this kind of thing with register_cleanup and had problems like random segfaults. I think it was because other cleanup handlers sometimes needed access to these resources. Now it uses pnotes(). Todo is to add scope configuration for each classes. The URL http://bulknews.net/lib/archives/Apache-Singleton-0.02.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MI/MIYAGAWA/Apache-Singleton-0.02.tar.gz size: 1621 bytes md5: 89a86023ea672f571860e91696ff03bb 0.02 Sat Dec 22 16:58:34 JST 2001 - use pnotes instead of register_cleanup (Thanks to Perrin Harkins [EMAIL PROTECTED]) -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
[ANNOUNCE] Apache::Singleton 0.03
On Sat, 22 Dec 2001 17:04:11 +0900 Tatsuhiko Miyagawa [EMAIL PROTECTED] wrote: Now it uses pnotes(). Todo is to add scope configuration for each classes. Added subclasses with own object lifetime configuration. I myself am just a little dubious about its implementation, especially for Server scope. Any suggestions welcome. The URL http://bulknews.net/lib/archives/Apache-Singleton-0.03.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MI/MIYAGAWA/Apache-Singleton-0.03.tar.gz size: 3415 bytes md5: ba59d1e0acfd6364b045ba869c6b799c 0.03 Sat Dec 22 22:29:50 JST 2001 - Added test for multiple classes * Added Request, Process, Server subclasses NAME Apache::Singleton - Singleton class for mod_perl SYNOPSIS package Printer; use base qw(Apache::Singleton); # same: default is per Request package Printer::PerRequest; use base qw(Apache::Singleton::Request); package Printer::PerProcess; use base qw(Apache::Singleton::Process); package Printer::PerServer; use base qw(Apache::Singleton::Server); DESCRIPTION Apache::Singleton works the same as Class::Singleton, but with various object lifetime (scope). See the Class::Singleton manpage first. OBJECT LIFETIME By inheriting one of the following sublasses of Apache::Singleton, you can change the scope of your object. Request use base qw(Apache::Singleton::Request); One instance for one request. Apache::Singleton will remove intstance on each request. Implemented using mod_perl pnotes API. This is the default scope, so inheriting from Apache::Singleton would do the same effect. Process use base qw(Apache::Singleton::Process); One instance for one httpd process. Implemented using package global. Notice this is the same beaviour with Class::Singleton ;) Server use base qw(Apache::Singleton::Server); One instance for one server (across all httpd processes). Implemented using Cache::SharedMemoryCache (IPC). Note that multiple process cannot share blessed reference without serialization, so *One instance for one server* is just an idea. What it means is, one instance for one process, and multiple instances with shared data across one server. See t/05_server.t in this module distribution for what it exactly means. AUTHOR Original idea by Matt Sergeant [EMAIL PROTECTED] and Perrin Harkins [EMAIL PROTECTED]. Code by Tatsuhiko Miyagawa [EMAIL PROTECTED] This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO the Apache::Singleton::Request manpage, the Apache::Singleton::Process manpage, the Apache::Singleton::Server manpage, the Class::Singleton manpage, the Cache::SharedMemoryCache manpage -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: [ANNOUNCE] Apache::Singleton 0.03
On Sat, 22 Dec 2001 09:23:30 -0500 DeWitt Clinton [EMAIL PROTECTED] wrote: One instance for one server (across all httpd processes). Implemented using Cache::SharedMemoryCache (IPC). Maybe you want to consider directly using Cache::SharedMemoryBackend instead of the SharedMemoryCache class. The full cache class has the overhead of dealing with object expiration times, which isn't going to be necessary for the Singleton. I'll look into it. Thanks for the input. Also, try experimenting with the FileBackend as your sharing mechanism instead of shared memory. If you have a large number of Singleton objects (unlikely, but possible) then this may be a huge performance win. Exactly. -- Tatsuhiko Miyagawa
Re: Cache::Cache locking
On Sat, 22 Dec 2001 06:55:15 -0800 (PST) brian moseley [EMAIL PROTECTED] wrote: Apache::Singleton::Server got me thinking about Cache::Cache and locking again. if i'm going to have a server-global object, i am going to need to protect against multiple processes updating it simultaneously, right? Right. Which makes me remember current Apache::Singleton::Server is complete broken :( it doesn't update changed attribute to shared data in IPC ... would fix. -- Tatsuhiko Miyagawa
ANNOUNCE: Apache:Singleton 0.01 (Re: Tips tricks needed :))
On Thu, 20 Dec 2001 08:57:32 - Matt Sergeant [EMAIL PROTECTED] wrote: Yeah, just like that. Why don't you wrap it up and stick it on CPAN? Saves me another module :-) Okay ;) The URL http://bulknews.net/lib/archives/Apache-Singleton-0.01.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MI/MIYAGAWA/Apache-Singleton-0.01.tar.gz size: 1641 bytes md5: 57abd03817ead367287d1f5908c0143b NAME Apache::Singleton - Singleton class for mod_perl SYNOPSIS package Printer; use base qw(Apache::Singleton); # just the same as Class::Singleton DESCRIPTION Apache::Singleton works the same as Class::Singleton, but clears the singleton out on each request. This module checks $ENV{MOD_PERL}, so it just works well in non-mod_perl environment. AUTHOR Original idea by Matt Sergeant [EMAIL PROTECTED]. Code by Tatsuhiko Miyagawa [EMAIL PROTECTED] This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO the Class::Singleton manpage -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Tips tricks needed :)
On Thu, 20 Dec 2001 11:51:30 -0500 Perrin Harkins [EMAIL PROTECTED] wrote: Like this? (using register_cleanup instead of pnotes) Better to use pnotes. I started out doing this kind of thing with register_cleanup and had problems like random segfaults. I think it was because other cleanup handlers sometimes needed access to these resources. I'll take care of it. Thanks for the input. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Tips tricks needed :)
On Wed, 19 Dec 2001 16:01:22 - Matt Sergeant [EMAIL PROTECTED] wrote: Actually I was wondering about writing an Apache::Singleton class, that works the same as Class::Singleton, but clears the singleton out on each request (by using pnotes). Would anyone be interested in that? Like this? (using register_cleanup instead of pnotes) package Apache::Singleton; use strict; use vars qw($VERSION); $VERSION = '0.01'; use Apache; sub instance { my $class = shift; # get a reference to the _instance variable in the $class package no strict 'refs'; my $instance = $class\::_instance; unless (defined $$instance) { $$instance = $class-_new_instance(@_); Apache-request-register_cleanup(sub { undef $$instance }); } return $$instance; } sub _new_instance { bless {}, shift; } -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
ANNOUNCE: Log::Dispatch::Config 0.06
Log::Dispatch::Config provides a way to configure Log::Dispatch with various config file (default AppConfig, but you can plug your own!). Newest version 0.06 is now on its way to CPAN. 0.06 Tue Dec 18 21:27:51 JST 2001 --- developer API change --- * Added Log::Dispatch::Configurator and docs/tests for it (Thanks to Matt Sergeant [EMAIL PROTECTED]) * Added Date/Time format configuration (Thanks to Matt Sergeant) - Deprecated ${XXX} style format - Switched to fully qualified variable from use vars (for inheritance) This version has several minor API changes (mainly for developers). * You can write your custom config parser (XML::Simple or whatever you want) by subclassing L::D::Configurator. its API is documented in Log::Dispatch::Config. * Added Datetime format configuration via %d{}. It tries to use Time::Piece's strftime first, otherwise POSIX. - Deprecated ${foo} style format. Many thanks to Matt Sergeant. The URL http://bulknews.net/lib/archives/Log-Dispatch-Config-0.06.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MI/MIYAGAWA/Log-Dispatch-Config-0.06.tar.gz size: 8540 bytes md5: be0afc3f36d7728f36a14f3ac396997b -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
ANNOUNCE: Log::Dispatch::Config 0.04
Log::Dispatch::Config provides a way to configure Log::Dispatch with AppConfig style config file format. newest version 0.04 has done whole architecture redesign (subclassing, kickout messy closure), and now is on its way to CPAN. 0.04 Thu Dec 6 18:33:50 JST 2001 * --- API change (with backward compatibility) --- Whole architecture redesign: now inherits from Log::Dispatch. The URL http://bulknews.net/lib/archives/Log-Dispatch-Config-0.04.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MI/MIYAGAWA/Log-Dispatch-Config-0.04.tar.gz size: 5435 bytes md5: ae6fdb0caf61641ba35a622235b9f0d2
Re: ANNOUNCE: Log::Dispatch::Config 0.04
0.04 has a problem in Makefile.PL (CVS replaces $Log: with his RCS keyword, Crap!). Now 0.05 is uploaded or can be fetched from: http://bulknews.net/lib/archives/Log-Dispatch-Config-0.05.tar.gz On Thu, 06 Dec 2001 19:01:34 +0900 Tatsuhiko Miyagawa [EMAIL PROTECTED] wrote: Log::Dispatch::Config provides a way to configure Log::Dispatch with AppConfig style config file format. newest version 0.04 has done whole architecture redesign (subclassing, kickout messy closure), and now is on its way to CPAN. 0.04 Thu Dec 6 18:33:50 JST 2001 * --- API change (with backward compatibility) --- Whole architecture redesign: now inherits from Log::Dispatch. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: [RFC] Apache::CacheContent - Caching PerlFixupHandler
On Thu, 06 Dec 2001 10:04:26 -0800 Bill Moseley [EMAIL PROTECTED] wrote: BTW -- I think where the docs are cached should be configurable. I don't like the idea of the document root writable by the web process. Maybe: Alias /cached /tmp/cache -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: [RFC] Apache::CacheContent - Caching PerlFixupHandler
On Thu, 6 Dec 2001 08:19:09 -0800 Paul Lindner [EMAIL PROTECTED] wrote: I've attached a README below. To download it go to http://www.modperlcookbook.org/code.html Nice one. here's a patch to make the sample code work :) --- CacheContent.pm~Thu Dec 6 22:11:35 2001 +++ CacheContent.pm Fri Dec 7 03:23:39 2001 @@ -6,6 +6,7 @@ @Apache::CacheContent::ISA = qw(Apache); use Apache; +use Apache::Log; use Apache::Constants qw(OK SERVER_ERROR DECLINED); use Apache::File (); --- eg/CacheWeather.pm~ Thu Dec 6 08:10:09 2001 +++ eg/CacheWeather.pm Fri Dec 7 03:24:14 2001 @@ -8,7 +8,7 @@ use strict; -@CacheWeather::ISA = qw(Cookbook::CacheContent); +@CacheWeather::ISA = qw(Apache::CacheContent); sub ttl { my($self, $r) = @_; -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Apache::Session Problem -- Addendum
On Wed, 21 Nov 2001 23:23:33 - Jonathan M. Hollin [EMAIL PROTECTED] wrote: 42: tie %session, 'Apache::Session::DBI', 43: {DataSource = dbi:$db_driver:sessions:$db_address}; put $sid (session id: undef for fresh) after 'Apache::Session::MySQL'. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
ANNOUNCE: Log::Dispach::Config 0.01
Here I've finished the first version of Log4j for perl. There already exists a great Logging module Log::Dispatch by Dave Rolsky and I don't like reinventing the wheels, so my new module Log::Dispatch::Config just optionally drives configuration parsing functionality, which Log::Dispatch lacks, against Log4j. It's now on its way to CPAN and can also be downloaded from: http://bulknews.net/lib/archives/Log-Dispatch-Config-0.01.tar.gz file: $CPAN/authors/id/M/MI/MIYAGAWA/Log-Dispatch-Config-0.01.tar.gz size: 4656 bytes md5: 8300cde5fcf0b8d5f254464434d2f73b Any suggestionss are highly welcome. Thanks. -- NAME Log::Dispatch::Config - Log4j for Perl SYNOPSIS use Log::Dispatch::Config; Log::Dispatch::Config-configure('/path/to/config'); my $dispatcher = Log::Dispatch-instance; DESCRIPTION Log::Dispatch::Config provides a way to configure Log::Dispatch with configulation file (in AppConfig format). I mean, this is log4j for Perl, not with all API compatibility though. METHOD This module has one class method `configure' which parses config file and declares `instance' method in Log::Dispatch namespace. So what you should do is call `configure' method once in somewhere (like `startup.pl' in mod_perl), then you can get configured dispatcher instance via `Log::Dispatch-instance'. CONFIGURATION Here is an example of the config file: dispatchers = file screen file.class = Log::Dispatch::File file.min_level = debug file.filename = /path/to/log file.mode = append file.format = [%d] [%p] %m at %F line %L%n screen.class = Log::Dispatch::Screen screen.min_level = info screen.stderr = 1 screen.format = %m Config file is parsed with AppConfig module, see the AppConfig manpage when you face configuration parsing error. GLOBAL PARAMETERS dispatchers dispatchers = file screen `dispatchers' defines logger names, which will be splitted by spaces. If this parameter is unset, no logging is done. format format = [%d] [%p] %m at %F line %L%n format = [${datetime}] [${prioity}] ${message} at ${filename} line ${line}\n `format' defines log format. `%X' style and `${XXX}' style are both supported. Possible conversions format are %d ${datetime}datetime string %p ${priority}priority (debug, indo, warn ...) %m ${message} message string %F ${filename}filename %L ${line}line number %P ${package} package %nnewline (\n) `format' defined here would apply to all the log messages to dispatchers. This parameter is optional. PARAMETERS FOR EACH DISPATCHER Parameters for each dispatcher should be prefixed with name., where name is the name of each one, defined in global `dispatchers' parameter. class screen.class = Log::Dispatch::Screen `class' defines class name of Log::Dispatch subclasses. This parameter is essential. format screen.format = -- %m -- `format' defines log format which would be applied only to the dispatcher. Note that if you define global `format' also, `%m' is double formated (first global one, next each dispatcher one). This parameter is optional. (others) screen.min_level = info screen.stderr = 1 Other parameters would be passed to the each dispatcher construction. See Log::Dispatch::* manpage for the details. SINGLETON Declared `instance' method would make `Log::Dispatch' class singleton, so multiple calls of `instance' will all result in returning same object. my $one = Log::Dispatch-instance; my $two = Log::Dispatch-instance; # same as $one See GoF Design Pattern book for Singleton Pattern. But in practice, in persistent environment like mod_perl, Singleton instance is not so useful. Log::Dispatch::Config defines `instance' method so that the object reloads itself when configuration file is modified since its last object creation time. TODO * LogLevel configuration depending on caller package like log4j? AUTHOR Tatsuhiko Miyagawa [EMAIL PROTECTED] This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO the Log::Dispatch manpage, the AppConfig manpage -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: inconsistency between CGI.pm and Apache::Request
On Tue, 6 Nov 2001 15:52:20 -0500 Lincoln Stein [EMAIL PROTECTED] wrote: I'm amazed that CGI.pm does this, but you're right. What's bad is that this style doesn't work as expected: p $r-param(foo=[qw(a b c)]) That's it! Any plan to fix this *strange* behaviour? -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
inconsistency between CGI.pm and Apache::Request
There is some inconsistency between CGI.pm and Apache::Request's param() method, especially in handling of multivalued parameter. $q = CGI-new; $q-param(foo = qw(a b c)); @foo = $q-param('foo'); # ('a', 'b', 'c') $q-param(bar = [ qw(a b c) ]); @bar = $q-param('bar'); # (['a', 'b', 'c']) $r = Apache::Request-new(Apache-request); $r-param(foo = qw(a b c)); # die with an error $r-param(bar = [ qw(a b c) ]); @bar = $r-param('bar'); # ('a', 'b', 'c') Am I the only one who wants consistency between the two? CGI.pm 2.78 Apache::Request 0.33 -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Excellent article on Apache/mod_perl at eToys
On Thu, 18 Oct 2001 19:11:04 -0700 (PDT) Andrew Ho [EMAIL PROTECTED] wrote: I checked the list archives and it didn't look like this had been posted yet. For those of you who haven't seen it yet... a great read on perl.com about the Apache/mod_perl setup at eToys, co-authored by our own mod_perl regular contributer Perrin Harkins. http://www.perl.com/pub/a/2001/10/17/etoys.html I've translated this article into Japanese, and you can get it on http://bulknews.net/lib/doc-ja/etoys.ja.html http://bulknews.net/lib/doc-ja/etoys.ja.pod Just wanted to let you know. Thanks for the excellent article, Perrin! -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: ANN/RFC: Apache::Session::Generate variants
On Thu, 11 Oct 2001 01:06:33 -0500 (CDT) Dave Rolsky [EMAIL PROTECTED] wrote: Jeff, if you're still maintaining this package it'd be nice to put out a new release. If not, it'd be good to give it to someone else. Hell, I'll volunteer if no one more interested comes along. I don't have any big plans for it but I can at least integrate patches and such. Apache::Session is in use in a lot of places and it would be good to have an active maintainer. ++1. And I don't mind taking over, if nobody else wants to. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
ANN/RFC: Apache::Session::Generate variants
Here is Apache::Session::Generate::* variants, which especially uses Apache standard C-modules. Apache::Session::Generate::ModUniqueId http://bulknews.net/lib/archives/Apache-Session-Generate-ModUniqueId-0.01.tar.gz http://bulknews.net/lib/archives/Apache-Session-Generate-ModUniqueId-0.01.html uses mod_unique_id for session id. Apache::Session::Generate::ModUsertrack http://bulknews.net/lib/archives/Apache-Session-Generate-ModUsertrack-0.01.tar.gz http://bulknews.net/lib/archives/Apache-Session-Generate-ModUsertrack-0.01.html uses mod_usertrack's cookie for session id. Suggestions patches are welcome. Thanks. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: ANN/RFC: Apache::Session::Generate variants
These are now on CPAN, which I've forgotten to mention. Note that if you try to use these modules functionality, Apache::Session::Flex should be patched with one included in both tarballs. Thanks. On Thu, 11 Oct 2001 01:30:29 +0900 Tatsuhiko Miyagawa [EMAIL PROTECTED] wrote: Here is Apache::Session::Generate::* variants, which especially uses Apache standard C-modules. Apache::Session::Generate::ModUniqueId http://bulknews.net/lib/archives/Apache-Session-Generate-ModUniqueId-0.01.tar.gz http://bulknews.net/lib/archives/Apache-Session-Generate-ModUniqueId-0.01.html uses mod_unique_id for session id. Apache::Session::Generate::ModUsertrack http://bulknews.net/lib/archives/Apache-Session-Generate-ModUsertrack-0.01.tar.gz http://bulknews.net/lib/archives/Apache-Session-Generate-ModUsertrack-0.01.html uses mod_usertrack's cookie for session id. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: ANN/RFC: Apache::Session::Generate variants
On Wed, 10 Oct 2001 17:23:04 -0700 (PDT) Ask Bjoern Hansen [EMAIL PROTECTED] wrote: Apache::Session::Generate::ModUsertrack http://bulknews.net/lib/archives/Apache-Session-Generate-ModUsertrack-0.01.tar.gz http://bulknews.net/lib/archives/Apache-Session-Generate-ModUsertrack-0.01.html uses mod_usertrack's cookie for session id. Don't do that! mod_usertrack is not meant to be used for secure session ids. I know, I know! just an example of using *already tracked* cookie for newly generated sessions. My another plan is to release my session id tracking modules, which Apache::Session doesn't do. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: ANN/RFC: Apache::Session::Generate variants
On Wed, 10 Oct 2001 17:22:23 -0700 (PDT) Ask Bjoern Hansen [EMAIL PROTECTED] wrote: Note that if you try to use these modules functionality, Apache::Session::Flex should be patched with one included in both tarballs. I sent a patch to Jeffrey last week or such that (I imagine) covers the same thing. Wow, I did almost half a year ago :-) http://aspn.activestate.com/ASPN/Mail/Message/modperl/532294 -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: ANNOUNCE: Apache::OpenIndex
On Thu, 27 Sep 2001 16:36:37 -0500 George Sanderson [EMAIL PROTECTED] wrote: Apache::OpenIndex (OpenIndex-1.00.tar.gz) was uploaded to CPAN on 14Sep2001 and is currently released. This was my first module. I enjoyed journey. It doesnt compile with per 5.005_03, here is a patch. http://bulknews.net/lib/archives/patches/Apache-OpenIndex-1.00.patch And, you'd better use make dist to pack the archive when you upload it to CPAN. -- Tatsuhiko Miyagawa [EMAIL PROTECTED] Apache-OpenIndex-1.00.patch Description: Binary data
Re: Apache::Hello
On Mon, 17 Sep 2001 13:15:44 -0700 Ray and Lara Recendez [EMAIL PROTECTED] wrote: # vi Hello.pm Hello.pm 26 lines, 392 characters package Apache::Hello; # File: Apache/Hello.pm use strict; use Apache::Constants qw(:common); sub handler { my $r = shift; $r-content-type('text/html'); s/content-type/content_type/ Maybe you've got the error msg like Undefined subroutine Apache::Hello::type called at ... -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
RFC: Apache::Session::CacheAny
Announcing the Adapter module which provides a way to use Cache::Cache subclasses as Apache::Session storage implementation. http://bulknews.net/lib/archives/Apache-Session-CacheAny-0.01.readme http://bulknews.net/lib/archives/Apache-Session-CacheAny-0.01.tar.gz Any suggestions are welcome. Thanks. -- NAME Apache::Session::CacheAny - use Cache::* for Apache::Session storage SYNOPSIS use Apache::Session::CacheAny; tie %session, 'Apache::Session::CacheAny', $sid, { CacheImpl = 'Cache::FileCache', }; tie %size_aware_session, 'Apache::Session::CacheAny', $sid, { CacheImpl= 'Cache::SizeAwareFileCache', Namespace= 'apache-session-cacheany', DefaultExpiresIn = '2 hours', AutoPurgeOnGet = 0, AutoPurgeOnSet = 1, MaxSize = 10_000, }; DESCRIPTION Apache::Session::CacheAny is a bridge between Apache::Session and Cache::Cache. This module provides a way to use Cache::Cache subclasses as Apache::Session storage implementation. ARGUMENTS You must specify class name of Cache::Cache implementation (like Cache::SharedMemoryCache) in arguments to the constructor. See the Apache::Session::Store::CacheAny manpage for details about other optional arguments. NOTE Apache::Session::CacheAny uses Apache::Session::Lock::Semaphore as its locking scheme. You can use Apache::Session::Flex to change that. AUTHOR Tatsuhiko Miyagawa [EMAIL PROTECTED] This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO the Apache::Session manpage, the Cache::Cache manpage -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: RFC: Apache::Session::CacheAny
On Sun, 09 Sep 2001 15:24:14 -0700 Perrin Harkins [EMAIL PROTECTED] wrote: Announcing the Adapter module which provides a way to use Cache::Cache subclasses as Apache::Session storage implementation. Hmmm... Don't take this the wrong way, but what's the purpose of this? To glue Cache::Cache with Apache::Session. That's all :-) Apache::Session does very little beyond what Cache::Cache does. In fact, the only things I can think of are the tied interface, which is slower than methods and often confuses people who make updates deep within the structure that don't trigger a save, and the ID generation, which is really just a stub and needs to be replaced for any serious project. Cache::Cache is a cache interface for any key-value pairs with optioinal automatic expire purge. Apache::Session is a framework for persisntent hash data with unique identifier and automatic serialiization/deserialization for hash. Why not combine these two? That's all what this module does. Also, why bother with Apache::Session::Lock::Semaphore at all? Cache::Cache already provides atomic updates. You should be able to use NullLocker with the same level of safety. Cache::Cache ensures file-based atomic update. But IMHO it's not enough for Apache::Session's session transactions, which should be done exclusively. Session data would get logically inconsistent when there are multiple concurrent requests with same one session id. Off course, you can change that to adopt A::S::Lock::Null with A::S::Flex. -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: RFC: Apache::Session::CacheAny
On Sun, 09 Sep 2001 18:33:11 -0700 Perrin Harkins [EMAIL PROTECTED] wrote: To me, they both look like persistent hashes. Apache::Session assumes you will be storing a serialized hash in each hash value, and that it will generate IDs for keys if you don't supply one, but otherwise they're about the same. You're right. The (slight) difference you mention is all that this module does. Cache::Cache ensures file-based atomic update. But IMHO it's not enough for Apache::Session's session transactions, which should be done exclusively. Session data would get logically inconsistent when there are multiple concurrent requests with same one session id. Apache::Session uses shared read locks, so I think you can still have problems there. It doesn't gurantee an atomic read-change-modify. Forgot to mention 'Transaction = 1' argument. Thanks for fixing me. In fact, the storage model I heavily use is A::S::Store::MySQL, whick locking scheme is *always* exclusive. Now, without Transaction = 1 argument, there is no need to use locking scheme for preventing corrupted data update, because Cache::Cache already ensures it, as you wrote. Should I make Apache::Session::Lock::Cache, using Semaphore or File only in case of Transacton mode? package Apache::Session::Lock::Cache; use strict; use base qw(Apaache::Session::Lock::Semaphore); sub acquire_read_lock { 1 } sub release_read_lock { 1 } sub acquire_write_lock { my($self, $session) = @_; if ($session-{args}-{Transaction}) { $self-SUPER::acquire_write_lock($session); } } # blah, blah -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
ANNOUNCE: Apache::No404Proxy 0.03
Annoucing the Apache::No404Proxy module, which serves as 404-free HTTP proxy server! Note that you should be careful before really start using this... Read the whole document! The URL http://bulknews.net/lib/archives/Apache-No404Proxy-0.03.tar.gz has entered CPAN as file: $CPAN/authors/id/M/MI/MIYAGAWA/Apache-No404Proxy-0.03.tar.gz size: 3204 bytes md5: 9c35ea3a8c5f8c852ccf5ac244c15b8a -- NAME Apache::No404Proxy - 404 Redirecting Proxy SYNOPSIS # in httpd.conf PerlTransHandler Apache::No404Proxy # default uses ::Google DESCRIPTION Oops, 404 Not found. But wait..., there is a Google cache! Apache::No404Proxy serves as a proxy server, which automaticaly detects 404 responses and redirects your browser to Google cache. Set your browser's proxy setting to Apache::No404Proxy based server, and it becomes 404 free now! See also the section on RESRICTIONS FOR USE before you use this. SUBCLASSING Default cache archive is Google's one. Here is how you customize this. * Declare your URL translator class. * Inherit from Apache::No404Proxy. * Define translate() method. That's all. Here is an example of implementation, extracted from Apache::No404Proxy::Google. package Apache::No404Proxy::Google; use WWW::Cache::Google; use base qw(Apache::No404Proxy); sub translate { my($class, $uri) = @_; return WWW::Cache::Google-new($uri)-as_string; } Define translate() method as a class method. Argument $uri is a string that represents URI. At last, remember to add the following line to httpd.conf: PerlTransHandler Apache::No404Proxy::Google RESTRICTIONS FOR USE READ THIS before you use this proxy, especially for the default Google implementation. This proxy may or may not break terms of service of Google. In fact, Google prohibits *Automatic Query* without their permissions. See http://www.google.com/terms_of_service.html for details. Yes, this means you are recommended to contact staff at Google, otherwise your IP address would be blacklisted from Google :( The one you should get contact with is Ray Sidney, whose email addy is [EMAIL PROTECTED]. Thanks to Ray for his kindness. AUTHOR Tastuhiko Miyagawa [EMAIL PROTECTED] This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module comes WITHOUT ANY WARRANTY. SEE ALSO the Apache::ProxyPassThru manpage, the LWP::UserAgent manpage, the Apache::No404Proxy::Google manpage -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
ANNOUNCE: Apache::ACEProxy 0.01
NAME Apache::ACEProxy - IDN compatible ACE proxy server SYNOPSIS # in httpd.conf PerlTransHandler Apache::ACEProxy # default uses ::RACE DESCRIPTION Apache::ACEProxy is a mod_perl based HTTP proxy server, which handles internationalized domain names correctly. This module automaticaly detects IDNs in Host: header and converts them in ACE encoding. Set your browser's proxy setting to Apache::ACEProxy based server, and you can browse web-sites of multilingual domain names. SUBCLASSING Default ACE encoding is RACE. Here's how you customize this. * Declare your ACE encoder class (like DUDE, AMC-ACE-Z). * Inherit from Apache::ACEProxy. * Define encode() class method. That's all. Here's an example of implementation, extracted from Apache::ACEProxy::RACE. package Apache::ACEProxy::RACE; use base qw(Apache::ACEProxy); use Convert::RACE qw(to_race); use Unicode::String qw(utf8); sub encode { my($class, $domain) = @_; return to_race(utf8($domain)-utf16); } Not that you should define encode() method as a class method. Argument $domain is a (maybe UTF8) string that your browser sends to the proxy server. At last, remember to add the following line to httpd.conf or so: PerlTransHandler Apache::ACEProxy::RACE CAVEATS This module (at least Apache::ACEProxy::RACE) assumes input domain names are encoded in UTF8. But currently it's known that: * MSIE's always send URL as UTF8 preference does NOT ALWAYS send correct UTF8 string. * Netscape 4.x does NOT send URL as UTF8, but in local encodings. So, this proxy server doesn't always work well with all the domains for all the browsers. Suggestions, patches and reports are welcome about this fact. AUTHOR Tastuhiko Miyagawa [EMAIL PROTECTED] This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This module comes with NO WARRANTY. SEE ALSO the Apache::ProxyPassThru manpage, the LWP::UserAgent manpage, the Unicode::String manpage, the Apache::ACEProxy::RACE manpage -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: ANNOUNCE: Apache::ACEProxy 0.01
On Mon, 20 Aug 2001 18:09:07 +0200 Robin Berjon [EMAIL PROTECTED] wrote: Not that you should define encode() method as a class method. I assume you meant Note :-) Oops. Thanks for fix. CAVEATS This module (at least Apache::ACEProxy::RACE) assumes input domain names are encoded in UTF8. But currently it's known that: * MSIE's always send URL as UTF8 preference does NOT ALWAYS send correct UTF8 string. This has come up on the dav-dev list. As far as MS DAV clients are concerned, the User-Agent can be used to know whether or not it respects that setting. Of course, in order to do proper conversion when it doesn't respect it you still need to know the local encoding that it uses. In my environment, User-Agent: strings is always Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90) It seems to be independent with whether that setting is enables. The problem is, even if we enable the setting, MSIE sometimes sends corrupted UTF-8 string. In my environment, delimiting dots in domain names are corrupted as UTF-8. So, this proxy server doesn't always work well with all the domains for all the browsers. Suggestions, patches and reports are welcome about this fact. Perhaps you could add a configuration directive to allow it to translate from local encodings (which the directive would specify) to UTF-8 ? Agree. Or you should overload encode() easily, if you know how to translate local encodings which your browser uses, to UTF8. I don't know how Unicode::String deals with bad encodings, but other conversion modules (eg Text::Iconv) just die. Perhaps wrapping the conversion in an eval {} in order to provide a nice error message to people that use broken browsers would be a good idea ? Already done :-) Here's an excerpt from ACEProxy.pm. # Encode hostname to ACE my $uri = URI-new($r-uri); my $ace_host; eval { $ace_host = join '.', map { # RFC 1035: letter, digit, hyphen /^[\x30-\x39\x41-\x5a\x61-\x7a\x2d]*$/ ? $_ : $class-encode($_); } split /\./, $uri-host; }; if ($@) { (my $exception = $@) =~ s/ at .*$//; chomp $exception; require Apache::Log; $r-log-error(Apache::ACEProxy: error happens while ACE conversion: $exc eption); return; } -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: How do I STOP Apache::CodeRed sending me messages
On Sun, 19 Aug 2001 18:56:37 +1000 Robert [EMAIL PROTECTED] wrote: I configured Apache::CodeRed to send me messages with each email and so on - How do I stop it from doikn that? I changed the CodeRed.pm file, but it's being ignored? Configuration variables for Apache::CodeRed seem to be hardwired in CodeRed.pm itself. Reuven, why not kick out these variables as those defined by PerlSetVar in http.conf file? For instance, PerlSetVar CodeRedFromAddress [EMAIL PROTECTED] You can get this variable via my $fromaddr = $r-dir_config('CodeRedFromAddress'); -- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Bug??
On Wed, 1 Aug 2001 13:12:44 +0200 Issac Goldstand [EMAIL PROTECTED] wrote: based on the earlier discussion about detecting https :) That will take care of standard http/https, but what if we have a custom client connecting on weird ports _without_ putting the port in the URL? Wouldn't it make sense to just take $ENV{SERVER_PORT} and join() _that_ to make the unique filename? That'll take care of all the weird server combinations possible including SSL, as only one listening socket can physically bind to a port. It'll even transparently take care of weird back-end server problems, as no matter how many servers seem to be on http://frontend:80, the backends MUST be unique combinations of either different hostnames or different ports... Agreed here. We've tried to set up development/production environment in the same one server with config like following (simplified): Listen 80# production Listen 8080 # development VirtualHost _default_:80 DocumentRoot /home/production /VirtualHost VirtualHost _default_:8080 DocumentRoot /home/development /VirtualHost Yeah, this will lead to mixups of the following two URLs, which we don't want. http://hostname/foo.cgi = /home/prodution/foo.cgi http://hostname:8080/foo.cgi = /home/environment/foo.cgi Patch follows, or do we have to make our own PortAwareRegistry which inherits from Apache::RegistryNG ? Thanks. --- Registry.pm.origWed Aug 15 19:17:42 2001 +++ Registry.pm Wed Aug 15 19:18:19 2001 @@ -70,7 +70,7 @@ if ($Apache::Registry::NameWithVirtualHost $r-server-is_virtual) { my $name = $r-get_server_name; - $script_name = join , $name, $script_name if $name; + $script_name = join , $name, $r-get_server_port, $script_name if $name; } # Escape everything into valid perl identifiers -- Tatsuhiko Miyagawa mailto:[EMAIL PROTECTED]
Re: Apache::Session not updating session
On Tue, 14 Aug 2001 00:27:28 -0700 Michael A Nachbaur [EMAIL PROTECTED] wrote: I'm using Apache::Session::File, and am setting a cookie for my sessionid, and my code is currently running in plain-old CGI mode (one of the libraries I'm using keeps segfaulting under mod_perl for some strange reason). When I visit the CGI, it successfully creates the session file in the /tmp directory, and all subsequent accesses to the page successfully load the session information from the right file on disk. However, my problem is that any value I set in my session is never updated on disk. I have tried explicitly calling tied(%session)-save and delete, to no avail. Can I have a look at snippet of your code, please? Well, this doc (from Apache::Session) may help you, though I don't know this is the case. Note that Apache::Session does only a shallow check to see if anything has changed. If nothing changes in the top level tied hash, the data will not be updated in the back- ing store. You are encouraged to timestamp the session hash so that it is sure to be updated. -- Tatsuhiko Miyagawamod_perl Mailing List mailto:[EMAIL PROTECTED] http://bulknews.net/lib/ml/
Re: where to report apache::session 1.53 bug ?
Hi, Here are patches I've made ages ago. http://bulknews.net/lib/archives/Apache-Session-File.pm.patch http://bulknews.net/lib/archives/Apache-Session-Flex.pm.patch Thanks On Thu, 28 Jun 2001 19:15:33 +0700 Iwan Garnadi [EMAIL PROTECTED] wrote: BUG : 1. Flex , using Apache::Session::File bug in Apache::Session TIEHASH method for validate attribute in line 379 : {$self-{validate}}($self); I am just commented this to get by pass the error ! -- Tatsuhiko Miyagawa Livin' On The EDGE, Co.,Ltd. mailto:[EMAIL PROTECTED] http://www.edge.co.jp/
Re: [OT] Lightweight CGI.pm - Why?
Hi, On Sun, 20 May 2001 11:37:44 +0800 Gunther Birznieks [EMAIL PROTECTED] wrote: The reason I have used them in the past is that it is easier to do things like widgets. TT and many pure template systems don't seem to have as much of a widget concept when it comes to form variables. It's nice to know that if you print a radio button form element using CGI.pm, that if the value was set previously, CGI.pm knows how to print which ones are checked and non checked and all that kind of crap. HTML::FillInForm makes it possible while keeping code and design apart! I use this in combination of HTML::Template. -- Tatsuhiko Miyagawa Livin' On The EDGE, Co.,Ltd. mailto:[EMAIL PROTECTED] http://www.edge.co.jp/
Apache::Session::Flex
Hi, Apache::Session::Flex doesn't work well when restoring object with existing session id. It is because Apache::Session tries to call A::S::Generate::* (currently MD5 only) class's validate() method which Apache::Session::Flex doesn't set. Patch below fixes this. --- Flex.pm.origFri May 4 22:00:13 2001 +++ Flex.pm Fri May 4 22:11:48 2001 @@ -42 +42,2 @@ -eval '$incl-{$gen} = \' . $gen . '::generate' || die $@; +eval '$incl-{$gen}-[0] = \' . $gen . '::generate' || die $@; +eval '$incl-{$gen}-[1] = \' . $gen . '::validate' || die $@; @@ -53 +54,2 @@ -$self-{generate} = $incl-{$gen}; +$self-{generate} = $incl-{$gen}-[0]; +$self-{validate} = $incl-{$gen}-[1]; -- Tatsuhiko Miyagawa Livin' On The EDGE, Co.,Ltd. mailto:[EMAIL PROTECTED] http://www.edge.co.jp/
Patch for Apache::Session::Lock::File
Here's a patch for Apache::Session::Lock::File::clean(), which can never clean up the session files. --- File.pm.origThu Apr 12 15:37:08 2001 +++ File.pm Thu Apr 12 15:37:36 2001 @@ -133,7 +133,7 @@ my @files = readdir(DIR); foreach my $file (@files) { if ($file =~ /^Apache-Session.*\.lock$/) { -if ((stat($dir.'/'.$file))[8] - $now = $time) { +if (($now - stat($dir.'/'.$file))[8] = $time) { open(FH, "+$dir/".$file) || next; flock(FH, LOCK_EX) || next; unlink($dir.'/'.$file) || next; -- Tatsuhiko Miyagawa Bulknews http://bulknews.net/ mailto:[EMAIL PROTECTED]Perl Lib http://bulknews.net/lib/
Apache::Session::MySQL problem
I'm using Apache::Session 1.51 + mysql 3.22.32 + mod_perl 1.24 + Apache 1.3.11. They work well except one problem. The problem is, if an acquired Session ID (from Cookie) is not stored in the session database, Apache goes like panic: POPSTACK Callback called exit. I know Apache::Session will die "Object does not exist in the data store" when it can't restore a session from database. So my script catch that exception with eval block. But panic will happen. why ? httpd.conf -- Files ~ "\.cgi$" SetHandler perl-script PerlHandler Apache::Registry Options +ExecCGI #PerlInitHandler Apache::StatINC #PerlSetVar StatINCDebug On PerlModule Apache::DBI /Files sample.cgi -- use strict; use Apache; use Apache::Session::MySQL; use CGI; use CGI::Cookie; my $q = new CGI; my %session; eval { my $r = Apache-request; my %cookie = CGI::Cookie-parse($r-header_in('Cookie')); my $sid = $cookie{SID}-value; tie %session, 'Apache::Session::MySQL', $sid, { DataSource = "dbi:mysql(RaiseError=1):dbname", UserName= "user", Password= "passwd", LockDataSource = "dbi:mysql(RaiseError=1):dbname", LockUserName= "user", LockPassword= "passwd", }; }; if ($@) { print $q-header, $@; } Any helps? +-+-+-+-+-+-+-+-+-+-+- Tatsuhiko Miyagawa [EMAIL PROTECTED]
Re: Apache::Session::MySQL problem
Thu, 20 Jul 2000 14:29:40 -0700 (PDT) "Jeffrey W. Baker" [EMAIL PROTECTED] wrote: The problem is, if an acquired Session ID (from Cookie) is not stored in the session database, Apache goes like panic: POPSTACK Callback called exit. I know Apache::Session will die "Object does not exist in the data store" when it can't restore a session from database. So my script catch that exception with eval block. But panic will happen. why ? Bug in Perl. Upgrade. my perl version is 5.005_03 with FreeBSD 4.0. shoud I update this to perl 5.6.0 ?? +-+-+-+-+-+-+-+-+-+- Tatsuhiko Miyagawa [EMAIL PROTECTED]