Here is how I handled in the past.
In a model file:
def bydb(name=None):
if name: session.db_name=name
else: name=session.db_name
commdb=DAL(name)
commdb.define_table(.....)
commdb.define_table(.....)
commdb.define_table(.....)
return commdb
and use it as needed with
bydb('sqlite://mytempdb.sqlite')
or
bydb()
On Aug 16, 5:36 am, "david.waldrop" <[email protected]> wrote:
> I am working on an application and have encountered an issue I cant
> seem to solve. I have an app based on the supplied scaffolding. It
> has a "db" variable defined in the model. The db is available to all
> the other controlers in the application without any problem.
>
> Additionally, in one of the controllers (creatcommunity) I create a
> seperate dynamic database (commdb) that is stored in a separate
> subdirectory of the applications "database" folder. My problem is
> twofold.
>
> 1) Once commdb is created is is not available to subsequent
> controllers that operate on the tables contained in the database. So
> for example, once the user selects a community, I open the
> corresponding commdb and display a list of posts. I am now trying to
> implement the ability for a user to edit a community posts, but cannot
> figure out how to reference the commdb.
>
> 2) Once a database is defined how do you re-open it without redefining
> it?
>
> I have played arouynd with session variables, and defining what I
> thought would be global variables in the model, but it seems as if
> these behave more like consonants and are unable to be changed in
> controllers.