Exemple #1
0
    def POST(self):
        x = web.input(agedata={})
        agebits = {}
        try:
            description = x['description']
            shortname = x['shortname']
            fullname = x['fullname']
            agefile = x['agedata'].file
            gamever = x['gameversion']
            agever = x['version']
        except KeyError:
            raise common.MissingParam()

        # Confirm that the zip file looks like a real age     
        plasma_utils.validate_zip(agefile, shortname)

        if not age_name_re.match(shortname):
            raise common.BadParam('shortname')
        if not age_fullname_re.match(fullname):
            raise common.BadParam('fullname')
        if not gamever in config.acceptable_game_versions:
            raise common.BadParam('gameversion')
        new_id = agedb.createAge(shortname=shortname, fullname=fullname, description=description, creator=userdb.ctx.uid)
        # Now that we have an age, we need to stash the file
        fileid = agedb.createFile(age=new_id, gamever=gamever, version=agever, status='NEW')
        filename = config.agefiles_path+str(fileid)+'.zip'
        out = open(filename, 'wb')
        agefile.seek(0)
        out.write(agefile.read())
        out.close()
        plasma_utils.update_seqprefix(filename, new_id)
        raise web.redirect(config.ages_path+'/'+str(new_id));
Exemple #2
0
 def POST(self, ageid):
     creator = agedb.ageCreator(ageid)
     if userdb.ctx.uid != creator:
         raise web.Forbidden()
     x = web.input(agedata={})
     agebits = {}
     try:
         agefile = x['agedata'].file
         gamever = x['gameversion']
         agever = x['version']
     except KeyError:
         raise common.MissingParam()
     # Confirm that the zip file looks like a real age     
     plasma_utils.validate_zip(agefile, shortname, ageid)
     if not gamever in config.acceptable_game_versions:
         raise common.BadParam('gameversion')
     fileid = agedb.createFile(age=new_id, gamever=gamever, version=agever, status='NEW')
     filename = config.agefiles_path+str(fileid)+'.zip'
     out = open(filename, 'wb')
     agefile.seek(0)
     out.write(agefile.read())
     out.close()
     raise web.redirect(config.ages_path+'/'+str(ageid));