[Zope3-Users] zc.table FieldColumn question

2006-11-17 Thread ksmith93940-dev
Does anyone have a simple example of how FieldColumn
is used?

I'm quite sure I'm missing a very serious step here,
but have been unable to figure out how to trigger
the update method. Any help at all would be
appreciated.

I've tried the following, the request values show on
screen but fail to update the object. 


class MovieColumnSubmit(fieldcolumn.SubmitColumn):

def getId(self, item, formatter):

return fieldcolumn.toSafe(item.__name__)

   



class MovieColumn(fieldcolumn.FieldColumn):

def getId(self, item, formatter):

return fieldcolumn.toSafe(item.__name__)





class TableView(BrowserPage):



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)



return htmlhead/headbodyform
action=./@@TableView.html%s/form/body/html
% formatter()  




___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] zc.table FieldColumn question

2006-11-17 Thread ksmith93940-dev
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 htmlhead/headbodyform
action=./@@TableView.html%s/form/body/html
% formatter()  





___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] zc.table FieldColumn question

2006-11-17 Thread Gary Poster


On Nov 17, 2006, at 3:00 PM, [EMAIL PROTECTED] wrote:


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


We have two separate stages (and methods) in our views, update and  
render.  In our views, we *explicitly* call the field columns' input,  
and then call their update during the update stage.  Sometimes we  
only call input/update if some other event happens, like an Apply  
button being clicked on the page.


Then we render.

HTH

Gary
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users