I have an app that displays a tree of containers. The root container is a
user, and the children of that are containers which have names ad contain
children until we reach the leaves which are entities that actually do
stuff (as jobs submitted to a grid).
At most levels in the tree you have things you can do, like
Add a child
Delete the node you have selected and all its children
Rename the selected Node.
Duplicate a child of your selected node or any of its siblings into your
currently selected node as a child.
When we get to the leaves, well they have a list of templates which you can
use to add to the end of the child list of the node contining the leaf or
insert immediately before the selected workflow node.
For the workflow add/insert, I use a stackpanel of lists of workflow
templates (Alphabetical which includes all, Most frequently used, Useful
for a specific purpose like alignment, etc)
When one selects a node, buttons appear for what you can do for that
particular entity. Yes the treenodes have entity titles, like Projects,
Analysis Runs, Workflows, etc.
OK... I send the tree as a flattened list with (name, (ident, level)) as
the basic list element. From that it is easy to make the tree on the
page.
When a node is clicked, like for project, a butto appears to allow you to
add an analysis run (which is a child of project). The add rotuine is a
simple form with many hidden fields to identify the database entities
actually in play, but locally I generate entity labels and a list of names
which are NOT allowed because they are already in the namespace. THe
namespace is very simple. Analysis Runs are unique withi a Project,
Projects are unique within user spaces... workflows are universally unique,
and so are users.
So validation time for the form...
# this opportunity to perform validation.
self.gx = self.gb.getText()
if (self.gx in self.child_names):
Window.alert("The text name must NOT exist in your namespace")
event.setCancelled(True)
elif (len(self.gx) == 0):
Window.alert("The text boxes must not be empty and")
event.setCancelled(True)
sends nasty alerts if the field is left blank, but identical code in Rename
works fine. The only real difference between Rename and Add, for page
purposes, is that Rename does an item = item.getParent() before doing
[str(el.getHTML()) for el in item.getChildren()]
because Rename must validate that it is not being renamed to any of its
siblings while Add doesn't want to Add a child with the same name as any of
its children)
More than the validate fails. Submit does not seem to Post, yet the code
for each is identical. And Duplicate, which contributed code to each of
thse classes... Well it works as well as any other entity.
I am not getting any error messages, just a silent failure, as if the
button were dead, yet the non-blank part of the validation works well--that
is I get a complaint as I expect when I input a blank field.)
Michael Moore
Any similar experiences /ideas? This is making me crazy!
--