blooparksystems / website

Odoo Website builder related addons
GNU Affero General Public License v3.0
10 stars 33 forks source link

501 error when changing the seo_url of blog.blog model to have a url /blog #38

Closed jholze closed 8 years ago

jholze commented 8 years ago

steps to reproduce

Traceback (most recent call last):
  File "/opt/odoo/addons/website/models/ir_http.py", line 242, in _handle_exception
    response = super(ir_http, self)._handle_exception(exception)
  File "/opt/odoo/openerp/addons/base/ir/ir_http.py", line 147, in _handle_exception
    return request._handle_exception(exception)
  File "/opt/odoo/openerp/http.py", line 737, in _handle_exception
    return super(HttpRequest, self)._handle_exception(exception)
  File "/opt/odoo/openerp/addons/base/ir/ir_http.py", line 172, in _dispatch
    result = request.dispatch()
  File "/opt/odoo/openerp/http.py", line 768, in dispatch
    r = self._call_function(**self.params)
  File "/opt/odoo/openerp/http.py", line 315, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/openerp/http.py", line 311, in checked_call
    result.flatten()
  File "/opt/odoo/openerp/http.py", line 1367, in flatten
    self.response.append(self.render())
  File "/opt/odoo/openerp/http.py", line 1360, in render
    context=request.context)
  File "/opt/odoo/openerp/api.py", line 223, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/addons_bloopark/website_seo/models/ir_ui_view.py", line 179, in render
    engine=engine, context=context)
  File "/opt/odoo/openerp/api.py", line 223, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/addons/website/models/ir_ui_view.py", line 143, in render
    return super(view, self).render(cr, uid, id_or_xml_id, values=values, engine=engine, context=context)
  File "/opt/odoo/openerp/api.py", line 223, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/addons/web_editor/models/ir_ui_view.py", line 29, in render
    return super(view, self).render(cr, uid, id_or_xml_id, values=values, engine=engine, context=context)
  File "/opt/odoo/openerp/api.py", line 223, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/addons/base/ir/ir_ui_view.py", line 1065, in render
    return self.pool[engine].render(cr, uid, id_or_xml_id, qcontext, loader=loader, context=context)
  File "/opt/odoo/openerp/api.py", line 223, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 253, in render
    return self.render_node(element, qwebcontext, generated_attributes=qwebcontext.pop('generated_attributes', ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 296, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 319, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 294, in render_node
    result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 458, in render_tag_call
    res = self.render(cr, uid, template, d)
  File "/opt/odoo/openerp/api.py", line 223, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 253, in render
    return self.render_node(element, qwebcontext, generated_attributes=qwebcontext.pop('generated_attributes', ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 296, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 319, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 296, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 319, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 296, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 319, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 296, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 319, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 296, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 319, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 296, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 319, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 296, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 319, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 296, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 319, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 294, in render_node
    result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 434, in render_tag_if
    return self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 319, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 294, in render_node
    result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 425, in render_tag_foreach
    ru.append(self.render_element(element, template_attributes, generated_attributes, copy_qwebcontext))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 319, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 281, in render_node
    self, element, attribute_name, attribute_value, qwebcontext)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 360, in render_att_att
    return [(attribute_name[6:], self.eval(attribute_value, qwebcontext))]
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 194, in eval
    raise_qweb_exception(message="Could not evaluate expression %r" % expr, expression=expr, template=template)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 191, in eval
    return qwebcontext.safe_eval(expr)
  File "/opt/odoo/openerp/addons/base/ir/ir_qweb.py", line 104, in safe_eval
    return eval(expr, None, locals_dict, nocopy=True, locals_builtins=True)
  File "/opt/odoo/openerp/tools/safe_eval.py", line 298, in safe_eval
    return eval(c, globals_dict, locals_dict)
  File "", line 1, in <module>
  File "/opt/odoo/addons_bloopark/website_seo/models/ir_ui_view.py", line 46, in url_for
    location = url_for_lang(location, lang)
  File "/opt/odoo/addons_bloopark/website_seo_blog/models/ir_ui_view.py", line 38, in url_for_lang
    blog_url = url_parts.pop(0)
QWebException: "pop from empty list" while evaluating
"url_for(request.httprequest.path + '?' + keep_query(), lang=lg[0])"
kaerdsar commented 8 years ago

What URL did you try to set?

jholze commented 8 years ago

i was not done ;) - i tried the /blog because it is the best url you can have (from seo perspective), but i think the issue is the structure of the blog model, because it is possible to have different blogs like blog, news or another. The odoo normal behavior is like /blog/blog-1 and if we have second blog with different posts like /blog/news-1 for example.

kaerdsar commented 8 years ago

I was working wit this issues. I'm not so sure about the structure. We were set SEO URL for blog in the way: (1) /[blog-seo-url] instead of (2) /blog/[blog-seo-url]

I understand by your comments that we prefer the second option. If you have only one blog probably is better to use /blog directly, otherwise if you have more than one blog it would be useful to have url like /blog/news and /blog/more. Also in issue #14 @fczaja proposed to use /[blog-seo-url]/[tag-seo-url] for tags instead of /[blog-seo-url]/tag/[tag-seo-url].

What do you think?

jholze commented 8 years ago

@kaerdsar i will discuss it with @rruebner on monday. He is one day off and i think he is still sleeping :)

jholze commented 8 years ago

@rruebner @kaerdsar in the case we have two or more blog what it the problem to have urls like /blog/ and slash /news/ together ?

rruebner commented 8 years ago

@jholze There is no problem with this case. If this issue is solved we can use /blog and /news for two blog.blog.

kaerdsar commented 8 years ago

The url '/blog' is already used in Odoo. If we use it for a blog then overwrite the view 'website_blog.latest_blogs' where you have a view of all post per blogs. I think we must ensure the url 'blog' can't be used in the seo_url via a validation.

rruebner commented 8 years ago

@jholze Is the solution that we exclude "blog" as possible SEO url fine for you?

@kaerdsar Opening "/blog" doesn't throw the error. Still to do:

jholze commented 8 years ago

@kaerdsar After a short meeting with robert we decided the following

  1. the way odoo implements the blog is not so bad, because /blog is the main page and the blog.blog is something like a topic inside the blog eg. /tech-news & /marketing-news
  2. so like robert wrote, we need some kind of validation if the user entered /blog in the SEO field.
  3. we need to update how odoo generates the url's for the blog.blog

An example

current state

if you have two blog.blog like /news & /seo-news the urls of the blog posts are like /blog/news/post/the-future-of-emails-1 - and same for the other blog.blog but the url should be like /blog/the-future-of-emails.

new state

if someone entered a blog.blog page like /blog/news he will see all related blog posts which are given for this blog.blog item but if he clicks on a blog post, the url should not have the blog.blog SEO url value within the url.

We also need to update the way we have implemented the url handling for the blog.blog. the current way is like /news & /seo-news but should be like the odoo way /blog/news /blog/seo-news like a subcategory.

kaerdsar commented 8 years ago

Added modifications to update blog seo urls. Still missing javascript validations. We didn't talk about tags, for tags I used this url: /blog//.

The pull requested is updated with the new commits.