I have a project tefbusiness and two packages in this project: physical and entities.
In physical I have a class PhysObject. In entities I have a class Person.
I would like class Person (entities.Person) to inherit from the class PhysObject (physical.PhysObject).
The steps I take to achieve this:
1. in the tefbusiness::entities diagram I do right-click and select "Create shortcut..."
2. I select tefbusiness -> PyUML -> tefbusiness.uml -> <Model> tefbusiness -> <Package> physical -> <Class> PhysObject
3. I drag Generalization from Person to PhysObject.
4. I click the second PyUML icon (it works now with 1.2.1)
The problem is that tefbusiness/src/entities/Person.py looks like this:
=============================================
class Person(PhysObject):
def __init__(self):
self.firstName = None # created by PyUML
self.lastName = None # created by PyUML
=============================================
Of cource it will not work correctly, because it lacks "from physical import PhysObject".
The preferred code for me would look like this (to prevent namespace pollution):
class Person(physical.PhysObject):
def __init__(self):
self.firstName = None # created by PyUML
self.lastName = None # created by PyUML
=============================================
Do I do something wrong? Is it an expected behaviour? Should I add import lines manually? Should I give up about avoiding namespace pollution?
regards,
Filip Zyzniewski
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
the import generation was removed because Jakob had problems with auto-generation when he already imported classes with another type of statement than PyUML uses.
I added support for that in a new experimental branch:
You can uninstall the feature and install the experimental one to test this.
Please not that PyUML creates only statements of the type "from package import Class" at the moment! To change this (to prevent namespace pollution), help is always welcome!
Please also note that creating generalizations with classes added by "Create shortcut" might not work. In my tests this worked only in one direction. This is a bug in Uml2Tools, not in PyUML, as the generalization was not added to the model by the editor.
The safer way to do cross-package-inheritance is to use views (by the third PyUML button). Here, you can combine classes from different packages in one view and create assiciations between them.
Hope this helped,
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I have a project tefbusiness and two packages in this project: physical and entities.
In physical I have a class PhysObject. In entities I have a class Person.
I would like class Person (entities.Person) to inherit from the class PhysObject (physical.PhysObject).
The steps I take to achieve this:
1. in the tefbusiness::entities diagram I do right-click and select "Create shortcut..."
2. I select tefbusiness -> PyUML -> tefbusiness.uml -> <Model> tefbusiness -> <Package> physical -> <Class> PhysObject
3. I drag Generalization from Person to PhysObject.
4. I click the second PyUML icon (it works now with 1.2.1)
The problem is that tefbusiness/src/entities/Person.py looks like this:
=============================================
class Person(PhysObject):
def __init__(self):
self.firstName = None # created by PyUML
self.lastName = None # created by PyUML
=============================================
Of cource it will not work correctly, because it lacks "from physical import PhysObject".
The preferred code for me would look like this (to prevent namespace pollution):
=============================================
import physical
class Person(physical.PhysObject):
def __init__(self):
self.firstName = None # created by PyUML
self.lastName = None # created by PyUML
=============================================
Do I do something wrong? Is it an expected behaviour? Should I add import lines manually? Should I give up about avoiding namespace pollution?
regards,
Filip Zyzniewski
Hello,
the import generation was removed because Jakob had problems with auto-generation when he already imported classes with another type of statement than PyUML uses.
I added support for that in a new experimental branch:
http://eclipse-pyuml.sourceforge.net/update_site_experimental
You can uninstall the feature and install the experimental one to test this.
Please not that PyUML creates only statements of the type "from package import Class" at the moment! To change this (to prevent namespace pollution), help is always welcome!
Please also note that creating generalizations with classes added by "Create shortcut" might not work. In my tests this worked only in one direction. This is a bug in Uml2Tools, not in PyUML, as the generalization was not added to the model by the editor.
The safer way to do cross-package-inheritance is to use views (by the third PyUML button). Here, you can combine classes from different packages in one view and create assiciations between them.
Hope this helped,
Martin