属性操作
添加属性到对象:
格式:manage_addProperty(id, value, type, REQUEST=None):
实例:new_id.manage_addProperty(id='alt', value="", type='string')
更改已有的属性值:格式:manage_changeProperties(REQUEST=None, **kw):
实例:new_id.manage_changeProperties(title="thisTitle")
删除已有的属性值:
格式:manage_delProperties(ids=None, REQUEST=None):
对象管理(Manage object)
取得对象的路径:
绝对路径: obj.absolute_url()
相对路径: obj.portal_url
删除对象:
context.manage_delObjects(itemObj.id)
添加第三方产品:
add the third_products:
/* delete obj_id */
context.invokeFactory('Product',obj_id)
/* add obj_id */
productObj = getattr(context,obj_id)
/* set obj_id's properties */
productObj.edit(title = obj_title,
thumbnail = obj_thumbnail,
image = obj_image,
detail = obj_detail)
页面转向:
Page redirect:
ZPT: here.REQUEST.RESPONSE.redirect(here.portal_url()+'/orderForm')
PythonScript: context.REQUEST.RESPONSE.redirect(here.portal_url()+'/orderForm')
权限检查:
Check roles:
tal:condition="python:'Manager' in context.portal_membership.getAuthenticatedMember().getRoles()
File 文件对象Body更新:
/* update_data() ---> manage_update() */ ----- Object ( File )
检查一个产品是否存在:
if context.portal_factory.getFactoryTypes().has_key(type_name)
检查是否有type_name这个产品类别
重复结构:
ZPT 代码
- <table border="1" width="100%">
- <tr>
- <th>Numberth>
- <th>Idth>
- <th>Meta-Typeth>
- <th>Titleth>
- tr>
- <tr tal:repeat="item container/objectValues">
- <td tal:content="repeat/item/number">#td>
- <td tal:content="item/getId">Idtd>
- <td tal:content="item/meta_type">Meta-Typetd>
- <td tal:content="item/title">Titletd>
- tr>
- table>
condition元素的使用:
ZPT 代码
- <p tal:condition="request/cookies/verbose | nothing">
- Here's the extra information you requested.
- p>
- <table tal:condition="container/objectValues"
- border="1" width="100%">
- <tr>
- <th>Numberth>
- <th>Idth>
- <th>Meta-Typeth>
- <th>Titleth>
- tr>
- <tr tal:repeat="item container/objectValues">
- <td tal:content="repeat/item/number">#td>
- <td tal:content="item/getId">Idtd>
- <td tal:content="item/meta_type">Meta-Typetd>
- <td tal:content="item/title">Titletd>
- tr>
- table>
更改属性:
ZPT代码
- <td><img src="/misc_/OFSP/Folder_icon.gif"
- tal:attributes="src item/icon">
- <span tal:replace="item/meta_type">Meta-Typespan>
- td>
继续更新中.....