1
0
Fork 0

code cleanup for argparse support (addresses #33)

* remove unused code from CliCommand class
 * improve parameter handling in BackendTo constructor
 * return entity in BackendEntityHandler's create method
 * add a default value for country in ClientCli
 * pass dictionary from parsed arguments to ClientHandler's create
   method
 * correctly handle special chars in ClientCli output
This commit is contained in:
Jan Dittberner 2009-08-01 17:10:28 +02:00
parent b8139e91f2
commit 45b2865e8e
4 changed files with 33 additions and 174 deletions

View file

@ -58,6 +58,7 @@ class BackendEntityHandler(object):
sess.rollback()
self.logger.exception("Exception in create.")
raise
return entity
def fetchall(self, **kwargs):
"""Fetches all entities of the managed entity type."""

View file

@ -26,13 +26,14 @@ class BackendTo(object):
"""Backend transfer object class."""
def __init__(self, config, **kwargs):
cols = object_mapper(self).local_table.columns.keys()
for (key, value) in kwargs.items():
self.__setattr__(key, unicode(value, 'utf8'))
if key in cols and value is not None:
self.__setattr__(key, unicode(value, 'utf8'))
def __repr__(self, **kwargs):
if 'verbose' in kwargs and kwargs['verbose']:
cols = [col for col in \
object_mapper(self).local_table.columns.keys()]
cols = object_mapper(self).local_table.columns.keys()
format = "%(class)s:"
format = format + ", ".join([col + "=%(" + col + ")s" for col in \
cols])