Re: [Django] #16176: Overwriting a property with field during model inheritance.

2021-06-15 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
 Reporter:  czepiel.artur@…  |Owner:
 |  Thomas_Moronez
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Carlton Gibson):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 Fixed in 225d96533a8e05debd402a2bfe566487cc27d95f

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/081.82eb5a63aef588149952bd9e8666d3b9%40djangoproject.com.


Re: [Django] #16176: Overwriting a property with field during model inheritance.

2021-06-11 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
 Reporter:  czepiel.artur@…  |Owner:
 |  Thomas_Moronez
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  dev
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  1 => 0
 * stage:  Accepted => Ready for checkin


Comment:

 [https://github.com/django/django/pull/14508 PR]

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/081.b389527954bd556213284b8c068a0f96%40djangoproject.com.


Re: [Django] #16176: Overwriting a property with field during model inheritance.

2015-10-20 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
 Reporter:  czepiel.artur@…  |Owner:
 |  Thomas_Moronez
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Phist0ne):

 I stumbled upon this bug lately using django 1.8 and am willing to provide
 a patch.

 The main problem seems that creating an attribute containing a django
 field on a model does not overwrite any descriptors (with `__set__`
 defined) from ancestor classes, which does not match the behavior of
 standard python classes.
 It makes sense to me that the attributes corresponding to model fields are
 not set until the class is instantiated, since the values for these fields
 are not available on class creation.
 Therefore my suggested solution would be very similar to Thomas_Moronez's
 patch. What confuses me though is that the proposed patch seems to not
 call contribute_to_class.

 In my opinion there are three possible solutions:
   * delete all class attributes that will be overwritten by fields later
 (e.g. in add_to_class after the "contribute-to-class" check")
   * delete class attributes that have a `__set__` method defined
   * set the class attributes to a specific value (e.g. a to be written
 class) to mark them as to be overwritten later (melinath's suggestion)

 Is this still considered a bug and if so which one is the preferred
 solution?

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/081.254859b670457a79a8fce52d26dda428%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #16176: Overwriting a property with field during model inheritance.

2014-05-16 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
 Reporter:  czepiel.artur@…  |Owner:
 Type:  Bug  |  Thomas_Moronez
Component:  Database layer   |   Status:  assigned
  (models, ORM)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by oinopion):

 * needs_better_patch:  0 => 1


Comment:

 Patch no longer applies cleanly.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/081.aec9be1bc5f6400cf1aa46de78786b79%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #16176: Overwriting a property with field during model inheritance.

2013-03-14 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
 Reporter:  czepiel.artur@…  |Owner:
 Type:  Bug  |  Thomas_Moronez
Component:  Database layer   |   Status:  assigned
  (models, ORM)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Thomas_Moronez):

 I modified the add_to_class method to check if the value of the attribute
 is a property. If it is it sets the attribute to the class with a None
 value. I took melinath's suggestion too set the field's name to None.This
 does fix the bug, and does not break test in model_inheritance_regress.
 However, as developer carljm, pointed out, backwards-incompatibility may
 be present as the patch adds 4 unit test failures.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #16176: Overwriting a property with field during model inheritance.

2013-03-11 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
 Reporter:  czepiel.artur@…  |Owner:
 Type:  Bug  |  Thomas_Moronez
Component:  Database layer   |   Status:  assigned
  (models, ORM)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by carljm):

 I don't think the proposed error-reraising is a good idea. For one thing,
 we can't be sure that the `AttributeError` is in fact due to a property
 from an abstract base class, it could be due to a definition of
 `__setattr__`, a metaclass, or possibly other even more diabolical things.
 For another, when we can avoid it it's a bad idea to obscure the original
 traceback by catching one exception and raising another one in its place.

 melinath's suggestion to set all fields as class attributes so they
 override descriptors from a parent class is certainly worth considering,
 as it would make models behave more like regular Python classes. This
 could result in some backwards-incompatibility; would need to look into it
 more to get a clearer sense of what cases might cause trouble, but I think
 it's probably acceptable if documented in the release notes.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #16176: Overwriting a property with field during model inheritance.

2013-02-25 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
 Reporter:  czepiel.artur@…  |Owner:
 Type:  Bug  |  Thomas_Moronez
Component:  Database layer   |   Status:  assigned
  (models, ORM)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Thomas_Moronez):

 * has_patch:  0 => 1
 * needs_tests:  1 => 0


Comment:

 Added a try ... except statement that throws a more descriptive error
 message. That way the user can know the error lies within the use of the
 @property descriptor and can simply modify the name of the field.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #16176: Overwriting a property with field during model inheritance.

2013-01-16 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
 Reporter:  czepiel.artur@…  |Owner:
 Type:  Bug  |  Thomas_Moronez
Component:  Database layer   |   Status:  assigned
  (models, ORM)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Thomas_Moronez):

 * owner:  nobody => Thomas_Moronez
 * status:  new => assigned


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #16176: Overwriting a property with field during model inheritance.

2013-01-11 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
 Reporter:  czepiel.artur@…  |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:   |  Needs documentation:  0
Has patch:  0|  Patch needs improvement:  0
  Needs tests:  1|UI/UX:  0
Easy pickings:  0|
-+-

Comment (by metzlar@…):

 I made this work by defining the property dynamically inside the parent
 model definition:


 {{{
 class SomeTestModel(models.Model):
  some_field = models.CharField(max_length=100)

  class Meta:
  abstract = True

  @classmethod
  def __new__(cls, *args, **kwargs):
  inst = models.Model.__new__(cls, *args, **kwargs)
  if cls is SomeTestModel:
  inst.other_field = property(lambda x: "[OTHER] %s" %
 getattr(x, 'some_field'))
  return inst
 }}}

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #16176: Overwriting a property with field during model inheritance.

2012-06-01 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
 Reporter:  czepiel.artur@…  |Owner:  anonymous
 Type:  Bug  |   Status:  new
Component:  HTTP handling|  Version:  master
 Severity:  Release blocker  |   Resolution:
 Keywords:  x| Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by anonymous):

 * keywords:   => x
 * owner:  nobody => anonymous
 * has_patch:  0 => 1
 * component:  Database layer (models, ORM) => HTTP handling
 * severity:  Normal => Release blocker


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #16176: Overwriting a property with field during model inheritance.

2011-07-16 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
   Reporter: |  Owner:  nobody
  czepiel.artur@…| Status:  new
   Type:  Bug|  Component:  Database layer
  Milestone: |  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:
   Triage Stage:  Accepted   |  Has patch:  0
Needs documentation:  0  |Needs tests:  1
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
Changes (by teraom):

 * cc: teraom (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #16176: Overwriting a property with field during model inheritance.

2011-06-08 Thread Django
#16176: Overwriting a property with field during model inheritance.
-+-
   Reporter: |  Owner:  nobody
  czepiel.artur@…| Status:  new
   Type:  Bug|  Component:  Database layer
  Milestone: |  (models, ORM)
Version:  SVN|   Severity:  Normal
 Resolution: |   Keywords:
   Triage Stage:  Accepted   |  Has patch:  0
Needs documentation:  0  |Needs tests:  1
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
Changes (by melinath):

 * needs_better_patch:   => 0
 * stage:  Unreviewed => Accepted
 * needs_tests:   => 1
 * needs_docs:   => 0


Comment:

 I can confirm that this bug exists. It happens with CharFields, but not
 ForeignKeys. I haven't actually checked, but I'm guessing that the problem
 lies in the use of contribute_to_class, which would mean that the
 attribute with the field's name would never actually be set on the class -
 and thus the property would not be overridden... If that is the problem,
 one possible solution would be to just always set the attribute with the
 field's name to None.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.