PaferaPy Async 0.1
ASGI framework focused on simplicity and efficiency
|
Represents a webpage in the system. More...
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... | |
![]() | |
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 | |
![]() | |
d | |
dbaccess | |
dbacl | |
dbaclid | |
dbgroup | |
dbowner | |
id | |
Additional Inherited Members | |
![]() | |
list | SECURE_FIELDS |
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.
def system.page.system_page.__init__ | ( | self | ) |
Initialize all fields at creation like a good programmer should.
Reimplemented from pafera.modelbase.ModelBase.
def system.page.system_page.Render | ( | self, | |
g | |||
) |
def system.page.system_page.RenderCSS | ( | self, | |
url | |||
) |
def system.page.system_page.RenderJS | ( | self, | |
url | |||
) |