Hi there,
I would like to reuse my model in a non-TG python application - to keep me DRY.
i don't think anything will stop you
Is there an _expression_ I can evaluate in model.py to determine if I'm
running inside CherryPy/TurboGears or not?
well yes you could check the modules that are loaded for example locals() should be diferent.
Something like:
from sqlalchemy import *
if runningingcherrypy:
from turbogears import identity
from turbogears.database import PackageEngine
engine = __engine__ = PackageEngine("softproof")
__meta__ = BoundMetaData(__engine__)
.. classes dealing with TG identiti etc ...
else:
__meta__ = Metadata()
.. classes to use in both TG and other app...
why not do it the other way around?
if someVariableYouControl:
... non tg code
else
... turbogears stuff
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

