Book a Demo

Author Topic: Python attributes  (Read 5040 times)

abierbaum

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Python attributes
« on: February 06, 2007, 08:49:49 am »
I have been evaluating EA for our company and I am impressed so far but there are some limits with Python that are causing some headaches.

1) Is it possible to have the python code generator (and synch) generate and handle attributes from the model or is this prevented because of the way python handles object attributes (ie. creates them on the fly)?

If so, would it be possible to instead store this information as part of the comment string for the class itself?  For example with a documentation tool like epydoc I commonly create a class header something like this:

Code: [Select]

class MyClass(object):
  """ This class does something.
      @ivar attrib1   This attribute holds data for doing X.
      @ivar attrib2   This is used for another thing.
  """
  def __init__(self):
     self.attrib1 = 10
     ...


Is it possible to get the round-trip code handling to work with something like this?

2) When I reverse engineer a directory of python packages something like this:


module_base
  - package1
     - Class1.py
     - Class2.py
  - package2
     - Class3.py


I use reverse engineering with a package per directory.  The reverse generation picks up all the classes correctly and creates the packages too.  The problem is that the class model diagram for module_base does not contain UML representations for the packages in it's diagram.  Is there something I have to do to get them in there or is the reverse generation failing?

Thanks,
Allen

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: Python attributes
« Reply #1 on: February 06, 2007, 09:20:06 am »
Not many EA Python users - or at least, answers.

Only other similar question was here http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=general;action=display;num=1164131224;start=0#0
which didn't get a conclusive reply. (Maybe Propad now has all the answers !)

Still, Sparx may have done something wonderful since last year ..

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Python attributes
« Reply #2 on: February 06, 2007, 01:41:53 pm »
Well, you could modify the code templates to generate the comment string as you want.

Open the Class Notes template and add a list over all attributes with a custom template.  (eg. %list="Attribute__ClassNote" @separator="\n"%)

Just be aware that if you subsequently reverse engineer this class the comment will then include the attribute notes as well, and the final implication if you generate that out again you get them twice.

You could also modify the Class Body template to generate the body of the automatically generated constructor, or even the Operation Body template to do the same with modelled constructors.

EA doesn't create package diagrams for any supported language.  You can drag and drop them onto a diagram, but that's about it.

Finally, the next major version of EA is expected to have some improvements to the way packages are generated from the model.