Skip to content

Instantly share code, notes, and snippets.

@jvanasco
Created February 6, 2012 19:09
Show Gist options
  • Save jvanasco/1754135 to your computer and use it in GitHub Desktop.
Save jvanasco/1754135 to your computer and use it in GitHub Desktop.
pyramid - how to automatically map the version of deform's static components that you're using to a subdir (on startup)
def main(global_config, **settings):
...
config.add_subscriber(\
'myApp.subscribers.deform_static_prep',
'pyramid.events.ApplicationCreated')
...
deform.static_subdir = deform
import deform
import os
import myApp
def deform_static_prep(event):
static_subdir= event.app.registry.settings['deform.static_subdir']
deform_dir= os.path.dirname(deform.__file__)
deform_dir_static= os.path.join( deform_dir , 'static' )
app_dir= os.path.dirname( myApp.__file__ )
app_dir_static= os.path.join( app_dir , 'static' )
app_dir_static_deform= os.path.join( app_dir_static , static_subdir )
if os.path.lexists(app_dir_static_deform):
os.unlink(app_dir_static_deform)
os.symlink( deform_dir_static, app_dir_static_deform )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment