[Grok-dev] megrok.rdb, Oracle, and views.
Jeffrey D Peterson
bgpete at gmail.com
Wed Feb 17 08:51:09 EST 2010
So, given your previous input I have made this change, and this also works.
def setupDatabaseSkipCreate(metadata):
"""Set up of ORM for engine in current site.
This will:
* reflect any reflected tables that need to be reflected from the
database
into classes.
"""
reflectTables(metadata)
notify(DatabaseSetupEvent(metadata))
diff of setup.py
24,35d23
< def setupDatabaseSkipCreate(metadata):
< """Set up of ORM for engine in current site.
<
< This will:
<
< * reflect any reflected tables that need to be reflected from the
database
< into classes.
<
< """
< reflectTables(metadata)
< notify(DatabaseSetupEvent(metadata))
<
Diff of __init__.py
8c8
< from megrok.rdb.setup import setupDatabase, setupDatabaseSkipCreate
---
> from megrok.rdb.setup import setupDatabase
Please let me know if this works for you and if someone will attempt to make
the changes permanent.
Thanks.
--
Jeffrey D Peterson
> -----Original Message-----
> From: grok-dev-bounces at zope.org [mailto:grok-dev-bounces at zope.org] On
> Behalf Of Martijn Faassen
> Sent: Saturday, February 13, 2010 3:57 AM
> To: grok-dev at zope.org
> Subject: Re: [Grok-dev] megrok.rdb, Oracle, and views.
>
> Hi there,
>
> Jeffrey D Peterson wrote:
> [snip]
> > In setup.py I simply added a parameter and conditional to the
> setupDatabase
> > function:
> >
> > def setupDatabase(metadata, skip_create=False):
> > """Set up of ORM for engine in current site.
> >
> > This will:
> >
> > * reflect any reflected tables that need to be reflected from the
> > database
> > into classes.
> >
> > * create any tables in the database that haven't been yet
> reflected.
> > """
> > reflectTables(metadata)
> > if not skip_create:
> > createTables(metadata)
> > notify(DatabaseSetupEvent(metadata))
>
> Hm, I'd like a way to avoid this boolean flag. As far as I can see you
> need a function that does two things:
>
> * reflect tables
>
> * send the database setup event
>
> What if we just exposed reflectTables in megrok.rdb so you can call
> that
> directly? I'm trying to recall why DatabaseSetupEvent needs to be sent
> here, but I wonder whether we could move it somewhere else instead.
>
> That just would feel slightly better to me than a boolean that changes
> the behavior.
>
> Regards,
>
> Martijn
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev
More information about the Grok-dev
mailing list