pombreda / django-page-cms

Automatically exported from code.google.com/p/django-page-cms
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

unable to add a page #152

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. make a new database (I'm using an sqlite for testing purpose)
2. make a template to be used for pages
3. put in this template one placeholder and one tag that uses the
   current page, eg: {% show_content current_page "title" %}
4. try to add a new page using the admin interface

What is the expected output? What do you see instead?
Instead of the admin page I obtain:

TemplateSyntaxError at /admin/pages/page/add/

Caught an exception while rendering: Failed lookup for key [current_page]
in ...

I'm using the last version of django-page with django 1.1.

Digging in the pages code I've found the culprit:

def get_placeholders(template_name):
    """Return a list of PlaceholderNode found in the given template"""
    try:
        temp = loader.get_template(template_name)
    except TemplateDoesNotExist:
        return []

    request = get_request_mock()

    try:
        # to avoid circular import
        from pages.views import details
        context = details(request, only_context=True)
    except Http404:
        context = {}
    temp.render(RequestContext(request, context))
    plist, blist = [], []
    placeholders_recursif(temp.nodelist, plist, blist)
    return plist

the default context used if details raised an Http404 lacks a current_page
entry. details raise an Http4040 because there is no pages in the db.

I attach a small patch that works for me, but I don't have a full
comprehension of the pages internals to know if it can works for everyone.

Original issue reported on code.google.com by cinghial...@gmail.com on 21 Aug 2009 at 2:53

Attachments:

GoogleCodeExporter commented 9 years ago
Solved in the last revision

Original comment by batiste....@gmail.com on 23 Aug 2009 at 10:57