Changeset 1440

Show
Ignore:
Timestamp:
02/22/08 15:02:26 (8 months ago)
Author:
JensDiemer
Message:

A new way to setup contextrobots?
I am not really convinced of it yet.

Location:
trunk/pylucid/PyLucid
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/PyLucid/index.py

    r1429 r1440  
    4545 
    4646 
    47 def _render_cms_page(context, page_content=None): 
     47def _render_cms_page(request, context, page_content=None): 
    4848    """ 
    4949    render the cms page. 
     
    5151    - render a _command request: The page.content is the output from the plugin. 
    5252    """ 
     53    if request.anonymous_view == False: 
     54        # context["robots"] was set in contex_processors.static() 
     55        # Hide the response from search engines 
     56        context["robots"] = "NONE,NOARCHIVE" 
     57 
    5358    current_page = context["PAGE"] 
    5459 
     
    9297    For index() and handle_command() views. 
    9398    """ 
     99    # add additional attribute 
     100    request.anonymous_view = True 
     101 
    94102    try: 
    95103        context = RequestContext(request) 
     
    227235    context = _get_context(request, current_page_obj) 
    228236    # Get the response for the requested cms page: 
    229     response = _render_cms_page(context) 
     237    response = _render_cms_page(request, context) 
    230238 
    231239    if use_cache: 
     
    317325        ) 
    318326 
    319     return _render_cms_page(context, page_content) 
     327    return _render_cms_page(request, context, page_content) 
    320328 
    321329 
  • trunk/pylucid/PyLucid/plugins_internal/auth/auth.py

    r1439 r1440  
    166166                "Warning: DEBUG is ON! Should realy only use for debugging!" 
    167167            ) 
     168 
     169        # This view is available for anonymous users. Only a anonymous user 
     170        # must login ;) 
     171        # But the html line <meta name="robots" content="{{ robots }}" /> 
     172        # should be set to "NONE,NOARCHIVE" 
     173        self.request.anonymous_view = False 
    168174 
    169175        UsernameForm = forms.form_for_model(User, fields=("username",)) 
  • trunk/pylucid/PyLucid/system/context_processors.py

    r1435 r1440  
    1717    http://www.djangoproject.com/documentation/templates_python/#writing-your-own-context-processors 
    1818    """ 
    19     context_extras = {} 
    20  
    21     #___________________________________________________________________________ 
    22  
    23     context_extras['powered_by'] = mark_safe( 
    24         '<a href="http://www.pylucid.org">PyLucid v%s</a>' \ 
     19    return { 
     20        "powered_by": mark_safe( 
     21            '<a href="http://www.pylucid.org">PyLucid v%s</a>' \ 
    2522                                                        % PYLUCID_VERSION_STRING 
    26     ) 
    27  
    28     #___________________________________________________________________________ 
    29  
    30     # The module_manager set "must_login": 
    31     if getattr(request, "must_login", False): 
    32         context_extras["robots"] = "NONE,NOARCHIVE" 
    33     else: 
    34         context_extras["robots"] = "index,follow" 
    35  
    36     #___________________________________________________________________________ 
    37  
    38     return context_extras 
    39  
     23        ), 
     24        # This value would be changed in index._render_cms_page(), if the 
     25        # plugin manager or any plugin set request.anonymous_view = False 
     26        "robots": "index,follow", 
     27    } 
    4028 
    4129 
     
    5341        txt = "%s [%s]" % (_("Log out"), request.user.username) 
    5442    else: 
    55         url = URLs.commandLink("auth", "login/?next=%s" % request.path) 
     43#        url = URLs.commandLink("auth", "login/?next=%s" % request.path) 
     44        url = URLs.commandLink("auth", "login") 
    5645        txt = _("Log in") 
    5746 
    58     context["login_link"] = mark_safe( 
    59         '<a href="%s">%s</a>' % (url, txt) 
    60     ) 
    61      
     47    context["login_link"] = mark_safe('<a href="%s">%s</a>' % (url, txt)) 
     48 
    6249    # Put the language information into the context, if it exists. 
    6350    # see: http://www.djangoproject.com/documentation/i18n/ 
     
    6653    else: 
    6754        context['django_language']='' 
    68  
    6955 
    7056 
  • trunk/pylucid/PyLucid/system/plugin_manager.py

    r1416 r1440  
    131131        # User must be login to use this method 
    132132        # http://www.djangoproject.com/documentation/authentication/ 
    133  
    134         request.must_login = True # For static_tags an the robot tag 
    135  
    136133        if request.user.is_anonymous(): 
    137134            # User is not logged in 
     
    148145            raise AccessDenied 
    149146 
     147    # set if the current request was viewable for anonymous user 
     148    # interesting for: <meta name="robots" content="{{ robots }}" /> 
     149    if request.anonymous_view == True: 
     150        # Only change anonymous_view, if it not set to False in the past. 
     151        if method_cfg["must_login"] or method_cfg["must_admin"]: 
     152            request.anonymous_view = False 
     153 
    150154    URLs = context["URLs"] 
    151155    URLs.current_plugin = plugin_name 
     
    193197    """ 
    194198    output = run(context, response, plugin_name, method_name, url_args) 
     199 
    195200    return output 
    196201