@observe('<STR_LIT>','<STR_LIT>','<STR_LIT>')<EOL><INDENT>def _update_menus(self,change):<DEDENT>
menus = {}<EOL>links = [p.link for p in self.pages if p.link] + self.links <EOL>for link in links:<EOL><INDENT>for menu in link.menus:<EOL><INDENT>if menu not in menus:<EOL><INDENT>menus[menu] = []<EOL><DEDENT>menus[menu].append(link)<EOL><DEDENT><DEDENT>for name,menu in menus.items():<EOL><INDENT>k = '<STR_LIT>'.format(name)<EOL>if hasattr(self,k):<EOL><INDENT>setattr(self,k,menu)<EOL><DEDENT><DEDENT>
When pages change, update the menus