Hi,
But what about a more efficient tree implementation (at least for retrieving
) like nested sets or materialized paths.
PhpDoctrine has an implementation
http://www.doctrine-project.org/documentation/manual/1_1/en/hierarchical-data#nested-set
<http://www.doctrine-project.org/documentation/manual/1_1/en/hierarchical-data#nested-set>This
was why I used doctrine in a few projects.
Even for implementing by myself I don't know how to do that, is there a
method to extend default table behavior, are there some events like
before_insert, or something like that? (sorry if it is a basic question, I
am still new to web2py, but was interested by this question)

On Thu, Oct 15, 2009 at 1:05 AM, Yarko Tymciurak <[email protected]> wrote:

> On Wed, Oct 14, 2009 at 4:44 PM, Giedrius <[email protected]> wrote:
>
>>
>> How i can make recursive one to many relation? I want to have
>> generalized categories like: Programing langauge / High level /
>> Python, Programing langauge / Low level / C, Programing langauge /
>> High level / PHP, Programing langauge / Low level / ASM and so on..
>> I tried to like this, but got an error:
>>
>> db.define_table('category',
>>                Field('name'),
>>                Field('parent_id', db.category),
>>                Field('info'))
>>
>
> To do self-reference or forward reference, use this form:
>
>                  Field('parent_id', 'reference category'),
>
>
> You can find more about this in section 6.13 of the Manual, "Self-Reference
> and Aliases"
> ( http://www.web2py.com/examples/default/docs )
>
> - Yarko
>
>
>>
>>
>> Traceback (most recent call last):
>>  File "/home/giedrius/web2py/gluon/restricted.py", line 178, in
>> restricted
>>    exec ccode in environment
>>  File "/home/giedrius/web2py/applications/shop/models/db.py", line
>> 74, in <module>
>>    Field('parent_id', db.category),
>>  File "/home/giedrius/web2py/gluon/sql.py", line 537, in __getattr__
>>    return dict.__getitem__(self,key)
>> KeyError: 'category'
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to