Re: [PyPerSyst-Devel] Fwd: sandbox/gldnspud/fieldproblem ...
Brought to you by:
pobrien
|
From: Matthew S. <gld...@us...> - 2004-06-25 21:30:44
|
Is the attached patch closer to what you had in mind? It's smaller and simpler and probably more efficient :-) The changes it makes are: pypersyst.field.field.Field already had a _bypass attribute that could be set to True to keep __init__ from validating the value. __init__ now has a 'bypass' argument defaulting to None, that if set to something other than None will override the _bypass attribute. pypersyst.entity.base.Entity.__init__ now accepts a 'bypass' argument defaulting to None. If it is set to True or False, it is passed along to the field constructor which will act as described above. Additionally, if it is set to True, any field for which there is no corresponding value in 'attrs' will be given the value None. pypersyst.entity.entity.Entity.txb_create sets bypass=True when creating its surrogate instance. Any custom txb_create in someone's code would need to do this as well. Matthew Scott wrote: > Patrick K. O'Brien wrote: > >> So instead of Field.__init__() calling self.set(value), the value >> would not be passed as an argument to __init__, and the user of the >> field would have to call field.set(value) explicitly. That would >> allow us to constuct a field with no value, which is what you want for >> a create surrogate. >> > I agree that having this kind of ability in Field rather than hacked > into Entity would be smarter though. Perhaps it already supports this > and I didn't look closely enough :) I'll investigate and see what I > discover. |