From 805a8364a6ce7295edb2bad37bd26e12e3dbecac Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Mon, 26 Oct 2009 14:35:09 +0000 Subject: [PATCH] Continuation of bug fixes and integration-related fixes. --- sfatables/runtime.py | 21 ++++++++++++++++++++- sfatables/xmlrule.py | 14 +++++--------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/sfatables/runtime.py b/sfatables/runtime.py index 1aac7731..8f5c323f 100644 --- a/sfatables/runtime.py +++ b/sfatables/runtime.py @@ -16,12 +16,28 @@ class SFATablesRules: self.active_context = {} self.contexts = None # placeholder for rspec_manger self.sorted_rule_list = [] + self.final_processor = '__sfatables_wrap_up__.xsl' chain_dir_path = os.path.join(sfatables_config,chain_name) rule_list = List().get_rule_list(chain_dir_path) for rule_number in rule_list: self.sorted_rule_list = self.sorted_rule_list + [XMLRule(chain_name, rule_number)] return + def wrap_up(self, doc): + filepath = os.path.join(sfatables_config, 'processors', self.final_processor) + + if not os.path.exists(filepath): + raise Exception('Could not find final rule filter') + + styledoc = libxml2.parseFile(filepath) + style = libxslt.parseStylesheetDoc(styledoc) + result = style.applyStylesheet(doc, None) + stylesheet_result = style.saveResultToString(result) + style.freeStylesheet() + doc.freeDoc() + result.freeDoc() + + return stylesheet_result def set_context(self, request_context): self.active_context = request_context @@ -79,11 +95,14 @@ class SFATablesRules: intermediate_rspec = doc for rule in self.sorted_rule_list: + import pdb + pdb.set_trace() intermediate_rspec = rule.apply_interpreted(intermediate_rspec) + intermediate_rspec = XMLRule().wrap_up(intermediate_rspec) if (rule.terminal): break - final_rspec = XMLRule().wrap_up(intermediate_rspec) + final_rspec = self.wrap_up(intermediate_rspec) return final_rspec def main(): diff --git a/sfatables/xmlrule.py b/sfatables/xmlrule.py index a72a480e..310c8439 100644 --- a/sfatables/xmlrule.py +++ b/sfatables/xmlrule.py @@ -35,20 +35,16 @@ class XMLRule: filepath = os.path.join(sfatables_config, 'processors', self.final_processor) if not os.path.exists(filepath): - # TODO: final_processor is not there yet - return doc#rspec + raise Exception('Could not find final rule filter') styledoc = libxml2.parseFile(filepath) style = libxslt.parseStylesheetDoc(styledoc) - #doc = libxml2.parseDoc(rspec) result = style.applyStylesheet(doc, None) - stylesheet_result = style.saveResultToString(result) + stylesheet_result = result#style.saveResultToString(result) style.freeStylesheet() - doc.freeDoc() - result.freeDoc() + #doc.freeDoc() + #result.freeDoc() - import pdb - pdb.set_trace() return stylesheet_result def match(self, rspec): @@ -113,7 +109,7 @@ class XMLRule: self.chain = None self.xmldoc = None self.terminal = 0 - self.final_processor = '__sfatables_wrap_up__.xsl' + self.final_processor = '__sfatables_rule_wrap_up__.xsl' self.arguments = {'match':None,'target':None} self.processors = {'match':None,'target':None} -- 2.43.0