Beispiel #1
0
    def testSplitSegments(self):
        self.assertEqual(['a'], utils.split_segments('a'))
        self.assertEqual(['a', 'a/b'], utils.split_segments('a/b'))
        self.assertEqual(['a', 'a/b', 'a/b/c'], utils.split_segments('a/b/c'))

        self.assertEqual(['a'], utils.split_segments('a', sep='.'))
        self.assertEqual(['a', 'a.b'], utils.split_segments('a.b', sep='.'))
        self.assertEqual(['a', 'a.b', 'a.b.c'],
                         utils.split_segments('a.b.c', sep='.'))
  def testSplitSegments(self):
    self.assertEqual(['a'], utils.split_segments('a'))
    self.assertEqual(['a', 'a/b'], utils.split_segments('a/b'))
    self.assertEqual(['a', 'a/b', 'a/b/c'], utils.split_segments('a/b/c'))

    self.assertEqual(['a'], utils.split_segments('a', sep='.'))
    self.assertEqual(['a', 'a.b'], utils.split_segments('a.b', sep='.'))
    self.assertEqual(['a', 'a.b', 'a.b.c'],
                     utils.split_segments('a.b.c', sep='.'))
Beispiel #3
0
    def __init__(self, key, user=None, meta=None):
        super(Activity, self).__init__()

        self.timestamp = datetime.datetime.utcnow()
        self.key = key
        self.user = user
        self.meta = meta
        self._keys = utils.split_segments(self.key, sep='.')

        # Make the activity_id relatively unique.
        hashed = hashlib.md5()
        hashed.update(self.key)
        hashed.update(self.timestamp.isoformat(sep='T'))
        hashed.update(os.environ.get('REQUEST_ID_HASH', ''))
        if self.user:
            hashed.update(self.user.email)
        self.activity_id = utils.safe_join(
            ACTIVITY_DIR, self.key, self.timestamp.strftime('%Y/%m/%d'),
            '{}-{}.json'.format(self.timestamp.isoformat(sep='T'),
                                hashed.hexdigest()[:6]))
  def __init__(self, key, user=None, meta=None):
    super(Activity, self).__init__()

    self.timestamp = datetime.datetime.utcnow()
    self.key = key
    self.user = user
    self.meta = meta
    self._keys = utils.split_segments(self.key, sep='.')

    # Make the activity_id relatively unique.
    hashed = hashlib.md5()
    hashed.update(self.key)
    hashed.update(self.timestamp.isoformat(sep='T'))
    hashed.update(os.environ.get('REQUEST_ID_HASH', ''))
    if self.user:
      hashed.update(self.user.email)
    self.activity_id = utils.safe_join(
        ACTIVITY_DIR, self.key, self.timestamp.strftime('%Y/%m/%d'),
        '{}-{}.json'.format(
            self.timestamp.isoformat(sep='T'), hashed.hexdigest()[:6]))