I like the record(foo) idea. We use something similar at work. In our equivalent of Jifty::Object we have a model() method that does essentially this (but with a grosser ORM).
Cheers, Sterling -----Original Message----- From: Jesse Vincent <[EMAIL PROTECTED]> Sent: Saturday, August 30, 2008 2:00 AM To: Nifty apps in a Jiffy <jifty-devel@lists.jifty.org> Subject: Re: [jifty-devel] Easier model usage On Aug 29, 2008, at 11:22 PM, Chia-liang Kao wrote: > > > IIRC you previously had a hack M("Foo") which gives you the foo model, > maybe we can do something like M("Foo", Load => 1) and M("Foo", > LoadByCols => foo => 'abc', email => [EMAIL PROTECTED]') ? I'd prefer > polluting the namespace in a more finite and deterministic way, rather > than having all models generating toplevel package. > so maybe M() for model helper and MC() for collection helper? I guess > that would help a lot for plugin writers as well. I actually sort of wonder if we jsut want a shortcut for Jifty->app_class(); Class(Model => 'Foo'); Class(Model => 'FooCollection'); But at that point, I get sad about the toplevel pollution. And hrm. I don't know if a middleground will make gugod happy. It almost feels like we sort of want a functional subset of jifty to do what gugod is looking for. > I've been very frustrated to write something like: > > my $m = Jifty->app_class(Model => "Foo")->new > $m->load($id); Right now, the best we can do is: my $m = Jifty->app_class(Model => "Foo")->load($id); Gugod's extension gives us: my $m = Foo(1); CL's proposal gets us to: M(Foo => Load => 1); Gugod's syntax is very very pretty but does have a namespace clobbering issue and can't generalize easily to other kinds of classes without more stompyness. I suppose we could do something like: my $m = Jifty->record('Foo')->load($id); or even my $m = record('foo')->load($id); We might be able to get to: my $m = record foo load ($id); Other ideas? _______________________________________________ jifty-devel mailing list jifty-devel@lists.jifty.org http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel _______________________________________________ jifty-devel mailing list jifty-devel@lists.jifty.org http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel