I’ve defined a new Column type called File, which should let me store only the file name in the database. Then I would store the actual file in the file system at root+subfolder+name.
File(root, subfolder="", max_length=100, **kwargs)
The problem I’m having is that I’d like to define the root in a PasteDeploy config file. How do I define this at runtime so I can access the configuration?
To me this sounds like your schema needs some more thought. Even if you implement a custom column type, that type still has to be mapped into SQL column types that your engine supports. For folder and filename, this is most naturally two
varcharcolumns. So why not just use two fields,pathandfilename, both of typeString(256)in your class?As for the configurable root, this sounds like you want to specify the
pathrelative to this root, so that you can change it only in one place. Having most of your configuration in the database, except for one thing which is stored in a config file, to me is a code smell. I would consider it preferable over that to have the root be a column in some other configuration table, and use aForeignKeyto refer to the root that way.