@@ -238,7 +238,8 @@ def __init__(self, client, db):
238238 protocol = 'http'
239239 host = self .client .env ['HTTP_HOST' ]
240240 tracker = self .client .env ['TRACKER_NAME' ]
241- self .base_path = '%s://%s/%s/rest/' % (protocol , host , tracker )
241+ self .base_path = '%s://%s/%s/rest' % (protocol , host , tracker )
242+ self .data_path = self .base_path + '/data'
242243
243244 def props_from_args (self , cl , args , itemid = None ):
244245 """Construct a list of properties from the given arguments,
@@ -393,7 +394,7 @@ def get_collection(self, class_name, input):
393394 raise Unauthorised ('Permission to view %s denied' % class_name )
394395
395396 class_obj = self .db .getclass (class_name )
396- class_path = self .base_path + class_name
397+ class_path = '%s/%s/' % ( self .data_path , class_name )
397398
398399 # Handle filtering and pagination
399400 filter_props = {}
@@ -494,7 +495,7 @@ def get_element(self, class_name, item_id, input):
494495 result = {
495496 'id' : item_id ,
496497 'type' : class_name ,
497- 'link' : self .base_path + class_name + item_id ,
498+ 'link' : '%s/%s/%s' % ( self .data_path , class_name , item_id ) ,
498499 'attributes' : dict (result )
499500 }
500501
@@ -537,8 +538,8 @@ def get_attribute(self, class_name, item_id, attr_name, input):
537538 result = {
538539 'id' : item_id ,
539540 'type' : type (data ),
540- 'link' : "%s%s %s/%s" %
541- (self .base_path , class_name , item_id , attr_name ),
541+ 'link' : "%s/%s/ %s/%s" %
542+ (self .data_path , class_name , item_id , attr_name ),
542543 'data' : data
543544 }
544545
@@ -597,7 +598,7 @@ def post_collection(self, class_name, input):
597598 raise UsageError ("Must provide the %s property." % msg )
598599
599600 # set the header Location
600- link = self .base_path + class_name + item_id
601+ link = '%s/%s/%s' % ( self .data_path , class_name , item_id )
601602 self .client .setHeader ("Location" , link )
602603
603604 # set the response body
@@ -650,7 +651,7 @@ def put_element(self, class_name, item_id, input):
650651 result = {
651652 'id' : item_id ,
652653 'type' : class_name ,
653- 'link' : self .base_path + class_name + item_id ,
654+ 'link' : '%s/%s/%s' % ( self .data_path , class_name , item_id ) ,
654655 'attribute' : result
655656 }
656657 return 200 , result
@@ -701,7 +702,7 @@ def put_attribute(self, class_name, item_id, attr_name, input):
701702 result = {
702703 'id' : item_id ,
703704 'type' : class_name ,
704- 'link' : self .base_path + class_name + item_id ,
705+ 'link' : '%s/%s/%s' % ( self .data_path , class_name , item_id ) ,
705706 'attribute' : result
706707 }
707708
@@ -885,7 +886,7 @@ def patch_element(self, class_name, item_id, input):
885886 result = {
886887 'id' : item_id ,
887888 'type' : class_name ,
888- 'link' : self .base_path + class_name + item_id ,
889+ 'link' : '%s/%s/%s' % ( self .data_path , class_name , item_id ) ,
889890 'result' : result
890891 }
891892 else :
@@ -914,7 +915,7 @@ def patch_element(self, class_name, item_id, input):
914915 result = {
915916 'id' : item_id ,
916917 'type' : class_name ,
917- 'link' : self .base_path + class_name + item_id ,
918+ 'link' : '%s/%s/%s' % ( self .data_path , class_name , item_id ) ,
918919 'attribute' : result
919920 }
920921 return 200 , result
@@ -980,7 +981,7 @@ def patch_attribute(self, class_name, item_id, attr_name, input):
980981 result = {
981982 'id' : item_id ,
982983 'type' : class_name ,
983- 'link' : self .base_path + class_name + item_id ,
984+ 'link' : '%s/%s/%s' % ( self .data_path , class_name , item_id ) ,
984985 'attribute' : result
985986 }
986987 return 200 , result
0 commit comments