RE: [Zope] Boolean dtml redux
---- "Steve Drees" <drees@the-bridge.net> wrote:
ugh. this looks like a good place for a python script.
I get that a lot. I don't do python yet! I'm trying to work in dtml only, though I know it's getting harder and harder.
if you insist, try this.
<untested>
<dtml-in expr="_[foldername].objectValues()" sort="bobobase_modification_time" reverse> <dtml-unless "_.getitem(_['sequence-item']).index_hide"> blah blah blah </dtml-unless> </dtml-in>
</untested>
Both this and the alternative you sent after generate errors: Traceback (innermost last): File /usr/local/zope/2-3-2/lib/python/ZPublisher/Publish.py, line 223, in publish_module File /usr/local/zope/2-3-2/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/zope/2-3-2/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: Traversable) File /usr/local/zope/2-3-2/lib/python/ZPublisher/Publish.py, line 171, in publish File /usr/local/zope/2-3-2/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: index_html) File /usr/local/zope/2-3-2/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: index_html) File /usr/local/zope/2-3-2/lib/python/OFS/DTMLDocument.py, line 189, in __call__ (Object: index_html) File /usr/local/zope/2-3-2/lib/python/DocumentTemplate/DT_String.py, line 538, in __call__ (Object: index_html) File /usr/local/zope/2-3-2/lib/python/OFS/DTMLMethod.py, line 182, in __call__ (Object: index_outline) File /usr/local/zope/2-3-2/lib/python/DocumentTemplate/DT_String.py, line 538, in __call__ (Object: index_outline) File /usr/local/zope/2-3-2/lib/python/DocumentTemplate/DT_In.py, line 717, in renderwob (Object: _[foldername].objectValues()) File /usr/local/zope/2-3-2/lib/python/DocumentTemplate/DT_Util.py, line 334, in eval (Object: _.getitem(id).index_hide) (Info: id) File <string>, line 0, in ? SystemError: (see above) -Leigh Ann __________________________________________________ FREE voicemail, email, and fax...all in one place. Sign Up Now! http://www.onebox.com
Leigh Ann Hildebrand wrote:
---- "Steve Drees" <drees@the-bridge.net> wrote:
ugh. this looks like a good place for a python script.
I get that a lot. I don't do python yet! I'm trying to work in dtml only, though I know it's getting harder and harder.
look. Get Python Scripts installed. If necessary, get "learning python" (book w/mouse on cover). DTML is *much harder* than python for logic. In that spirit, I give you 7 lines in python that will do what you want: # let's get a list of the objects here. obj_list=context.objectValues() # we'll go through the list by counting # up to its length. for index in range(len(obj_list)): # if we're past the end of the shortened list, we're done. if len(obj_list) >= index: break # let's get it out of it's wrapper only_object = obj_list[index].aq_explicit # delete it if it's hidden if getattr(only_object, 'index_hide', None): del obj_list[index] # give me the list back return obj_list I tested this, it should work. Put it in the root of your zope as a python script called filteredItems and then you can just dtml-in over it like so: <dtml-in filteredItems> <dtml-var sequence-item> </dtml-in> You will like zope much more if you use the twin power of python scripts and page templates, IMNSHO. ~ethan Zopatista Community Liason/Prostelytizer :)
participants (2)
-
ethan mindlace fremen -
Leigh Ann Hildebrand