[EMAIL PROTECTED] wrote:

Is all of this already done in some way within Brian's KitViewer code? I'm
sure people must do this all the time. It's just not obvious to me what
the best approach is. Thanks for any hints.


This is easier than it seems. Since you are using KitViewer I'll explain a possible solution that I use:

def lookup(storage, attribute, data):
    view = storage.view(SPECIALVIEWS[attribute])
     # somehow convert view and data into what you want to return

class KitTable:
 def GetValue(self, row, col):
     attribute = self._headers[col] # get the attribute name
     data = self.table[row, col]     # get the data
      if attribute in SPECIAL_COLUMN_NAMES:
         data = lookup(self.table.storage, attribute, data)
      return str(data)

What this does is, when a piece of data is getting retrieved, see if it is a special attribute class. I tend to use attribute XXXX_id to mean look up this id in table XXXX so my lookup function is something like

def lookup(storage, attribute, id):
    view = storage.view(attribute.split("_")[0])
    index = view.find(id=id)
    if index == -1:
       return ""
     return view[index].name

Of course, it is a little more complicated than that since I return different values depending on what the view being retrieved is and for speed issues you should make sure that the view is a hash view or ordered on the 'id' property.

Another complication is how to you set these values inside the grid. I tend to generate a pull down menu from the currently acceptable values in the XXXX table.

I'm writing a next generation KitViewer as we speak with internal support for these operations, but it won't be ready for a while.

--------------------------------------
Gary H. Merrill
Director and Principal Scientist, New Applications
Data Exploration Sciences
GlaxoSmithKline Inc.
(919) 483-8456


Brian


_______________________________________________ metakit mailing list - [EMAIL PROTECTED] http://www.equi4.com/mailman/listinfo/metakit

Reply via email to