[Petal] [PATCH] Options via constructor rather than package globals

Steve Purkis spurkis at mkdoc.com
Thu Jun 5 16:07:59 BST 2003


On Thursday, June 5, 2003, at 02:17  pm, Fergal Daly wrote:

> On Thursday 05 June 2003 11:01 am, Jean-Michel Hiver wrote:
>> Having the options at an object level did really involve quite a lot 
>> of
>> changes. So instead of making the rest of Petal code aware of 
>> per-object
>> options, I changed the process() method to declare the global options
>> variables as local and set them to the per-objects options.
>
> I think this pretty much guarantees that using these features with 
> threads is
> not safe. I'm not sure how many people will want to use Petal with 
> threads
> but...

Not only not thread safe... consider:

	my $tmpl1 = Petal->new( 'tmpl1.html', base_dir => '/foo' );
	my $tmpl2 = Petal->new( 'tmpl2.html', base_dir => '/tmp' );
	...
	$tmpl1->process();
	...
	$tmpl2->process();

	# templates may come from both /tmp *and* /foo for $tmpl2...

A potential nightmare unless you tread carefully...

-Steve



More information about the Petal mailing list