Changeset 1300

Show
Ignore:
Timestamp:
10/31/07 09:59:38 (2 years ago)
Author:
JensDiemer
Message:

add a permalink redirect

Location:
trunk/pylucid/PyLucid
Files:
3 modified

Legend:

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

    r1298 r1300  
    219219    return response 
    220220 
    221  
    222 def handle_command(request, page_id, module_name, method_name, url_args): 
    223     """ 
    224     handle a _command request 
     221def _get_page(request, page_id): 
     222    """ 
     223    returns the page object. 
     224    TODO: Check int(page_id)! 
    225225    """ 
    226226    setup_debug(request) 
     
    238238            ) 
    239239        ) 
     240    return current_page_obj 
     241 
     242def handle_command(request, page_id, module_name, method_name, url_args): 
     243    """ 
     244    handle a _command request 
     245    """ 
     246    current_page_obj = _get_page(request, page_id) 
    240247 
    241248    context = _get_context(request, current_page_obj) 
     
    302309 
    303310    return HttpResponsePermanentRedirect(url) 
     311 
     312def permalink(request, page_id): 
     313    """ 
     314    redirect to the real page url. 
     315    """ 
     316    current_page_obj = _get_page(request, page_id) 
     317    url = current_page_obj.get_absolute_url() 
     318    return redirect(request, url) 
  • trunk/pylucid/PyLucid/settings_example.py

    r1290 r1300  
    332332# Prefix to the django admin panel 
    333333ADMIN_URL_PREFIX = "_admin" 
     334# the redirect to the real page url 
     335PERMALINK_URL_PREFIX = "_goto" 
    334336 
    335337 
  • trunk/pylucid/PyLucid/urls.py

    r1229 r1300  
    7676    ), 
    7777    #_____________________________________ 
     78    # permalink 
     79    ( 
     80        ( 
     81            '^%s/' 
     82            '(?P<page_id>\d+)/$' 
     83        ) % settings.PERMALINK_URL_PREFIX, 
     84        'PyLucid.index.permalink' 
     85    ), 
     86    #_____________________________________ 
    7887    # CMS PAGE VIEW 
    7988    # A normal CMS page url simply consists of the page shortcuts. 
     
    102111    #-------------------------------------------------------------------------- 
    103112) 
    104  
    105113urlpatterns = patterns('', *urls)