Exemple #1
0
### populate records ###########################################################
import datetime
if db(table_content.created_on<request.now-datetime.timedelta(minutes=60)).count():
    table_content.truncate()
    table_file.truncate()
    session.flash = 'the database has been refreshed'
    redirect(managed_html.edit_url('page1'))

### fake authentication ########################################################

from gluon.storage import Storage
session.auth = Storage(hmac_key='test', user=Storage(email='*****@*****.**'))

### demo functions #############################################################

managed_html.switch_mode()
    
def index():
    return dict(page1=A('page1', _href=managed_html.edit_url('page1')),
                page2=A('page2', _href=managed_html.edit_url('page2')))
    
def page1():
    response.view = 'plugin_managed_html/page1.html'
    return dict(managed_html=managed_html, URL=managed_html.url, ORIGINAL_URL=URL)
                
def page2():
    response.view = 'plugin_managed_html/page2.html'
    return dict(managed_html=managed_html, URL=managed_html.url, ORIGINAL_URL=URL)
    
    
def download():
        
### populate records ###########################################################
import datetime
if db(table_content.created_on < request.now - datetime.timedelta(minutes=60)).count():
    table_content.truncate()
    table_file.truncate()
    session.flash = 'the database has been refreshed'
    redirect(URL('index'))

### fake authentication ########################################################

session.auth = Storage(hmac_key='test', user=Storage(email='*****@*****.**'))

### demo functions #############################################################

managed_html.switch_mode()


def index():
    return dict(page1=A('page1', _href=URL('page1', args=EDIT_MODE)),
                page2=A('page2', _href=URL('page2', args=EDIT_MODE)))


def page1():
    response.view = 'plugin_managed_html/page1.html'
    return dict(managed_html=managed_html, URL=managed_html.url, ORIGINAL_URL=URL)

        
def page2():
    response.view = 'plugin_managed_html/page2.html'
    return dict(managed_html=managed_html, URL=managed_html.url, ORIGINAL_URL=URL)