Actually I thought that global_metadata was deprecated not Dynamic
since you said i should not be using it.

creating metadata in the base.py causes a trace, using:

from sqlalchemy import *
g.metadata = MetaData()


D:\Projects\Pylons_projects\gameolymp>paster setup-app development.ini
Traceback (most recent call last):
  File "C:\Python24\Scripts\paster-script.py", line 7, in ?
    sys.exit(
  File "c:\python24\lib\site-packages\PasteScript-1.3.4-py2.4.egg\paste
\script\c
ommand.py", line 76, in run
    invoke(command, command_name, options, args[1:])
  File "c:\python24\lib\site-packages\PasteScript-1.3.4-py2.4.egg\paste
\script\c
ommand.py", line 115, in invoke
    exit_code = runner.run(args)
  File "c:\python24\lib\site-packages\PasteScript-1.3.4-py2.4.egg\paste
\script\a
ppinstall.py", line 65, in run
    return super(AbstractInstallCommand, self).run(new_args)
  File "c:\python24\lib\site-packages\PasteScript-1.3.4-py2.4.egg\paste
\script\c
ommand.py", line 210, in run
    result = self.command()
  File "c:\python24\lib\site-packages\PasteScript-1.3.4-py2.4.egg\paste
\script\a
ppinstall.py", line 451, in command
    installer.setup_config(
  File "c:\python24\lib\site-packages\PasteScript-1.3.4-py2.4.egg\paste
\script\a
ppinstall.py", line 579, in setup_config
    mod = import_string.try_import_module(mod_name)
  File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste\util
\import_stri
ng.py", line 81, in try_import_module
    return import_module(module_name)
  File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste\util
\import_stri
ng.py", line 67, in import_module
    mod = __import__(s)
  File "D:\Projects\Pylons_projects\gameolymp\gameolymp\websetup.py",
line 4, in
 ?
    from gameolymp.maf.models.models import *
  File "D:\Projects\Pylons_projects\gameolymp\gameolymp\maf\models
\models.py", l
ine 23, in ?
    from user import *
  File "D:\Projects\Pylons_projects\gameolymp\gameolymp\maf\models
\user.py", lin
e 6, in ?
    from gameolymp.lib.base import *
  File "D:\Projects\Pylons_projects\gameolymp\gameolymp\lib\base.py",
line 16, i
n ?
    g.metadata = MetaData()
  File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\registry.py", li
ne 128, in __setattr__
    setattr(self._current_obj(), attr, value)
  File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\registry.py", li
ne 177, in _current_obj
    raise TypeError(
TypeError: No object (name: G) has been registered for this thread

On Jun 13, 6:15 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Jun 13, 2007, at 12:07 PM, voltron wrote:
>
>
>
> > aha, ok, thanks, but I saw it in the docs, ist it deprecated?  Then I
> > ´m in a spot
>
> DynamicMetaData is not deprecated.   but when you connect to it, its
> a thread-local connection.  other threads that access it wont have
> any engine. you just want to use a regular MetaData, which these days
> has a connect() method.  but you might not even need to do that with
> a pylons configuration.
>
>
>
> > If I go the route of creating meta first I would have to create it in
> > every table file, in users.py, addresses.py e.tc. I tried using a file
> > called _initmodels.py and created the metadata only once and made alle
> > the separate table files import from it, but that ultimately failed
> > because when I imported it in websetup.py in pylons so I can use it to
> > setup my databses and app, it did not find the metadata properly, it
> > assumed it was another metadata, and naturally, no dtabases were
> > created
>
> that sounds like you need to get control of your application
> modules.  you should declare your metadata in some common place, like
> for pylons in base.py or app_globals.py, where everyone else can get
> to it.
>
> but additionally, Pylons connects the database to the session, so
> typically in a pylons app theres not even any need to connect the
> engine to the metadata.  to issue a create_all() just do
> metadata.create_all(connectable=sessioncontext.current.connect()).


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

Reply via email to