On Tue, Mar 14, 2017 at 05:52:20PM +1100, Shane Rigby wrote:
> Thanks again, all received.
> 
> With the options of `blank=True, null=True` for attributes, some more
> thought is required - Blank and Null have different implications. Our
> schema usually allows Null (the attribute does not exist) but not Blank (a
> zero length string). To be fully correct, the XSD give enough information
> to derive if Null or Blank is allowed. What you have done is a great
> approximation for now. I'll investigate a bit further what is the correct
> approach.
> 
> I've tested the code you provided and found one addition change required -
> to replace line 123 in gends_run_gen_django.py (sys.stdout.write(msg)) with
> 
>             if isinstance(msg, str):
>                 sys.stdout.write(msg)
>             else:
>                 sys.stdout.write(msg.decode('utf-8'))

Thanks.

> 
> I had to do this to ensure the message could be decoded before trying to do
> so.
> 
> After making this change the generated files all worked nicely.
> 
> An unrelated question: I understand gends_run_gen_django.py uses Popen to
> run the three other scripts. Is there a fundamental reason for using Popen
> to do this rather than calling the python module from within python
> directly? For our use case I think a python to python call would be easier
> - but I wanted to check with you before spending effort on it.

I'll look into it.

I've looked at it a bit.  Seems it will take more re-design than I
had hoped.  If you have a suggestion, let me know.  Here are some
notes, although since it's not actually broken, I hesitate to
suggest that we spend too much time on it.

The current method (with Popen) does cause some awkwardness.
For example, I can't use pdb to debug code in those sub-modules when
called with Popen.

My only excuse is that I wanted to reuse the existing code as
quickly as I could.  And now, it looks like a bad decision.

One way to fix this would be, for each of the modules that we
want to run, (1) to set sys.argv to the command line arguments that
we want and then (2) call `main()`` directly (eliminating Popen).
Or, is that still too much of a kludge?

One problem with making this kind of change is that the current
method captures output (stdout and stderr) from each step and uses
that to check for errors.  It then stops, if one of these steps has
errors.

I tried redirecting the output from those sub-modules to a StringIO
object (io.StringIO in Python 3).  But, I got an error.  Don't know
why.  It was mysterious.  Maybe something is going on that I don't
know about having to do with getopt or argparse.

Dave

> 
> Once again - thanks in advance!
> 
> Cheers,
> 
> Shane
> 
> On Thu, Mar 9, 2017 at 10:18 AM, Dave Kuhlman <dkuhl...@davekuhlman.org>
> wrote:
> 
> > Shane,
> >
> > Changed files have been sent.
> >
> > If you do not receive the email with the attached files, let me
> > know.  It means I'm having trouble getting through your firewall or
> > your spam filter or something.
> >
> > Dave
> >
> > --
> >
> > Dave Kuhlman
> > http://www.davekuhlman.org
> >


-- 

Dave Kuhlman
http://www.davekuhlman.org

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to