答复: 答复: [zope-chinese] 怎样取得当前目录 下对象的id?

"Gary Jia" <[email protected]>
Newsgroups gmane.comp.web.zope.chinese,gmane.spam.detected
Message-ID <[email protected]>
File 这样的内容类的id是一个方法不是一个属性
所以你得用id()    最安全的是用  getId()

当然最好你再调用之前做一个判断
因为id 在有的内容类里面会被定义成属性
你可以这样判断,
method = object.id
if callable(method):
    return method()
else:
    return method

-----邮件原件-----
发件人: [email protected]
[mailto:[email protected]] 代表 Who Bruce
发送时间: 2004年9月1日 12:56
收件人: [email protected]
主题: Re: 答复: [zope-chinese] 怎样取得当前目录下对象的id?

Gary Jia:

DTML method的内容
<dtml-var standard_html_header>
<h2><dtml-var title_or_id> <dtml-var document_title></h2> <ul> <dtml-in
ListCurruentDir> <li><a href="&dtml-absolute_url;"><dtml-var
title_or_id></a></li> </dtml-in> </ul> <dtml-var standard_html_footer>

这是script(python)的内容,id是ListCurruentDir:
# Example code:

# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote request =
container.REQUEST RESPONSE =  request.RESPONSE

results=[]
for object in context.objectValues(['File']):
    if object.id.startswith('test'):
        results.append(object)
return results
显示的是当前目录下的全部文件,根本就没有达到

错误信息:
Site Error

An error was encountered while publishing this resource.

Error Type: RuntimeError
Error Value: function attributes not accessible in restricted mode

Troubleshooting Suggestions

    * The URL may be incorrect.
    * The parameters passed to this resource may be incorrect.
    * A resource that this resource relies on may be encountering an error.

For more detailed information about the error, please refer to the error
log.

If the error persists please contact the site maintainer. Thank you for your
patience. 

======= 2004-09-01 11:27:56 Gary Jia wrote: =======

>那是出错了还是怎么了,如果有错误那就把错误信息发过来看看。
>
>-----邮件原件-----
>发件人: [email protected]
>[mailto:[email protected]] 代表 Who Bruce
>发送时间: 2004年9月1日 11:05
>收件人: [email protected]
>主题: [zope-chinese] 怎样取得当前目录下对象的id?
>
>我写了一个script(python),希望返回id以test开头的文件,但好像不起作用,大家
帮
>忙看看,thanks!
>
>results=[]
>for object in context.objectValues('File'):
>    if object.id.startswith('test'):
>        results.append(object)
>return results
>
>_________________________________________________________________
>享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com
>
>_______________________________________________
>zope-chinese list
>[email protected]
>http://zope.cn/mailman/listinfo/zope-chinese
>
>_______________________________________________
>zope-chinese list
>[email protected]
>http://zope.cn/mailman/listinfo/zope-chinese
>

= = = = = = = = = = = = = = = = = = = =
			

        Bruce Who
        [email protected]
          2004-09-01

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  

_______________________________________________
zope-chinese list
[email protected]
http://zope.cn/mailman/listinfo/zope-chinese



_______________________________________________
zope-chinese list
[email protected]
http://zope.cn/mailman/listinfo/zope-chinese
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.