本文整理匯總了Python中Session.Session.getState方法的典型用法代碼示例。如果您正苦於以下問題:Python Session.getState方法的具體用法?Python Session.getState怎麽用?Python Session.getState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Session.Session
的用法示例。
在下文中一共展示了Session.getState方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: MasterController
# 需要導入模塊: from Session import Session [as 別名]
# 或者: from Session.Session import getState [as 別名]
class MasterController(object):
#import header and footer
HEADER = open("header.html", "r").read()
FOOTER = open("footer.html", "r").read()
URL_BASE = '/~kou/3132GroupProject'
_session = None
def __init__(self):
self._session = Session()
def markup(self, posts):
markup = ''
markup += '<div id="wrap2">'
markup += '<img border="0" src="' + self.URL_BASE + '/gglogo.png" alt="gogeo logo" width="250" height="125">'
markup += '<img border="0" src="' + self.URL_BASE + '/banner.png" alt="banner" width="1000" height="125">'
markup += '</div>'
markup += '</br >'
markup += '<div id="wrap">'
markup += '<h3> Geo-Location </h3>'
markup += '<div id="map">'
markup += '</div>'
markup += '</div>'
markup += '<div id="wrap4">'
print self._session._cookie
if self._session.getState():
markup += '<form action="' + self.URL_BASE + '/post/create" method="GET" class="post-form">'
markup += '<p>'
markup += '<label for="post">Post</label><br />'
markup += '<textarea name="post" rows="5" cols="80"></textarea><br />'
markup += '<input type="submit" value="Post" class="post-form-submit"/>'
markup += '</p>'
markup += '<input type="hidden" name="user_id" value="' + self._session._user_id + '"/>'
markup += '</form>'
markup += '<div class="post-form-links"><a href="' + self.URL_BASE + '/user/logout">Logout</a></div>'
else:
markup += '<form action="' + self.URL_BASE + '/user/login" method="POST" class="login-form">'
markup += '<p>'
markup += '<label for="user_name">User Name</label><br />'
markup += '<input name="user_name" />'
markup += '</p>'
markup += '<p>'
markup += '<label for="password">Password</label><br />'
markup += '<input type="password" name="password" />'
markup += '</p>'
markup += '<input type="submit" value="Login" class="login-form-submit"/>'
markup += '</p>'
markup += '</form>'
for post_id in posts:
markup += '<div class="post-wrapper">'
markup += '<span class="post-author">Author: '
markup += posts[post_id]['user_id']
markup += '</span>'
markup += '<span class="post-location" data-lat="' + posts[post_id]['lat'] + '" data-lng="' + posts[post_id]['lng'] + '">'
markup += 'lat: ' + posts[post_id]['lat'] + ' lng: ' + posts[post_id]['lng']
markup += '</span>'
markup += '<div class="post-content">'
markup += posts[post_id]['post']
markup += '</div>'
markup += '<span class="post-date"><em>' + posts[post_id]['created_at'] + '</em></span>'
markup += '</div>'
markup += '<div class="post-links">'
if self._session._role == 'admin':
markup += '<a href="' + self.URL_BASE + '/post/delete?post_id=' + str(post_id) + '">Delete this post</a>'
markup += '</div>'
markup += '<div class="comments_wrapper">'
if posts[post_id]['comments']:
markup += '<h4>Comments:</h4>'
for comment_id in posts[post_id]['comments']:
markup += '<div class="comment-wrapper">'
markup += '<p>' + posts[post_id]['comments'][comment_id]['comment'] + '</p>'
if self._session.getState():
markup += '<div class="comment-form">'
markup += '<form action="' + self.URL_BASE + '/comment/create" method="POST">'
markup += '<p>'
markup += '<label for="comment">Comment</label><br />'
markup += '<textarea name="comment" rows="3" cols="50"></textarea><br />'
markup += '<input type="submit" value="Comment" class="comment-form-submit"/>'
markup += '</p>'
markup += '<input type="hidden" name="post_id" value="' + str(post_id) + '"/>'
markup += '<input type="hidden" name="user_id" value="' + self._session._user_id + '"/>'
markup += '</form>'
#check permissions and add delete, comment, and edit links here
#.........這裏部分代碼省略.........
示例2: markup
# 需要導入模塊: from Session import Session [as 別名]
# 或者: from Session.Session import getState [as 別名]
def markup(self, posts):
session = Session()
markup = ''
markup += '<div id="wrap2">'
markup += '<img border="0" src="gglogo.png" alt="gogeo logo" width="250" height="125">'
markup += '<img border="0" src="banner.png" alt="banner" width="1000" height="125">'
markup += '</div>'
markup += '</br >'
markup += '<div id="wrap">'
markup += '<h3> Geo-Location </h3>'
markup += '<div id="map">'
markup += '</div>'
markup += '</div>'
markup += '<div id="wrap4">'
if session.getState():
markup += '<form action="post/create" method="GET" class="post-form">'
markup += '<p>'
markup += '<label for="post">Post</label><br />'
markup += '<textarea name="post" rows="5" cols="80"></textarea><br />'
markup += '<input type="submit" value="Post" class="post-form-submit"/>'
markup += '</p>'
markup += '</form>'
else:
markup += '<form action="user/login" method="POST" class="login-form">'
markup += '<p>'
markup += '<label for="user_name">User Name</label><br />'
markup += '<input name="user_name" />'
markup += '</p>'
markup += '<p>'
markup += '<label for="password">Password</label><br />'
markup += '<input type="password" name="user_name" />'
markup += '</p>'
markup += '<input type="submit" value="Login" class="login-form-submit"/>'
markup += '</p>'
markup += '</form>'
while True:
post = posts.fetch_row(1,1)
if not post: break
markup += '<div class="post-wrapper">'
markup += '<span class="post-author">Author: '
markup += str(post[0]['user_id'])
markup += '</span>'
markup += '<span class="post-location" data-lat="' + str(post[0]['lat']) + '" data-lng="' + str(post[0]['lng']) + '">'
markup += 'lat: ' + str(post[0]['lat']) + ' lng: ' + str(post[0]['lng'])
markup += '</span>'
markup += '<div class="post-content">'
markup += post[0]['post']
markup += '</div>'
markup += '<span class="post-date"><em>' + post[0]['created_at'].strftime('%m/%d/%Y') + '</em></span>'
markup += '</div>'
# add options here
# markup += '<div class="post-links">"
#check permissions and add delete, comment, and edit links here
# markup += '</div>'
markup += '<hr />'
markup += '</div>'
return markup