Addind imports to a class namespace
Ryan K
ryankaskel at gmail.com
Sat Jul 11 13:56:48 EDT 2009
Okay so below is the acutal code. I am starting to think there is no
reason why I can't install the post_save signal in signals.py itself
and thereby avoid this issue entirely.
models.py:
class Link(CommonAbstractModel):
...
class Menu(CommonAbstractModel):
....
class StaticPage(CommonAbstractModel):
,,,
class CachedMenuXhtml(CommonAbstractModel):
...
post_save.connect(signals.build_menu, sender=Link)
post_save.connect(signals.build_menu, sender=Menu)
--------------------
# Signlas for caching of menu XHTML
class GenerateMenuXhtml(threading.Thread):
def __init__(self, instance):
from asqcom.apps.staticpages.models import Menu, Link,
CachedMenuXhtml
self.Link = Link
self.Menu = Menu
self.CachedMenuXhtml = CachedMenuXhtml
# Function to run on post_save signal
def build_menu(sender, instance, **kwargs):
GenerateMenuXhtml(instance).start()
More information about the Python-list
mailing list