能够为plone添加路由配置
collective.routes的Python项目详细描述
简介
plone的路由实现。是什么推动了路线的实施 正在查询门户目录。
路线示例:
/posts/{effective:year}/{effective:month}/{effective:day}
添加路线:
from collective.routes import addRoute addRoute('BlogItems', '/posts/{effective:year}/{effective:month}/{effective:day}', defaultQuery={'portal_type': 'News Item'}, allowPartialMatch=True)
启用它
在路由可用之前,您需要首先启用该路由 在你想使用它的网站上。这可以通过 站点设置中的路由配置面板。
现成路线
collective.routes有几个示例路由 它是预先包装的。
博客文章
< DL>
博客文章
/posts/{effective:year}/{effective:month}/{effective:day}
exmaple网址:
/posts/2011 ~ Show all posts from 2011 /posts/2011/10 ~ Show all from 2011 and the month of October /posts/2011/10/5 ~ Show the blog posted October 5, 2011
定义:
addRoute('Blog Posts', '/posts/{effective:year}/{effective:month}/{effective:day}', defaultQuery={'portal_type': 'News Item', 'sort_on': 'effective', 'sort_order': 'reverse'}, allowPartialMatch=True)
标记内容
< DL>示例网址:
/tagged/foo ~ Show all posts tagged `foo` /tagged/foo/bar ~ Show all posts tagged `foo` and `bar` /tagged/foo/bar/woo ~ Show all posts tagged `foo`, `bar` and `woo`
定义:
addRoute('Tagged', '/tagged/{Subject}/{Subject}/{Subject}', defaultQuery={'portal_type': 'News Item', 'sort_on': 'effective', 'sort_order': 'reverse'}, allowPartialMatch=True)
路由语法
语法非常基本,只有一些变化。
文字
文本字符串匹配:
/string-to-match
将匹配"字符串匹配"
查询
匹配任何内容并将其保持为查询参数:
/{Subject}
将匹配任何字符串,然后将该值保留为查询 用于门户目录查询的参数。
日期查询
有三个子指令与零件匹配:
/{effective:year}/{effective:month}/{effective:day}
然后将对门户目录进行查询 使用。
自定义对象检索
如果您希望绕过普通的门户目录查询 要检索对象,可以提供自己的对象 查找方法。
示例:
/posts/{effective:year}/{effective:month}/{effective:day}0
摆弄已发布的对象
如果您想在最后一刻添加接口 在发布遍历之前,这是您要使用的。
这对于添加接口非常有用,因为 已发布的对象被包装,以便维护面包屑 出版时。
示例:
/posts/{effective:year}/{effective:month}/{effective:day}1
自定义呈现的视图
您可以自定义为找到的 对象也:
/posts/{effective:year}/{effective:month}/{effective:day}2
addroute签名
允许参数
< DL>