コード例 #1
0
ファイル: Django.py プロジェクト: ict-felix/stack
	def load(tableName, mappings, parser):
		Django.logger.info('Django.load')
		try:
			Table =  PolicyRuleTableModel.objects.get(name = tableName)
		# Translation of exceptions: Django -> PyPElib
		except ObjectDoesNotExist:
			raise ZeroPolicyObjectsReturned("[Django Driver] There is no table with name: " + tableName)
		except MultipleObjectsReturned:
			raise MultiplePolicyObjectsReturned("[Django Driver] There are multiple tables with name: " + tableName)
		except Exception as e:
			raise Exception("[Django Driver] Some error occurred when trying to fetch table table with name: " + tableName + ". Exception: " + str(e))

		ruleTable = RuleTable(Table.name,mappings,Table.defaultParser, Table.defaultPersistence,False, eval(Table.type), Table.uuid)
		ruleTable._ruleSet = Django.loadRuleSet(Table.uuid)
		ruleTable._persist = Table.defaultPersistenceFlag
		ruleTable._mappings = mappings
		ruleTable._resolver = Resolver(mappings)
		return ruleTable
コード例 #2
0
ファイル: SQLAlchemy.py プロジェクト: ict-felix/stack
	def load(tableName, mappings, parser):
		SQLAlchemy.logger.info('SQLAlchemy.load')
		try:
			Table =  DB_SESSION.query(PolicyRuleTableModel).filter(PolicyRuleTableModel.name == tableName).one()
		# Translation of exceptions: SQLAlchemy -> PyPElib
		except NoResultFound:
			raise ZeroPolicyObjectsReturned("[SQLAlchemy Driver] There is no table with name: " + tableName)
		except MultipleResultsFound:
			raise MultiplePolicyObjectsReturned("[SQLAlchemy Driver] There are multiple tables with name: " + tableName)
		except Exception as e:
			raise Exception("[SQLAlchemy Driver] Some error occurred when trying to fetch table table with name: " + tableName + ". Exception: " + str(e))

		ruleTable = RuleTable(Table.name,mappings,Table.defaultParser, Table.defaultPersistence,False, eval(Table.type), Table.uuid)
		ruleTable._ruleSet = SQLAlchemy.loadRuleSet(Table.uuid)
		ruleTable._persist = Table.defaultPersistenceFlag
		ruleTable._mappings = mappings
		ruleTable._resolver = Resolver(mappings)
		return ruleTable