Hi,

I updated my system to turbogears 1.0.4b2 with SQLAlchemy 0.4. I now
see sometimes an InvalidRequestError when running a DB query.

This happens on my own project (with mysql) and a quickstarted project
(with sqlite). Below is a small piece of code on a quickstarted
project that generates the error for me (i've seen the problem also
outside of a scheduler job and with other tables than the Visit table
but this way it seems easyest to reproduce).

any ideas on how to debug this?

regards

Stefan


The traceback:
ERROR DURING TASK EXECUTION Could not locate any Engine or Connection
bound to mapper 'Mapper|Visit|visit'
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/TurboGears-1.0.4b2-py2.5.egg/
turbogears/scheduler.py", line 337, in threadedcall
    self.execute()
  File "/usr/lib/python2.5/site-packages/TurboGears-1.0.4b2-py2.5.egg/
turbogears/scheduler.py", line 218, in execute
    self.action(*self.args, **self.kw)
  File "/home/saes/work/temp/testproject/testproject/controllers.py",
line 20, in some_test
    for v in session.query(Visit).filter(Visit.c.expiry >
datetime.now()):
  File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.4.0-py2.5.egg/
sqlalchemy/orm/query.py", line 619, in __iter__
    return self._execute_and_instances(context)
  File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.4.0-py2.5.egg/
sqlalchemy/orm/query.py", line 622, in _execute_and_instances
    result = self.session.execute(querycontext.statement,
params=self._params, mapper=self.mapper)
  File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.4.0-py2.5.egg/
sqlalchemy/orm/session.py", line 525, in execute
    engine = self.get_bind(mapper, clause=clause)
  File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.4.0-py2.5.egg/
sqlalchemy/orm/session.py", line 641, in get_bind
    raise exceptions.InvalidRequestError("Could not locate any Engine
or Connection bound to mapper '%s'" % str(mapper))
InvalidRequestError: Could not locate any Engine or Connection bound
to mapper 'Mapper|Visit|visit'


I tested with the following modification to a project started with tg-
admin -i -s testproject:

created the DB with tg-admin sql create
added to the RootController (plus necessary imports):
    def __init__(self):
        import turbogears.scheduler
        turbogears.scheduler.add_interval_task(action=self.some_test,
taskname='do_something', initialdelay=0, interval=10)

        controllers.RootController.__init__(self)

    def some_test(self):
        from datetime import datetime
        for v in session.query(Visit).filter(Visit.c.expiry >
datetime.now()):
            print str(v)

> tg-admin info
TurboGears Complete Version Information

TurboGears requires:

* TurboGears 1.0.4b2
* SQLAlchemy 0.4.0
* TurboKid 1.0.3
* TurboJson 1.1.1
* TurboCheetah 0.9.5
* simplejson 1.7.1
* setuptools 0.6c6
* RuleDispatch 0.5a0.dev-r2306
* PasteScript 1.3.4
* FormEncode 0.7.1
* DecoratorTools 1.4
* configobj 4.4.0
* CherryPy 2.2.1
* Cheetah 2.0rc8
* kid 0.9.6
* RuleDispatch 0.5a0.dev-r2306
* Cheetah 2.0rc8
* PyProtocols 1.0a0dev-r2302
* PasteDeploy 1.3
* Paste 1.3
* DecoratorTools 1.4

Toolbox Gadgets

* info (TurboGears 1.0.4b2)
* catwalk (TurboGears 1.0.4b2)
* shell (TurboGears 1.0.4b2)
* designer (TurboGears 1.0.4b2)
* widgets (TurboGears 1.0.4b2)
* admi18n (TurboGears 1.0.4b2)

Identity Providers

* sqlobject (TurboGears 1.0.4b2)
* sqlalchemy (TurboGears 1.0.4b2)

tg-admin Commands

* info (TurboGears 1.0.4b2)
* shell (TurboGears 1.0.4b2)
* quickstart (TurboGears 1.0.4b2)
* update (TurboGears 1.0.4b2)
* sql (TurboGears 1.0.4b2)
* i18n (TurboGears 1.0.4b2)
* toolbox (TurboGears 1.0.4b2)

Visit Managers

* sqlobject (TurboGears 1.0.4b2)
* sqlalchemy (TurboGears 1.0.4b2)

Template Engines

* cheetah (TurboCheetah 0.9.5)
* genshi-markup (Genshi 0.4)
* genshi-text (Genshi 0.4)
* genshi (Genshi 0.4)
* kid (TurboKid 1.0.3)
* json (TurboJson 1.1.1)

Widget Packages


TurboGears Extensions

* visit (TurboGears 1.0.4b2)
* identity (TurboGears 1.0.4b2)

> uname -a
Linux saes-laptop 2.6.20-16-386 #2 Sun Sep 23 19:47:10 UTC 2007 i686
GNU/Linux

(Kubuntu)


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