ckan / ckanext-pages

A simple builtin CMS for CKAN sites
GNU General Public License v3.0
51 stars 101 forks source link

AttributeError: 'module' object has no attribute 'link_to' #40

Closed jonatan-hoff closed 7 years ago

jonatan-hoff commented 7 years ago

Hello The first time I ran ckan with the plugin enabled the page edit functionality worked fine. When I added my first page the site responds with internal server error on any page containing the navigation menu. The log contained the following error "AttributeError: 'module' object has no attribute 'link_to'". The error occurs in line 45 in the plugin file: "link = h.link_to(page.get('title')". I am running ckan version 2.6.0a. Any idea how to solve this? Thank you

skarampatakis commented 7 years ago

I can confirm that I am having the same issue using 2.7.0a.

CarlQLange commented 7 years ago

here too.

CarlQLange commented 7 years ago

I worked around this by changing the lines that use link_to to just template '<a href="%s">%s</a>' strings instead.

amercader commented 7 years ago

This is likely caused by the loading of the helper module functions dynamically. link_to does essentially what you are doing @CarlQLange so would you mind sending a PR with your fix please? Thanks!

CarlQLange commented 7 years ago

Sure! In the meantime here's the relevant lines (plugin.py, line 45 or so):

        if page['page_type'] == 'blog':
            link = h.literal('<a href="/blog/%s">%s</a>' % (str(page['name']), str(page['title'])))
        else:
            link = h.literal('<a href="/pages/%s">%s</a>' % (str(page['name']), str(page['title'])))
jonatan-hoff commented 7 years ago

This solution solved my problem. Thank you