[CHG] make slugify optional by fp request

bzr revid: xmo@openerp.com-20131011075509-q6vzqiyzmfb7tugb
This commit is contained in:
Xavier Morel 2013-10-11 09:55:09 +02:00
parent 672a76a002
commit 11065601c9
1 changed files with 10 additions and 2 deletions

View File

@ -7,17 +7,25 @@ import json
import logging
import os
import datetime
import re
from sys import maxint
import psycopg2
import slugify
import werkzeug
import werkzeug.exceptions
import werkzeug.utils
import werkzeug.wrappers
from PIL import Image
try:
from slugify import slugify
except ImportError:
def slugify(s, max_length=None):
spaceless = re.sub(r'\s+', '-', s)
specialless = re.sub(r'[^-_a-z0-9]', '', spaceless)
return specialless[:max_length]
import openerp
from openerp.addons.website.models import website
from openerp.addons.web import http
@ -53,7 +61,7 @@ class Website(openerp.addons.web.controllers.main.Home):
def pagenew(self, path, noredirect=NOPE):
module = 'website'
# completely arbitrary max_length
idname = slugify.slugify(path, max_length=50)
idname = slugify(path, max_length=50)
request.cr.execute('SAVEPOINT pagenew')
imd = request.registry['ir.model.data']