this is the relative vs absolute import conflict, see python 2.5 news 
and the PEP about it. i'm not sure if last py2.5 really does all 
that, it didnt work here.

The code u have, imports the module via different paths - some 
relative, e.g. current dir, and other absolute - e.g. via pythonpath, 
and other relative on another level, from parent dir.

one thing u could do is to have all imports of some module being from 
same root, e.g. vor.model, or higher if need be.
another thing that could help is to hack sys.modules and to alias by 
hand certain modules to differnt possible names, but its said in the 
above PEP that sysmodules will disappear one day...

svil

On Saturday 21 July 2007 18:32:33 Jesse James wrote:
> On Jul 20, 10:42 pm, [EMAIL PROTECTED] wrote:
> > this ain't SA issue, but if u want a solution, u have to provide
> > more data, and do some prints here-there.
> >
> > > When a scheduled job is run, its specified module is loaded
> > > using __import__ . This works fine unless the loaded module has
> > > an 'import model' in it. If so, I get this:
> > > Traceback (most recent call last):
> > >   File "C:\Projects\VOR\tg\vor\jobs.py", line 210, in runJob
> > >     module = __import__(modname)
> > >   File "C:\Projects\VOR\tg\vor\account.py", line 4, in ?
> > >     import model
> > >   File "C:\Projects\VOR\tg\vor\model.py", line 11, in ?
> > >     Column("content", Unicode)
> > >   File "build\bdist.win32\egg\sqlalchemy\schema.py", line 128,
> > > in __call__
> > > ArgumentError: Table 'None.keyed_file' is already defined for
> > > this MetaData instance.
> >
> > so AFAIget it, runJOB is the starter. And the module u try to
> > import is 'account'?
> > put a
> >   print 'XX',__name__
> > on first line of model.py. if u see more than one 'XX', then the
> > module is being loaded multiple times, probably via different
> > names/paths, e.g. as model.py, vor.model.py - and u'll see the
> > path.
>
> Yes. here's what I see after putting in the print as you suggested:
> [EMAIL PROTECTED] vor]$ sudo ./start-vor.py prod.cfg
> XX vor.model
> XX model
> XX model
>
> The first one is 'vor.model' for the static import declaration in
> one of the files of the application.
> The other 2 are from the dynamic __import__ of the runJob function,
> which ran twice in this test.
>
> So, what's up with the vor.model thing? If that is how it is being
> loaded, how do I avoid reloading it as 'model'?
> In other words, should I first attempt to
> __import__('vor.'+modname) in runJob() ?
>
> I'm still a bit of a python newbie.
>
>
> 


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