Re: db.models.options help with a piece of code analysis.

2016-01-18 Thread Elton Pereira de Lima
Really, it's true!

Thanks for help!

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/bc30deff-2f95-4769-9195-ab74ab03b1c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: db.models.options help with a piece of code analysis.

2016-01-18 Thread charettes
FWIW, as Marteen pointed out, the `Meta` attribute is only available on
abstract classes because of these lines 

.

Simon

Le lundi 18 janvier 2016 13:09:16 UTC-5, charettes a écrit :
>
> Hi Elton,
>
> From what I understand the line you pointed at doesn't delete the model 
> `Meta`
> attribute but the `_meta.meta` attribute which makes it possible for 
> `Bar.Meta`
> to subclass `Foo.Meta` even if `Foo.Meta.abstract is not True`.
>
> Simon
>
> Le lundi 18 janvier 2016 12:34:29 UTC-5, Elton Pereira de Lima a écrit :
>>
>> Hello charettes!
>>
>> Analyzing the code further, I saw that it was impossible for the Bar Meta 
>> class inherits from Foo.Meta because when this code 
>>  
>> is executed, the Meta class ceases to exist because of this line 
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/0cdc4202-c2f1-43f5-9efe-5d765843c65b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: db.models.options help with a piece of code analysis.

2016-01-18 Thread charettes
Hi Elton,

>From what I understand the line you pointed at doesn't delete the model 
`Meta`
attribute but the `_meta.meta` attribute which makes it possible for 
`Bar.Meta`
to subclass `Foo.Meta` even if `Foo.Meta.abstract is not True`.

Simon

Le lundi 18 janvier 2016 12:34:29 UTC-5, Elton Pereira de Lima a écrit :
>
> Hello charettes!
>
> Analyzing the code further, I saw that it was impossible for the Bar Meta 
> class inherits from Foo.Meta because when this code 
>  
> is executed, the Meta class ceases to exist because of this line 
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/ecab49d8-7b78-45ed-b5eb-fc378792058b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: db.models.options help with a piece of code analysis.

2016-01-18 Thread Marten Kenbeek
Hi Elton,

Django makes the Meta class of abstract models available as Foo.Meta. This 
allows you to define common Meta options on the abstract base class, and 
inherit the base Meta in your concrete child models. So the above example 
won't work as you noted, but this will:

class Foo(models.Model):
class Meta:
app_label = 'app'
abstract = True

class Bar(models.Model):
class Meta(Foo.Meta):
pass

assert 'app_label' not in Bar.Meta.__dict__
assert Bar.Meta.app_label == 'app'


On Monday, January 18, 2016 at 6:34:29 PM UTC+1, Elton Pereira de Lima 
wrote:
>
> Hello charettes!
>
> Analyzing the code further, I saw that it was impossible for the Bar Meta 
> class inherits from Foo.Meta because when this code 
>  
> is executed, the Meta class ceases to exist because of this line 
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/411c9ca0-f718-4ae5-835c-fcaa6edd4cf6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: db.models.options help with a piece of code analysis.

2016-01-18 Thread Elton Pereira de Lima
Hello charettes!

Analyzing the code further, I saw that it was impossible for the Bar Meta 
class inherits from Foo.Meta because when this code 
 
is executed, the Meta class ceases to exist because of this line 

.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/8254ecd9-0182-450c-a6f0-074ad5bd49da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: db.models.options help with a piece of code analysis.

2016-01-18 Thread Elton Pereira de Lima
Thanks for help!

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/2f95e42a-b869-4abf-88cd-6675f8db0d1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: db.models.options help with a piece of code analysis.

2016-01-15 Thread charettes
Hi Elton,

>From a quick look this branch seems to handle attributes inherited from
possible `Meta` bases.

e.g.

class Foo(models.Model):
class Meta:
app_label = 'app'

class Bar(models.Model):
class Meta(Foo.Meta):
pass

assert 'app_label' not in Bar.Meta.__dict__
assert Bar.Meta.app_label == 'app'

Cheers,
Simon

Le vendredi 15 janvier 2016 10:36:45 UTC-5, Elton Pereira de Lima a écrit :
>
> What's up guys!
>
> I am studying the core of django and I came across a piece of code that 
> confused me.
>
>
> https://github.com/django/django/blob/master/django/db/models/options.py#L192-L194
>
> If meta_attr is a copy of self.meta .__ dict__, then when will the marked 
> section will run?
>
> Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/192e9289-ea1d-43c5-b711-7b9111328878%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.