django - Reloading python module in all threads -


I wrote some material management mechanism on Django. Users can create pages with different URLs. Page for the route, I'm default Django URL router mechanics:

  pages = CMSHelpers () includes get_available_pages () urlpatterns = patterns ( 'url (r' ^ $ ' ('App.home.site.urls', namespace = 'homepage')), URL (r 'search /', include ('app search search.', Namespace = 'search')), url (r '^ include Ajax /', the page in the pages ( 'app.ajax.site.urls', namespace = 'ajax')),) + stable (settings.MEDIA_URL, DOCUMENT_ROOT = settings.MEDIA_ROOT): if Page.module .slug: try: urlpatterns + = pattern ('', url ('^% s /'% page.url.strip ('/'), included ('App.% S.site.urls'% page.module slug, name space = page.module.slug + '-' + page.module_params), kwargs = {'page_data': pages})) logging.debug ("Imported module% s for url% s"% (page.url.bar ('/', page.module.slug)) except importError: logging.debug ("urls.py import for module% s Can not be done "% page.module.slug) Continue to the second: include urlpatterns + = pattern ('', url (r '^ captcha /', ''),)   

Problem:

When the DJXO app is being started, Python cache gets all URL patterns and when user CMS The page changes the URL, so I Uarelpetran but only'm reload the current Uvssii process / thread :

  urlconf = settings.SUBDOMAIN_URLCONFS [ " www "] clear_url_caches () reload (sys.modules [urlconf]) reload = import_module (urlconf) If hasattr (reload, 'urlpatterns'): reloaded_urls = getattr (reload, 'urlpatterns') set_urlconf (tuple (reloaded_urls ))  

Then the user gets this random 404 error when he tries to use this page on the site.

So, how can I reload the module for all USB processes / threads?

Given that the web app generally uses "nothing shared" architecture Are there any kind of data store really exhaustive on external requests? An external data archive can have an updated timestamp, which compares each of its working threads / process timestamps and decides to reload the module.

But, a good way to do this is to make a callple URL pattern for pages like r '^ (? P & lt; url & gt; *) / $' To include and route it to a single handler which should look at the specific page handler and what it says.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -