[Zope3-Users] zc.table - how does sorting work?

Laurence Rowe l at lrowe.co.uk
Tue Mar 14 11:54:56 EST 2006


Hi there,

I'm trying to use zc.table to format the output of one of my forms. it 
seems to work ok for the unsorted formatter, but not for the 
StandalonSortFormatter. Here is the code that works with plain formatter:

> columns = (
>     GetterColumn(name=u'dn', title=u'Distinguished Name', getter=lambda i, f: i.dn, subsort=True),
>     GetterColumn(name=u'displayName', title=u'Name', getter=lambda i, f: i.displayName, subsort=True),
>     GetterColumn(name=u'mail', title=u'Email Address', getter=lambda i, f: i.mail, subsort=True),
>     )
> 
> class LDAPFilterForm(form.Form):
>     form_fields = form.Fields(interfaces.ILDAPFilter)
> 
>     @form.action("Search")
>     def handle_search_action(self, action, data):
>         search = interfaces.ILDAPSearch(self.context, None)
>         results = search.search(data['filter'])
>         self.table = table.Formatter(self.context, self.request, list(results), columns=columns)
>         return self.table()

but when I change the Formatter to StandaloneSortFormatter, I still get 
the same html output. I have tried adding in this from the zc.table readme:

> for c in columns:
>     directlyProvides(c, zc.table.interfaces.ISortableColumn)
> 
> @adapter(IRequest)
> @implementer(Interface)
> def dummyResource(request):
>     return lambda:'/@@/zc.table'
> 
> provideAdapter(dummyResource, name='zc.table')

But then I get the following traceback:

> 2006-03-14T16:34:32 ERROR SiteError http://localhost:8080/@@/zc.table
> Traceback (most recent call last):
>   File "/usr/lib/python2.4/site-packages/zope/publisher/publish.py", line 135, in publish
>     object = request.traverse(object)
>   File "/usr/lib/python2.4/site-packages/zope/publisher/browser.py", line 500, in traverse
>     ob = super(BrowserRequest, self).traverse(object)
>   File "/usr/lib/python2.4/site-packages/zope/publisher/http.py", line 451, in traverse
>     ob = super(HTTPRequest, self).traverse(object)
>   File "/usr/lib/python2.4/site-packages/zope/publisher/base.py", line 289, in traverse
>     subobject = publication.traverseName(
>   File "/usr/lib/python2.4/site-packages/zope/app/publication/publicationtraverse.py", line 56, in traverseName
>     ob2 = ob.publishTraverse(request, nm)
>   File "/usr/lib/python2.4/site-packages/zope/app/publisher/browser/resources.py", line 40, in publishTraverse
>     locate(resource, sm, name)
>   File "/usr/lib/python2.4/site-packages/zope/app/location/location.py", line 72, in locate
>     object.__name__ = name
> TypeError: func_name must be set to a string object
> exceptions.TypeError:
> func_name must be set to a string object
>> /usr/lib/python2.4/site-packages/zope/app/location/location.py(72)locate()
> -> object.__name__ = name

Using the debugger I can see:

> (Pdb) name
> u'zc.table

Any ideas? I'm stumped.

Laurence



More information about the Zope3-users mailing list