From: Brian Merrell <brian@me...> - 2005-08-23 06:20:38
I am trying to figure out how to best use the "magic" methods. Code
for one columns needs to look at other columns and in some cases
completely aborts the creation of the object. Both these issues
create problems as I don't always have the other columns set when my
"magic" _set code runs.
Is there any way for the non-magic (ie not intercepted by user code)
columns to be set first?
Is there someway to run our code after all of the columns have been
set but before the the object is actually inserted (and change
columns as we please)? Can we abort at this point?
My current workaround it to create a classmethod that returns an
instance (or aborts) and performs all the columns analysis. However
I don't like that it isn't built into the default behavior (ie if I
just create the object and don't call this method then all of my
rules, business logic, etc. are ignored)
Thanks for any help.
On Tue, Aug 23, 2005 at 02:20:22AM -0400, Brian Merrell wrote:
> Is there any way for the non-magic (ie not intercepted by user code)
> columns to be set first?
There is no, probably. You may want to look into main.py, and modify
methods _create() and set(). Patches that do not break anything will be
> Is there someway to run our code after all of the columns have been
> set but before the the object is actually inserted (and change
> columns as we please)? Can we abort at this point?
Try to intercept _SO_finishCreate() method. Don't forget to call
parent's method if you want to do INSERT.
Oleg Broytmann http://phd.pp.ru/ phd@...
Programmers don't die, they just GOSUB without RETURN.