Forum OpenACS Development: Re: ad_page_contract to be used on includes

Collapse
Posted by Jun Yamog on
Hi,

Actually I wrote the code similar to what you guys are saying.  Then Dave B pointed to me what he was trying to do.  Initially I said wow that will be nice.  I might need that instead of putting on the comments of ad_page_contract how to properly use the included .tcl.

I went into my merry way hoping that someday ad_page_contract will be like that.  Anyway after a while due to extensive use of includes and the forms and lists that I was making, I keep on forgeting what parameters to pass.  So I have to read the comments I put in the child file.  Then I remember what DaveB told me, I asked DaveB about that patch.  I then applied it to my instance.  I then found out that it did not work when the request came from a rp_internal_redirect.  I fixed it a bit, then I ended up with the implementation above, after discussion with DaveB.

What this new behaviour means is that it enforces ad_page_contract on includes too.  Actually the coding style of what Rob said is what I have done initially.  I then told DaveB I don't get it.  It works for me.  Then he explained further, then I realize that DaveB idea of using includes and ad_page_contract is proper.

Should the includes pages blindly process the form vars.  Or should the parent page do it?  What also happens if the parent page process the form var?  I am not sure if its ok to use another construct that functions the same as ad_page_contract.

Just look at this:

parent.adp

<include src="child" foo="bar">

child.tcl

ad_page_contract {} {foo:notnull}

In the current form of ad_page_contract.  It will put an error of two values of foo.  So the work around is either remove foo="bar" or remove foo:notnull.  Which I think both workarounds seems to remove how the include is to be used.  Or the include can't be used as stand alone, no ad_page_contract.

What this patch does is that.  If a child.tcl is included.  You have to follow what is stated in ad_page_contract which is foo:notnull and pass it in the include tag.  Also with the patch its now possible to have the parent code to compute for foo.  Which normally may be just a form var of child.  This way pages that normally process form vars can be included on parent pages and the parent pages can alter and/or produce the vars in ad_page_contract.

ad_page_contract can now enforce passing through form vars or what vars much be present on include tags.  I hope things are more clear.  Hope to get more opinion about this.  Thanks.

Come to think of it I maybe should call set_page_form_data_gathered 1 when processing includes.