如何从REPL中呈现Zope DTML

2024-04-26 21:02:50 发布

您现在位置:Python中文网/ 问答频道 /正文

如何从REPL-say中呈现zopedtml而不使用Folder对象或类似的测试用例?你知道吗

我有一个名为/tmp的文件/tmp.dtml格式包括以下内容:

<dtml-var test>

我可以走这么远:

from AccessControl import ImplC as impl
from App.special_dtml import DTMLFile

#globals has test variable define if that helps?
dtml_page = DTMLFile('/tmp/tmp',globals())
dtml_page() give "None\n"

如何将正确的命名空间注入DTMLFile对象或在调用过程中注入?你知道吗


Tags: 文件对象fromtestimportpage测试用例folder
1条回答
网友
1楼 · 发布于 2024-04-26 21:02:50

这似乎管用。不过,我想在没有文件夹的情况下模拟一下。你知道吗

class Test(Folder):
    test = "World"
    dtml = DTMLFile('/tmp/tmp')
dtmlobj = Test()
dtmlobj.dtml()

从文件夹继承的类在这里似乎很重要,原因不太清楚?你知道吗

我不明白为什么测试。测试从要呈现的文件夹继承测试的位置。这是某种Zope大会吗?你知道吗

我试过了

dtml = DTMLFile('/tmp/tmp') 
setattr(dtml,'test','foo') 
dtml.render()

我认为这是关于“自我”有正确的变量,但显然不是。你知道吗

相关问题 更多 >