Commit 35df9ccd authored by Georgios D. Tsoukalas's avatar Georgios D. Tsoukalas
Browse files

provide random Name

parent 53874dc5
# -*- coding: utf-8 -*-
#
# Copyright 2012 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
......@@ -35,6 +37,7 @@
from synnefo.lib.commissioning import (CanonifyException, SpecifyException,
Specificator, Null, Integer, Text,
Tuple, ListOf, Dict, Args)
from random import choice, randint
Context = Dict(classname='Context', null=True, show=False)
......@@ -43,6 +46,11 @@ class Name(Text):
self.opts.update({'regex': "[\w.:@+/-]+", 'maxlen':512})
Text.init(self)
def _random_choice(self, kw):
alphabet = u'abcdef_1233490.:@/-αβγδεζ'
length = randint(0, 48)
return ''.join(choice(alphabet) for _ in xrange(length))
class Nonnegative(Integer):
def init(self):
self.opts.update({'minimum': 0})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment