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

Represents a webpage in the system. More...

Inheritance diagram for system.page.system_page:
pafera.modelbase.ModelBase

Public Member Functions

def __init__ (self)
 Initialize all fields at creation like a good programmer should. More...
 
def Render (self, g)
 Returns a string containing the full HTML of the page. More...
 
def RenderCSS (self, url)
 Converts a stylesheet URL into the full link tag. More...
 
def RenderJS (self, url)
 Converts a stylesheet URL into the full script tag. 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

 cssfiles
 
 jsfiles
 
- Public Attributes inherited from pafera.modelbase.ModelBase
 d
 
 dbaccess
 
 dbacl
 
 dbaclid
 
 dbgroup
 
 dbowner
 
 id
 

Additional Inherited Members

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

Detailed Description

Represents a webpage in the system.

Note that database pages can contain a variety of page fragments in addition to different languages, so they are quite versatile in what they can do.

requiredgroups are a list of group names that are needed to view the page.

headerid, contentid, and the rest are used to load page fragments into various sections.

path is the URL for the page such as /index.html

pyfile is the module and name of a python function which will be called with the global object g and add content to the page by returning a string.

template is the template file used to create the page. It's unused as of now since we only use one standard template.

jsfiles is a list of URLs to load JavaScript files. They can be local or remote. Note that the system will automatically load a JavaScript file of the same path and name. Thus, if you create a page at /newapp/testing.html, the system will try to find and load /newapp/testing.js without you having to do anything.

cssfiles is the same but for CSS files.

translations are system translation files to automatically load for use in the page. They will also be available to any JavaScript files included in the system.

title, content, and markdown are all translation fields, meaning that you can have completely separate content for each language at the same URL. markdown text will be automatically converted by the Python markdown library and stored in content.

contentfunc is pure python code run in the context of the page.Render() function and passed to the exec() function. Yes, I'm quite aware of the dangers of dynamic code evaluation, but honestly, if you have someone running around randomly inserting code into your database, you already have much bigger problems than a page function. Look at the entry for /logout.html to see a simple and convenient use of this field.

wallpaper is the URL to a file which will automatically fill the background of the page. It's a quick way to give different pages distinctive feels.

flags can contain PAGE_DONT_CACHE, which is self-explanatory, and PAGE_LOAD_HOOKS. Hooks are JavaScript files with the same name as this page in other apps which can add functionality to this app's pages. See /system/manageusers.html for an example of this.

Definition at line 83 of file page.py.

Constructor & Destructor Documentation

◆ __init__()

def system.page.system_page.__init__ (   self)

Initialize all fields at creation like a good programmer should.

Reimplemented from pafera.modelbase.ModelBase.

Definition at line 445 of file page.py.

Member Function Documentation

◆ Render()

def system.page.system_page.Render (   self,
  g 
)

Returns a string containing the full HTML of the page.

Definition at line 466 of file page.py.

◆ RenderCSS()

def system.page.system_page.RenderCSS (   self,
  url 
)

Converts a stylesheet URL into the full link tag.

Definition at line 449 of file page.py.

◆ RenderJS()

def system.page.system_page.RenderJS (   self,
  url 
)

Converts a stylesheet URL into the full script tag.

Definition at line 459 of file page.py.

Member Data Documentation

◆ cssfiles

system.page.system_page.cssfiles

Definition at line 473 of file page.py.

◆ jsfiles

system.page.system_page.jsfiles

Definition at line 470 of file page.py.


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