本文整理汇总了Python中MVC.MVC类的典型用法代码示例。如果您正苦于以下问题:Python MVC类的具体用法?Python MVC怎么用?Python MVC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MVC类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prowl_alerts
def prowl_alerts( self, message ):
UserModel = MVC.loadModel( 'User' )
users = UserModel.getUsersWithMeta( 'prowl-apikey' )
Prowl = MVC.loadDriver('Prowl')
for user in users:
Prowl.send( user['meta']['prowl-apikey'], message[0], message[1], 1 )
# End File: models/ModelAlert.py
示例2: index
def index( self ):
ModelArticles = MVC.loadModel('Articles')
ModelArticlesSources = MVC.loadModel('ArticlesSources')
data = {
'articles' : ModelArticles.getAll(),
'sources' : ModelArticlesSources.getAll()
}
return self.Renderer.build( 'admin/articles/index.html', data )
示例3: info
def info( self, user_id = False ):
UserModel = MVC.loadModel( 'User' )
ACL = MVC.loadHelper( 'ACL' )
data = {}
if user_id != False:
data['user'] = UserModel.getById( user_id )
data['roles'] = ACL.getAllRoles()
return self.Renderer.make( 'admin/user/info.html', data )
else:
return 'error'
示例4: settings
def settings( self, *boom ):
UsersModel = MVC.loadModel('User')
Settings = MVC.loadHelper( 'Settings' )
#Settings.update( 'url', 'http://www.somewhere.com' )
tpl_args = {
'users' : UsersModel.getAll(),
'settings' : Settings.get_options()
}
view = env.get_template('settings/index.html')
return view.render( d = tpl_args )
示例5: acl_perm_update
def acl_perm_update( self, **kwargs ):
if kwargs:
ACL = MVC.loadHelper( 'ACL' )
if kwargs['perm_id'] == '':
Misc = MVC.loadHelper( 'Misc' )
perm_id = ACL.createPerm( Misc.slug( kwargs['perm_name'] ), kwargs['perm_name'] )[0]
if kwargs['role_id'] != '':
ACL.createRolePerm( kwargs['role_id'], perm_id )
raise cherrypy.HTTPRedirect( '/admin/user_acl/' )
# End File: controllers/admin/ControllerAdminUser.py
示例6: getLoadLevel
def getLoadLevel( self, article, hide = True, load_level = 'light' ):
if load_level == 'full':
ModelArticlesSources = MVC.loadModel('ArticlesSources')
article['source'] = ModelArticlesSources.getByID( article['source_id'] )
article['meta'] = self.getMeta( article['id'] )
if article['meta']:
if 'assoc_company' in article['meta']:
ModelCompany = MVC.loadModel('Company')
article['meta']['companies'] = []
for c_id in article['meta']['assoc_company']['value']:
article['meta']['companies'].append( ModelCompany.getByID( c_id, hide ) )
return article
示例7: info
def info( self, company_id = None ):
if company_id:
ModelCompany = MVC.loadModel('Company')
# ModelCompanyNews = MVC.loadModel('CompanyNews')
company = ModelCompany.getByID( company_id, 'full', hide = False )
if not company:
raise cherrypy.HTTPRedirect( '/admin/error/?e="cantfindcompany"' )
ModelArticles = MVC.loadModel('Articles')
data = {
'company' : company,
'articles' : ModelArticles.getByCompany( company_id )
}
return self.Renderer.build( 'admin/companies/info.html', data )
else:
raise cherrypy.HTTPRedirect( '/admin/error/?e="cantfindcompany"' )
示例8: dashboard
def dashboard( self ):
Weather = MVC.loadModel('Weather')
tpl_args = {
'weather_indoor' : Weather.get_current()
}
view = env.get_template('index.html')
return view.render( d = tpl_args )
示例9: meta_create
def meta_create( self, **kwargs ):
if kwargs:
User = MVC.loadModel('User')
help_text = ''
parent = ''
User.addMeta( kwargs['user_id'], kwargs['meta_key'], kwargs['meta_value'], kwargs['pretty_name'], help_text, parent )
raise cherrypy.HTTPRedirect( '/admin/user/info/%s' % kwargs['user_id'] )
示例10: index
def index( self ):
"""
Main home page.
"""
Company = MVC.loadModel( 'Company' )
SimpleStats = MVC.loadModel( 'SimpleStats' )
data = {
'random_company' : Company.getRandom(),
'stats' : {
'company_count' : SimpleStats.countOfCompanies(),
'people_count' : SimpleStats.countOfPeople(),
'article_count' : SimpleStats.countOfArticles(),
'sources_count' : SimpleStats.countOfArticlesSources()
}
}
return self.Renderer.build( 'frontend/index.html', data )
示例11: chart_water_temp
def chart_water_temp( self ):
WaterModel = MVC.loadModel('Water')
tpl_args = {
'water_stats' : WaterModel.get_stats( )
}
view = env.get_template('water/chart-temp.html')
return view.render( d = tpl_args )
示例12: update
def update( self, **kwargs ):
Settings = MVC.loadHelper( 'Settings')
if kwargs['meta_id'] == '':
Settings.create( kwargs['meta_key'], kwargs['meta_value'] )
else:
Settings.update( kwargs['meta_key'], kwargs['meta_value'] )
raise cherrypy.HTTPRedirect( '/admin/settings' )
示例13: people
def people( self ):
"""
Roster page of people
"""
PeopleModel = MVC.loadModel('People')
data = { 'people' : PeopleModel.getAll() }
return self.Renderer.build( 'frontend/people.html' )
示例14: chart_humidity
def chart_humidity( self ):
Weather = MVC.loadModel('Weather')
tpl_args = {
'weather_stats' : Weather.get_stats( )
}
view = env.get_template('weather/chart-humidity.html')
return view.render( d = tpl_args )
示例15: sensor_sht1x
def sensor_sht1x():
global verbose
if verbose:
print 'SHTX Sensor'
GPIO = MVC.loadDriver( 'GPIO' )
reading = GPIO.read_sht1x()
return reading