Created
February 6, 2012 19:09
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(global_config, **settings): | |
... | |
config.add_subscriber(\ | |
'myApp.subscribers.deform_static_prep', | |
'pyramid.events.ApplicationCreated') | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deform.static_subdir = deform |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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