svn keywords
[plcapi.git] / PLC / Slices.py
index 0e24f9c..aeb9f09 100644 (file)
@@ -1,4 +1,5 @@
 # $Id$
+# $URL$
 from types import StringTypes
 import time
 import re
@@ -48,6 +49,9 @@ class Slice(Row):
                        Parameter(str, "Fully qualified hostname"))]
        }
 
+    view_tags_name="view_slice_tags"
+    tags = {}
+
     def validate_name(self, name):
         # N.B.: Responsibility of the caller to ensure that login_base
         # portion of the slice name corresponds to a valid site, if
@@ -253,8 +257,15 @@ class Slices(Table):
     def __init__(self, api, slice_filter = None, columns = None, expires = int(time.time())):
         Table.__init__(self, api, Slice, columns)
 
-        sql = "SELECT %s FROM view_slices WHERE is_deleted IS False" % \
-              ", ".join(self.columns)
+        # the view that we're selecting upon: start with view_slices
+        view = "view_slices"
+        # as many left joins as requested tags
+        for tagname in self.tag_columns:
+            view= "%s left join %s using (%s)"%(view,Slice.tagvalue_view_name(tagname),
+                                                Slice.primary_key)
+            
+        sql = "SELECT %s FROM %s WHERE is_deleted IS False" % \
+              (", ".join(self.columns.keys()+self.tag_columns.keys()),view)
 
         if expires is not None:
             if expires >= 0: