Ignore:
Timestamp:
Oct 2, 2008, 8:18:40 AM (16 years ago)
Author:
broder
Message:

Update (at least some of) the web code to work with newer a SQLAlchemy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-www/code/validation.py

    r879 r1001  
    7979    if machine:
    8080        owner = machine.owner
    81     return Machine.select_by(owner=owner)
     81    return Machine.query().filter_by(owner=owner)
    8282
    8383def maxMemory(owner, g, machine=None, on=True):
     
    111111    else:
    112112        machine_id = None
    113     disk_usage = Disk.query().filter_by(Disk.c.machine_id != machine_id,
    114                                         owner=owner).sum(Disk.c.size) or 0
     113    disk_usage = Disk.query().filter(Disk.c.machine_id != machine_id).\
     114                     join('machine').\
     115                     filter_by(owner=owner).sum(Disk.c.size) or 0
    115116    return min(MAX_DISK_SINGLE, MAX_DISK_TOTAL-disk_usage/1024.)
    116117
     
    118119    machines = getMachinesByOwner(owner)
    119120    active_machines = [m for m in machines if m.name in g.xmlist_raw]
    120     if len(machines) >= MAX_VMS_TOTAL:
     121    if machines.count() >= MAX_VMS_TOTAL:
    121122        return 'You have too many VMs to create a new one.'
    122123    if len(active_machines) >= MAX_VMS_ACTIVE:
     
    270271    if machine is not None and name == machine.name:
    271272        return None
    272     if not Machine.select_by(name=name):
     273    if not Machine.query().filter_by(name=name):
    273274        if not validMachineName(name):
    274275            raise InvalidInput('name', name, 'You must provide a machine name.  Max 63 chars, alnum plus \'-\', does not begin or end with \'-\'.')
Note: See TracChangeset for help on using the changeset viewer.