Re: [Zope] tal loop to render table
En/na Dennis Schulz ha escrit: I would like to build a tal loop that renders a list of elements (widgets in my case) in a table. (for example I have a list of 9 items, then it renders a table: five rows with 2,2,2,2,1 items) the table has 2 columns, so i would need to open and close the table row every second item. I tried to check with a condition if the row is odd or even, but unopened and unclosed tags are not valid. Is there any possibiliy to do this with tal? Tricky and not tested from restricted code ... but you're asking for a tal solution: table tal:define=lpython:the_list + [ None ]; rows python:zip(l[0::2], l[1::2]); tr tal:repeat=row rows td tal:repeat=cell row /td /tr /table An example: the_list = [1,2,3,4,5,6,7,8,9] l = the_list + [ None ] zip(l[0::2], l[1::2]) [(1, 2), (3, 4), (5, 6), (7, 8), (9, None)] the_list = [1,2,3,4,5,6,7,8,9,10] l = the_list + [ None ] zip(l[0::2], l[1::2]) [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)] Instead of the tricky use of zip and extended slices write a more generic python script : convert_list_to_array(the_list, column_count=2) HTH ___ 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 )
Re: [Zope] DTML Call Fails
En/na [EMAIL PROTECTED] ha escrit: A little bit of legacy DTML fun here... Zope 2.9.3 On save of a DTML Method, why would this dtml-call fail: dtml-let standards=REQUEST.SESSION dtml-call standards.set('AR-DA-08', AR-DA-08) /dtml-let AR - DA - 08 ^ octal literal HTH ___ 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 )
Re: [Zope] Can't nest dtml-in using prefix ...
En/na Jesper Steen Steffensen ha escrit: This won't work: dtml-in qry_user_roles prefix=outer dtml-in qry_roles dtml-if expr=outer_role==role Roles are matching /dtml-if /dtml-in /dtml-in I get an error that says key error - outer_role doesn't exist. It doesn't matter if I prefix the inner dtml-in as well. (I've read it isn't necessary though) Why won't the prefix work for me? maybe outer_item.role == role ? HTH ___ 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 )
Re: [Zope] Newbie: Missing a Variable (TAL/METAL Question)
En/na beno - ha escrit: Here is the error it throws as reported through the TTW: Site Error An error was encountered while publishing this resource. *KeyError* Sorry, a site error occurred. Traceback (innermost last): number is defined *only* in the block where you define it and enclosed blocks, in the first TD in your case. IIRC TAL provides a way to make a variable global, not sure, never used it. A more structured way would be to wrap all TDs with some block that defines number: div tal:define=number repeat/item/number tal:omit-tag= td tal:content=number/td ... metal:use-macro=here/?number/macros/author ... ... /div HTH ___ 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 )
Re: [Zope] DB in Zope
En/na Alan ha escrit: Hi! I need a very simple DB in Zope, a table with 5 columns, less than 100 entries, to write, read and update, nothing else. Is Gadfly a serious option? Do l loose my database if Zope is restarted? Which other option, easy to use? A tutorial? Take a look at PropertyTools: http://iungo.org/products/PropertyTools HTH ___ 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 )
Re: [Zope] accessing object from a list constructed in __init__.py
En/na kevin7kal ha escrit: Ok, thank you for that. I can create the list of objects from the __of__(self) attribute without the wrapper error now, but I still cannot access that attribute through zope. Here is my code again, along with my zope content. Another thing I've missed, class1 isn't persistent, but you store instances in Zclass2.attribute1a. This can explain the can't pickle error. HTH ___ 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 )
Re: [Zope] accessing object from a list constructed in __init__.py
En/na kevin7kal ha escrit: I've changed my code a bit, adding the docstring, Persistent to all classes and __allow_access_to_unprotected_attributes__ = 1 to all classes. Still, I recieve the same error. Sorry, my fault, should be __allow_access_to_unprotected_subobjects__. If it does work then add the security declarations. HTH ___ 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 )
Re: [Zope] accessing object from a list constructed in __init__.py
En/na kevin7kal ha escrit: I'm doing some work with Five and have an aquisition related issue. first, zope is zope 2.9.3 The trouble is with accessing the attributes of objects stored in the number property in class2. class2 must inherit from ExtensionClass.Base (or some subclass, like Acquisition.Explicit) in order to be acquisition aware. HTH ___ 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 )
Re: [Zope] accessing object from a list constructed in __init__.py
En/na kevin7kal ha escrit: Ok, thank you for that. I can create the list of objects from the __of__(self) attribute without the wrapper error now, but I still cannot access that attribute through zope. Your description is vague. A traceback could be useful. Maybe the problem is security related. Not sure, I'm still not acquainted with zope + new style classes + five. To test it add: __allow_access_to_unprotected_attributes__ = 1 to class1, class2 and Zclass2 definitions. OTOH Zclass2.myZclass() lacks a docstring Some unrelated notes: Zclass2.__init__ shouldn't return anything SimpleItem inherits from Acquisition.Implicit, and class2 inherits from Acquisition.Explicit. Making Zclass2 inherit from Acquisition.Explicit is both redundant and useless. HTH ___ 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 )
Re: [Zope] ZWiki with Zope 2.7, OS X Server 10.4.x
En/na baiewola ha escrit: I didn't find anything on zwiki.org about this issue, and I tried Googling with no success. If you have experienced this issue, would you please tell me how you fixed it? http://zwiki.org/1269AddingA054ZwikiThroughTheZMIFailsBecauseOfACaseMismatch HTH ___ 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 )
Re: [Zope] Is it possible to render a TAL expression from a Page Template?
En/na [EMAIL PROTECTED] ha escrit: Suppose I have a variable foo that has value request/name|nothing. Is it possible from a Python Script to have this evaluated as a TAL expression? AFAIK TALES machinery ($ZOPE_HOME/lib/python/Products/PageTemplates) can't be accessed from restricted code. Maybe ZTUtils, PythonScript.standard or other module expose it in some way, I don't know. Alternatives? * External method: from Products.PageTemplates.Expressions import getEngine def evalTAL(talstr, **kw) : engine = getEngine() comp = engine.compile(talstr) return engine.getContext(**kw).evaluate(comp) then, from a PythonScript do: result = context.evalTAL(request/name|nothing, here=context, request=REQUEST) * Create a PageTemplate named evalTAL with a body like: foo tal:replace=python:path(options['param'])/foo then, from a PythonScript do: result = context.evalTAL(param=request/name|nothing) result will always be an string. Not a serious alternative, just a creative way. HTH ___ 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 )
Re: [Zope] DELETE Objects
Erik Billing escribió: Ok. Thanx. But why is it like this? I imagine that deleting an object in a folder where I do not have permission to delete every object, or the folder itself, is a quite common task. Using the manage_delObjects and a proxy really feels like I'm fighting the zope security instead of getting support by it. Proxy roles are provided/supported by zope security machinery, where's the fight? Or am I thinking wrong in the first place? What I really want to do is letting users answer a question object and the answers should be stored somewhere. A user must later be able to change or remove his answer, but of course not the answers of any other user. I place all answers objects belonging to a certain question in one folder, and I have the previously mentioned situation. The only problem with proxy role (AFAICS) is users being able to delete answers from other users. In your current design the script with proxy role could (should) check if the current user is allowed to delete an answer (looking at some attribute). I don't see a big problem. I know it is not that much of a problem to use a proxy, but if I can change my design in some way so can avoid the proxy I imagine that would be better. Well, store all answers from a user in the same folder. Sl. ___ 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 )
Re: [Zope] import error
David Bear wrote: Will attempting to import a zexp file (and exported plone site) I get the following error: result=apply(object,args) # Type scr to step into published object. File /home/webenv/zope/lib/python/OFS/ObjectManager.py, line 532, in manage_importObject raise BadRequest, 'Invalid file name %s' % escape(file) BadRequest: Invalid file name InfoTechnical.zexp Acording to ObjectManager source this exception is raised because you're suplying a path with a directory component (some/dir/InfoTechnical.zexp) def manage_importObject(self, file, REQUEST=None, set_owner=1): Import an object from a file dirname, file=os.path.split(file) if dirname: raise BadRequestException, 'Invalid file name %s' % escape(file) HTH -- (@ @) oOO(_)OOo-- Ojo por ojo y el mundo acabara ciego /\ Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain) --- ___ 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 )
Re: [Zope] Sharing global data between threads / locking a method
Jonathan wrote: A possible solution: create a property field on the folder where the external methods are stored. Have your external method update this property field when the external method starts and again when it exits. This way you can test whether or not the external method is currently in operation. You could store this property field on a temp_folder for faster performance. Not sure if this will work. If I understand correctly how does Zope/ZODB transaction machinery works, if you set a property on some persistent object the change will be visible only after the transaction has been commited, wich usually happens at the end of the request, so other threads/requests will always get a long_process_finished value for the property. Regarding Max M question, a simple solution could be to use a file (filesystem, not zope) as lock. HTH -- (@ @) oOO(_)OOo-- Ojo por ojo y el mundo acabara ciego /\ Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain) --- ___ 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 )
Re: [Zope-dev] Re: [Zope-Checkins] CVS: Products/PluginIndexes/common- UnIndex.py:1.20.2.7
Chris Withers wrote: Tres Seaver wrote: +if set is None: +set = IISet(()) +elif type(set) is IntType: # isinstance(set, int) for 2.8 How come isinstance is only to be used for 2.8? Hi, when I wrote the patch and the test case I tried to be consistent with the actual code. On 2.7 the check was done with type() while on 2.8 with isinstance(), so I added a comment. Probably I should have stated this in the collector entry. Regards -- (@ @) oOO(_)OOo-- Ojo por ojo y el mundo acabara ciego /\ Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain) --- ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )