Shane,

Thanks for catching these.

Here are replies to your comments in the last several emails.

I've added your fixes, I think; see below.

In a separate email, I've attached the latest versions of the files
we've changed for the Django stuff.  I've also attached diffs, in
case that works better for you.

A few notes:

> I forgot to mention that I needed to change one line in
> gends_run_gen_django.py from:
> 
>         sys.stdout.write(msg)
> 
> to
> 
>         sys.stdout.write(msg.decode('utf-8'))
> 
> for it to work in my environment.

What?  Wait.  You're using Python 3, right?  In Python 3, a string
does not have a `decode` method.

Are you sometimes using Python 2?  But, in Python that does not seem
to make a difference in my environment.  Are you on MS Windows or
Apple Mac?

Anyway, I changed it to this:

    diff -r 15f406c4f1dd django/gends_run_gen_django.py
    --- a/django/gends_run_gen_django.py    Wed Mar 08 11:17:51 2017 -0800
    +++ b/django/gends_run_gen_django.py    Wed Mar 08 11:18:14 2017 -0800
    @@ -117,7 +117,10 @@
     
     def dbg_msg(options, msg):
         if options['verbose']:
    -        sys.stdout.write(msg)
    +        if sys.version_info.major == 2:
    +            sys.stdout.write(msg.decode('utf-8'))
    +        else:
    +            sys.stdout.write(msg)

> In generatedssuper.py I made a small change to add the class_name into the
> relatedname and it looks like it works for me:

Seems good to me.  I've used your fix.  Here is a diff:

        diff -r 15f406c4f1dd django/generatedssuper.py
        --- a/django/generatedssuper.py Wed Mar 08 11:17:51 2017 -0800
        +++ b/django/generatedssuper.py Wed Mar 08 11:22:21 2017 -0800
        @@ -218,8 +218,8 @@
                                                 '    %s = models.ForeignKey(\n 
       "%s_model",\n' % (
                                                         name, data_type, ))
                                         wrtmodels(
        -                    '        related_name="{}_{}",\n'.format(
        -                        name, data_type, ))
        +                    '        related_name="{}_{}_{}",\n'.format(
        +                        class_name, name, data_type, ))
                                         if is_optional:
                                                 wrtmodels(
                                                         '        blank=True, 
null=True,\n')


> I have an optional attribute but it is enforcing not null on the database
> side:
> 
>  NumberOfEmployees = models.IntegerField(blank=True)
> 
> Instead it should be:
> 
>  NumberOfEmployees = models.IntegerField(blank=True, null=True)
> 
> Is this scenario something you had considered?

I'm not too sure about the rules for using parameters `blank` and
`null`, but it seems like we should be doing the same thing for
attributes that we are doing for element children.  Specifically, we
should only generate `blank=True, null=True` when the attribute
really is optional.  I've made that change.  My tests show that it
seems to work.

Please let me know if these changes work for you and it you have
additional issues.

Dave


-- 

Dave Kuhlman
http://www.davekuhlman.org

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to