Hi there,

I saw on stackoverflow that you prefer questions here :)

I need to display a form for a nested table structure. This means that
a record of a table might have a reference to another record of that
table. I have no idea how to model  something like this using DAL and
SQLFORM. I guess it isn't even possible but  you might have another
idea to implementi this.

To illustrate my problem  think about some xml or html structure where
a node of a certain type can contain nodes of other types as well as
nodes of the same type.

<div id='some_div_record'>
    <ul id='root_ul_ref'>
        <li id='first_li_ref'>text</li>
         ...
        <li id='nth_li_ref'>nth text</li>
     <ul>
     <div id='another_div_record'>
         ...
      </div>
</div>

A div block might contain other div blocks. This seems not to be
possible to model using DAL:

db.define_table('div',
    Field('text', type='string'),
    Field('ul', type=db.ul),
    Field('div', db.div))

This attempt results in some KeyError: 'div', probably caused because
db.div is about to defined but referenced before it could be
constructed fully.

The second part of the problem I'm facing might be an even tougher
one. Because I not only need to store references to _one_ another
record of the same table but to a unknown number of such records. (It
is not known how many divs the user choses to nest within...)

I guess this requires another table like db.div_to_div which contains
the references (ids) but then I'm lost on ideas how to connect
implement the view which connects all this and enables the user to
enter his data.

Reply via email to