diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index bfa93ae099b10f41c704d87de9b3d65b8238d432..1a600e05bbda957429931f5886e04ace32f025be 100644 --- a/src/caosdb/common/models.py +++ b/src/caosdb/common/models.py @@ -36,6 +36,7 @@ from os.path import isdir from random import randint from sys import hexversion from tempfile import NamedTemporaryFile +from warnings import warn from lxml import etree @@ -1360,26 +1361,40 @@ class Record(Entity): class File(Record): - """This class represents caosdb's file entities.""" + """This class represents CaosDB's file entities. - # @ReservedAssignment - ''' - @param name: A name for this file record (That's an entity name - not to be misunderstood for the last segment of the files path). - @param from_location: A file's/folder's location on the file system of the server (server will copy that file into it's file system). - @param pickup: A file/folder in the DropOffBox (the server will mv that file into it's file system). - @param description: A description for this file record. - @param file: A local path or python file object. - @param properties: A list of properties for this file record. - @param thumbnail: A thumbnail which is to be shown by the webui. + For inserting a new file to the server, `path` gives the new location, and + (exactly?) one of `file` and `pickup` should (must?) be given to specify the + source of the file. + + Symlinking from the "extroot" file system is not supported by this API yet, + it can be done manually using the `InsertFilesInDir` flag. For sample code, + look at `test_files.py` in the Python integration tests of the + `load_files.py` script in the advanced user tools. + + @param name: A name for this file record (That's an entity name - not to be + confused with the last segment of the files path). @param id: An ID. - ''' + @param description: A description for this file record. + @param path: The complete path, including the file name, of the file in the + server's "caosroot" file system. + @param file: A local path or python file object. The file designated by + this argument will be uploaded to the server via HTTP. + @param pickup: A file/folder in the DropOffBox (the server will move that + file into its "caosroot" file system). + @param thumbnail: (Local) filename to a thumbnail for this file. + @param properties: A list of properties for this file record. @todo is this + implemented? + @param from_location: Deprecated, use `pickup` instead. + + """ def __init__(self, name=None, id=None, description=None, # @ReservedAssignment - datatype=None, path=None, file=None, # @ReservedAssignment - pickup=None, thumbnail=None, from_location=None): + path=None, file=None, pickup=None, # @ReservedAssignment + thumbnail=None, from_location=None): Record.__init__(self, id=id, name=name, description=description) self.role = "File" - self.datatype = datatype + self.datatype = None # location in the fileserver self.path = path @@ -1390,6 +1405,9 @@ class File(Record): self.pickup = pickup + if from_location is not None: + warn(DeprecationWarning( + "Param `from_location` is deprecated, use `pickup instead`.")) if self.pickup is None: self.pickup = from_location @@ -2514,12 +2532,13 @@ class Container(list): sync_remote_entities = [] for remote_entity in remote_container: - if remote_entity.name is not None \ - and (str(remote_entity.name) == str(local_entity.name) or - (name_case_sensitive is False and - str(remote_entity.name).lower() == str( - local_entity.name).lower())) \ - and remote_entity not in used_remote_entities: + if (remote_entity.name is not None + and (str(remote_entity.name) == str(local_entity.name) + or + (name_case_sensitive is False and + str(remote_entity.name).lower() == str( + local_entity.name).lower())) + and remote_entity not in used_remote_entities): sync_remote_entities.append(remote_entity) used_remote_entities.append(remote_entity)