On Feb 1, 11:17 pm, Robin B <robi...@gmail.com> wrote:
> On Feb 1, 4:37 pm, BearXu <bearx...@gmail.com> wrote:
> > 3)In Django table can be inherited like:
> > class *Place*(models.Model):
> >     name = models.CharField(max_length=50)
> > class Restaurant(*Place*):---------------------> Can it be done in DAL?
> >     serves_hot_dogs = models.BooleanField()
> >     serves_pizza = models.BooleanField()
> web2py has a way to do table inheritance.

For this simple example of extending a base set of fields & adding
extras, yes it can be done as follows:
timestamp=SQLTable(None,'timestamp',
            SQLField('created_on','datetime',
                          readable=False,
                          writable=False,
                          default=request.now),
            SQLField('modified_on','datetime',
                          readable=False,
                          writable=False,
                          default=request.now,update=request.now))

db.define_table('mytable',timestamp,
                SQLField('my_extra_field'))

However this doesn't provide the ability to do a search of all sub-
tables without a JOIN as-per Single-Table Inheritance:
http://groups.google.com/group/web2py/browse_thread/thread/d9715e7b751c1e56/eb4533ebc0d683bf

I have no idea whether the Django version allows that or not...

F
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to