Browse Source

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

Guénaël Muller 7 years ago
parent
commit
93bbf69e60

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

68
         path = normpath(path)
68
         path = normpath(path)
69
         root_path = environ['http_authenticator.realm']
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
         if path == root_path:
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
         workspace_api = WorkspaceApi(current_user=user, session=session)
75
         workspace_api = WorkspaceApi(current_user=user, session=session)
76
         workspace = self.get_workspace_from_path(path, workspace_api)
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
         parent_path = dirname(path)
79
         parent_path = dirname(path)
80
         if parent_path == root_path:
80
         if parent_path == root_path:
81
             if not workspace:
81
             if not workspace:
82
                 return None
82
                 return None
83
-            return resources.Workspace(
83
+            return resources.WorkspaceResource(
84
                 path=path,
84
                 path=path,
85
                 environ=environ,
85
                 environ=environ,
86
                 workspace=workspace,
86
                 workspace=workspace,
107
 
107
 
108
         # Easy cases : path either end with /.deleted, /.archived or /.history, then we return corresponding resources
108
         # Easy cases : path either end with /.deleted, /.archived or /.history, then we return corresponding resources
109
         if path.endswith(SpecialFolderExtension.Archived) and self._show_archive:
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
         if path.endswith(SpecialFolderExtension.Deleted) and self._show_delete:
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
         if path.endswith(SpecialFolderExtension.History) and self._show_history:
115
         if path.endswith(SpecialFolderExtension.History) and self._show_history:
116
             is_deleted_folder = re.search(r'/\.deleted/\.history$', path) is not None
116
             is_deleted_folder = re.search(r'/\.deleted/\.history$', path) is not None
120
                 else HistoryType.Archived if is_archived_folder \
120
                 else HistoryType.Archived if is_archived_folder \
121
                 else HistoryType.Standard
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
         # Now that's more complicated, we're trying to find out if the path end with /.history/file_name
125
         # Now that's more complicated, we're trying to find out if the path end with /.history/file_name
126
         is_history_file_folder = re.search(r'/\.history/([^/]+)$', path) is not None
126
         is_history_file_folder = re.search(r'/\.history/([^/]+)$', path) is not None
127
 
127
 
128
         if is_history_file_folder and self._show_history:
128
         if is_history_file_folder and self._show_history:
129
-            return resources.HistoryFileFolder(
129
+            return resources.HistoryFileFolderResource(
130
                 path=path,
130
                 path=path,
131
                 environ=environ,
131
                 environ=environ,
132
                 content=content
132
                 content=content
143
             content = self.get_content_from_revision(content_revision, content_api)
143
             content = self.get_content_from_revision(content_revision, content_api)
144
 
144
 
145
             if content.type == ContentType.File:
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
             else:
147
             else:
148
                 return resources.HistoryOtherFile(path, environ, content, content_revision)
148
                 return resources.HistoryOtherFile(path, environ, content, content_revision)
149
 
149
 
153
         if content is None:
153
         if content is None:
154
             return None
154
             return None
155
         if content.type == ContentType.Folder:
155
         if content.type == ContentType.Folder:
156
-            return resources.Folder(
156
+            return resources.FolderResource(
157
                 path=path,
157
                 path=path,
158
                 environ=environ,
158
                 environ=environ,
159
                 workspace=content.workspace,
159
                 workspace=content.workspace,
162
                 user=user,
162
                 user=user,
163
             )
163
             )
164
         elif content.type == ContentType.File:
164
         elif content.type == ContentType.File:
165
-            return resources.File(
165
+            return resources.FileResource(
166
                 path=path,
166
                 path=path,
167
                 environ=environ,
167
                 environ=environ,
168
                 content=content,
168
                 content=content,
170
                 user=user
170
                 user=user
171
             )
171
             )
172
         else:
172
         else:
173
-            return resources.OtherFile(
173
+            return resources.OtherFileResource(
174
                 path=path,
174
                 path=path,
175
                 environ=environ,
175
                 environ=environ,
176
                 content=content,
176
                 content=content,

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

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