Bug 322467 - Python Code imports self parameter in operation
Summary: Python Code imports self parameter in operation
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: 2.10.2
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-17 08:13 UTC by g2spot
Modified: 2014-06-18 07:18 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.13.3
Sentry Crash Report:


Attachments
ignore all 'self' parameters during import (931 bytes, patch)
2014-04-23 20:05 UTC, Erik Rakhorst
Details

Note You need to log in before you can comment on or make changes to this bug.
Description g2spot 2013-07-17 08:13:33 UTC
While importing python code, umbrello imports also the 'self' parameter of each operation. On generation however, it creates one automatically. So if I import python code, then generate it, I suddenly have two 'self' parameters.
I see two solutions:
- do not import the 'self' parameter
- have an option to generate the 'self' parameter automatically

Reproducible: Always

Steps to Reproduce:
1. import python code including some operations (with the 'self' paramter)
2. generate code from the imported design
3. check generated files to see double 'self' parameter in operations
Actual Results:  
'self' parameter is present two times in generated code

Expected Results:  
Either way do not import 'self' parameter or do not generate it automatically every time
Comment 1 Erik Rakhorst 2014-04-23 20:05:15 UTC
Created attachment 86235 [details]
ignore all 'self' parameters during import

This will fix the dual self parameters after an import and export of python code.
Comment 2 Oliver Kellogg 2014-05-29 12:22:09 UTC
Git commit b68bd35c944d3abee7a5f5d1c982f1cd144e765a by Oliver Kellogg.
Committed on 29/05/2014 at 12:22.
Pushed by okellogg into branch 'master'.

Apply modified version of https://bugs.kde.org/attachment.cgi?id=86235

umbrello/codeimport/pythonimport.h
- Add member m_isStatic of type bool defaulting to false.

umbrello/codeimport/pythonimport.cpp function parseStmt()
- Decode "@staticmethod" to set m_isStatic true.
- In handling of keyword "def",
  - If first parameter is not named "self" then set m_isStatic true and add
    the parameter via Import_Utils::addMethodParameter(); else do not add
    the parameter.
  - At call to Import_Utils::insertMethod(), provide m_isStatic as argument
    `isStatic'.
  - Reset m_isStatic false after call to Import_Utils::insertMethod().

M  +20   -2    umbrello/codeimport/pythonimport.cpp
M  +1    -0    umbrello/codeimport/pythonimport.h

http://commits.kde.org/umbrello/b68bd35c944d3abee7a5f5d1c982f1cd144e765a
Comment 3 Oliver Kellogg 2014-06-16 19:42:13 UTC
Git commit de77ff0c13706fd2784e11a721be96dd97747f98 by Oliver Kellogg.
Committed on 29/05/2014 at 12:22.
Pushed by okellogg into branch 'KDE/4.13'.

Apply modified version of https://bugs.kde.org/attachment.cgi?id=86235

umbrello/codeimport/pythonimport.h
- Add member m_isStatic of type bool defaulting to false.

umbrello/codeimport/pythonimport.cpp function parseStmt()
- Decode "@staticmethod" to set m_isStatic true.
- In handling of keyword "def",
  - If first parameter is not named "self" then set m_isStatic true and add
    the parameter via Import_Utils::addMethodParameter(); else do not add
    the parameter.
  - At call to Import_Utils::insertMethod(), provide m_isStatic as argument
    `isStatic'.
  - Reset m_isStatic false after call to Import_Utils::insertMethod().

M  +20   -2    umbrello/codeimport/pythonimport.cpp
M  +1    -0    umbrello/codeimport/pythonimport.h

http://commits.kde.org/umbrello/de77ff0c13706fd2784e11a721be96dd97747f98