天道酬勤,学无止境

zope

Setting a variable for a Z SQL method

问题 在 Plone 中,我有一个 Z SQL 方法: SELECT [aapp_qtitle] ,[aapp_mtitle] ,[aapp_sdate] ,[aapp_duration] FROM [AAPP].[dbo].[M_PageBodyElement] where [aapp_id]=<dtml-sqlvar aapp_id type=int> 如何在我的 Plone 页面代码中设置 aapp_id 的值? 好的,谢谢 Matthew 确切的模板代码是什么? 我试过了: <p tal:define="AAPPInfo python:here.get/AAPPInfo(aapp_id=100003).dictionaries()"></p> <p tal:repeat="records context/AAPPInfo"> <span tal:replace="records/aapp_qtitle">Title: </span><br> 但我得到名称“AAPPInfo”未定义错误。 回答1 例如,如果 ZSQL 方法被称为“getAAPPInfo”,您可以像这样从 Python 调用它: AAPPInfo = context.getAAPPInfo(aapp_id=1).dictionaries() if AAPPInfo: print AAPPInfo[0][

2022-04-20 14:08:09    分类:技术分享    sql   plone   zope

Save file to plone site using python

问题 我在 python 中生成一个 xml 文件,我需要将它保存到我的 plone 站点,但不确定如何保存。 def generate_sitemap_index_file(self, sites): """ Generate a google sitemap index file """ root = ET.Element("sitemapindex") for site in sites: sitemap = ET.SubElement(root, "sitemap") loc = ET.SubElement(sitemap, "loc") loc.text = self.aq_parent.absolute_url() + "/googlesitemap/" + site ET.ElementTree(root).write("sitemap_index.xml") 此函数将文件保存到我的zinstance文件夹中,但 zope 不知道它。 回答1 您可以在 Plone 中创建一个名为 File 的内容对象。 请参阅:http://docs.plone.org/external/plone.api/docs/content.html#create-content 这里有一个 untestet 例子给你一个猜测: # -*- coding: utf-8 -*- from

2022-04-20 10:24:03    分类:技术分享    python   plone   zope

Save file to plone site using python

I am generating an xml file in python, I need to save it to my plone site but am unsure how to. def generate_sitemap_index_file(self, sites): """ Generate a google sitemap index file """ root = ET.Element("sitemapindex") for site in sites: sitemap = ET.SubElement(root, "sitemap") loc = ET.SubElement(sitemap, "loc") loc.text = self.aq_parent.absolute_url() + "/googlesitemap/" + site ET.ElementTree(root).write("sitemap_index.xml") This function saves the file into my zinstance folder, but zope isn't aware of it.

2022-04-17 01:39:41    分类:问答    python   plone   zope

Python multithreading

I have this scenario: A web page created with Zope/Plone and some mine python API. There's a web page, call it "a", that by a python method calls a database (Postgres) and returns some information. On page "a" you can modify database data "offline" (I intend that the changes aren't written in the database instantly but in a second moment when you press "save" and call a python API method). So, imagine this scenario: an user, called "Sam", loads the page and start to modify data. Meanwhile an user, called "Sara", modifies the database by the page "a" clicking "save". Now Sam doesn't have the

2022-04-16 08:34:04    分类:问答    python   ajax   multithreading   zope

Zope.Schema/Plone - How can I set the value of a Datetime field in an updateWidget function?

On a plone site I am working on, I have a form that is used to edit records of objects stored mapped to a table in the backend database. In the interface class, one of the fields is a schema.Datetime field. class ICalibration(Interface): """Interface class for calibration records """ ... Last_Calibration = schema.Datetime(title=u"Last Calibration" description=u"date of last calibration", ) ... In my updateWidgets function, in the edit form, I try to set the value of the widget, class EditCalibration(form.Form): grok.name('edit-calibration') grok.require('zope2.View') grok.context(ISiteRoot)

2022-04-05 17:42:56    分类:问答    python   plone   zope

Zope: cannot access REQUEST under property decorator

I'm trying to use the property decorator in a Class. While it works well per se, I can't use any code that has to access the REQUEST. class SomeClass(): #Zope magic code _properties=({'id':'someValue', 'type':'ustring', 'mode':'r'},) def get_someValue(self): return self.REQUEST @property def someValue(self): return self.REQUEST Although calling get_someValue gets me the desired result, trying to access someValue raises an AttributeError. What's the logic behind this behaviour? Is there a way to get around this limitation? (I'm using Zope 2.13.16, Python 2.7.3)

2022-03-26 18:34:20    分类:问答    python   properties   request   zope

Setting a variable for a Z SQL method

In Plone I have a Z SQL methood: SELECT [aapp_qtitle] ,[aapp_mtitle] ,[aapp_sdate] ,[aapp_duration] FROM [AAPP].[dbo].[M_PageBodyElement] where [aapp_id]=<dtml-sqlvar aapp_id type=int> How can I set the value of aapp_id in my Plone page code? OK thanks Matthew what's the exact template code? I've tried: <p tal:define="AAPPInfo python:here.get/AAPPInfo(aapp_id=100003).dictionaries()"></p> <p tal:repeat="records context/AAPPInfo"> <span tal:replace="records/aapp_qtitle">Title: </span><br> But I get name 'AAPPInfo' is not defined error.

2022-03-23 22:10:26    分类:问答    sql   plone   zope

plone 中的文件是否存在与修订数量一样多的副本?(Do as many copies as the number of revisions exist for a file in plone?)

问题 在plone中,如果将文件(或任何内容)修改4次,则存在多少物理副本? 我正在使用 plone 4.1,其中文件和图像存储在文件系统上。 回答1

2022-03-13 20:07:00    分类:技术分享    python   plone   zope