scratchpad
tlm
<!--
<p>I have a Perl CGI script that has the following structure (in pseudo code):</p>
<c>
if called without session ID
create new session id
use this id to cache a data stub (with "expect-more-data" flag set)
fork
if parent
respond with a 302 redirect whose URL is the script URL + the session ID
exit
if child
repeat for i in 1..20
sleep 1 second
add "i\n" to the cached data
unset the "expect-more-data" flag in the cached data object
exit
else (i.e. session ID available)
retrieve cached data
if "expect-more-data" flag is set
add "...continuing..." at the end of the response
add <meta http-equiv="refresh" content="3"/> to the response's header
display a page with the newly retrieved data
</c>
<p>This works fine with Safari, but with Firefox (v. 3), the browser appears to freeze for about 20 seconds and then it displays only the last page</p>
<p>What's really strange is that if one looks at Apache's access logs, when the request is done via Safari, one sees several GET requests logged, right in synch with the page updates as they're being displayed by the browser, as expected. But when one uses Firefox, the access log show only two GET requests, the very first one and the very last one, and they both appear simultaneously when the last (and only) page is finally displayed. It's as if the initial request via Firefox was not deemed finalized until the very last one was...</p>
<p>What's even stranger is that when I got rid of the '<meta http-equiv="refresh".../>' directive, and instead implemented the refresh using JavaScript, the observed behavior was exactly the same, both for Safari and for Firefox.</p>
<p>I'm stumped...</p>
-->
<!--
<p>Hi, merlyn!</p>
<p>(BTW, we gotta stop meeting like this... :-) Is there a better venue to bring up issues regarding <c>CGI::Prototype</c>?)<p>
<p>The docs for <c>CGI::Prototype</c> says that one should subclass the main class "in a 'Class::Prototyped'-style manner to override most of its behavior."</p>
<p>I understand the principles behind Class::Prototyped subclassing, but when it comes to the practical details of day-to-day coding, well... let's just say that I have a much better grasp of standard Perl subclassing.</p>
<p>Therefore, I could really use seeing a concrete example of this type of subclassing in the context of a <c>CGI::Prototype</c> app (i.e. as opposed to the examples given in the <c>Class::Prototyped</c> docs).</p>
<p>I looked at the test application you have in the distribution under t/TestApp, but I was surprised to find that all the subclassing done in that application is of the form <c>use base My::App</c>, which (barring some serious magic from <c>Class::Prototype</c>) follows the standard Perl subclassing style.</p>
<p>Could you point me to a <c>CGI::Prototype</c> app that does its subclassing in the <c>Class::Prototyped</c> way? (Pleeeease?)</p>
<p>Thanks in advance!</p>
<p>Regards,</p>
<p><small>tlm</small></p>
-->
<!--
<p>Hi, merlyn!</p>
<p>The docs for <c>CGI::Prototype</c> suggest that the feature of being able to use expressions such as <c>[% self.CGI.self_url %]</c> or <c>[% self.param( 'foo' ) %]</c> is built-in, but that's really not the case, since any real application will override <c>CGI::Prototype::render</c> which typically will clobber the feature.</p>
<p>I'm not sure what the best way to salvage this feature as advertised would be. I suppose that it could be encapsulated in a method, say <c>template_vars</c>, which <c>CGI::Prototype::render</c> would call for the second argument in the <c>$tt->process(...)</c> call:
<c>
sub render {
my $self = shift;
my $tt = $self->engine;
$tt->process($self->template, { $self->template_vars }, \my $output)
or die $tt->error; # passes Template::Exception upward
$self->display($output);
}
sub template_vars {
my $self = shift;
my $self_object = $self->reflect->object; # in case we have a classname
return ( self => $self_object );
}
</c>
In this way at least some simple programs could get away with just overriding <c>template_vars</c> and using <c>SUPER</c> to easily incorporate the feature:
<c>
sub template_vars {
my $self = shift;
return ( $self->SUPER::template_vars, foo => 'bar' );
}
</c>
</p><p>Just my $0.02. Regards.</p>
-->
<!--
I tried what I <em>think</em> [id://561630] suggests, but I'm getting a "can't locate object method" error. I tried a few variants, all with similar results. What am I doing wrong?</p>
<c>
# Super/Module.pm
{
package Super::Module;
sub foo {
print __PACKAGE__ . ': ' . __LINE__ . "\n";
}
}
1;
__END__
# Some/Module.pm
package Some::Module;
use Super::Module;
our $VERSION = '0.1';
our @ISA = qw( Super::Module );
package Some::Module::YeWhoEnters;
*Some::Module::YeWhoEnters =
*Some::Module::YeWhoEnters = \@Super::Module::ISA;
sub Some::Module::foo {
my $class = shift;
$class->SUPER::foo();
print __PACKAGE__ . ': ' . __LINE__ . "\n";
}
1;
__END__
# test.pl
use strict;
use warnings;
use Some::Module;
Some::Module->foo();
__END__
Can't locate object method "foo" via package "Some::Module::YeWhoEnters" at Some/Module.pm line 15.
</c>
<p>Spot the bug:</p>
<c>
sub foo {
my $hashref = shift;
while ( my ( $key, $value ) = each %$hashref ) {
return if sometest( $key );
frobnicate( $key, $value );
}
}
</c>
-->
<!--
[mod://Getopt::Euclid] refers several times to the non-existent [mod://POD::Text]. Patch below:
<code>
+++ - Thu Nov 10 21:32:08 2005
@@ -536,7 +536,7 @@
sub _print_and_exit {
my ($pod, $paged) = @_;
- if (-t *STDOUT and eval { require POD::Text }) {
+ if (-t *STDOUT and eval { require Pod::Text }) {
if ($paged) {
eval { require IO::Page } or eval { require IO::Pager::Page };
}
@@ -1218,11 +1218,11 @@
This argument cause the program to print the complete POD documentation
for the program and exit. If the standard output stream is connected to
-a terminal and the POD::Text module is available, the POD is formatted
+a terminal and the Pod::Text module is available, the POD is formatted
before printing. If the IO::Page or IO::Pager::Page module is available,
the formatted documentation is then paged.
-If standard output is not connected to a terminal or POD::Text is not
+If standard output is not connected to a terminal or Pod::Text is not
available, the POD is not formatted.
=item --version
</c>
<p>Welcome, ladies and gentlemen, to The Perl Gallery.</p>
<p>This evening we take look at the unholy mix of [doc://map] and [doc://return].</p>
<p>Let's begin with the argument-less form of <tt>return</tt>. How often have we seen a routine that ends in a plain <tt>return;</tt>? "Oh, that just returns <tt>undef</tt>." Really? Consider this:
<c>
sub nasty {
if ( $_[ 0 ] % 3 ) {
return $_[ 0 ];
}
else {
return;
}
}
my @x = map nasty( $_ ), 1..10;
</c>
Quick, how many elements in <tt>@x</tt>? 7 or 10?
</c>
<blockquote><em><p>
</p></em></blockquote>
<code>
</code>
<div class="pmsig"><div class="pmsig-439528">
<p><small>the lowliest monk</small></p>
</div></div>
-->
<!--
<p>I promise this is my last DB design question for the evening!</p>
<p>Here's a different design problem, having to do with synonyms. Suppose that you're trying to model some entities "in the world", but each one of these entities has multiple names (aka synonyms). Let's say that there are, for example, 10 different namespaces, and that each entity has 0, 1, or <em>possibly several</em> synonyms in each of these namespaces.
</p>
<p>I have a very large collection of entities and a very large (and fluid) collection of attributes that these the entities can have. Both collections are in the hundreds of thousands. The relation of entities and the attributes they have is many-to-many, but in general any one entity has very few attributes, relative to the total number of possible attributes.</p>
<p>I thought that I would create two tables, one for entities and one for attributes, and a third table to record the associations between entities and attributes.</p>
-->
<!--<p>If I have a production version of a (PostgreSQL) RDB, say <tt>mydb</tt>, and a development version, <tt>mydbdev</tt>, what's the quickest way to update <tt>mydb</tt> so that it matches current state of <tt>mydbdev</tt>?</p>
<p>Also, is there anything like revision control for RDBs?</p>
-->
<!--
<p>I suppose this problem must come up very often: how can one have the same field refer to foreign keys of different tables? For example, suppose that you have a database of people, but that these people fall into distinct categories, and for each category you want to keep track of different fields. One possible solution would be to have a table of people</p>
-->
<!--
<p>I learned SQL a very long time ago; I'm basically having to relearn it from scratch.</p>
<p>Here's an elementary question. Suppose I have two tables that are defined like this:
<c>
create table foo (
id serial,
name varchar(60) not null,
constraint foo_pk primary key(id),
constraint foo_name unique(name)
);
create table bar (
id serial,
foo_id integer not null references foo (id),
name varchar(500) not null,
constraint bar_pk primary key(id)
);
</c>
...and I insert a record into <tt>foo</tt> like this:
<c>
insert into foo(name) values('Mumble Frotz');
</c>
OK, now I want to insert a record into <tt>bar</tt> whose <tt>foo_id</tt> field matches the <tt>id</tt> field of the <tt>foo</tt> record for <tt>"Mumble Frotz"</tt>. What's a simple SQL statement to do this?
</p>
-->
<!--
<h4>diary of a pmdevil newbie</h4>
<p>2005-05-29</p>
<p>just got admitted to pmdev</p>
<p>I already thought of a project/patch: implement automatic [date] to date and [time] to time conversion.</p>
<p>i just learned (from [belg4mit]) about the template in the pmdev wiki, though it doesn't help much with the date issue.</p>
<p>Look at all these new available nodelets! pmdev nodelet seems to be the most useful for the new pmdevil.</p>
<p>Must read Everything Bible(s). /me is in candystore...</p>
<p>2005-06-03</p>
<p>Printed some pages from the Everthing Bible today. A bit of a pain, and in the end not what I was expecting. There's definitely room for improvement in the "ease of access to documentation" department. pmdev needs an on ramp.</p>
<p>2005-06-16</p>
<p>Another idea, this one for the Newest Nodes Node: selectively marking nodes as read (instead of a global flag affecting all nodes showing).
-->