Wrap all execution in try-block, don't raise in except block unless
--backtrace is passed to the command line.
Signed-off-by: Jan Lindemann <jan@janware.com>
StringTree.find(key, val) (and Config.find(), for that matter)
returns a list of paths with sections containing children matching
key / val pairs. One of them can be None, which acts as a wildcard.
Signed-off-by: Jan Lindemann <jan@janware.com>
Using cast.from_str('blah') seems more logical than cast.cast_str(),
so add that alias and see how it fares.
Signed-off-by: Jan Lindemann <jan@janware.com>
ArgsContainer provides an interface similar to
argparse.ArgumentParser and can be used as a drop-in replacement when
fishing for arguments.
Signed-off-by: Jan Lindemann <jan@janware.com>
There's an assertion in StringTree.py.__set(), assert self.content !=
str(content), which often triggers. Not sure what the idea behind the
assertion was, disable it.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add database session API to db. This is a breaking change, because
from this commit on, a session object has to be passed to every
query.
This commit also removes any reference to Cmds / App objects. An
instantiated database object can be worked with outside of an App.
Signed-off-by: Jan Lindemann <jan@janware.com>
Support property edit_columns, intended to populate forms where rows
are created or edited, defaulting to log_columns.
Signed-off-by: Jan Lindemann <jan@janware.com>
Add the following methods:
add_child_row_location(self, parent_table: Union[Self, str], **kwargs) -> Optional[str]
add_child_row_location_rules(self) -> Iterable[str]
add_child_row_location_rule(self, child_table: Union[Self, str]) -> Optional[str]
These are meant to be called from different pieces of code:
- add_child_row_location() is meant to be used where the parent is
rendered, to display a link to adding another child
- add_child_row_location_rules() and add_child_row_location_rule()
are meant to be invoked where processing is going to be done, i.e.
likely code rendering child row content
Signed-off-by: Jan Lindemann <jan@janware.com>
Config.branch(path) just silently returns the entire tree if path
doesn't exist in the config. Fix that.
Signed-off-by: Jan Lindemann <jan@janware.com>
refuse_mode_mask can be passed to the constructor and determines
which permission bits need to be absent from config file modes if
they smell like they contain secrets.
Signed-off-by: Jan Lindemann <jan@janware.com>
Make Config's ctor accept strings as values for glob_paths, as
opposed to lists. This covers the canonical case of one configuration
file being passed.
Signed-off-by: Jan Lindemann <jan@janware.com>
The parsed args container is passed to the run() function and friends
for convenient use. Sometimes, though, the base classes or umbrella
commands need to make use of it, too, even more so as they may define
command line arguments via add_arguments(). However, run() or _run()
or whatever is never called on them, neither any other callback, so
make args available to them as a member variable.
Signed-off-by: Jan Lindemann <jan@janware.com>
Initializing Config from a StringTree object doesn't stop it from
looking for config files to read. Stop that.
Signed-off-by: Jan Lindemann <jan@janware.com>