[Zope3-Users] zc.table FieldColumn question

ksmith93940-dev at yahoo.com ksmith93940-dev at yahoo.com
Fri Nov 17 15:00:46 EST 2006


Ok, so the following "works", but if someone with more
knowledge could comment on this I'd appreciate it.


class MovieColumnSubmit(fieldcolumn.SubmitColumn):

    def getId(self, item, formatter):

        return fieldcolumn.toSafe(item.__name__)

    

    def update(self, items, data, formatter):

        pass

        

class MovieColumn(fieldcolumn.FieldColumn):

    def getId(self, item, formatter):



        return fieldcolumn.toSafe(item.__name__)

    

    def update(self, items, data, formatter):

        changed = False

        for item in items:

            id = self.getId(item, formatter)

            v = data.get(id, self)

            if v is not self and self.get(item,
formatter) != v:

                self.set(item, v, formatter)

                changed = True

        if changed:

            self.setAnnotation('changed', changed,
formatter)

        return changed

        

class TableView(BrowserPage):

    """ Browser Page """

    

    columns = (

       MovieColumn( IMovieTime['brief']),

      MovieColumn( IMovieTime['times']),

      MovieColumnSubmit("apply", "MYFORM"),

               )

  

    def __call__(self):

        items = [value for name, value in
self.context.items()]

        formatter = table.Formatter(

                self.context, self.request, items,
('brief', 'times', 'MYFORM'),

                columns=self.columns,
prefix="tableview")

        columns = self.columns

        for index, value in enumerate(columns):

            data = columns[index].input(items,
formatter)

            columns[index].update(items, data,
formatter)

        

        return """<html><head></head><body><form
action="./@@TableView.html">%s</form></body></html>"""
% formatter()  







More information about the Zope3-users mailing list