<commit_before>## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN.
##
## CDS Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## CDS Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

"""CDS Invenio Access Control MailCookie."""

__revision__ = "$Id$"

__lastupdated__ = """$Date$"""

"""These functions are temporaly managing roles and other authorization via
unique urls sent by email.
"""

import sys
if sys.hexversion < 0x2060000:
    from md5 import md5
else:
    from hashlib import md5

from invenio.config import CFG_SITE_LANG, CFG_SITE_SECURE_URL
from invenio.dbquery import run_sql
from invenio.access_control_admin import acc_get_role_id, acc_add_user_role
from datetime import datetime, timedelta
from random import random
from cPickle import dumps, loads


class InvenioWebAccessMailCookieError(Exception):
    pass

class InvenioWebAccessMailCookieDeletedError(Exception):
    pass


_authorizations_kind = ('pw_reset', 'mail_activation', 'role', 'authorize_action')
_datetime_format = "%Y-%m-%d %H:%M:%S"

def mail_cookie_create_generic(kind, params, cookie_timeout=timedelta(days=1), onetime=False):<commit_msg>WebComment: allow subscriptions to discussions<commit_after>## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 CERN.
##
## CDS Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## CDS Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

"""CDS Invenio Access Control MailCookie."""

__revision__ = "$Id$"

__lastupdated__ = """$Date$"""

"""These functions are temporaly managing roles and other authorization via
unique urls sent by email.
"""

import sys
if sys.hexversion < 0x2060000:
    from md5 import md5
else:
    from hashlib import md5

from invenio.config import CFG_SITE_LANG, CFG_SITE_SECURE_URL
from invenio.dbquery import run_sql
from invenio.access_control_admin import acc_get_role_id, acc_add_user_role
from datetime import datetime, timedelta
from random import random
from cPickle import dumps, loads


class InvenioWebAccessMailCookieError(Exception):
    pass

class InvenioWebAccessMailCookieDeletedError(Exception):
    pass


_authorizations_kind = ('pw_reset', 'mail_activation', 'role', 'authorize_action',
                        'comment_msg')
_datetime_format = "%Y-%m-%d %H:%M:%S"

def mail_cookie_create_generic(kind, params, cookie_timeout=timedelta(days=1), onetime=False):
{'fraction_non_alphanumeric': 0.08402432283029299, 'fraction_numerical': 0.030403537866224434, 'mean_word_length': 5.092592592592593, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '905961', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1046, 'n_words': 436}