Changeset 616:1ecc55248c5a


Ignore:
Timestamp:
11/06/12 14:42:30 (11 months ago)
Author:
Santiago Piccinini (SAn) <spiccinini@…>
Branch:
default
rebase_source:
a4c148b18540592b04653e81e01c2a9562560a5e
Message:

Some cleaned-up to settings.py

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cyclope/middleware.py

    r373 r584  
    2424 
    2525import cyclope 
     26import cyclope.settings # Leave this here 
    2627 
    2728class LayoutMiddleware(object): 
     
    3738                request.session['layout'] = layout 
    3839                request.session['layout_template'] = layout.get_template_path() 
    39                  
     40 
    4041            else: 
    4142                if request.session.has_key('layout'): 
     
    4950                request.session['layout_template'] = cyclope.settings.CYCLOPE_DEFAULT_TEMPLATE 
    5051 
    51                  
     52 
  • cyclope/settings.py

    r615 r616  
    4848""" 
    4949 
    50 import sys, os 
     50import os 
     51import sys 
    5152 
    5253from django.conf import settings 
     
    111112CYCLOPE_PROJECT_NAME = os.path.basename(CYCLOPE_PROJECT_PATH) 
    112113 
     114CYCLOPE_BASE_CONTENT_TYPES = site.base_content_types 
     115 
    113116import themes 
    114117 
     
    131134    return site_settings 
    132135 
    133 CYCLOPE_BASE_CONTENT_TYPES = site.base_content_types 
    134  
    135 CYCLOPE_SITE_SETTINGS = get_site_settings() 
    136  
    137 # If the site has already been set up we read some settings 
    138 # and make them available at module level 
    139 if CYCLOPE_SITE_SETTINGS is not None: 
    140     CYCLOPE_BASE_URL = "http://"+ CYCLOPE_SITE_SETTINGS.site.domain 
     136def populate_from_site_settings(site_settings): 
     137    # Read some settings and make them available at module level 
     138    CYCLOPE_SITE_SETTINGS = site_settings 
     139    CYCLOPE_BASE_URL = "http://" + CYCLOPE_SITE_SETTINGS.site.domain # FIXME: could be https 
    141140    CYCLOPE_CURRENT_THEME = CYCLOPE_SITE_SETTINGS.theme 
    142141    if CYCLOPE_CURRENT_THEME in themes.get_local_themes(): 
     
    159158                CYCLOPE_DEFAULT_LAYOUT.template) 
    160159 
    161         #TODO(nicoechaniz): fix this workaround. It's here for migrations on the Layout model, which fail to complete with a DatabaseError when this module is imported. Eg: cyclope/migrations/0011... 
     160        # TODO(nicoechaniz): fix this workaround. It's here for migrations on the 
     161        # Layout model, which fail to complete with a DatabaseError when this 
     162        # module is imported. Eg: cyclope/migrations/0011... 
    162163        except DatabaseError: 
    163164            pass 
     165 
     166    # Update the settings module with the settings 
     167    for name, value in locals().copy().iteritems(): 
     168        if name.startswith("CYCLOPE"): 
     169            globals()[name] = value 
     170 
     171CYCLOPE_SITE_SETTINGS = get_site_settings() 
     172populate_from_site_settings(CYCLOPE_SITE_SETTINGS) 
    164173 
    165174def _refresh_site_settings(sender, instance, created, **kwargs): 
Note: See TracChangeset for help on using the changeset viewer.