On May 19, 2006, at 14:15, Aaron Trevena wrote:

Hi All,

After my talk at the local Perl Mongers on Wednesday, I spoke to
Barbie about handling multiple actions in a single request.

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.

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..

$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

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]);

Any thoughts, suggestions and feedback appreciated

I hate to sound negative but I think that's far less clear and far less easy and takes us even further down the path of mixing up what is a model, what is a view and what is a controller (my $0.02 worth - I think Maypole does a really bad job of making the distinction but I think that's almost inevitable in a web app).

Having said that, I have had had uses for this in the past. I think that component is the best approach for this sort of situation. It keeps the code simple, both in the Maypole core and the application itself.

I don't see a problem with doing this as long as the current system works just fine. I *really* would like to see us support something like an 'object' method that returns a single object when we have one because I've done three commercial biggish Maypole projects now and they all have plenty of situations where we had just one object in context.

I also like the context of $r->objects($a, $b) doing the same thing as $r->objects([$a, $b]) because I have lists of objects fairly often and it would be conceptually simpler to be able to pass that list to the objects method.

On a similar note, I've been trying to think of a good way to use Class::DBI iterators there instead of just returning lists.

nic
May

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




-------------------------------------------------------
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