Maybe I'm wrong but this patch define DEFAULT_ALGO at "django
installation" level. I think it shoud be defined at prject level.
something like this

>>> try:
...     DEFAULT_ALGO = settings.DEFAULT_ALGO
... except NameError:
...     DEFAULT_ALGO = 'sha1'

does refer to project settings have some side issues I can't see?

On 28 Ago, 19:57, Tim Chase <[EMAIL PROTECTED]> wrote:
> > thanks opend ticket #8647
>
> Attached is a patch against contrib/auth/models.py that should
> add an "algo" parameter to set_password so it takes an algorithm.
>
> -tim
>
> [specify_algo.diff]Index: models.py
> ===================================================================
> --- models.py   (revision 8666)
> +++ models.py   (working copy)
> @@ -9,6 +9,7 @@
>  import urllib
>
>  UNUSABLE_PASSWORD = '!' # This will never be a valid hash
> +DEFAULT_ALGO = 'sha1'
>
>  try:
>      set
> @@ -103,12 +104,12 @@
>          return self.name
>
>  class UserManager(models.Manager):
> -    def create_user(self, username, email, password=None):
> +    def create_user(self, username, email, password=None, algo=DEFAULT_ALGO):
>          "Creates and saves a User with the given username, e-mail and 
> password."
>          now = datetime.datetime.now()
>          user = self.model(None, username, '', '', email.strip().lower(), 
> 'placeholder', False, True, False, now, now)
>          if password:
> -            user.set_password(password)
> +            user.set_password(password, algo)
>          else:
>              user.set_unusable_password()
>          user.save()
> @@ -172,9 +173,8 @@
>          full_name = u'%s %s' % (self.first_name, self.last_name)
>          return full_name.strip()
>
> -    def set_password(self, raw_password):
> +    def set_password(self, raw_password, algo=DEFAULT_ALGO):
>          import random
> -        algo = 'sha1'
>          salt = get_hexdigest(algo, str(random.random()), 
> str(random.random()))[:5]
>          hsh = get_hexdigest(algo, salt, raw_password)
>          self.password = '%s$%s$%s' % (algo, salt, hsh)
> @@ -343,7 +343,7 @@
>      def delete(self):
>          raise NotImplementedError
>
> -    def set_password(self, raw_password):
> +    def set_password(self, raw_password, algo=DEFAULT_ALGO):
>          raise NotImplementedError
>
>      def check_password(self, raw_password):
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to