Sorry about the mess with the repeated post.

Removed metadata = MetaData()
and added
from tg21tut.model import metadata, DBSession

Now I get all the tables. Many thanks. I am a beginner!
Also adding, query and polymorphic query now works.

BTW in one quickstart tutorial paster shell development.ini
put me into IPython which was quite nifty. Now I get
Pylons Interactive Shell. Did not find where that is configured.

Ernst



On Sep 9, 11:55 am, Michael Pedersen <[email protected]> wrote:
> Why did you add that line? If you look at the quickstart, you'll see you
> should have no reason to do so (unless I am grossly misunderstanding what
> you did).  Specifically, look at project/model/__init__.py
>
> You're supposed to import any other SQLAlchemy objects you make into that
> file, and then everything will work fine. By making your own metadata, and
> possibly overriding the other metadata object in __init__.py, you've ensured
> that your app will likely never work.
>
> If any of the above is unable to clear up the issues, please post some
> example code in your next email, and we will try to show you what changes to
> make. As for how to use SQLAlchemy with your code, have you worked through
> the tutorials yet? They cover it pretty well.
>
>
>
> On Wed, Sep 8, 2010 at 9:19 PM, ernst <[email protected]> wrote:
> > Hi,
> > I have made a quickstart project with authentication.
> > paster setup-app development.ini
> > creates the tables for model/auth.py
>
> > I add file model/Application.py  which contains nothing relating to
> > sql alchemy (except the imports)
> > setup-app still works fine.
>
> > Then I add this line:
> > metadata = MetaData()
> > and setup-app breaks (see output at end of mail =========)
>
> > A) It did work when I set up tables and mappings for joint table
> > inheritance (sort of: the tables for
> > model/Application.py were created correctly but the ones for model/
> > auth.py were no longer created ! ).
>
> > B) Then I changed table and mapping definitions to single table
> > inheritance and I get this error. By eliminating lines from the new
> > code I could isolate the problem back to that one line:
> > metadata = MetaData()
>
> > Thank you for advice. Also pointers to documentation about the
> > SQLAlchemy integration into TurboGears are welcome.
>
> > Regards
> > Ernst
>
> > =================
> > paster setup-app development.ini
> > /home/ernst/tg21b2/bin/paster:5: UserWarning: Module pkg_resources was
> > already imported from /home/ernst/tg21b2/lib/python2.5/site-packages/
> > setuptools-0.6c8-py2.5.egg/pkg_resources.pyc, but /usr/lib/python2.5/
> > site-packages is being added to sys.path
> >  from pkg_resources import load_entry_point
> > /home/ernst/tg21b2/bin/paster:5: UserWarning: Module site was already
> > imported from /home/ernst/tg21b2/lib/python2.5/site.pyc, but /usr/lib/
> > python2.5/site-packages is being added to sys.path
> >  from pkg_resources import load_entry_point
> > Running setup_config() from tg21tut.websetup
> > Creating tables
> > 10:47:05,272 INFO  [sqlalchemy.engine.base.Engine.0x...1f0c] BEGIN
> > 10:47:05,280 INFO  [sqlalchemy.engine.base.Engine.0x...1f0c] select
> > nextval('"tg_user_user_id_seq"')
> > 10:47:05,280 INFO  [sqlalchemy.engine.base.Engine.0x...1f0c] None
> > 10:47:05,287 INFO  [sqlalchemy.engine.base.Engine.0x...1f0c] ROLLBACK
> > Traceback (most recent call last):
> >  File "/home/ernst/tg21b2/bin/paster", line 9, in <module>
> >    load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')
> > ()
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > PasteScript-1.7.3-py2.5.egg/paste/script/command.py", line 84, in run
> >    invoke(command, command_name, options, args[1:])
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > PasteScript-1.7.3-py2.5.egg/paste/script/command.py", line 123, in
> > invoke
> >    exit_code = runner.run(args)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > PasteScript-1.7.3-py2.5.egg/paste/script/appinstall.py", line 68, in
> > run
> >    return super(AbstractInstallCommand, self).run(new_args)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > PasteScript-1.7.3-py2.5.egg/paste/script/command.py", line 218, in run
> >    result = self.command()
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > PasteScript-1.7.3-py2.5.egg/paste/script/appinstall.py", line 456, in
> > command
> >    self, config_file, section,
> > self.sysconfig_install_vars(installer))
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > PasteScript-1.7.3-py2.5.egg/paste/script/appinstall.py", line 598, in
> > setup_config
> >    mod.setup_app, command, filename, section, vars)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > PasteScript-1.7.3-py2.5.egg/paste/script/appinstall.py", line 612, in
> > _call_setup_app
> >    func(command, conf, vars)
> >  File "/home/ernst/tg21b2/tg21tut/tg21tut/websetup/__init__.py", line
> > 19, in setup_app
> >    bootstrap.bootstrap(command, conf, vars)
> >  File "/home/ernst/tg21b2/tg21tut/tg21tut/websetup/bootstrap.py",
> > line 47, in bootstrap
> >    model.DBSession.flush()
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/scoping.py", line 127, in do
> >    return getattr(self.registry(), name)(*args, **kwargs)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/session.py", line 1354, in
> > flush
> >    self._flush(objects)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/session.py", line 1432, in
> > _flush
> >    flush_context.execute()
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 261, in
> > execute
> >    UOWExecutor().execute(self, tasks)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 753, in
> > execute
> >    self.execute_save_steps(trans, task)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 768, in
> > execute_save_steps
> >    self.save_objects(trans, task)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/unitofwork.py", line 759, in
> > save_objects
> >    task.mapper._save_obj(task.polymorphic_tosave_objects, trans)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/mapper.py", line 1428, in
> > _save_obj
> >    c = connection.execute(statement.values(value_params), params)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py", line 824, in
> > execute
> >    return Connection.executors[c](self, object, multiparams, params)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py", line 872, in
> > _execute_clauseelement
> >    parameters=params
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py", line 938, in
> > __create_execution_context
> >    return dialect.execution_ctx_cls(dialect, connection=self,
> > **kwargs)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/default.py", line 172, in
> > __init__
> >    self.__process_defaults()
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/default.py", line 359, in
> > __process_defaults
> >    val = drunner.get_column_default(c)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/databases/postgres.py", line
> > 907, in get_column_default
> >    return self.execute_string(exc.encode(self.dialect.encoding))
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py", line 1861, in
> > execute_string
> >    conn._cursor_execute(self.cursor, stmt, params)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py", line 950, in
> > _cursor_execute
> >    self._handle_dbapi_exception(e, statement, parameters, cursor,
> > context)
> >  File "/home/ernst/tg21b2/lib/python2.5/site-packages/
> > SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/engine/base.py", line 931, in
> > _handle_dbapi_exception
> >    raise exc.DBAPIError.instance(statement, parameters, e,
> > connection_invalidated=is_disconnect)
> > sqlalchemy.exc.ProgrammingError: (ProgrammingError) relation
> > "tg_user_user_id_seq" does not exist
> >  'select nextval(\'"tg_user_user_id_seq"\')' None
>
> > --
> > 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]<turbogears%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/turbogears?hl=en.
>
> --
> Michael J. Pedersen
> My IM IDs: Jabber/[email protected], ICQ/103345809, AIM/pedermj022171
>           Yahoo/pedermj2002, MSN/[email protected]

-- 
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