From 8e82f8a06885dd31effe9015467834fbbbc98f47 Mon Sep 17 00:00:00 2001 From: Eric Price Date: Tue, 9 Oct 2007 22:50:11 -0400 Subject: [PATCH] fix invalid input exception, and let you "change" machine to it's own name svn path=/trunk/web/; revision=164 --- templates/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/templates/main.py b/templates/main.py index bf40069..c708752 100755 --- a/templates/main.py +++ b/templates/main.py @@ -34,7 +34,7 @@ class InvalidInput(MyException): the select box). """ def __init__(self, err_field, err_value, expl=None): - super(InvalidInput, self).__init__(expl) + MyException.__init__(self, expl) self.err_field = err_field self.err_value = err_value @@ -585,6 +585,8 @@ def testDisk(user, disksize, machine=None): def testName(user, name, machine=None): if Machine.select_by(name=name) == []: return name + if name == machine.name: + return name raise InvalidInput('name', name, "Already taken") @@ -610,20 +612,21 @@ def modify(user, fields): contact = testContact(user, fields.getfirst('contact')) hostname = testHostname(owner, fields.getfirst('hostname'), machine) - name = testName(user, fields.getfirst('name')) + name = testName(user, fields.getfirst('name'), machine) oldname = machine.name olddisk = {} memory = fields.getfirst('memory') if memory is not None: memory = validMemory(user, memory, machine) + else: + memory = machine.memory if memory != machine.memory: machine.memory = memory disksize = testDisk(user, fields.getfirst('disk')) if disksize is not None: disksize = validDisk(user, disksize, machine) - for disk in machine.disks: disk.size = disksize olddisk[disk.guest_device_name] = disk.size -- 1.7.9.5