durusmail: quixote-users: updated qxdemo
updated qxdemo
2004-05-16
updated qxdemo
John Miller
2004-05-16
I'm glad to report that I managed to implement additional functionality
in qxdemo. I'd like to describe some of the design decisions I made to
see if any other alternatives exist that I should consider. You can see
and use the current version here:

http://kawabunga.soe.umich.edu/qxdemo/

I've basically kept the look and feel of the original demo :^) (And
remember that this is a .cgi version.)

The biggest problem I had was resolving the URL path as it went from a
category class to a link class. To do this, I added a second method in
the Category class parallel to 'get_category' called 'get_link'. I then
called this method in the modified '_q_lookup' method in the CategoryUI
class:

'''
def _q_lookup (self, request, component):
     subcat = self.category.get_category(component)
     if subcat is None:
         link = self.category.get_link(component)
         if link is None:
             # No such category or link
             raise errors.TraversalError("No such category or link: %s"
% component)
         c=LinkUI(link)
         return c
     c = CategoryUI(subcat)
     return c
'''

So, if a call to get_category comes back as None, I try calling
get_link and if successful, jump to a small LinkUI class modeled on the
CategoryUI class. All that the LinkUI class does is define the
'editlink' and 'deletelink' methods which instantiate the
'LinkEditForm' and 'LinkDeleteForm' classes modeled on the
'CategoryEditForm' class.

The second major issue was resorting subcategories and links after
editing them. In order to do so I had to change the signature of the
Category class and the Link class to include their enclosing parent. I
need that information to invoke the sorting routine provided, and
didn't know any other way to get it. Is there? In other words, given an
instance of a subcategory, is there any way to know the enclosing
category (as the class was originally written)? Or does it have to be
provided at the point of instantiation, as I've done now?

If anyone wants the source for this, please ask. (Or should I just
attach a .gz to a message to this group?) I also hope these changes
could be incorporated into a .2 release of qxdemo. I've found qxdemo to
be an exceedingly useful introduction to quixote and I feel others
might benefit from an expanded version.

John Miller



reply