Changeset 1001 for trunk


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

Location:
trunk/packages/sipb-xen-www/code
Files:
5 edited

Legend:

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

    r879 r1001  
    1414
    1515from invirt.config import structs as config
    16 from invirt.database import Machine, Disk, Type, NIC, CDROM, ctx, meta
     16from invirt.database import Machine, Disk, Type, NIC, CDROM, session, meta
    1717
    1818# ... and stolen from xend/uuid.py
  • trunk/packages/sipb-xen-www/code/main.py

    r912 r1001  
    4141from getafsgroups import getAfsGroupMembers
    4242from invirt import database
    43 from invirt.database import Machine, CDROM, ctx, connect, MachineAccess, Type, Autoinstall
     43from invirt.database import Machine, CDROM, session, connect, MachineAccess, Type, Autoinstall
    4444from invirt.config import structs as config
    4545
  • trunk/packages/sipb-xen-www/code/templates/functions.tmpl

    r864 r1001  
    2121#def cdromList($default="", $onchange=None)
    2222#filter None
    23 $databaseList(sorted($database.CDROM.select(), key=lambda x: x.description),
     23$databaseList(sorted($database.CDROM.query(), key=lambda x: x.description),
    2424              default, onchange, 'cdrom', 'cdromlist', 'cdrom_id', 'description')
    2525#end filter
     
    2828#def autoList($default="", $onchange=None)
    2929#filter None
    30 $databaseList(sorted($database.Autoinstall.select(), key=lambda x: x.description),
     30$databaseList(sorted($database.Autoinstall.query(), key=lambda x: x.description),
    3131              default, onchange, 'autoinstall', 'autoinstalllist', 'autoinstall_id', 'description')
    3232#end filter
  • 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 \'-\'.')
  • trunk/packages/sipb-xen-www/code/webcommon.py

    r874 r1001  
    4646    def getMachines(self):
    4747        if self.isadmin:
    48             return Machine.query().join('acl').select_by(
     48            return Machine.query().join('acl').filter_by(
    4949                database.or_(MachineAccess.c.user == self.username,
    5050                             Machine.c.adminable == True))
    5151        else:
    52             return Machine.query().join('acl').select_by(user=self.username)
     52            return Machine.query().join('acl').filter_by(user=self.username)
    5353
    5454    machines = cachedproperty(getMachines)
Note: See TracChangeset for help on using the changeset viewer.