entity.py
branchstable
changeset 6099 b22a4a3895df
parent 6098 a0fde9334dd0
child 6100 3cd1e6a74830
--- a/entity.py	Wed Aug 11 16:17:05 2010 +0200
+++ b/entity.py	Wed Aug 11 15:54:44 2010 +0200
@@ -51,6 +51,18 @@
                 return card
     return '1'
 
+def can_use_rest_path(value):
+    """return True if value can be used at the end of a Rest URL path"""
+    if value is None:
+        return False
+    value = unicode(value)
+    # the check for ?, /, & are to prevent problems when running
+    # behind Apache mod_proxy
+    if value == u'' or u'?' in value or u'/' in value or u'&' in value:
+        return False
+    return True
+
+
 
 class Entity(AppObject):
     """an entity instance has e_schema automagically set on
@@ -502,7 +514,7 @@
         path = etype.lower()
         if mainattr != 'eid':
             value = getattr(self, mainattr)
-            if value is None or unicode(value) == u'':
+            if not can_use_rest_path(value):
                 mainattr = 'eid'
                 path += '/eid'
             elif needcheck: