On Feb 8, 9:16 pm, Vladimir Dronnikov <[email protected]> wrote:
> Hi!
>
> Wonder how pylons people deal with the subj.
>
> Suppose entity A has OneToMany relation to entity B. What is the best
> practice to represent the relation in show/edit templates?
> Of particular interest are perspectives *to reuse* B show/edit
> template in div/iframe of A show/edit template. Are there chances to
> work out sufficiently generic template to show any entity?
>
> --
> Vladimir
Hi Vlad.
While I'm probably the least experienced person on this list, in my
apps I tend to create generic CRUD (Create Read Update Delete)
functionality.
That is, I create a controller plus templates that given any model
class/object, will introspect it (or will get the columns and their
corresponding types from an appropriate description/annotation) and
create a form for each of C,R,U,D (actually one with different actions
available)
In the case of relations I tend to allow many-to-one relations to be
edited in the many end (i.e. the model class where the foreign key is
stored).
Given A(id, fk_b_id), B(id), with A.b holding a reference to a B
object via the A.fk_b_id foreign key ('many' end of relationship), and
B.list_of_a holding a list of references to objects of A (the 'one'
end of relationship), I tend to put a combobox in the form for A,
allowing it to select one of the available B objects. I also tend not
to put some kind of multiple select list in the form for editing B
since many of my users may not know how to select multiple entries in
such a control (by holding Ctrl down).
This setup is similar, but much less generic, to the CatWalk app which
featured in Turbogears.
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.