> > > - it is possible to use model and utility code outside of TG, there are
> > > recipes how to do that.
>
> > > - your can *not* use controllers in a CLI (or at least not useful, and
> > > not without major performance drawbacks). You can't even easily import
> > > from them.
>
> > not import it... so this is a major drawbacks!
>
> Not really. Your controller-classes should be about presentation logic you
> don't need in the CLI.
This is what I've done
I've put the logic into a module named admin.py
admin.py is also used as a CLI.
But each time I use the DBSession within admin.py, I get a :
sqlalchemy.exc.UnboundExecutionError: Could not locate a bind
configured on mapper Mapper|User|tg_user, SQL expression or this
Session
any idea on how I should do this.
I thought about copying how websetup.py works. But websetup gets some
information from paster that I do not know how to reproduce or to
include into paster.
cED
P.S. the full error message is:
(tg2env)briner dhcp]./admin.py --show-dhcp-of-all
Traceback (most recent call last):
File "./admin.py", line 184, in <module>
lusr=User.fetch_list_active()
File "/home/system/briner/ws/frog2_tg2/src/frog/frog/model/auth.py",
line 167, in fetch_list_active
return cls.fetch_list_intern()+cls.fetch_list_extern()
File "/home/system/briner/ws/frog2_tg2/src/frog/frog/model/auth.py",
line 160, in fetch_list_intern
return DBSession.query(cls).filter_by(_in_ldap=True).all()
File "/home/system/briner/ws/tg2env/lib/python2.5/site-packages/
SQLAlchemy-0.5.1-py2.5.egg/sqlalchemy/orm/query.py", line 1131, in all
return list(self)
File "/home/system/briner/ws/tg2env/lib/python2.5/site-packages/
SQLAlchemy-0.5.1-py2.5.egg/sqlalchemy/orm/query.py", line 1225, in
__iter__
return self._execute_and_instances(context)
File "/home/system/briner/ws/tg2env/lib/python2.5/site-packages/
SQLAlchemy-0.5.1-py2.5.egg/sqlalchemy/orm/query.py", line 1228, in
_execute_and_instances
result = self.session.execute(querycontext.statement,
params=self._params, mapper=self._mapper_zero_or_none())
File "/home/system/briner/ws/tg2env/lib/python2.5/site-packages/
SQLAlchemy-0.5.1-py2.5.egg/sqlalchemy/orm/session.py", line 752, in
execute
engine = self.get_bind(mapper, clause=clause, **kw)
File "/home/system/briner/ws/tg2env/lib/python2.5/site-packages/
SQLAlchemy-0.5.1-py2.5.egg/sqlalchemy/orm/session.py", line 893, in
get_bind
', '.join(context)))
sqlalchemy.exc.UnboundExecutionError: Could not locate a bind
configured on mapper Mapper|User|tg_user, SQL expression or this
Session
--
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.