Category List and speaking URL
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3000 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
ab4442fb03
commit
73042183b3
2 changed files with 10 additions and 1 deletions
|
@ -22,6 +22,8 @@ Layout-based concept views.
|
||||||
$Id$
|
$Id$
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
from zope.traversing.browser import absoluteURL
|
from zope.traversing.browser import absoluteURL
|
||||||
|
@ -45,7 +47,7 @@ class ConceptView(object):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def url(self):
|
def url(self):
|
||||||
return '%s/.%s' % (absoluteURL(self.node, self.request), self.context.uid)
|
return '%s/.%s-%s' % (absoluteURL(self.node, self.request), self.context.uid, normalize(self.context.title))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def children(self):
|
def children(self):
|
||||||
|
@ -54,3 +56,8 @@ class ConceptView(object):
|
||||||
view.node = self.node
|
view.node = self.node
|
||||||
yield view
|
yield view
|
||||||
|
|
||||||
|
|
||||||
|
pattern = re.compile(r'[ /\?\+%]')
|
||||||
|
|
||||||
|
def normalize(text):
|
||||||
|
return pattern.sub('-', text)
|
||||||
|
|
|
@ -40,6 +40,8 @@ class NodeTraverser(ItemTraverser):
|
||||||
def publishTraverse(self, request, name):
|
def publishTraverse(self, request, name):
|
||||||
if name.startswith('.'):
|
if name.startswith('.'):
|
||||||
if len(name) > 1:
|
if len(name) > 1:
|
||||||
|
if '-' in name:
|
||||||
|
name, ignore = name.split('-', 1)
|
||||||
uid = int(name[1:])
|
uid = int(name[1:])
|
||||||
target = util.getObjectForUid(uid)
|
target = util.getObjectForUid(uid)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue