Hello,

In tg2.

cp model.template mymodel.py

Inside I put what? If I do this then system complains about:

recall_table = Table('recall_db', metadata, autoload=True)

class Recall(object):
    def __init__(self, **kw):
        """automatically mapping attributes"""
        for key, value in kw.iteritems():
            setattr(self, key, value)

#Mapping of Table to Python Object Class
mapper(Recall, recall_table)

and the bottom of the __init__.py says:
from myapp.model.mymodel import Recall

That doesn work because:

sqlalchemy.exc.UnboundExecutionError: The MetaData is not bound to an
Engine or Connection.  Execution can not proceed without a database to
execute against.  Either execute with an explicit connection or assign
the MetaData's .bind to enable implicit execution.


So I read in __init__

def init_model(engine):
    """Call me before using any of the tables or classes in the model."""

    DBSession.configure(bind=engine)
    # If you are using reflection to introspect your database and create
    # table objects for you, your tables must be defined and mapped inside
    # the init_model function, so that the engine is available if you
    # use the model outside tg2, you need to make sure this is called before
    # you use the model.

    #
    # See the following example:

    #global t_reflected

    #t_reflected = Table("Reflected", metadata,
    #    autoload=True, autoload_with=engine)

    #mapper(Reflected, t_reflected)


But what does that mean???
Where did Reflected came from??
How should I use get my model imported so it stays in the mymodel.py
file and the __init__ only imports it.?

Ideas?

Thanks,
Lucas

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to