>
> For the Wiki Tutorial, In the show(): controller in default.py there
> is the following statement:
>
> db.comment.page_id.default = this_page.id
>
> I can't quite figure out what it means. Are we setting the default
> value of the page_id field for the comment table to be 'this_page.id"?
> However, in this case, this_page is being fetched from the database,
> so potentially this default value could change everytime the show()
> controller is called. This defeats the point of defining a default
> value.
>
Actually, that's exactly the idea. The default will be different for each 
unique page. That way, when someone submits a comment on a given page, the 
page_id will automatically be the id of the page being viewed. There's no 
reason the default value specified for a field has to be universally 
constant across all requests. The default value can be changed 
programmatically at any time. In fact, it can even be a lambda function 
that calculates a new value for each insert.

Anthony
 

Reply via email to