[jifty-devel] Strange result with column named "log"!
Jesse Vincent
jesse at bestpractical.com
Mon Sep 4 12:45:01 EDT 2006
On Mon, Sep 04, 2006 at 11:13:55AM +0200, Wolfgang Kinkeldei wrote:
> > After digging into Jifty's code, I found that this behaviour came
> >from
> >the existence of the log method of the Object class, mother of
> >(almost every Jifty classes including) the Jifty::Record class.
>
> The same result will happen with any column name that is equal to a
> method of Jifty::Record or its superclasses Jifty::DBI::Record or
> Jifty::Object. This is due to the fact, that Jifty::DBI::Record
> constructs accessors for the column names by building subs to access
> the column's value.
>
> Inside the admin mode, the actions access the values by calling
> $self->record->$field
>
> IDEA: by using overloading (use overload ('%{}' => sub {...}) on the
> Jifty::DBI::Record object could behave different when used in hash
> context and using a tied hash on the Record.
> Then, any column's value could get retrieved (or set) by accessing:
> $self->record->{$field}
Tied things tend to break in exciting and unexpected ways. Instead, I'd
rather expose "get" and "set" methods. This does have the somewhat
unfortunate side-effect of not letting users override set_xxx and xxx
directly. They'd be forced to use the before_ and after_ hooks we've
provided.
> >PS: by the way, the Jifty module has a logger method that seems
> > to be used nowhere.
>
> ...but it could be used by frontend programmers.
I suspect Jifty::Object->log should be refactored to use that master
Jifty->logger.
Best,
Jesse
More information about the jifty-devel
mailing list