Ejemplo n.º 1
0
 def render(self, template, context=None, globals=None, layout=False):
     if context is None:
         context = {}
     context.update({
         'cur_user':self.cur_user(),
         'is_spider': self.is_spider(),
         'request': self.request,
     })
     
     context['qq_login_url'] = ''
     if USER_MODEL in [1,3]:
         if not context['cur_user']:
             from qqweibo import APIClient as qqAPIClient
             qqclient = qqAPIClient(app_key=QQ_APP_ID, app_secret=QQ_APP_KEY)
             context['qq_login_url'] = qqclient.get_authorize_url()
             #建议把qq_login_url 值设为静态(如下示例),并把上面三行屏蔽掉
             #context['qq_login_url'] = 'https://graph.qq.com/oauth2.0/authorize?scope=get_user_info&redirect_uri=http%3A//myskoda.sinaapp.com/qqcallback&response_type=code&client_id=100305902'
     
     return engine.render(template, context, globals, layout)
Ejemplo n.º 2
0
                'recent_node':
                Node.get_recent_node(),
                'hot_node':
                Node.get_hot_node(),
                #'recent_topic_objs': Commomkvdb.get_comment_topic_by_keys('recent-topic-home'),
                'comment_topic_objs':
                Commomkvdb.get_comment_topic_by_keys(
                    'recent-comment-topic-home'),
            },
            layout='_layout.html')


### qq login
from qqweibo import APIClient as qqAPIClient

qqclient = qqAPIClient(app_key=QQ_APP_ID, app_secret=QQ_APP_KEY)


class QQLoginPage(BaseHandler):
    def get(self):
        if USER_MODEL == 2:
            self.redirect('/sigin')
            return

        self.clear_all_cookies()
        qq_login_url = qqclient.get_authorize_url()
        self.echo('qqlogin.html', {
            'title': "QQ一键安全登录",
            'qq_login_url': qq_login_url,
        },
                  layout='_layout.html')
Ejemplo n.º 3
0
class HomePage(BaseHandler):
    def get(self):
        self.echo('home.html', {
            'title': "首页",
            'topic_objs': Commomkvdb.get_topic_by_keys('recent-topic-home'),
            'site_counts': Count.get_site_counts(),
            'newest_node': Node.get_newest(),
            'recent_node': Node.get_recent_node(),
            'hot_node': Node.get_hot_node(),
            #'recent_topic_objs': Commomkvdb.get_comment_topic_by_keys('recent-topic-home'),
            'comment_topic_objs': Commomkvdb.get_comment_topic_by_keys('recent-comment-topic-home'),
        }, layout='_layout.html')

### qq login
from qqweibo import APIClient as qqAPIClient
qqclient = qqAPIClient(app_key=QQ_APP_ID, app_secret=QQ_APP_KEY)
class QQLoginPage(BaseHandler):
    def get(self):
        if USER_MODEL==2:
            self.redirect('/sigin')
            return
        
        self.clear_all_cookies()
        qq_login_url = qqclient.get_authorize_url()
        self.echo('qqlogin.html', {
            'title': "QQ一键安全登录",
            'qq_login_url': qq_login_url,
        }, layout='_layout.html')

class QQCallback(BaseHandler):
    def get(self):