# Path: mod/_config.py

# 
# Path: mod/models/jwc_cache.py
# class JWCCache(Base):
#     __tablename__ = 'jwc'
#     date = Column(Integer, primary_key=True)
#     text = Column(String(10240), nullable=False)


from .._config import jwcCacheTime
from BeautifulSoup import BeautifulSoup
from config import JWC_URL, TIME_OUT
from tornado.httpclient import HTTPRequest, HTTPClient
from ..models.jwc_cache import JWCCache
from sqlalchemy.orm.exc import NoResultFound
from time import time, localtime, strftime
import tornado.web
import tornado.gen
import json, base64
import urllib,traceback,os
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2014-12-12 18:17:20
# @Author  : yml_bright@163.com


class JWCHandler(tornado.web.RequestHandler):

    @property
    def db(self):
        return self.application.db

    def get(self):
        self.write("hello")
    def on_finish(self):
        self.db.close()

    def post(self):
        retjson = {'code':200, 'content':''}
        try:

# Path: mod/_config.py

# 
# Path: mod/models/jwc_cache.py
# class JWCCache(Base):
#     __tablename__ = 'jwc'
#     date = Column(Integer, primary_key=True)
#     text = Column(String(10240), nullable=False)


# Path: mod/jwc/handler.py
from .._config import jwcCacheTime
from BeautifulSoup import BeautifulSoup
from config import JWC_URL, TIME_OUT
from tornado.httpclient import HTTPRequest, HTTPClient
from ..models.jwc_cache import JWCCache
from sqlalchemy.orm.exc import NoResultFound
from time import time, localtime, strftime
import tornado.web
import tornado.gen
import json, base64
import urllib,traceback,os

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date    : 2014-12-12 18:17:20
# @Author  : yml_bright@163.com


class JWCHandler(tornado.web.RequestHandler):

    @property
    def db(self):
        return self.application.db

    def get(self):
        self.write("hello")
    def on_finish(self):
        self.db.close()

    def post(self):
        retjson = {'code':200, 'content':''}
        try:

            status = self.db.query(JWCCache).filter( JWCCache.date > int(time())-jwcCacheTime).order_by(JWCCache.date.desc()).all()