Author: justi9
Date: 2007-10-10 14:12:30 -0400 (Wed, 10 Oct 2007)
New Revision: 999
Modified:
mgmt/cumin/python/wooly/__init__.py
mgmt/cumin/python/wooly/forms.py
mgmt/cumin/python/wooly/widgets.py
Log:
Cleans up state handling. Makes some more ui state
session-persistent, so that for instance the tab you navigated from is
still visible when you return.
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2007-10-10 17:04:51 UTC (rev 998)
+++ mgmt/cumin/python/wooly/__init__.py 2007-10-10 18:12:30 UTC (rev 999)
@@ -86,11 +86,11 @@
if str:
return str
- def scope(self, session, params):
- params.update(self.parameters)
+ def save_parameters(self, session):
+ session.save_parameters(self.parameters)
for child in self.children:
- child.scope(session, params)
+ child.save_parameters(session)
def process(self, session, object):
if session.debug:
@@ -180,6 +180,10 @@
if self.object:
return self.object.get(session)
+ def save_parameters(self, session):
+ if self.get_object(session) != None:
+ super(Frame, self).save_parameters(session)
+
def do_process(self, session, object):
new_object = self.get_object(session)
super(Frame, self).do_process(session, new_object)
@@ -343,6 +347,7 @@
self.values = dict()
self.errors = dict() # widget => list of str
self.redirect = None
+ self.saved_parameters = list()
self.debug = True
@@ -410,6 +415,9 @@
def set_redirect(self, redirect):
self.redirect = redirect
+ def save_parameters(self, params):
+ self.saved_parameters += params
+
def marshal(self):
return self.marshal_page() + "?" + self.marshal_url_vars()
@@ -417,11 +425,11 @@
return self.get_page().name
def marshal_url_vars(self, separator=";"):
- params = set()
- self.get_page().scope(self, params)
+ self.get_page().save_parameters(self)
+
vars = list()
- for param in params:
+ for param in self.saved_parameters:
key = param.path()
value = self.get(key)
default = param.get_default(self)
@@ -451,6 +459,8 @@
self.set_page(self.app.get_page(string))
def unmarshal_url_vars(self, string, separator=";"):
+ self.get_page().save_parameters(self)
+
vars = string.split(separator)
for var in vars:
Modified: mgmt/cumin/python/wooly/forms.py
===================================================================
--- mgmt/cumin/python/wooly/forms.py 2007-10-10 17:04:51 UTC (rev 998)
+++ mgmt/cumin/python/wooly/forms.py 2007-10-10 18:12:30 UTC (rev 999)
@@ -17,8 +17,9 @@
def render_hidden_inputs(self, session, object):
writer = Writer()
- params = set()
- session.get_page().scope(session, params)
+ session.get_page().save_parameters(session)
+
+ params = set(session.saved_parameters)
params.difference_update(self.form_params)
for param in params:
Modified: mgmt/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/cumin/python/wooly/widgets.py 2007-10-10 17:04:51 UTC (rev 998)
+++ mgmt/cumin/python/wooly/widgets.py 2007-10-10 18:12:30 UTC (rev 999)
@@ -28,14 +28,6 @@
return mode
- def scope(self, session, params):
- params.update(self.parameters)
-
- mode = self.get_selected_mode(session)
-
- if mode:
- mode.scope(session, params)
-
def do_process(self, session, object):
mode = self.get_selected_mode(session)
Show replies by date