plone

How to set TAL condition to check the file type and accordingly render the template in Plone 4.1

懵懂的女人 提交于 2019-12-11 09:42:25
问题 How to use the tal condition to check the file type and render the template in Plone 4.1 My file preview template rendering depends upon the file extension. If file extension is 'pdf', I wish to use something like this:(just started working with TAL, TALES, METAL) <tal:define="file_nm global string:${here/absolute_url}" <tal:condition="file_nm.slice[-3:] = 'pdf'"> <embed width="100%" height="100%" name="plug-in" tal:attributes="src string:${here/absolute_url}#" draggable="false" onselectstart

Save file to plone site using python

天大地大妈咪最大 提交于 2019-12-11 09:38:03
问题 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

quickinstaller.installProduct 'installs' stuff that doesn't even exist. How do I raise an exception?

半城伤御伤魂 提交于 2019-12-11 09:06:39
问题 I have a config.py in my product, having: DEPENDENCIES = ['bbbbbbbbbbbb'] #This doesn't exist And in my setuphandlers.py : for dependency in DEPENDENCIES: if not quickinstaller.isProductInstalled(dependency): quickinstaller.installProduct(dependency) And now I have a bbbbbbbbbbbb entry in my portal_quickinstaller's Contents tab. (http://localhost:8080/Plone/portal_quickinstaller/manage_main). What should I do to make the dependencies section 'complain' (raise an exception, whatever) if the

customise site search so a parent type is returned based on it's children's content

心不动则不痛 提交于 2019-12-11 08:25:36
问题 I have a dexterity content type which is folderish and I would like to have it show up in search results based on it's child's content (pdfs etc). Is this possible, where and how would this be achieved? 回答1: One possible solution is to reindex the searchableText of the children on the parent and not on the item itself (concatenate the searchableText of all children). Your new searchableText Index could look like this: @indexer(IYourContainerType) def SearchableText(obj): searchable_text = obj

plone.memoize cache depending on function's return value

☆樱花仙子☆ 提交于 2019-12-11 08:05:42
问题 i'm trying to cache the return value of a function only in case it's not None. in the following example, it makes sense to cache the result of someFunction in case it managed to obtain data from some-url for an hour. if the data could not be obtained, it does not make sense to cache the result for an hour (or more), but probably for 5 minutes (so the server for some-domain.com has some time to recover) def _cachekey(method, self, lang): return (lang, time.time() // (60 * 60)) @ram.cache(

How to inject template code in Plone?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 07:54:12
问题 My goal is to inject some HTML-Code in front of every Plone article (between the page's header and the first paragraph)? I'm running Plone 4. Does anyone have a hint on how to realize that? The other question is: is it possible to place some HTML code randomly in every Plone article? 回答1: Use viewlets for both usecases. A viewlet can be inserted in different parts of the rendered page, depending on both the viewlet manager you register it to and and what interfaces the viewlet applies to. The

buildout can't find pip packages for Plone

喜夏-厌秋 提交于 2019-12-11 06:24:19
问题 I'm trying to add add-ons to Plone through buildout but it can't find the packages. I've tried it in a virtualenv andd the system wide python I followed the set up on the Plone site Setup instructions Every add-on I try brings up the following error Installing instance. /home/a/Plone/zinstance/local/lib/python2.7/site-packages/pkg_resources/__init__.py:192: RuntimeWarning: You have iterated over the result of pkg_resources.parse_version. This is a legacy behavior which is inconsistent with

My Archetypes-based content type can't be viewed

可紊 提交于 2019-12-11 06:09:13
问题 I have a little Plone extension which contains a simple Archetypes-based content type (the same which I had not been able to add TTW, see my previous question); the project setup is on GitHub. After adding an object, I get a KeyError: 'view' during execution of the plone.abovecontenttitle content provider: {'container': <MyType at /plone/test-for-new-types/a-mytype-object>, 'context': <MyType at /plone/test-for-new-types/a-mytype-object>, 'default': <object object at 0x7fc4f8ebe520>, 'here':

How can I hook a transformation in the transformation chain?

孤人 提交于 2019-12-11 05:40:58
问题 As far as I understand it, a transformation chain is filled with transforms after calculating the shortest path between original and target mimetypes (see convertTo() and _findPath() in Products.PortalTransforms.TransformEngine ). How can I hook a transformation in the transformation chain. Are there maybe other means to hook a transformation? If yes are there some example or documentation? 来源: https://stackoverflow.com/questions/24222774/how-can-i-hook-a-transformation-in-the-transformation

Plone - Cannot untick “Inherit permissions from higher levels”

∥☆過路亽.° 提交于 2019-12-11 05:15:02
问题 On the sharing tab of any Folder or File, I can untick "Inherit permissions from higher levels", but when I click save, it does not stick. I do not want my SalesGroup to have access to or even see the name of my ManagementFolder. Plone 4.3.1 running on Windows. I have tried logging into Plone as admin & a folder owner. I have also tried from multiple browsers. 来源: https://stackoverflow.com/questions/18604039/plone-cannot-untick-inherit-permissions-from-higher-levels