Show
Ignore:
Timestamp:
07/03/09 09:34:57 (13 months ago)
Author:
JensDiemer
Message:

* add PyLucid objects via middleware. So it's exist everywhere.
* add a "robots" field in PageMeta? for {{ page_robots }}
* add "urls_filename" in PluginPage?: It's for admin views.
* setup lang_entry direct in PyLucid objects.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/0.9/pylucid_project/apps/pylucid/system/pylucid_objects.py

    r2037 r2071  
    1919""" 
    2020 
     21from django.conf import settings 
     22 
    2123from pylucid.models import Language 
    2224from pylucid.system import extrahead 
    2325from pylucid.preference_forms import SystemPreferencesForm 
    2426 
     27 
    2528class PyLucidRequestObjects(object): 
    2629    """ PyLucid request objects """ 
    27     def __init__(self): 
     30    def __init__(self, request): 
    2831        self.system_preferences = SystemPreferencesForm().get_preferences() 
    2932        default_lang_code = self.system_preferences["lang_code"] 
    3033        self.default_lang_code = default_lang_code 
    3134        self.default_lang_entry = Language.objects.get(code=default_lang_code) 
    32          
     35 
     36        # The current language instance 
     37        try: 
     38            self.lang_entry = Language.objects.get(code=request.LANGUAGE_CODE) 
     39        except Language.DoesNotExist: 
     40            self.lang_entry = self.default_lang_entry 
     41            if settings.PYLUCID.I18N_DEBUG: 
     42                request.page_msg.error( 
     43                    'Favored language "%s" does not exist -> use default lang from system preferences' % ( 
     44                        request.LANGUAGE_CODE 
     45                    ) 
     46                ) 
     47 
    3348        # Storing extra html head code from plugins, used in: 
    3449        # pylucid.defaulttags.extraheadBlock - redirect {% extrahead %} block tag content 
    3550        # pylucid_plugin.extrahead.context_middleware - insert the data into the global page 
    3651        self.extrahead = extrahead.ExtraHead() 
    37          
     52 
    3853        # objects witch will be set later: 
    3954        #self.pagetree - The current PageTree model instance 
    4055        #self.pagemeta - The current PageMeta model instance 
    4156        #self.pagecontent - PageContent instance, but only if the current page is not a PagePlugin! 
    42         #self.lang_entry - The current language instance 
    4357        #self.page_template - The globale page template as a string 
    4458        #self.context - The globale context