Hi, I would like to invoke an operation along the lines of: <dtml-in "dot.kde.org(sort_on='date',sort_order='reverse')" size=40> Unfortunately, Zope doesn't take too kindly to the fact that the Object I'm trying to access has a . in it -- it complains that Object "dot" does not exist. To be sure, my Squishdot instance has been called "dot.kde.org" since the site inception and I've worked around name problems as they presented themselves so far... How can I escape the .'s in "dot.kde.org" so that I can access it as a normal Squishdot object? Thanks! Navin.
On Sunday 09 June 2002 11:53 pm, Navindra Umanee wrote:
Hi,
I would like to invoke an operation along the lines of:
<dtml-in "dot.kde.org(sort_on='date',sort_order='reverse')" size=40>
Unfortunately, Zope doesn't take too kindly to the fact that the Object I'm trying to access has a . in it -- it complains that Object "dot" does not exist. To be sure, my Squishdot instance has been called "dot.kde.org" since the site inception and I've worked around name problems as they presented themselves so far...
How can I escape the .'s in "dot.kde.org" so that I can access it as a normal Squishdot object?
<untested> <dtml-in expr="_['dot.kde.org'](sort_on='date',sort_order='reverse')" size=40> or in script python #id=get_dot o=getattr(context,'dot.kde.org') return o(sort_on='date',sort_order='reverse')[:40] so that in your dtml, you'd do <dtml-in expr="get_dot"> </untested> hope it works so that it can be hth :P
Thanks! Navin.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- http://www.kedai.com.my/ http://www.kedai.com.my/eZine http://www.zope.org/Members/kedai http://www.my-zope.org I will follow you! Damage Inc.
Hi! Bakhtiar A Hamid <kedai@kedai.com.my> wrote:
<untested> <dtml-in expr="_['dot.kde.org'](sort_on='date',sort_order='reverse')" size=40>
This looks like it should work, unfortunately I get an error along the lines of: <strong>Error Type: AttributeError</strong><br> <strong>Error Value: no __call__ method defined</strong><br> File /var/zope/lib/python/DocumentTemplate/DT_Util.py, line 339, in eval (Object: _['dot.kde.org'](sort_on='date',sort_order='reverse')) (Info: _) Any idea why? I'm pretty sure 'Squishdot Site' is callable this way, because I know at least 2 people doing it (but they don't have the . problem). Also, SquishSite subclasses ZCatalog, and SquishSite defines the __call__ method here: # Searchable interface security.declareProtected(View, '__call__') def __call__(self, REQUEST=None, internal=0, **kw): brains = apply(self.searchResults,(REQUEST,),kw) if internal: return map(lambda x: x.getObject(), brains) return brains If you have any thoughts on what may be going wrong, I'd appreciate it. I'll check out the Python code when I get a chance. Thanks, Navin.
On Monday 10 June 2002 01:04 am, Navindra Umanee wrote:
Hi!
Bakhtiar A Hamid <kedai@kedai.com.my> wrote:
<untested> <dtml-in expr="_['dot.kde.org'](sort_on='date',sort_order='reverse')" size=40>
This looks like it should work, unfortunately I get an error along the lines of:
<strong>Error Type: AttributeError</strong><br> <strong>Error Value: no __call__ method defined</strong><br>
i think we need to pass the client, and mapping still untested <dtml-in expr="_['dot.kde.org'](_.None,_)(sort_on='date',sort_order='reverse')" size=40> which is ugly, methinks go with the script python. just a one line change -- http://www.kedai.com.my/ http://www.kedai.com.my/eZine http://www.zope.org/Members/kedai http://www.my-zope.org As you woke this morning, and open up your eyes... did you notice the tear stains lining your face were mine.
Bakhtiar A Hamid <kedai@kedai.com.my> wrote:
i think we need to pass the client, and mapping still untested <dtml-in expr="_['dot.kde.org'](_.None,_)(sort_on='date',sort_order='reverse')" size=40>
which is ugly, methinks
Ugliness has never been a concern! If only I could get it to work... :-) <strong>Error Type: AttributeError</strong><br> <strong>Error Value: no __call__ method defined</strong><br> File /var/zope/lib/python/DocumentTemplate/DT_In.py, line 655, in renderwob (Object: _['dot.kde.org'](_.None,_)(sort_on='date',sort_order='reverse')) File /var/zope/lib/python/DocumentTemplate/DT_Util.py, line 339, in eval (Object: _['dot.kde.org'](_.None,_)(sort_on='date',sort_order='reverse')) (Info: _) File <string>, line 0, in ? AttributeError: (see above)
go with the script python. just a one line change
Hmmm, this doesn't work either. I get a weird unauthorised error, although I tried full access. File /var/zope/lib/python/Products/PythonScripts/Guarded.py, line 273, in __getattr__ File /var/zope/lib/python/Products/PythonScripts/Guarded.py, line 152, in __careful_getattr__ Unauthorized: __getslice__ Thanks, Navin.
On Mon, 2002-06-10 at 10:25, Navindra Umanee wrote:
Bakhtiar A Hamid <kedai@kedai.com.my> wrote:
i think we need to pass the client, and mapping still untested <dtml-in expr="_['dot.kde.org'](_.None,_)(sort_on='date',sort_order='reverse')" size=40>
which is ugly, methinks
Ugliness has never been a concern! If only I could get it to work... :-)
<strong>Error Type: AttributeError</strong><br> <strong>Error Value: no __call__ method defined</strong><br> [snip]
_['foo'] is somewhat magical and tries to call the object named foo. So you are actually calling foo and then the result of foo by writing: _['foo'](_.None, _). Instead use getitem: _.getiem('some.dotted.name')(_.None, _, arg1=bar, arg2=spam, ...) assuming some.dotted.name is a DTML object. It would be slightly less messy to write a python script that did this call for you, but then you would have more objects to take care of... hth, -Casey
Navindra Umanee writes:
I would like to invoke an operation along the lines of:
<dtml-in "dot.kde.org(sort_on='date',sort_order='reverse')" size=40> Try:
<dtml-in "_.getitem('dot.kde.org')(sort_on=...)"> This assumes you have an object with name "dot.kde.org" (apparently a ZCatalog) accessible via your DTML namespace... More information in <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> Dieter
Thanks guys for all the help! The Casey and Dieter solutions both work like they should. Sorry for the spam, Jim. Unfortunately I found out the hard way that this method of using the catalog is *wholly* in appropriate for a site with 21000 comment/articles anyway. The time required is high, as is the memory blow-up. :-) Cheers, Navin.
participants (4)
-
Bakhtiar A Hamid -
Casey Duncan -
Dieter Maurer -
Navindra Umanee