How do I stop acquisition?
Up to Table of ContentsThis FAQ applies to: Any version.
Sometimes, it's helpful to prevent acquisition from looking elsewhere for an attribute when it isn't found on the current object. For example, consider the following:
We have a person object, with an attribute 'job' and a template/view that lists a persons jobs along with other attributes. We have an instance of this object named 'Joe'. His job is 'Dog Catcher'. Joe also has a daughter 'Emily', so we add a person object contained in 'Joe' to represent his child.
Now, in viewing Emily, unless she has a job of her own, when we ask to see her job, acquisition will move upward and use the 'job' attribute from her father. If she's following in her father's footsteps, that might not be such a bad thing, but what if she's only six and doesn't have a job yet? We could make a new template for kids, but that's wasteful. Instead, let's prevent acquisition from looking outside Emily for her job:
<div tal:condition="here/aq_explicit/job|nothing"
tal:content="here/job" id="job listing">[A person's job]</div>
That way, the div never appears if Emily has no job herself. Problem solved. Yay!