Browse Source

rename all resource with Resource Suffixe to avoid trouble with multiple class with same name

Guénaël Muller 6 years ago
parent
commit
93bbf69e60
3 changed files with 93 additions and 89 deletions
  1. 12 12
      tracim/lib/webdav/dav_provider.py
  2. 72 68
      tracim/lib/webdav/resources.py
  3. 9 9
      tracim/tests/library/test_webdav.py

+ 12 - 12
tracim/lib/webdav/dav_provider.py View File

@@ -68,19 +68,19 @@ class Provider(DAVProvider):
68 68
         path = normpath(path)
69 69
         root_path = environ['http_authenticator.realm']
70 70
 
71
-        # If the requested path is the root, then we return a Root resource
71
+        # If the requested path is the root, then we return a RootResource resource
72 72
         if path == root_path:
73
-            return resources.Root(path, environ, user=user, session=session)
73
+            return resources.RootResource(path, environ, user=user, session=session)
74 74
 
75 75
         workspace_api = WorkspaceApi(current_user=user, session=session)
76 76
         workspace = self.get_workspace_from_path(path, workspace_api)
77 77
 
78
-        # If the request path is in the form root/name, then we return a Workspace resource
78
+        # If the request path is in the form root/name, then we return a WorkspaceResource resource
79 79
         parent_path = dirname(path)
80 80
         if parent_path == root_path:
81 81
             if not workspace:
82 82
                 return None
83
-            return resources.Workspace(
83
+            return resources.WorkspaceResource(
84 84
                 path=path,
85 85
                 environ=environ,
86 86
                 workspace=workspace,
@@ -107,10 +107,10 @@ class Provider(DAVProvider):
107 107
 
108 108
         # Easy cases : path either end with /.deleted, /.archived or /.history, then we return corresponding resources
109 109
         if path.endswith(SpecialFolderExtension.Archived) and self._show_archive:
110
-            return resources.ArchivedFolder(path, environ, workspace, content)
110
+            return resources.ArchivedFolderResource(path, environ, workspace, content)
111 111
 
112 112
         if path.endswith(SpecialFolderExtension.Deleted) and self._show_delete:
113
-            return resources.DeletedFolder(path, environ, workspace, content)
113
+            return resources.DeletedFolderResource(path, environ, workspace, content)
114 114
 
115 115
         if path.endswith(SpecialFolderExtension.History) and self._show_history:
116 116
             is_deleted_folder = re.search(r'/\.deleted/\.history$', path) is not None
@@ -120,13 +120,13 @@ class Provider(DAVProvider):
120 120
                 else HistoryType.Archived if is_archived_folder \
121 121
                 else HistoryType.Standard
122 122
 
123
-            return resources.HistoryFolder(path, environ, workspace, content, type)
123
+            return resources.HistoryFolderResource(path, environ, workspace, content, type)
124 124
 
125 125
         # Now that's more complicated, we're trying to find out if the path end with /.history/file_name
126 126
         is_history_file_folder = re.search(r'/\.history/([^/]+)$', path) is not None
127 127
 
128 128
         if is_history_file_folder and self._show_history:
129
-            return resources.HistoryFileFolder(
129
+            return resources.HistoryFileFolderResource(
130 130
                 path=path,
131 131
                 environ=environ,
132 132
                 content=content
@@ -143,7 +143,7 @@ class Provider(DAVProvider):
143 143
             content = self.get_content_from_revision(content_revision, content_api)
144 144
 
145 145
             if content.type == ContentType.File:
146
-                return resources.HistoryFile(path, environ, content, content_revision)
146
+                return resources.HistoryFileResource(path, environ, content, content_revision)
147 147
             else:
148 148
                 return resources.HistoryOtherFile(path, environ, content, content_revision)
149 149
 
@@ -153,7 +153,7 @@ class Provider(DAVProvider):
153 153
         if content is None:
154 154
             return None
155 155
         if content.type == ContentType.Folder:
156
-            return resources.Folder(
156
+            return resources.FolderResource(
157 157
                 path=path,
158 158
                 environ=environ,
159 159
                 workspace=content.workspace,
@@ -162,7 +162,7 @@ class Provider(DAVProvider):
162 162
                 user=user,
163 163
             )
164 164
         elif content.type == ContentType.File:
165
-            return resources.File(
165
+            return resources.FileResource(
166 166
                 path=path,
167 167
                 environ=environ,
168 168
                 content=content,
@@ -170,7 +170,7 @@ class Provider(DAVProvider):
170 170
                 user=user
171 171
             )
172 172
         else:
173
-            return resources.OtherFile(
173
+            return resources.OtherFileResource(
174 174
                 path=path,
175 175
                 environ=environ,
176 176
                 content=content,

+ 72 - 68
tracim/lib/webdav/resources.py View File

@@ -74,13 +74,13 @@ class ManageActions(object):
74 74
         transaction.commit()
75 75
 
76 76
 
77
-class Root(DAVCollection):
77
+class RootResource(DAVCollection):
78 78
     """
79
-    Root ressource that represents tracim's home, which contains all workspaces
79
+    RootResource ressource that represents tracim's home, which contains all workspaces
80 80
     """
81 81
 
82 82
     def __init__(self, path: str, environ: dict, user: User, session: Session):
83
-        super(Root, self).__init__(path, environ)
83
+        super(RootResource, self).__init__(path, environ)
84 84
 
85 85
         self.user = user
86 86
         self.session = session
@@ -94,7 +94,7 @@ class Root(DAVCollection):
94 94
         )
95 95
 
96 96
     def __repr__(self) -> str:
97
-        return '<DAVCollection: Root>'
97
+        return '<DAVCollection: RootResource>'
98 98
 
99 99
     def getMemberNames(self) -> [str]:
100 100
         """
@@ -114,7 +114,11 @@ class Root(DAVCollection):
114 114
             workspace = self.workspace_api.get_one_by_label(label)
115 115
             workspace_path = '%s%s%s' % (self.path, '' if self.path == '/' else '/', transform_to_display(workspace.label))
116 116
 
117
-            return Workspace(workspace_path, self.environ, workspace)
117
+            return WorkspaceResource(
118
+                workspace_path,
119
+                self.environ,
120
+                workspace,
121
+            )
118 122
         except AttributeError:
119 123
             return None
120 124
 
@@ -146,7 +150,7 @@ class Root(DAVCollection):
146 150
         self.path, '' if self.path == '/' else '/', transform_to_display(new_workspace.label))
147 151
 
148 152
         transaction.commit()
149
-        return Workspace(workspace_path, self.environ, new_workspace)
153
+        return WorkspaceResource(workspace_path, self.environ, new_workspace)
150 154
 
151 155
     def getMemberList(self):
152 156
         """
@@ -158,7 +162,7 @@ class Root(DAVCollection):
158 162
         for workspace in self.workspace_api.get_all():
159 163
             workspace_path = '%s%s%s' % (self.path, '' if self.path == '/' else '/', workspace.label)
160 164
             members.append(
161
-                Workspace(
165
+                WorkspaceResource(
162 166
                     path=workspace_path,
163 167
                     environ=self.environ,
164 168
                     workspace=workspace,
@@ -170,7 +174,7 @@ class Root(DAVCollection):
170 174
         return members
171 175
 
172 176
 
173
-class Workspace(DAVCollection):
177
+class WorkspaceResource(DAVCollection):
174 178
     """
175 179
     Workspace resource corresponding to tracim's workspaces.
176 180
     Direct children can only be folders, though files might come later on and are supported
@@ -183,7 +187,7 @@ class Workspace(DAVCollection):
183 187
                  user: User,
184 188
                  session: Session
185 189
     ) -> None:
186
-        super(Workspace, self).__init__(path, environ)
190
+        super(WorkspaceResource, self).__init__(path, environ)
187 191
 
188 192
         self.workspace = workspace
189 193
         self.content = None
@@ -263,7 +267,7 @@ class Workspace(DAVCollection):
263 267
             path=self.path + '/' + file_name
264 268
         )
265 269
 
266
-    def createCollection(self, label: str) -> 'Folder':
270
+    def createCollection(self, label: str) -> 'FolderResource':
267 271
         """
268 272
         Create a new folder for the current workspace. As it's not possible for the user to choose
269 273
         which types of content are allowed in this folder, we allow allow all of them.
@@ -293,13 +297,13 @@ class Workspace(DAVCollection):
293 297
 
294 298
         transaction.commit()
295 299
 
296
-        return Folder('%s/%s' % (self.path, transform_to_display(label)),
297
-                      self.environ,
298
-                      content=folder,
299
-                      session=self.session,
300
-                      user=self.user,
301
-                      workspace=self.workspace,
302
-                      )
300
+        return FolderResource('%s/%s' % (self.path, transform_to_display(label)),
301
+                              self.environ,
302
+                              content=folder,
303
+                              session=self.session,
304
+                              user=self.user,
305
+                              workspace=self.workspace,
306
+                              )
303 307
 
304 308
     def delete(self):
305 309
         """For now, it is not possible to delete a workspace through the webdav client."""
@@ -325,7 +329,7 @@ class Workspace(DAVCollection):
325 329
 
326 330
             if content.type == ContentType.Folder:
327 331
                 members.append(
328
-                    Folder(
332
+                    FolderResource(
329 333
                         path=content_path,
330 334
                         environ=self.environ,
331 335
                         workspace=self.workspace,
@@ -337,7 +341,7 @@ class Workspace(DAVCollection):
337 341
             elif content.type == ContentType.File:
338 342
                 self._file_count += 1
339 343
                 members.append(
340
-                    File(
344
+                    FileResource(
341 345
                         path=content_path,
342 346
                         environ=self.environ,
343 347
                         content=content,
@@ -348,7 +352,7 @@ class Workspace(DAVCollection):
348 352
             else:
349 353
                 self._file_count += 1
350 354
                 members.append(
351
-                    OtherFile(
355
+                    OtherFileResource(
352 356
                         content_path,
353 357
                         self.environ,
354 358
                         content,
@@ -358,7 +362,7 @@ class Workspace(DAVCollection):
358 362
 
359 363
         if self._file_count > 0 and self.provider.show_history():
360 364
             members.append(
361
-                HistoryFolder(
365
+                HistoryFolderResource(
362 366
                     path=self.path + '/' + ".history",
363 367
                     environ=self.environ,
364 368
                     content=self.content,
@@ -371,7 +375,7 @@ class Workspace(DAVCollection):
371 375
 
372 376
         if self.provider.show_delete():
373 377
             members.append(
374
-                DeletedFolder(
378
+                DeletedFolderResource(
375 379
                     path=self.path + '/' + ".deleted",
376 380
                     environ=self.environ,
377 381
                     content=self.content,
@@ -383,7 +387,7 @@ class Workspace(DAVCollection):
383 387
 
384 388
         if self.provider.show_archive():
385 389
             members.append(
386
-                ArchivedFolder(
390
+                ArchivedFolderResource(
387 391
                     path=self.path + '/' + ".archived",
388 392
                     environ=self.environ,
389 393
                     content=self.content,
@@ -396,9 +400,9 @@ class Workspace(DAVCollection):
396 400
         return members
397 401
 
398 402
 
399
-class Folder(Workspace):
403
+class FolderResource(WorkspaceResource):
400 404
     """
401
-    Folder resource corresponding to tracim's folders.
405
+    FolderResource resource corresponding to tracim's folders.
402 406
     Direct children can only be either folder, files, pages or threads
403 407
     By default when creating new folders, we allow them to contain all types of content
404 408
     """
@@ -412,7 +416,7 @@ class Folder(Workspace):
412 416
             user: User,
413 417
             session: Session
414 418
     ):
415
-        super(Folder, self).__init__(
419
+        super(FolderResource, self).__init__(
416 420
             path=path,
417 421
             environ=environ,
418 422
             workspace=workspace,
@@ -549,7 +553,7 @@ class Folder(Workspace):
549 553
             try:
550 554
                 if content.type == ContentType.Folder:
551 555
                     members.append(
552
-                        Folder(
556
+                        FolderResource(
553 557
                             path=content_path,
554 558
                             environ=self.environ,
555 559
                             workspace=self.workspace,
@@ -561,7 +565,7 @@ class Folder(Workspace):
561 565
                 elif content.type == ContentType.File:
562 566
                     self._file_count += 1
563 567
                     members.append(
564
-                        File(
568
+                        FileResource(
565 569
                             path=content_path,
566 570
                             environ=self.environ,
567 571
                             content=content,
@@ -571,7 +575,7 @@ class Folder(Workspace):
571 575
                 else:
572 576
                     self._file_count += 1
573 577
                     members.append(
574
-                        OtherFile(
578
+                        OtherFileResource(
575 579
                             path=content_path,
576 580
                             environ=self.environ,
577 581
                             content=content,
@@ -588,7 +592,7 @@ class Folder(Workspace):
588 592
 
589 593
         if self._file_count > 0 and self.provider.show_history():
590 594
             members.append(
591
-                HistoryFolder(
595
+                HistoryFolderResource(
592 596
                     path=self.path + '/' + ".history",
593 597
                     environ=self.environ,
594 598
                     content=self.content,
@@ -601,7 +605,7 @@ class Folder(Workspace):
601 605
 
602 606
         if self.provider.show_delete():
603 607
             members.append(
604
-                DeletedFolder(
608
+                DeletedFolderResource(
605 609
                     path=self.path + '/' + ".deleted",
606 610
                     environ=self.environ,
607 611
                     content=self.content,
@@ -613,7 +617,7 @@ class Folder(Workspace):
613 617
 
614 618
         if self.provider.show_archive():
615 619
             members.append(
616
-                ArchivedFolder(
620
+                ArchivedFolderResource(
617 621
                     path=self.path + '/' + ".archived",
618 622
                     environ=self.environ,
619 623
                     content=self.content,
@@ -629,7 +633,7 @@ class Folder(Workspace):
629 633
 # Those object are now not in used by tracim and also not tested,
630 634
 
631 635
 
632
-class HistoryFolder(Folder):
636
+class HistoryFolderResource(FolderResource):
633 637
     """
634 638
     A virtual resource which contains a sub-folder for every files (DAVNonCollection) contained in the parent
635 639
     folder
@@ -644,7 +648,7 @@ class HistoryFolder(Folder):
644 648
                  content: Content=None,
645 649
                  type: str=HistoryType.Standard
646 650
     ) -> None:
647
-        super(HistoryFolder, self).__init__(
651
+        super(HistoryFolderResource, self).__init__(
648 652
             path=path,
649 653
             environ=environ,
650 654
             workspace=workspace,
@@ -665,7 +669,7 @@ class HistoryFolder(Folder):
665 669
         )
666 670
 
667 671
     def __repr__(self) -> str:
668
-        return "<DAVCollection: HistoryFolder (%s)>" % self.content.file_name
672
+        return "<DAVCollection: HistoryFolderResource (%s)>" % self.content.file_name
669 673
 
670 674
     def getCreationDate(self) -> float:
671 675
         return mktime(datetime.now().timetuple())
@@ -682,7 +686,7 @@ class HistoryFolder(Folder):
682 686
             content_parent=self.content
683 687
         )
684 688
 
685
-        return HistoryFileFolder(
689
+        return HistoryFileFolderResource(
686 690
             path='%s/%s' % (self.path, content.get_label_as_file()),
687 691
             environ=self.environ,
688 692
             content=content,
@@ -731,7 +735,7 @@ class HistoryFolder(Folder):
731 735
         
732 736
         for content in children:
733 737
             if content.is_archived == self._is_archived and content.is_deleted == self._is_deleted:
734
-                members.append(HistoryFileFolder(
738
+                members.append(HistoryFileFolderResource(
735 739
                     path='%s/%s' % (self.path, content.get_label_as_file()),
736 740
                     environ=self.environ,
737 741
                     content=content,
@@ -742,7 +746,7 @@ class HistoryFolder(Folder):
742 746
         return members
743 747
 
744 748
 
745
-class DeletedFolder(HistoryFolder):
749
+class DeletedFolderResource(HistoryFolderResource):
746 750
     """
747 751
     A virtual resources which exists for every folder or workspaces which contains their deleted children
748 752
     """
@@ -756,7 +760,7 @@ class DeletedFolder(HistoryFolder):
756 760
             session: Session,
757 761
             content: Content=None
758 762
     ):
759
-        super(DeletedFolder, self).__init__(
763
+        super(DeletedFolderResource, self).__init__(
760 764
             path=path,
761 765
             environ=environ,
762 766
             workspace=workspace,
@@ -769,7 +773,7 @@ class DeletedFolder(HistoryFolder):
769 773
         self._file_count = 0
770 774
 
771 775
     def __repr__(self):
772
-        return "<DAVCollection: DeletedFolder (%s)" % self.content.file_name
776
+        return "<DAVCollection: DeletedFolderResource (%s)" % self.content.file_name
773 777
 
774 778
     def getCreationDate(self) -> float:
775 779
         return mktime(datetime.now().timetuple())
@@ -823,7 +827,7 @@ class DeletedFolder(HistoryFolder):
823 827
 
824 828
                 if content.type == ContentType.Folder:
825 829
                     members.append(
826
-                        Folder(
830
+                        FolderResource(
827 831
                             content_path,
828 832
                             self.environ,
829 833
                             self.workspace,
@@ -834,7 +838,7 @@ class DeletedFolder(HistoryFolder):
834 838
                 elif content.type == ContentType.File:
835 839
                     self._file_count += 1
836 840
                     members.append(
837
-                        File(
841
+                        FileResource(
838 842
                             content_path,
839 843
                             self.environ,
840 844
                             content,
@@ -845,7 +849,7 @@ class DeletedFolder(HistoryFolder):
845 849
                 else:
846 850
                     self._file_count += 1
847 851
                     members.append(
848
-                        OtherFile(
852
+                        OtherFileResource(
849 853
                             content_path,
850 854
                             self.environ,
851 855
                             content,
@@ -855,7 +859,7 @@ class DeletedFolder(HistoryFolder):
855 859
 
856 860
         if self._file_count > 0 and self.provider.show_history():
857 861
             members.append(
858
-                HistoryFolder(
862
+                HistoryFolderResource(
859 863
                     path=self.path + '/' + ".history",
860 864
                     environ=self.environ,
861 865
                     content=self.content,
@@ -869,7 +873,7 @@ class DeletedFolder(HistoryFolder):
869 873
         return members
870 874
 
871 875
 
872
-class ArchivedFolder(HistoryFolder):
876
+class ArchivedFolderResource(HistoryFolderResource):
873 877
     """
874 878
     A virtual resources which exists for every folder or workspaces which contains their archived children
875 879
     """
@@ -882,7 +886,7 @@ class ArchivedFolder(HistoryFolder):
882 886
             session: Session,
883 887
             content: Content=None
884 888
     ):
885
-        super(ArchivedFolder, self).__init__(
889
+        super(ArchivedFolderResource, self).__init__(
886 890
             path=path,
887 891
             environ=environ,
888 892
             workspace=workspace,
@@ -895,7 +899,7 @@ class ArchivedFolder(HistoryFolder):
895 899
         self._file_count = 0
896 900
 
897 901
     def __repr__(self) -> str:
898
-        return "<DAVCollection: ArchivedFolder (%s)" % self.content.file_name
902
+        return "<DAVCollection: ArchivedFolderResource (%s)" % self.content.file_name
899 903
 
900 904
     def getCreationDate(self) -> float:
901 905
         return mktime(datetime.now().timetuple())
@@ -944,7 +948,7 @@ class ArchivedFolder(HistoryFolder):
944 948
 
945 949
                 if content.type == ContentType.Folder:
946 950
                     members.append(
947
-                        Folder(
951
+                        FolderResource(
948 952
                             content_path,
949 953
                             self.environ,
950 954
                             self.workspace,
@@ -955,7 +959,7 @@ class ArchivedFolder(HistoryFolder):
955 959
                 elif content.type == ContentType.File:
956 960
                     self._file_count += 1
957 961
                     members.append(
958
-                        File(
962
+                        FileResource(
959 963
                             content_path,
960 964
                             self.environ,
961 965
                             content,
@@ -965,7 +969,7 @@ class ArchivedFolder(HistoryFolder):
965 969
                 else:
966 970
                     self._file_count += 1
967 971
                     members.append(
968
-                        OtherFile(
972
+                        OtherFileResource(
969 973
                             content_path,
970 974
                             self.environ,
971 975
                             content,
@@ -975,7 +979,7 @@ class ArchivedFolder(HistoryFolder):
975 979
 
976 980
         if self._file_count > 0 and self.provider.show_history():
977 981
             members.append(
978
-                HistoryFolder(
982
+                HistoryFolderResource(
979 983
                     path=self.path + '/' + ".history",
980 984
                     environ=self.environ,
981 985
                     content=self.content,
@@ -989,7 +993,7 @@ class ArchivedFolder(HistoryFolder):
989 993
         return members
990 994
 
991 995
 
992
-class HistoryFileFolder(HistoryFolder):
996
+class HistoryFileFolderResource(HistoryFolderResource):
993 997
     """
994 998
     A virtual resource that contains for a given content (file/page/thread) all its revisions
995 999
     """
@@ -1002,7 +1006,7 @@ class HistoryFileFolder(HistoryFolder):
1002 1006
             user: User,
1003 1007
             session: Session
1004 1008
     ) -> None:
1005
-        super(HistoryFileFolder, self).__init__(
1009
+        super(HistoryFileFolderResource, self).__init__(
1006 1010
             path=path,
1007 1011
             environ=environ,
1008 1012
             workspace=content.workspace,
@@ -1013,7 +1017,7 @@ class HistoryFileFolder(HistoryFolder):
1013 1017
         )
1014 1018
 
1015 1019
     def __repr__(self) -> str:
1016
-        return "<DAVCollection: HistoryFileFolder (%s)" % self.content.file_name
1020
+        return "<DAVCollection: HistoryFileFolderResource (%s)" % self.content.file_name
1017 1021
 
1018 1022
     def getDisplayName(self) -> str:
1019 1023
         return self.content.get_label_as_file()
@@ -1040,7 +1044,7 @@ class HistoryFileFolder(HistoryFolder):
1040 1044
         left_side = '%s/(%d - %s) ' % (self.path, revision.revision_id, revision.revision_type)
1041 1045
 
1042 1046
         if self.content.type == ContentType.File:
1043
-            return HistoryFile(
1047
+            return HistoryFileResource(
1044 1048
                 path='%s%s' % (left_side, transform_to_display(revision.file_name)),
1045 1049
                 environ=self.environ,
1046 1050
                 content=self.content,
@@ -1066,7 +1070,7 @@ class HistoryFileFolder(HistoryFolder):
1066 1070
             left_side = '%s/(%d - %s) ' % (self.path, content.revision_id, content.revision_type)
1067 1071
 
1068 1072
             if self.content.type == ContentType.File:
1069
-                members.append(HistoryFile(
1073
+                members.append(HistoryFileResource(
1070 1074
                     path='%s%s' % (left_side, transform_to_display(content.file_name)),
1071 1075
                     environ=self.environ,
1072 1076
                     content=self.content,
@@ -1089,9 +1093,9 @@ class HistoryFileFolder(HistoryFolder):
1089 1093
         return members
1090 1094
 
1091 1095
 
1092
-class File(DAVNonCollection):
1096
+class FileResource(DAVNonCollection):
1093 1097
     """
1094
-    File resource corresponding to tracim's files
1098
+    FileResource resource corresponding to tracim's files
1095 1099
     """
1096 1100
     def __init__(
1097 1101
             self,
@@ -1101,7 +1105,7 @@ class File(DAVNonCollection):
1101 1105
             user: User,
1102 1106
             session: Session,
1103 1107
     ) -> None:
1104
-        super(File, self).__init__(path, environ)
1108
+        super(FileResource, self).__init__(path, environ)
1105 1109
 
1106 1110
         self.content = content
1107 1111
         self.user = user
@@ -1117,7 +1121,7 @@ class File(DAVNonCollection):
1117 1121
         # self.setPropertyValue('Win32FileAttributes', '00000021')
1118 1122
 
1119 1123
     def __repr__(self) -> str:
1120
-        return "<DAVNonCollection: File (%d)>" % self.content.revision_id
1124
+        return "<DAVNonCollection: FileResource (%d)>" % self.content.revision_id
1121 1125
 
1122 1126
     def getContentLength(self) -> int:
1123 1127
         return self.content.depot_file.file.content_length
@@ -1331,16 +1335,16 @@ class File(DAVNonCollection):
1331 1335
         ).action()
1332 1336
 
1333 1337
 
1334
-class HistoryFile(File):
1338
+class HistoryFileResource(FileResource):
1335 1339
     """
1336 1340
     A virtual resource corresponding to a specific tracim's revision's file
1337 1341
     """
1338 1342
     def __init__(self, path: str, environ: dict, content: Content, user: User, session: Session, content_revision: ContentRevisionRO):
1339
-        super(HistoryFile, self).__init__(path, environ, content, user=user, session=session)
1343
+        super(HistoryFileResource, self).__init__(path, environ, content, user=user, session=session)
1340 1344
         self.content_revision = content_revision
1341 1345
 
1342 1346
     def __repr__(self) -> str:
1343
-        return "<DAVNonCollection: HistoryFile (%s-%s)" % (self.content.content_id, self.content.file_name)
1347
+        return "<DAVNonCollection: HistoryFileResource (%s-%s)" % (self.content.content_id, self.content.file_name)
1344 1348
 
1345 1349
     def getDisplayName(self) -> str:
1346 1350
         left_side = '(%d - %s) ' % (self.content_revision.revision_id, self.content_revision.revision_type)
@@ -1369,12 +1373,12 @@ class HistoryFile(File):
1369 1373
         raise DAVError(HTTP_FORBIDDEN)
1370 1374
 
1371 1375
 
1372
-class OtherFile(File):
1376
+class OtherFileResource(FileResource):
1373 1377
     """
1374
-    File resource corresponding to tracim's page and thread
1378
+    FileResource resource corresponding to tracim's page and thread
1375 1379
     """
1376 1380
     def __init__(self, path: str, environ: dict, content: Content, user:User, session: Session):
1377
-        super(OtherFile, self).__init__(path, environ, content, user=user, session=session)
1381
+        super(OtherFileResource, self).__init__(path, environ, content, user=user, session=session)
1378 1382
 
1379 1383
         self.content_revision = self.content.revision
1380 1384
 
@@ -1393,7 +1397,7 @@ class OtherFile(File):
1393 1397
         return self.path
1394 1398
 
1395 1399
     def __repr__(self) -> str:
1396
-        return "<DAVNonCollection: OtherFile (%s)" % self.content.file_name
1400
+        return "<DAVNonCollection: OtherFileResource (%s)" % self.content.file_name
1397 1401
 
1398 1402
     def getContentLength(self) -> int:
1399 1403
         return len(self.content_designed)
@@ -1419,7 +1423,7 @@ class OtherFile(File):
1419 1423
             )
1420 1424
 
1421 1425
 
1422
-class HistoryOtherFile(OtherFile):
1426
+class HistoryOtherFile(OtherFileResource):
1423 1427
     """
1424 1428
     A virtual resource corresponding to a specific tracim's revision's page and thread
1425 1429
     """

+ 9 - 9
tracim/tests/library/test_webdav.py View File

@@ -8,7 +8,7 @@ from tracim.lib.core.user import UserApi
8 8
 from tracim.tests import eq_
9 9
 from tracim.lib.core.notifications import DummyNotifier
10 10
 from tracim.lib.webdav.dav_provider import Provider
11
-from tracim.lib.webdav.resources import Root
11
+from tracim.lib.webdav.resources import RootResource
12 12
 from tracim.models import Content
13 13
 from tracim.models import ContentRevisionRO
14 14
 from tracim.tests import StandardTest
@@ -88,8 +88,8 @@ class TestWebDav(StandardTest):
88 88
                 'bob@fsf.local',
89 89
             )
90 90
         )
91
-        assert root, 'Path / should return a Root instance'
92
-        assert isinstance(root, Root)
91
+        assert root, 'Path / should return a RootResource instance'
92
+        assert isinstance(root, RootResource)
93 93
 
94 94
     def test_unit__list_workspaces_with_user__ok(self):
95 95
         provider = self._get_provider(self.app_config)
@@ -100,14 +100,14 @@ class TestWebDav(StandardTest):
100 100
                 'bob@fsf.local',
101 101
             )
102 102
         )
103
-        assert root, 'Path / should return a Root instance'
104
-        assert isinstance(root, Root), 'Path / should return a Root instance'
103
+        assert root, 'Path / should return a RootResource instance'
104
+        assert isinstance(root, RootResource), 'Path / should return a RootResource instance'
105 105
 
106 106
         children = root.getMemberList()
107 107
         eq_(
108 108
             2,
109 109
             len(children),
110
-            msg='Root should return 2 workspaces instead {0}'.format(
110
+            msg='RootResource should return 2 workspaces instead {0}'.format(
111 111
                 len(children),
112 112
             )
113 113
         )
@@ -130,14 +130,14 @@ class TestWebDav(StandardTest):
130 130
                 'admin@admin.admin',
131 131
             )
132 132
         )
133
-        assert root, 'Path / should return a Root instance'
134
-        assert isinstance(root, Root), 'Path / should return a Root instance'
133
+        assert root, 'Path / should return a RootResource instance'
134
+        assert isinstance(root, RootResource), 'Path / should return a RootResource instance'
135 135
 
136 136
         children = root.getMemberList()
137 137
         eq_(
138 138
             2,
139 139
             len(children),
140
-            msg='Root should return 2 workspaces instead {0}'.format(
140
+            msg='RootResource should return 2 workspaces instead {0}'.format(
141 141
                 len(children),
142 142
             )
143 143
         )