On Fri, May 16, 2014 at 03:48:37PM +0200, Bart Wagenaar wrote:
> Hello Dave,
> 
> I got your email address from a colleague (Mikki Weesenaar) who has
> submitted another bug before. I probably found another bug :-)
> 
> In case a list of items can be added, the generated model has a function
> 'insert_window(self, index, value)' but instead of inserting an 'window'
> into an array, it actually replaces a value.
> 
> I have attached a simple XSD with which the fault can be 'created'. And
> also the generated python file (line 725 contains the fault).
> 

Bart,

Thanks for pointing this out, and thanks for providing the file that
reproduces it.  And, I can't think of any good reason or excuse that
would explain why I did it that way.

I agree that a Python programmer would expect it to do the insert
rather than the replacement.

OK, we could modify generateDS.py so that instead of this:

    def insert_window(self, index, value): self.window[index] = value

it generates the following:

    def replace_window_at(self, index, value): self.window[index] = value
    def insert_window_at(self, index, value): self.window.insert(index, value)

I was worried that there may be some code out there that depends on
the current behavior.  So, I've removed the old generated name
completely (insert_window, ...).  This change would cause code that
uses the old, exiting "insert_xx" method to throw an exception,
which  would alert the user to the need to change his/her code.
And, it should be relatively easy to search existing code that uses
a generated module for "insert_" to determine whether a change is
needed.

I've made the above fix.  This fix also makes an equivalent change
for "old style" getter and setter names (command line option
--use-getter-setter).  So, for example, with command line option
--use-getter-setter=old, it generates replaceWindowAt and
insertWindowAt.

What do you think?

You can get the patched version at Bitbucket:

    https://bitbucket.org/dkuhlman/generateds

If you get a chance to try it, please let me know what you think.

Dave


-- 

Dave Kuhlman
http://www.davekuhlman.org

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to