Re: AccountDeletion remains after expunge_deleted

2013-02-08 Thread robertlnewman
Hi Paton,

Not to be obtuse, but the question you are asking is actually unique to the 
Pinax project (http://pinaxproject.com/). AFAIK Django's manage.py doesn't have 
any expunge_deleted command (at least as far as my manage.py help output shows, 
and I am running the latest Django 1.4.2). You might get more luck asking this 
question in the Pinax Google Group (pinax-us...@googlegroups.com) which is 
specific to that project.

A quick browse of the Pinax source code (well, actually the Pinax creators 
sub-project django-user-accounts which is used by Pinax) you will see the 
following:
from django.core.management.base import BaseCommand

from account.models import AccountDeletion


class Command(BaseCommand):

help = "Expunge accounts deleted more than 48 hours ago."

def handle(self, *args, **options):
count = AccountDeletion.expunge()
print "%d expunged." % count

(source: 
https://github.com/pinax/django-user-accounts/blob/master/account/management/commands/expunge_deleted.py)

Going back up the tree (to the django-user-accounts account.models file) and 
looking at the source you will see the following (starting at line 342):
class AccountDeletion(models.Model):

user = models.ForeignKey(User, null=True, blank=True, 
on_delete=models.SET_NULL)
email = models.EmailField()
date_requested = models.DateTimeField(default=timezone.now)
date_expunged = models.DateTimeField(null=True, blank=True)

@classmethod
def expunge(cls, hours_ago=None):
if hours_ago is None:
hours_ago = settings.ACCOUNT_DELETION_EXPUNGE_HOURS
before = timezone.now() - datetime.timedelta(hours=hours_ago)
count = 0
for account_deletion in cls.objects.filter(date_requested__lt=before, 
user__isnull=False):
settings.ACCOUNT_DELETION_EXPUNGE_CALLBACK(account_deletion)
account_deletion.date_expunged = timezone.now()
account_deletion.save()
count += 1
return count

@classmethod
def mark(cls, user):
account_deletion, created = cls.objects.get_or_create(user=user)
account_deletion.email = user.email
account_deletion.save()
settings.ACCOUNT_DELETION_MARK_CALLBACK(account_deletion)
return account_deletion
(source: 
https://github.com/pinax/django-user-accounts/blob/master/account/models.py)

There you can see the expunge() method in its entirety. It actually looks like 
there is a specific time period before the users are deleted, but I am not a 
Pinax expert by any means.

Hope that helps, and good luck.
- Rob

On Feb 7, 2013, at 10:43 PM, Paton Lewis wrote:

> I started my project via:
> 
> django-admin.py startproject 
> --template=https://github.com/pinax/pinax-project-account/zipball/master 
> myproject
> 
> One of the features provided by the account system is delayed deletion of 
> accounts. When you delete an account, it isn't actually deleted. Instead, an 
> AccountDeletion object is created that tracks the deletion request. When you 
> run
> 
> manage.py expunge_deleted
> 
> then the AccountDeletion objects are iterated and any Account objects that 
> are more than 48 hours old are deleted.
> 
> My question has to do with the AccountDeletion objects. These objects aren't 
> deleted, and it looks like they remain in the database forever. Is this 
> intentional? Is there another command that expunges the AccountDeletion 
> objects? Or is this just a bug in the AccountDeletion class implementation?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

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




AccountDeletion remains after expunge_deleted

2013-02-08 Thread Paton Lewis
I started my project via:

django-admin.py startproject 
--template=https://github.com/pinax/pinax-project-account/zipball/master 
myproject

One of the features provided by the account system is delayed deletion of 
accounts. When you delete an account, it isn't actually deleted. Instead, 
an AccountDeletion object is created that tracks the deletion request. When 
you run

manage.py expunge_deleted

then the AccountDeletion objects are iterated and any Account objects that 
are more than 48 hours old are deleted.

My question has to do with the AccountDeletion objects. These objects 
aren't deleted, and it looks like they remain in the database forever. Is 
this intentional? Is there another command that expunges the 
AccountDeletion objects? Or is this just a bug in the AccountDeletion class 
implementation?

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