Commits

Anonymous committed 4cdea3a

Fixed ticket #70

Comments (0)

Files changed (2)

     # Try successive objects... (and also keep the remaining object list)
     objCache = {}
     isFirst = True
+    isSecond = False
     isDefault = False
     foundIt = False
     virtualPathList = []
     while objectPathList:
-        candidate = getObjFromPath(objectPathList, objCache)
-        if callable(candidate) and getattr(candidate, 'exposed', False):
-            foundIt = True
-            break
+        if isFirst or isSecond:
+            # Only try this for a.b.index() or a.b()
+            candidate = getObjFromPath(objectPathList, objCache)
+            if callable(candidate) and getattr(candidate, 'exposed', False):
+                foundIt = True
+                break
         # Couldn't find the object: pop one from the list and try "default"
         lastObj = objectPathList.pop()
         if not isFirst:
                 isDefault = True
                 break
             objectPathList.pop() # Remove "default"
-        isFirst = False
+        if isSecond:
+            isSecond = False
+        if isFirst:
+            isFirst = False
+            isSecond = True
 
     # Check results of traversal
     if not foundIt:

test/testObjectMapping.py

 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 """
 
-# TODO: Have a real object mapping test once the object mapping -> URI
-#   algorithm is finalized
-
 import helper
 
 code = """
     def other(self):
         return "other"
     other.exposed = True
+    def extra(self, *p):
+        return repr(p)
+    extra.exposed = True
     def notExposed(self):
         return "not exposed"
 class Dir1:
     ("/", "cpg.response.body == 'world'"),
     ("/dir1/myMethod", '''cpg.response.body == "myMethod from dir1, object Path is:'/dir1/myMethod'"'''),
     ("/this/method/does/not/exist", '''cpg.response.body == "default:('this', 'method', 'does', 'not', 'exist')"'''),
+    ("/extra/too/much", '''cpg.response.body == "default:('extra', 'too', 'much')"'''),
     ("/other", "cpg.response.body == 'other'"),
     ("/notExposed", '''cpg.response.body == "default:('notExposed',)"'''),
     ("/dir1/dir2/", "cpg.response.body == 'index for dir2, path is:/dir1/dir2/'"),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.