Changeset 2706 for package_branches


Ignore:
Timestamp:
Dec 20, 2009, 9:46:40 PM (14 years ago)
Author:
broder
Message:

fix super-long lines

File:
1 edited

Legend:

Unmodified
Added
Removed
  • package_branches/invirt-web/cherrypy-rebased/code/main.py

    r2705 r2706  
    200200
    201201    def parseCreate(self, fields):
    202         kws = dict([(kw, fields.get(kw)) for kw in 'name description owner memory disksize vmtype cdrom autoinstall'.split() if fields.get(kw)])
    203         validate = validation.Validate(cherrypy.request.login, cherrypy.request.state, strict=True, **kws)
    204         return dict(contact=cherrypy.request.login, name=validate.name, description=validate.description, memory=validate.memory,
    205                     disksize=validate.disksize, owner=validate.owner, machine_type=getattr(validate, 'vmtype', Defaults.type),
     202        kws = dict([(kw, fields.get(kw)) for kw in
     203         'name description owner memory disksize vmtype cdrom autoinstall'.split()
     204                    if fields.get(kw)])
     205        validate = validation.Validate(cherrypy.request.login,
     206                                       cherrypy.request.state,
     207                                       strict=True, **kws)
     208        return dict(contact=cherrypy.request.login, name=validate.name,
     209                    description=validate.description, memory=validate.memory,
     210                    disksize=validate.disksize, owner=validate.owner,
     211                    machine_type=getattr(validate, 'vmtype', Defaults.type),
    206212                    cdrom=getattr(validate, 'cdrom', None),
    207213                    autoinstall=getattr(validate, 'autoinstall', None))
     
    214220        try:
    215221            parsed_fields = self.parseCreate(fields)
    216             machine = controls.createVm(cherrypy.request.login, cherrypy.request.state, **parsed_fields)
     222            machine = controls.createVm(cherrypy.request.login,
     223                                        cherrypy.request.state, **parsed_fields)
    217224        except InvalidInput, err:
    218225            pass
     
    258265        def info(self, machine_id):
    259266            """Handler for info on a single VM."""
    260             machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
     267            machine = validation.Validate(cherrypy.request.login,
     268                                          cherrypy.request.state,
     269                                          machine_id=machine_id).machine
    261270            d = infoDict(cherrypy.request.login, cherrypy.request.state, machine)
    262271            checkpoint.checkpoint('Got infodict')
     
    270279            """Handler for modifying attributes of a machine."""
    271280            try:
    272                 modify_dict = modifyDict(cherrypy.request.login, cherrypy.request.state, machine_id, fields)
     281                modify_dict = modifyDict(cherrypy.request.login,
     282                                         cherrypy.request.state,
     283                                         machine_id, fields)
    273284            except InvalidInput, err:
    274285                result = None
    275                 machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
     286                machine = validation.Validate(cherrypy.request.login,
     287                                              cherrypy.request.state,
     288                                              machine_id=machine_id).machine
    276289            else:
    277290                machine = modify_dict['machine']
    278291                result = 'Success!'
    279292                err = None
    280             info_dict = infoDict(cherrypy.request.login, cherrypy.request.state, machine)
     293            info_dict = infoDict(cherrypy.request.login,
     294                                 cherrypy.request.state, machine)
    281295            info_dict['err'] = err
    282296            if err:
     
    308322            echo 1 > /proc/sys/net/ipv4/ip_forward
    309323            """
    310             machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
    311 
     324            machine = validation.Validate(cherrypy.request.login,
     325                                          cherrypy.request.state,
     326                                          machine_id=machine_id).machine
    312327            token = controls.vnctoken(machine)
    313328            host = controls.listHost(machine)
     
    334349            back = kwargs.get('back', None)
    335350            try:
    336                 d = controls.commandResult(cherrypy.request.login, cherrypy.request.state, command_name, machine_id, kwargs)
     351                d = controls.commandResult(cherrypy.request.login,
     352                                           cherrypy.request.state,
     353                                           command_name, machine_id, kwargs)
    337354                if d['command'] == 'Delete VM':
    338355                    back = 'list'
     
    348365            if back == 'list':
    349366                cherrypy.request.state.clear() #Changed global state
    350                 raise cherrypy.InternalRedirect('/list?result=%s' % urllib.quote(result))
     367                raise cherrypy.InternalRedirect('/list?result=%s'
     368                                                % urllib.quote(result))
    351369            elif back == 'info':
    352                 raise cherrypy.HTTPRedirect(cherrypy.request.base + '/machine/%d/' % machine_id, status=303)
     370                raise cherrypy.HTTPRedirect(cherrypy.request.base
     371                                            + '/machine/%d/' % machine_id,
     372                                            status=303)
    353373            else:
    354374                raise InvalidInput('back', back, 'Not a known back page.')
     
    508528    session.begin()
    509529    try:
    510         kws = dict([(kw, fields.get(kw)) for kw in 'owner admin contact name description memory vmtype disksize'.split() if fields.get(kw)])
     530        kws = dict([(kw, fields.get(kw)) for kw in
     531         'owner admin contact name description memory vmtype disksize'.split()
     532                    if fields.get(kw)])
    511533        kws['machine_id'] = machine_id
    512534        validate = validation.Validate(username, state, **kws)
Note: See TracChangeset for help on using the changeset viewer.