PaferaPy Async 0.1
ASGI framework focused on simplicity and efficiency
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
system.file.system_file Class Reference

Class for managing all uploaded files. More...

Inheritance diagram for system.file.system_file:
pafera.modelbase.ModelBase

Public Member Functions

def __init__ (self)
 Initialize all fields at creation like a good programmer should. More...
 
def FullPath (self)
 Returns the filesystem path for this file. More...
 
def MakeThumbnail (self, thumbsize='256')
 Creates or updates a thumbnail if needed. More...
 
def Process (self, g)
 Analyzes the file and inserts it into the system registry, or update any changed files. More...
 
def ThumbnailFile (self)
 Returns the filesystem path for an appropiate thumbnail. More...
 
def ThumbnailURL (self)
 Returns a URL to display the thumbnail image. More...
 
- Public Member Functions inherited from pafera.modelbase.ModelBase
def __cmp__ (self, o)
 Comparing means simply subracting the database ids. More...
 
def __eq__ (self, o)
 Two objects are equivalent if their models are the same and their IDs are the same. More...
 
def __hash__ (self)
 We take the easy route where the hash for an object is just its database ID. More...
 
def __init__ (self)
 Initialize all fields at creation like a good programmer should. More...
 
def __repr__ (self)
 Simply outputs the toJSON() function with the model name. More...
 
def __str__ (self)
 Simply calls the toJSON() function. More...
 
def CheckPassword (self, field, password)
 This special function checks to see if the password matches the hash stored in the field. More...
 
def GetACL (self, db)
 Since we store ACLs as a database lookup, be sure to use these getters and setters if you plan on using ACLs. More...
 
def HasSameValues (self, o)
 While operator = only checks class and ids, this checks every field to see if two objects or an object and a dict have the same values. More...
 
def OffsetTime (self, timeoffset)
 Change all datetime fields to the new time offset. More...
 
def Set (self, **kwargs)
 We use this method instead of direct attribute access in order to keep track of what values have been changed. More...
 
def SetAccess (self, access)
 Special security functions that are useful only if you have enabled security in _dbflags for the model. More...
 
def SetACL (self, db, acl)
 ACLs in Pafera are defined as a set of rules similar to cascading style sheets. More...
 
def SetGroup (self, groupid)
 Special security functions that are useful only if you have enabled security in _dbflags for the model. More...
 
def SetOwner (self, ownerid)
 Special security functions that are useful only if you have enabled security in _dbflags for the model. More...
 
def SetPassword (self, field, password)
 This special function hashes the password before saving the field. More...
 
def ToJSON (self, fields='')
 Converts this object into a format suitable for inclusion in JSON. More...
 
def UpdateFields (self, fieldnames)
 This is a convenience method to update fields without going through the Set() method. More...
 

Public Attributes

 filetype
 
 fullpath
 
 modified
 
 size
 
- Public Attributes inherited from pafera.modelbase.ModelBase
 d
 
 dbaccess
 
 dbacl
 
 dbaclid
 
 dbgroup
 
 dbowner
 
 id
 

Static Public Attributes

dictionary TYPES
 
- Static Public Attributes inherited from pafera.modelbase.ModelBase
list SECURE_FIELDS
 

Detailed Description

Class for managing all uploaded files.

This is a system-wide repository for user uploaded files that allows easy search and discovery while retaining security and ease of management. Files can be made searchable, requires a direct link to access, or locked down to the point where a timed access token is needed to access the file.

For efficiency, all uploaded images are converted to the webp format, audio to mp3, and video to h264 MP4s. If you don't want this behavior, modify the system/upload handler in system/__init__.py

Definition at line 37 of file file.py.

Constructor & Destructor Documentation

◆ __init__()

def system.file.system_file.__init__ (   self)

Initialize all fields at creation like a good programmer should.

Reimplemented from pafera.modelbase.ModelBase.

Definition at line 92 of file file.py.

Member Function Documentation

◆ FullPath()

def system.file.system_file.FullPath (   self)

Returns the filesystem path for this file.

Definition at line 98 of file file.py.

◆ MakeThumbnail()

def system.file.system_file.MakeThumbnail (   self,
  thumbsize = '256' 
)

Creates or updates a thumbnail if needed.

The default thumbnail size is 256x256, but if you are working with 
high resolution screens, feel free to use 512x512 or higher. 

You'll need to install imagemagick, ffmpeg, and ffmpegthumbnailer
to use this functionality.

Definition at line 366 of file file.py.

◆ Process()

def system.file.system_file.Process (   self,
  g 
)

Analyzes the file and inserts it into the system registry, or update any changed files.

Definition at line 158 of file file.py.

◆ ThumbnailFile()

def system.file.system_file.ThumbnailFile (   self)

Returns the filesystem path for an appropiate thumbnail.

Definition at line 113 of file file.py.

◆ ThumbnailURL()

def system.file.system_file.ThumbnailURL (   self)

Returns a URL to display the thumbnail image.

Definition at line 149 of file file.py.

Member Data Documentation

◆ filetype

system.file.system_file.filetype

Definition at line 121 of file file.py.

◆ fullpath

system.file.system_file.fullpath

Definition at line 95 of file file.py.

◆ modified

system.file.system_file.modified

Definition at line 172 of file file.py.

◆ size

system.file.system_file.size

Definition at line 172 of file file.py.

◆ TYPES

dictionary system.file.system_file.TYPES
static
Initial value:
= {
'document': 1,
'image': 2,
'sound': 3,
'video': 4,
'archive': 5,
'program': 6,
'spreadsheet': 7,
'presentation': 8,
'book': 9,
'text': 10,
'disk image': 11,
'webpage': 12,
'source code': 13,
'deleted': 126,
'other': 127,
}

Definition at line 73 of file file.py.


The documentation for this class was generated from the following file: