> Is there a way to somehow move my create_campaign() function inside
> Campaign.__init__? It is not wery important, more the matter of style.
>
sure you can just say:
class Campaign(object):
def __init__(self):
self.id = Campaign.c.id.default.scalar()
looks pretty stylish to me... :)
Yes I like that part. I started using it a few posts of yours ago.
I was actually thinking on calling this function from within __init__:
def create_campaign(**kw):
sql = "BEGIN :id := cc_util.create_campaign(...); END;"
# ... execute procedure via cursor.execute (), and fetch result ID back
return campaign_id # used to LOAD the object
and then to somehow fix the object in regard with objectstore/identitymap because you mention in the docs that __init__ is used to keep track of new objects (this is actually loaded from the database).
If not, I will make it as a @staticmethod called new or create.