On 19/05/06, Dave Howorth <[EMAIL PROTECTED]> wrote:
Aaron Trevena wrote:
> After my talk at the local Perl Mongers on Wednesday, I spoke to
> Barbie about handling multiple actions in a single request.

talk, barbie?

D & C Perl Mongers, 17th may - see use.perl :)

Barbie, leader of Birmingham Perl Mongers, one of organisers of
YAPC::EU this year.

> Currently this is handled by request.component which is now core
> Maypole rather than a plugin, but that seems a bit like using a
> sledgehammer to crack a nut for many jobs.

Do you have any examples of the kind of jobs for which it is and is not
overkill?

On a jobsite I recently put together, the front page had 2 lists -
latest and top jobs.

I ended up using the classes directly, bypassing maypoles handy bits
which was a shame as both could easily be simple re-usable actions,
and would work as components. But in I think components would be
wasteful, as it would require creation of a new request object and
repeating work un-necessary inside the request.

What would work better would be to provide the latest jobs, and top
jobs as groups of objects and then just copy the list template to
handle the subsets nicely.

> This bought me back to thinking about the objects array - I think it
> could be clearer and easier.
>
> Firstly, there are many cases where you only have one object and
> treating request.objects as an array makes templates and code less
> clear and more work. For this situation I want to provide $r->object()
> which will get set the first/only object in $r->objects.
>
> Secondly I'd like to provide named objects, but in a backward
> compatible manner..

I'm not sure what these are used for?

They're new - a way to get subsets of $r->objects.

> $r->objects will return all the objects in the default group
> $r->objects($obj1,$obj2) will put $obj1 and $obj2 into the default group
> $r->objects(foo => [$obj1, $obj2])  will put $obj1 and $obj2 into the
> 'foo' group
> $r->objects('foo') will return the objects in the foo group
> $r->objects(foo => [$obj1, $obj2], bar => [$obj1])  will put $obj1 and
> $obj2 into the foo group, and $obj1 in the bar group.
> $r->objects('foo','bar') will return the objects in the foo and bar
> groups in that order

The purpose of objects() is to pass data to the templates, yes? And the
view already provides an alias ('beers'). Do your groups show up as
extra template variables? If so, why restrict them to arrays of objects,
why not just permit arbitrary data structures? BTW, what are the limits
on the type of $obj1, $obj2 etc?

> To ensure clarity and avoid confusion the following will be errors :
> $r->objects('foo', $obj1, 'bar');
> $r->objects('foo' => [$obj1], 'bar');
> $r->objects(foo=>[$obj],$obj2);
> $r->objects([$obj1,$obj2]);

The last of these is currently how objects are set, no? So it can't be
an error if you want backward compatibility.

True - my bad, it should in fact do the same as $r->objects($obj1,$obj2);

cheers,

A.


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Maypole-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-devel

Reply via email to