I still don't get any errors or directories generated from this code,
any ideas?
if SHA1_RE.search(activation_key):
try:
profile = self.get(activation_key=activation_key)
except self.model.DoesNotExist:
return False
if not profile.activation_key_expired():
try:
import os
media_root = dzopastudio.settings.MEDIA_ROOT
user_directory_path = os.path.join(media_root,
'listings', 'neridaj')
os.mkdir(user_directory_path)
except:
print "directory could not be created."
user = profile.user
user.is_active = True
user.save()
profile.activation_key = self.model.ACTIVATED
profile.save()
return user
return False
On Jul 9, 1:22 pm, Friðrik Már Jónsson <[email protected]> wrote:
> Hi,
>
>
>
> > if SHA1_RE.search(activation_key):
> > try:
> > profile = self.get(activation_key=activation_key)
> > except self.model.DoesNotExist:
> > return False
> > if not profile.activation_key_expired():
> > user= profile.user
> > user.is_active = True
> > user.save()
> > profile.activation_key = self.model.ACTIVATED
> > profile.save()
> > try:
> > import os
> > os.mkdir(MEDIA_ROOT + '/listings/' +user)
> > except IOError:
> > print "could not create folder."
> > returnuser
> > return False
>
> For one, I'm a tad befuzzled that you don't get an unexpected indent
> error where your `print` statement is.
>
> Kindly hand over the value of `user_directory_path` and nobody will
> get hurt.
>
> user_directory_path = os.path.join(MEDIA_ROOT, 'listings', user.username)
> os.mkdir(user_directory_path)
> print user_directory_path
>
> > I'm attempting to use a try except to catch any error but I don't
> > think I'm using it correctly.
>
> If you don't want an exception when an IOError is thrown (e.g. can't
> write to that location), but instead want "could not create folder."
> printed on your runserver console, you are using it correctly.
>
> Regards,
> Friðrik Már
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---