Ignore:
Timestamp:
Oct 29, 2009, 1:36:41 AM (14 years ago)
Author:
price
Message:

fix super-long lines

File:
1 edited

Legend:

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

    r2524 r2525  
    205205
    206206    def parseCreate(self, fields):
    207         kws = dict([(kw, fields.get(kw)) for kw in 'name description owner memory disksize vmtype cdrom autoinstall'.split() if fields.get(kw)])
    208         validate = validation.Validate(cherrypy.request.login, cherrypy.request.state, strict=True, **kws)
    209         return dict(contact=cherrypy.request.login, name=validate.name, description=validate.description, memory=validate.memory,
    210                     disksize=validate.disksize, owner=validate.owner, machine_type=getattr(validate, 'vmtype', Defaults.type),
     207        kws = dict([(kw, fields.get(kw)) for kw in
     208         'name description owner memory disksize vmtype cdrom autoinstall'.split()
     209                    if fields.get(kw)])
     210        validate = validation.Validate(cherrypy.request.login,
     211                                       cherrypy.request.state,
     212                                       strict=True, **kws)
     213        return dict(contact=cherrypy.request.login, name=validate.name,
     214                    description=validate.description, memory=validate.memory,
     215                    disksize=validate.disksize, owner=validate.owner,
     216                    machine_type=getattr(validate, 'vmtype', Defaults.type),
    211217                    cdrom=getattr(validate, 'cdrom', None),
    212218                    autoinstall=getattr(validate, 'autoinstall', None))
     
    219225        try:
    220226            parsed_fields = self.parseCreate(fields)
    221             machine = controls.createVm(cherrypy.request.login, cherrypy.request.state, **parsed_fields)
     227            machine = controls.createVm(cherrypy.request.login,
     228                                        cherrypy.request.state, **parsed_fields)
    222229        except InvalidInput, err:
    223230            pass
     
    263270        def info(self, machine_id):
    264271            """Handler for info on a single VM."""
    265             machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
     272            machine = validation.Validate(cherrypy.request.login,
     273                                          cherrypy.request.state,
     274                                          machine_id=machine_id).machine
    266275            d = infoDict(cherrypy.request.login, cherrypy.request.state, machine)
    267276            checkpoint.checkpoint('Got infodict')
     
    275284            """Handler for modifying attributes of a machine."""
    276285            try:
    277                 modify_dict = modifyDict(cherrypy.request.login, cherrypy.request.state, machine_id, fields)
     286                modify_dict = modifyDict(cherrypy.request.login,
     287                                         cherrypy.request.state,
     288                                         machine_id, fields)
    278289            except InvalidInput, err:
    279290                result = None
    280                 machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
     291                machine = validation.Validate(cherrypy.request.login,
     292                                              cherrypy.request.state,
     293                                              machine_id=machine_id).machine
    281294            else:
    282295                machine = modify_dict['machine']
    283296                result = 'Success!'
    284297                err = None
    285             info_dict = infoDict(cherrypy.request.login, cherrypy.request.state, machine)
     298            info_dict = infoDict(cherrypy.request.login,
     299                                 cherrypy.request.state, machine)
    286300            info_dict['err'] = err
    287301            if err:
     
    313327            echo 1 > /proc/sys/net/ipv4/ip_forward
    314328            """
    315             machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine
    316 
     329            machine = validation.Validate(cherrypy.request.login,
     330                                          cherrypy.request.state,
     331                                          machine_id=machine_id).machine
    317332            token = controls.vnctoken(machine)
    318333            host = controls.listHost(machine)
     
    339354            back = kwargs.get('back', None)
    340355            try:
    341                 d = controls.commandResult(cherrypy.request.login, cherrypy.request.state, command_name, machine_id, kwargs)
     356                d = controls.commandResult(cherrypy.request.login,
     357                                           cherrypy.request.state,
     358                                           command_name, machine_id, kwargs)
    342359                if d['command'] == 'Delete VM':
    343360                    back = 'list'
     
    353370            if back == 'list':
    354371                cherrypy.request.state.clear() #Changed global state
    355                 raise cherrypy.InternalRedirect('/list?result=%s' % urllib.quote(result))
     372                raise cherrypy.InternalRedirect('/list?result=%s'
     373                                                % urllib.quote(result))
    356374            elif back == 'info':
    357                 raise cherrypy.HTTPRedirect(cherrypy.request.base + '/machine/%d/' % machine_id, status=303)
     375                raise cherrypy.HTTPRedirect(cherrypy.request.base
     376                                            + '/machine/%d/' % machine_id,
     377                                            status=303)
    358378            else:
    359379                raise InvalidInput('back', back, 'Not a known back page.')
     
    562582    session.begin()
    563583    try:
    564         kws = dict([(kw, fields.get(kw)) for kw in 'owner admin contact name description memory vmtype disksize'.split() if fields.get(kw)])
     584        kws = dict([(kw, fields.get(kw)) for kw in
     585         'owner admin contact name description memory vmtype disksize'.split()
     586                    if fields.get(kw)])
    565587        kws['machine_id'] = machine_id
    566588        validate = validation.Validate(username, state, **kws)
Note: See TracChangeset for help on using the changeset viewer.