def Update(section, ctype): session = DBEngine.NewSession() try: config_file = session.query(t_section_config, t_section_config_files).\ filter(and_(t_section_config.section == section, t_section_config.ctype == ctype)).\ filter(t_section_config.excute == t_section_config_files.id).first() if config_file is None: Log.Write("[Error]GameConfig Error:No GameConfig Data") return None config_file_info = { "section": config_file[0].section, "ctype": config_file[0].ctype, "version": config_file[0].version, "excute": config_file[0].excute, "url": config_file[1].url, "filepath": config_file[1].filepath, "url2": config_file[1].url2, "url3": config_file[1].url3 } if not GameConfigManager._config_dict.has_key( config_file_info["section"]): GameConfigManager._config_dict[ config_file_info["section"]] = {} GameConfigManager._config_dict[config_file_info["section"]][ config_file[0].ctype] = config_file_info return config_file_info except NoResultFound, nf: Log.Write("[Error]Database Error: %s" % str(nf)) return None
def Init(): session = DBEngine.NewSession() try: resourceVersions = session.query(t_section_resource).\ filter(t_section_resource.status == "excute").\ order_by(t_section_resource.id.desc()).all() if resourceVersions is None: Log.Write("[Error]GameResource Error: No GameResource Excute") return False appConfig = ConfigManager.Singleton() GameResourceManager._resource_dict = {} for resourceVersion in resourceVersions: version = resourceVersion.id needrestart = resourceVersion.needrestart versionFiles = session.query(t_section_resource_files).filter(t_section_resource_files.r_id == version).all() if versionFiles is None: continue versionFilesData = [] for versionFile in versionFiles: versionFileData = { "version": version, "id": versionFile.id, "url": versionFile.url, "filepath": versionFile.filepath, "platform": versionFile.platform, "length": versionFile.length, "needrestart": needrestart, "url2": versionFile.url2, "url3": versionFile.url3, } versionFilesData.append(versionFileData) GameResourceManager._resource_dict[version] = versionFilesData # Log.Write("GameResourceManager", GameResourceManager._resource_dict) return True except NoResultFound, nf: Log.Write("[Error]Database Error: %s" % str(nf)) return False
def Init(): session = DBEngine.NewSession() try: config_files = session.query(t_section_config, t_section_config_files). \ filter(t_section_config.excute == t_section_config_files.id).all() if config_files is None: Log.Write("[Error]GameConfig Error: No GameConfig Data") return False GameConfigManager._config_dict = {} appConfig = ConfigManager.Singleton() for config_file in config_files: section = config_file[0].section config_file_info = { "section": section, "ctype": config_file[0].ctype, "version": config_file[0].version, "excute": config_file[0].excute, "url": config_file[1].url, "filepath": config_file[1].filepath, "url2": config_file[1].url2, "url3": config_file[1].url3 } # Log.Write(section, config_file_info) if not GameConfigManager._config_dict.has_key(section): GameConfigManager._config_dict[section] = {} GameConfigManager._config_dict[section][ config_file[0].ctype] = config_file_info # for k, v in GameConfigManager._config_dict.items(): # Log.Write("section", k) return True except NoResultFound, nf: Log.Write("[Error]Database Error: %s" % str(nf)) return False
def UpdateVersion(version): session = DBEngine.NewSession() try: versionFilesData = [] targetVersion = session.query(t_section_resource).filter(t_section_resource.id == version).\ filter(t_section_resource.status == "excute").first() if targetVersion: appConfig = ConfigManager.Singleton() # GameResourceManager._resource_dict = {} needrestart = targetVersion.needrestart versionFiles = session.query(t_section_resource_files). \ filter(t_section_resource_files.r_id == version).all() if versionFiles: for versionFile in versionFiles: versionFileData = { "version": version, "id": versionFile.id, "url": versionFile.url, "filepath": versionFile.filepath, "platform": versionFile.platform, "length": versionFile.length, "needrestart": needrestart, "url2": versionFile.url2, "url3": versionFile.url3, } versionFilesData.append(versionFileData) if not versionFilesData: if GameResourceManager._resource_dict.has_key(version): del GameResourceManager._resource_dict[version] else: GameResourceManager._resource_dict[version] = versionFilesData # Log.Write("GameResourceManager", GameResourceManager._resource_dict) return True except NoResultFound, nf: Log.Write("[Error]Database Error: %s" % str(nf)) return False
def My_load_scalar_attributes(mapper, state, attribute_names): session = sessionlib._state_session(state) if not session: DBEngine.NewSession()._save_or_update_state(state) return load_scalar_attributesOld(mapper, state, attribute_names)