~rashi007/mailman/docsfix

« back to all changes in this revision

Viewing changes to src/mailman/model/pending.py

  • Committer: Barry Warsaw
  • Date: 2014-12-02 03:02:08 UTC
  • mto: (7264.4.22 py3)
  • mto: This revision was merged to the branch mainline in revision 7285.
  • Revision ID: barry@list.org-20141202030208-45txxq70yn98uz9m
test_requests succeeds now, after changing some LargeBinary columns into
Unicode columns.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import hashlib
32
32
 
33
33
from lazr.config import as_timedelta
34
 
from sqlalchemy import (
35
 
    Column, DateTime, ForeignKey, Integer, LargeBinary, Unicode)
 
34
from sqlalchemy import Column, DateTime, ForeignKey, Integer, Unicode
36
35
from sqlalchemy.orm import relationship
37
36
from zope.interface import implementer
38
37
from zope.interface.verify import verifyObject
71
70
    __tablename__ = 'pended'
72
71
 
73
72
    id = Column(Integer, primary_key=True)
74
 
    token = Column(LargeBinary)
 
73
    token = Column(Unicode)
75
74
    expiration_date = Column(DateTime)
76
75
    key_values = relationship('PendedKeyValue')
77
76
 
108
107
            right_now = time.time()
109
108
            x = random.random() + right_now % 1.0 + time.clock() % 1.0
110
109
            # Use sha1 because it produces shorter strings.
111
 
            token = hashlib.sha1(repr(x)).hexdigest()
 
110
            token = hashlib.sha1(repr(x).encode('utf-8')).hexdigest()
112
111
            # In practice, we'll never get a duplicate, but we'll be anal
113
112
            # about checking anyway.
114
113
            if store.query(Pended).filter_by(token=token).count() == 0: