add podlfe (performant one-dimensional list filler), prepare Locations and Tags for...
authorStephan Reichholf <sreichholf@users.schwerkraft.elitedvb.net>
Thu, 23 Apr 2009 17:15:11 +0000 (17:15 +0000)
committerStephan Reichholf <sreichholf@users.schwerkraft.elitedvb.net>
Thu, 23 Apr 2009 17:15:11 +0000 (17:15 +0000)
webinterface/src/WebComponents/Sources/LocationsAndTags.py
webinterface/src/webif.py

index 0df9151..160ae39 100644 (file)
@@ -40,8 +40,7 @@ class LocationsAndTags(Source):
                return tags
 
        def getText(self):
-               self.handleCommand(None)
-               print self.result
+               self.handleCommand(None)                
                lst = self.result
                xml = "<e2simplexmllist>\n"
                if self.result:
@@ -50,4 +49,13 @@ class LocationsAndTags(Source):
                xml += "</e2simplexmllist>\n"
                return xml
 
+       def getList(self):
+               self.handleCommand(None)
+               list = self.result
+               if list is None:
+                       list = []
+               
+               return list
+
        text = property(getText)
+       list = property(getList)
\ No newline at end of file
index d0d7944..41bf4b8 100644 (file)
@@ -419,6 +419,51 @@ class JavascriptUpdate(Converter):
                #                all other will replace this in JS
                return '<script>parent.set("%s", "%s");</script>\n'%(id, self.source.text.replace("\\", "\\\\").replace("\n", "\\n").replace('"', '\\"').replace('\xb0', '&deg;'))
 
+# the performant 'one-dimensonial listfiller' engine (podlfe)
+class SimpleListFiller(Converter):
+       def __init__(self, arg):
+               Converter.__init__(self, arg)
+               
+       def getText(self):
+               l = self.source.list
+               conv_args = self.converter_arguments
+               print "[webif.py] conv_args: " %conv_args
+               
+               list = [ ]
+               for element in conv_args:
+                       if isinstance(element, basestring):
+                               list.append((element, None))
+                       elif isinstance(element, ListItem):
+                               list.append((element, element.filternum))
+                       elif isinstance(element, ListMacroItem):
+                               list.append(element.macrodict[element.macroname], None)
+                       else:
+                               raise Exception("neither string, ListItem nor ListMacroItem")
+                       
+               strlist = [ ]
+               append = strlist.append
+               for item in l:
+                       for (element, filternum) in list:
+                               if not filternum:
+                                       append(element)
+                               elif filternum == 2:
+                                       append(str(item).replace("\\", "\\\\").replace("\n", "\\n").replace('"', '\\"'))
+                               elif filternum == 3:
+                                       append(escape_xml(str(item)))
+                               elif filternum == 4:
+                                       append(str(item).replace("%", "%25").replace("+", "%2B").replace('&', '%26').replace('?', '%3f').replace(' ', '+'))
+                               elif filternum == 5:
+                                       append(quote(str(item)))
+                               else:
+                                       append(str(item))
+               # (this will be done in c++ later!)
+
+               return ''.join(strlist)
+
+       text = property(getText)
+               
+                               
+
 # the performant 'listfiller'-engine (plfe)
 class ListFiller(Converter):
        def __init__(self, arg):