Login

Snippets by TheMysteriousX

Snippet List

FirstRun Middleware

Simple piece of middleware that redirects all requests to **settings.FIRSTRUN_APP_PATH**, until a lockfile is created. Tested on 1.3 only, but I do not believe it requires any special functionality beyond that provided in 1.1 This is useful if you need to force a user to run an installer, or do some configuration before your project can function fully. At first glance, such a thing would generate a lot of hits on the disk. However, once the lockfile has been created, the middleware unloads itself, so when a project is in a production environment, the lockfile is only checked once per process invocation (with passenger or mod_wsgi, that's not very often at all). Once your user has completed your FirstRun app, simply create the lockfile and the project will function as normal. For it to function, the following settings must be configured: * **settings.PROJECT_PATH** - absolute path to project on disk (e.g. */var/www/project/*) * **settings.FIRSTRUN_LOCKFILE** - relative path of the lockfile (e.g. */.lockfile*) * **settings.FIRSTRUN_APP_ROOT** - relative URL of the App you want to FirstRun (eg.*/firstrun/*)

  • middleware
  • django
  • redirect
Read More

TheMysteriousX has posted 1 snippet.