[jifty-devel] Easier model usage
jesse at bestpractical.com
Sat Aug 30 03:00:14 EDT 2008
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 => xyz at foo.com') ? 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
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
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);
my $m = record('foo')->load($id);
We might be able to get to:
my $m = record foo load ($id);
More information about the jifty-devel