Revision 4350ac98
b/snf-common/synnefo/lib/quotaholder/api/quotaholder.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
# |
|
1 | 3 |
# Copyright 2012 GRNET S.A. All rights reserved. |
2 | 4 |
# |
3 | 5 |
# Redistribution and use in source and binary forms, with or |
... | ... | |
35 | 37 |
from synnefo.lib.commissioning import (CanonifyException, SpecifyException, |
36 | 38 |
Specificator, Null, Integer, Text, |
37 | 39 |
Tuple, ListOf, Dict, Args) |
40 |
from random import choice, randint |
|
38 | 41 |
|
39 | 42 |
Context = Dict(classname='Context', null=True, show=False) |
40 | 43 |
|
... | ... | |
43 | 46 |
self.opts.update({'regex': "[\w.:@+/-]+", 'maxlen':512}) |
44 | 47 |
Text.init(self) |
45 | 48 |
|
49 |
def _random_choice(self, kw): |
|
50 |
alphabet = u'abcdef_1233490.:@/-αβγδεζ' |
|
51 |
length = randint(0, 48) |
|
52 |
return ''.join(choice(alphabet) for _ in xrange(length)) |
|
53 |
|
|
46 | 54 |
class Nonnegative(Integer): |
47 | 55 |
def init(self): |
48 | 56 |
self.opts.update({'minimum': 0}) |
Also available in: Unified diff