Commit b8ccc6c9 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

define __repr__() for MovementGroup class to visualise the structure.

[example]
(Pdb) my_root_group
<RootMovementGroup object at 0xa67a44c
 _group_list = [
   <OrderMovementGroup object at 0xa67af8c
    _group_list = [
      <DateMovementGroup object at 0xa67a0ec
       _group_list = [
         <PathMovementGroup object at 0xa67a64c
          _group_list = [
            <SectionPathMovementGroup object at 0xa67ab2c
             _group_list = [
               <PriceCurrencyMovementGroup object at 0xa67a10c
                _group_list = [
                  <DecisionPathMovementGroup object at 0xa67accc
                   _group_list = [
                     <AdministrationPathMovementGroup object at 0xa67a3cc
                      _group_list = [
                        <ResourceMovementGroup object at 0xa67abcc
                         _group_list = [
                           <BaseVariantMovementGroup object at 0xa67a20c
                            _group_list = [
                              <CausalityAssignmentMovementGroup object at 0xa67acec
                               _group_list = [
                                 <VariantMovementGroup object at 0xa67acac
                                  _group_list = [
                                    <CausalityAssignmentMovementGroup object at 0xa6a830c
                                     _movement_list = [<SimulationMovement at /erp5/portal_simulation/1/1>],
                                     _last_line_class_name = 'AdministrationPathMovementGroup',
                                     _separate_method_name_list = ['calculateAveragePrice', 'calculateAddQuantity'],
                                     _group_list = []>]>]>]>]>]>]>]>]>]>]>]>]>



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21546 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 818e453f
......@@ -208,6 +208,19 @@ class RootMovementGroup:
new_movement.setQuantityMethod("getAddQuantity")
return new_movement, None
def __repr__(self):
repr_str = '<%s object at 0x%x\n' % (self.__class__.__name__, id(self))
if self._movement_list:
repr_str += ' _movement_list = %r,\n' % self._movement_list
if self._group_list:
repr_str += ' _group_list = [\n%s]>' % (
'\n'.join([' %s' % x for x in (',\n'.join([repr(i) for i in self._group_list])).split('\n')]))
else:
repr_str += ' _last_line_class_name = %r,\n' % self._last_line_class_name
repr_str += ' _separate_method_name_list = %r,\n' % self._separate_method_name_list
repr_str += ' _group_list = []>'
return repr_str
allow_class(RootMovementGroup)
class OrderMovementGroup(RootMovementGroup):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment