@@ -305,19 +305,38 @@ def store(self, model, message):
305
305
raise StorageException ('Cannot save a model without a UUID set.' )
306
306
307
307
# ensure the directory exists
308
- file_name = os .path .join (
308
+ file_path = os .path .join (
309
309
self .repo .working_dir , self .git_name (model ))
310
- dir_name = os .path .dirname (file_name )
310
+
311
+ return self .store_data (
312
+ file_path , self .serializer .serialize (model ), message )
313
+
314
+ def store_data (self , file_path , data , message ):
315
+ """
316
+ Store some data in a file
317
+
318
+ :param str file_path:
319
+ Where to store the file.
320
+ :param obj data:
321
+ The data to write in the file.
322
+ :param str message:
323
+ The commit mesasge.
324
+ :returns:
325
+ The commit
326
+ """
327
+
328
+ # ensure the directory exists
329
+ dir_name = os .path .dirname (file_path )
311
330
if not (os .path .isdir (dir_name )):
312
331
os .makedirs (dir_name )
313
332
314
- with open (file_name , 'w' ) as fp :
333
+ with open (file_path , 'w' ) as fp :
315
334
# write the object data
316
- self . serializer . serialize ( model , fp )
335
+ fp . write ( data )
317
336
318
337
# add to the git index
319
338
index = self .repo .index
320
- index .add ([file_name ])
339
+ index .add ([file_path ])
321
340
return index .commit (message )
322
341
323
342
def delete (self , model , message ):
0 commit comments