src/snorlogue/filePathType

Source   Edit  

Implements the FilePath datatype to provide some way of dealing with Files

Types

FilePath = distinct string

A convenience type for norm models. To be used as type for model fields storing any sort of file. When a model with such a field is created, its file will automatically be stored in the in the configured MEDIA_ROOT directory. Any attempts to fetch that file will also assume that it is being stored in the MEDIA_ROOT directory.

This field can use the subdir pragma to store files in a sub directory within MEDIA_ROOT instead.

Source   Edit  

Procs

func `$`(x: FilePath): string {.borrow, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc add(x: var FilePath; s: FilePath) {....raises: [], tags: [], forbids: [].}
Appends the FilePath s to the FilePath x Source   Edit  
proc add(x: var FilePath; s: string) {....raises: [], tags: [], forbids: [].}
Appends the string s to the FilePath x Source   Edit  
func dbType(T: typedesc[FilePath]): string
Helper proc for norm to define which column-type to use for storing FilePath values. Source   Edit  
func dbValue(val: FilePath): DbValue {....raises: [], tags: [], forbids: [].}
Helper proc for norm to convert FilePath to DbValue. Source   Edit  
func to(dbVal: DbValue; T: typedesc[FilePath]): T:type
Helper proc for norm to convert DbValue to FilePath. Source   Edit  

Templates

template subdir(directory: string) {.pragma.}
A custom pragma for use with FilePath fields. Defines in which subdirectory of your MEDIA_ROOT folder the files of this field should be stored. Source   Edit