ZPT and attributes
Hi all: How I can create attribute names dynamically? For example, I want something like this: <books ref1="http://boo" ref2="http://foo" ...> Where ref1 and ref2, are created by the url list. I have done in DTML because I cannot with ZPT. Thanks...
On Apr 8, 2005 4:51 PM, Antonio Beamud Montero <antonio.beamud@linkend.net> wrote:
Hi all: How I can create attribute names dynamically?
tal:attributes="attributename expression" For example, I want something like this: <books tal:attributes="ref1 string:http://boo"; ref2 request/URL3" /> And so on. -- Lennart Regebro, Nuxeo http://www.nuxeo.com/ CPS Content Management http://www.cps-project.org/
El vie, 08-04-2005 a las 16:55 +0200, Lennart Regebro escribió:
On Apr 8, 2005 4:51 PM, Antonio Beamud Montero <antonio.beamud@linkend.net> wrote:
Hi all: How I can create attribute names dynamically?
tal:attributes="attributename expression"
Sorry, I haven't explain the problem correctly :) The problem is the number of "refX" depends on the list of urls, i.e. if I have ['http://foo', 'http://boo', 'http://google.com'] then I create: <books ref1='http://foo' ref2='http://boo' ref3='http://google.com'> but with ['http://foo'] I create: <books ref1='http://foo'> How I create refX? Greetings.
For example, I want something like this: <books tal:attributes="ref1 string:http://boo"; ref2 request/URL3" />
And so on.
On Apr 8, 2005 5:00 PM, Antonio Beamud Montero
The problem is the number of "refX" depends on the list of urls, i.e. if I have ['http://foo', 'http://boo', 'http://google.com'] then I create:
<books ref1='http://foo' ref2='http://boo' ref3='http://google.com'>
but with ['http://foo'] I create:
<books ref1='http://foo'>
Ah.
How I create refX?
I have no idea if that's even possible. -- Lennart Regebro, Nuxeo http://www.nuxeo.com/ CPS Content Management http://www.cps-project.org/
Hi Antonio,
Hi all: How I can create attribute names dynamically?
tal:attributes="attributename expression"
Sorry, I haven't explain the problem correctly :) The problem is the number of "refX" depends on the list of urls, i.e. if I have ['http://foo', 'http://boo', 'http://google.com'] then I create:
<books ref1='http://foo' ref2='http://boo' ref3='http://google.com'>
but with ['http://foo'] I create:
<books ref1='http://foo'>
How I create refX?
Greetings.
For example, I want something like this: <books tal:attributes="ref1 string:http://boo"; ref2 request/URL3" />
And so on. I think you are using zpt for the wrong thing. For me it seems that what you should use would be a xml product like ParsedXML. I haven't used it, but I have taken a look at the source code of Silva and saw that it may be possible to create dynamic attributes with a "setAttribute" or some thing like that.
Regards, Josef
Antonio Beamud Montero wrote:
How I can create attribute names dynamically? For example, I want something like this: <books ref1="http://boo" ref2="http://foo" ...>
Where ref1 and ref2, are created by the url list. I have done in DTML because I cannot with ZPT.
The easiest way is probably to create the tag in something else (e.g. a Python script) and then just insert it into your output at the relevant point: <books tal:replace="structure here/generateBooksTag" /> A better solution would be to avoid doing this in the first place.
Hi, I have been working through programatically adding and modifying my workflows. I managed to get my workflow factories installed and then used the manage_addWorkflow to obtain the desired workflow with the appropriate id. Where I am having trouble is changing my default workflow to my new workflow. In the ZMI this would be through the Workflow by Type (the first screen you come into when choosing the portal_workflow tool) once you had built one. For images, if I look at the source for images is 'chain_image' which is set to (Default). I am thinking it is the props should perhaps be a different type but I can't find anything googling that suggest that it is anything but a string. Should it a tuple? The method is manage_changeWorkflows(self, default_chain, props=None, Request=None) This is what I am doing to try and use it: workflow_tool = getToolByName(self, 'portal_workflow') # Modify workflow chain (Workflow by type) workflow_tool.manage_changeWorkflows(default_chain='chain_image', props='image_workflow', REQUEST=None) Here is the traceback: File "/usr/local/zope/instance1/Products/CMFCore/WorkflowTool.py", line 175, in manage_changeWorkflows chain = props.get(field_name, '(Default)').strip() AttributeError: 'str' object has no attribute 'get' It is probably something simple, hope someone can help me with where I am going wrong. Many thanks. Regards, David
I am getting closer: # Modify workflow chain (Workflow by type) workflow_tool.manage_changeWorkflows(default_chain='default_workflow', props=({'name':'chain_Image','value':'image_workflow'}), REQUEST=None) No errors now, but it sets all to Default instead of just the Image.... It seems I am not passing the correct properties. I am getting name and value from the html source of the form. Anyone know what these need to be? David On Saturday, April 9, 2005, at 12:41 PM, David Pratt wrote:
Hi, I have been working through programatically adding and modifying my workflows. I managed to get my workflow factories installed and then used the manage_addWorkflow to obtain the desired workflow with the appropriate id. Where I am having trouble is changing my default workflow to my new workflow. In the ZMI this would be through the Workflow by Type (the first screen you come into when choosing the portal_workflow tool) once you had built one. For images, if I look at the source for images is 'chain_image' which is set to (Default). I am thinking it is the props should perhaps be a different type but I can't find anything googling that suggest that it is anything but a string. Should it a tuple?
The method is manage_changeWorkflows(self, default_chain, props=None, Request=None)
This is what I am doing to try and use it:
workflow_tool = getToolByName(self, 'portal_workflow')
# Modify workflow chain (Workflow by type) workflow_tool.manage_changeWorkflows(default_chain='chain_image', props='image_workflow', REQUEST=None)
Here is the traceback:
File "/usr/local/zope/instance1/Products/CMFCore/WorkflowTool.py", line 175, in manage_changeWorkflows chain = props.get(field_name, '(Default)').strip()
AttributeError: 'str' object has no attribute 'get'
It is probably something simple, hope someone can help me with where I am going wrong. Many thanks.
Regards, David _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Solved this after trying more things. Here is what I used: # Modify workflow chain (Workflow by type) workflow_tool.manage_changeWorkflows(default_chain='default_workflow', props=({'chain_Image':'image_workflow','chain_Folder':'', 'chain_Topic':''}), REQUEST=None) Regards, David On Saturday, April 9, 2005, at 02:41 PM, David Pratt wrote:
I am getting closer:
# Modify workflow chain (Workflow by type)
workflow_tool.manage_changeWorkflows(default_chain='default_workflow',
props=({'name':'chain_Image','value':'image_workflow'}),
REQUEST=None)
No errors now, but it sets all to Default instead of just the Image.... It seems I am not passing the correct properties. I am getting name and value from the html source of the form. Anyone know what these need to be?
David
On Saturday, April 9, 2005, at 12:41 PM, David Pratt wrote:
Hi, I have been working through programatically adding and modifying my workflows. I managed to get my workflow factories installed and then used the manage_addWorkflow to obtain the desired workflow with the appropriate id. Where I am having trouble is changing my default workflow to my new workflow. In the ZMI this would be through the Workflow by Type (the first screen you come into when choosing the portal_workflow tool) once you had built one. For images, if I look at the source for images is 'chain_image' which is set to (Default). I am thinking it is the props should perhaps be a different type but I can't find anything googling that suggest that it is anything but a string. Should it a tuple?
The method is manage_changeWorkflows(self, default_chain, props=None, Request=None)
This is what I am doing to try and use it:
workflow_tool = getToolByName(self, 'portal_workflow')
# Modify workflow chain (Workflow by type) workflow_tool.manage_changeWorkflows(default_chain='chain_image', props='image_workflow', REQUEST=None)
Here is the traceback:
File "/usr/local/zope/instance1/Products/CMFCore/WorkflowTool.py", line 175, in manage_changeWorkflows chain = props.get(field_name, '(Default)').strip()
AttributeError: 'str' object has no attribute 'get'
It is probably something simple, hope someone can help me with where I am going wrong. Many thanks.
Regards, David _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (5)
-
Antonio Beamud Montero -
David Pratt -
Duncan Booth -
Josef Meile -
Lennart Regebro