RecordViewBase __add_fields__

5 views
Skip to first unread message

ozwyzard

unread,
May 30, 2011, 4:03:42 PM5/30/11
to sprox
Does sprox support __add_fields__ for RecordViewBase?

class record_view_type(MyRecordViewBase):
__model__ = ResourceNote
__add_fields__ = {'f_Author': None}
__limit_fields__ = ['f_Author', 'Name', 'Summary', 'Text']
__field_order = ['f_Author', 'Name', 'Summary', 'Text']
__headers__ = {'f_Author' : 'Author'}

class record_view_filler_type(MyRecordFiller):
__model__ = ResourceNote
__add_fields__ = {'f_Author': None}
def f_Author(self, obj, **kw):
return pmo.objattr(cls=User, id=obj.Author,
attr='user_name')

With the above code, I verified that f_Author() is indeed invoked and
the value is added to the values dictionary. I also verified that the
self.___widget__ in viewbase.py has the f_Author Widget as a child, as
in Widget('f_Author', children=[], **{}).

But the value for f_Author is *not* getting rendered.

Incidentally, similar functionality for the get_all() data_grid *does*
get rendered.

I have spent many hours digging through this. If anyone has further
pointers, kindly reply.

Thanks!
ozwyzard

percious

unread,
Sep 12, 2011, 10:42:16 PM9/12/11
to sp...@googlegroups.com
I have verified this is an issue and am currently fixing it in the sprox-0.7 branch as this is a new feature and sprox-0.6 is feature complete (bugfix only).

percious

unread,
Sep 12, 2011, 11:31:41 PM9/12/11
to sp...@googlegroups.com
Okay,

So, this actually works in 0.6 and 0.7.  YOu need to provide a widget to render the extra field however.  It should look something like:
from sprox.widgets import RecordFieldWidget

...

            __add_fields__ = {'extra': RecordFieldWidget(field_name='extra')}

So, no need to upgrade.  Let me know if this works.  This should probably have a better API, but it's late.


cheers.
-chris
Reply all
Reply to author
Forward
0 new messages