Re: django-registration question: activation_key_expired.boolean = True

2010-10-31 Thread adj7388
> This particular object is used by the admin:
>
> http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contri...
>
> Read through that carefully and you'll see the 'boolean' option and a
> few other useful tricks.

Well, this is embarrassing. I had actually read (err, skimmed?) that
page looking for the answer, and did not see the needle in the
haystack. After a more careful reading, it's perfectly clear.

The attribute name 'boolean' threw me off a bit. I thought maybe there
was some Python magic happening related to the fact that the function
returned a boolean. Now all is clear. Thanks very much.

Alan

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



Re: django-registration question: activation_key_expired.boolean = True

2010-10-31 Thread James Bennett
On Sun, Oct 31, 2010 at 8:48 AM, adj7388  wrote:
> What does that last line do? I have looked high and low in Django and
> Python documentation, but I can't find an example or explanation of
> this pattern. It appears to be clobbering the method
> 'activation_key_expired()' with a boolean that is always True. Surely
> there's something else at work here, isn't there?  Sorry if this is
> obvious to everyone but me, but I can't find the answer anywhere.

It sets an attribute on the instancemethod object
'activation_key_expired'. Remember: everything is an object, and you
can fiddle with attributes on any object.

This particular object is used by the admin:

http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display

Read through that carefully and you'll see the 'boolean' option and a
few other useful tricks.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



django-registration question: activation_key_expired.boolean = True

2010-10-31 Thread adj7388
This question refers to line 205 here:
http://bitbucket.org/ubernostrum/django-registration/src/b6b213d84d32/registration/models.py

In a nutshell:

class RegistrationProfile(models.Model):

def activation_key_expired(self):
...
expiration_date =
datetime.timedelta(days=settings.ACCOUNT_ACTIVATION_DAYS)
return self.activation_key == self.ACTIVATED or \
   (self.user.date_joined + expiration_date <=
datetime.datetime.now())
activation_key_expired.boolean = True  # <- what does this do?

What does that last line do? I have looked high and low in Django and
Python documentation, but I can't find an example or explanation of
this pattern. It appears to be clobbering the method
'activation_key_expired()' with a boolean that is always True. Surely
there's something else at work here, isn't there?  Sorry if this is
obvious to everyone but me, but I can't find the answer anywhere.

Thanks.
Alan

btw: James Bennett's django-registration app is great. Elegant, well
designed, and does exactly what it needs to. I learned a lot about
django and django testing just by reading the code.

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