On 9/16/05, Simon Willison <
swil...@gmail.com> wrote:
> tagfield = meta.FakeCharField()
> def load_tagfield(self):
> # Returns the contents of the field when it is displayed
> def save_tagfield(self, value):
...
Instead of Fake*, I suggest Deferred, or Mapped*, or Extended*. This
idea is pretty close to the protocol of __getitem__ call when o[x] is
used.
Otherwise, neat.
> Another extremely common problem is the need to have a field
> automatically set to some value when an item is created or updated
> (most commonly a field such as pub_date or last_modified). I wonder
> if the above mechanism, or something similar, cousd be used to solve
> that one as well.
Hmm, that's muddying the waters. I like the focus this has on mapping
in and out of the persistence layer. What you're talking about on
this 2nd thing is eventing, right? Maybe:
class Entry(meta.Model):
pub_date = meta.DateTimeField()
def init_pub_date(self):
#when model is new (not from persistence)
pass
def resync_pub_date(self):
#when model is updated, but not necessarily pub_date.
pass
def modify_pub_date(self):
#when pub_date, specifically, is changed.
I'll shut up now, since I won't be supplying patches any time soon. :-/