Zope & Plone 中的常用表达式 (不断更新中)

属性操作

添加属性到对象:

    格式: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 代码
 
  1. <table border="1" width="100%">  
  2.   <tr>  
  3.     <th>Numberth>  
  4.     <th>Idth>  
  5.     <th>Meta-Typeth>  
  6.     <th>Titleth>  
  7.   tr>  
  8.   <tr tal:repeat="item container/objectValues">  
  9.     <td tal:content="repeat/item/number">#td>  
  10.     <td tal:content="item/getId">Idtd>  
  11.     <td tal:content="item/meta_type">Meta-Typetd>  
  12.     <td tal:content="item/title">Titletd>  
  13.   tr>  
  14. 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>  

 

继续更新中.....
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值