On Fri, 2005-11-18 at 09:02 +0000, Aaron Trevena wrote:
> On 11/17/05, Peter Speltz <[EMAIL PROTECTED]> wrote:
> > > I've just come across something a bit inelegant in the mapping of
> > > path/table to classes.
> > >
> > > The hack I have just used is :
> > > PukkaEcommerce::Frontend->config->{table_to_class}{Information} =
> > > 'PukkaEcommerce::Information';

table_to_class is a completely undocumented implementation artefact of
CDBI::Plain, so I wouldn't worry about hacking it :)

> > > I am looking at providing a nice API to handle this kind of thing,
> >
> > I'm not real clearly understanding what kind of thing you are trying
> > to handle.   Are you wanting to set the table to class mapping
> > manually to override  the base model's  class_of($r, $table) results?
> > Or you want a better implementation of class_of  or you have no
> > class_of in your model ?

I think there are two separate issues here:

(1) How to map URLs to ($class, $method, @args)

I suspect this is what Aaron's most concerned about at the moment. My
view on this is to put in some new general mechanism (an API and a
default implementation). Catalyst is probably a good place to start. I
don't think that special purpose tweaks are a good idea.

(2) How to store name-mapping config information

Well, this is an old chestnut. It's still on my TODO list :(

> I'm replacing the custom mod_perl frontend to pukka plants, it already
> uses CDBI and TT, with maypole for the admin of the site.
> 
> However, I found that there wasn't a clear way to make
> http://url.to/Information/foo/bar use the Information class because
> the Information class had the table set as 'content' and I will be
> using the same database.

It works the other way around, doesn't it? The URL to use is 

  http://url.to/content/foo/bar 

The second line in handler_guts maps it to the class for you.

> I munged the class_of stuff and that seemed to fix it, but I should be
> able to specify what class maps to which 'table'. That piece of code
> is called in the driver after setup.
> 
> > I ran into issue with class_of. I did not have $r handy to pass to
> > class_of.  A ubiquitous $r would help but perhaps  a class_of
> > implementation without needing $r would be ideal. I have no idea how
> > that would be implemented, except a map hash stored in the base model
> > at setup.  Mabe that violates some MVC boundaries though.
> 
> I didn't need $r for that, can't imagine why you would need access to
> any request variables.

Because $r isn't the request. It's the controller :) Sure, it contains
request variables. But - and I'm guessing here - more important in
Peter's case is that it (and only it) contains the config. So in the
model, you have to have $r to access config. Which is broken, IMHO.

Cheers, Dave



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Maypole-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-devel

Reply via email to