@@ -428,7 +428,10 @@ def _validate(self, *args, **kwargs):
428428
429429 name = self .name
430430
431- # FIXME: Why is the PathField an ordered dict?
431+ # Why is the PathField an ordered dict?
432+ # Ans: The reason why the PathField use an ordered dict is because
433+ # for the FileTextField, the key is used as the path to the file and
434+ # the value is used as the context of the file
432435 # dict of normalized paths to a location or None
433436 paths = OrderedDict ()
434437
@@ -692,7 +695,7 @@ class About(object):
692695 about_resource_path_attr = 'about_resource_path'
693696
694697 # Required fields
695- required_fields = [ABOUT_FILE_PATH_ATTR , 'name' ]
698+ required_fields = ['name' ]
696699
697700 def get_required_fields (self ):
698701 return [f for f in self .fields if f .required ]
@@ -1137,7 +1140,7 @@ def get_field_names(abouts):
11371140 in any object, including custom fields.
11381141 """
11391142 fields = []
1140- fields .append (About .ABOUT_FILE_PATH_ATTR )
1143+ # fields.append(About.ABOUT_FILE_PATH_ATTR)
11411144
11421145 standard_fields = About ().fields .keys ()
11431146 standards = []
@@ -1179,10 +1182,17 @@ def about_object_to_list_of_dictionary(abouts):
11791182 for about in abouts :
11801183 # TODO: this wholeblock should be under sd_dict()
11811184 ad = about .as_dict ()
1185+ # Update the 'about_resource' field with the relative path
1186+ # from the output location
11821187 if 'about_file_path' in ad .keys ():
11831188 afp = ad ['about_file_path' ]
1184- afp = '/' + afp if not afp .startswith ('/' ) else afp
1185- ad ['about_file_path' ] = afp
1189+ afp_parent = posixpath .dirname (afp )
1190+ afp_parent = '/' + afp_parent if not afp_parent .startswith ('/' ) else afp_parent
1191+ about_resource = ad ['about_resource' ]
1192+ for resource in about_resource :
1193+ updated_about_resource = posixpath .join (afp_parent , resource )
1194+ ad ['about_resource' ] = OrderedDict ([(updated_about_resource , None )])
1195+ del ad ['about_file_path' ]
11861196 serialized .append (ad )
11871197 return serialized
11881198
0 commit comments