Page Object Access

It isa often handy to be able to access the page object for other pages (in my case, so I can build a nav bar). You can't do this easily in standard Albatross, because the Page Objects are stored in the PageObjectMixin in a class-local variable. So I had to wrap page_resgister() in my Application class and duplicate the __page_objects map.

Or we could expose the Page Objects a bit more directly:

--- albatross/app.py.DIST       Sun Jul 13 16:41:28 2003
+++ albatross/app.py    Thu Jul 24 11:04:07 2003
@@ -429,6 +429,12 @@
     def register_page(self, name, obj):
         self.__page_objects[name] = obj
 
+    def page_object(self, name):
+        return self.__page_objects[name]
+
+    def list_pages(self):
+        return self.__page_objects.keys()
+
     def load_page(self, ctx):
         if ctx.locals.__page__:
             name = ctx.locals.__page__

(beware the whitepsace munching!)

None: Page_Object_Access (last edited 2011-02-15 06:05:17 by localhost)