diff --git a/src/caosdb/common/models.py b/src/caosdb/common/models.py index 9c420c8cae75171e0b233f2fd23f87dc2fa61367..00ea33b60826d6cd1e12ceafcec4b303f75842f9 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,39 @@ 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 path 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): + """ + + def __init__(self, name=None, id=None, description=None, # @ReservedAssignment + 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 +1404,9 @@ class File(Record): self.pickup = pickup + if not from_location is None: + warn(DeprecationWarning( + "Param `from_location` is deprecated, use `pickup instead`.")) if self.pickup is None: self.pickup = from_location