This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User(Base): | |
__tablename__ = 'user' | |
id = db.Column(db.Integer, primary_key=True) | |
username = db.Column(db.String(30), unique=True) | |
email = db.Column(db.String(120), unique=True) | |
password = db.Column(db.String(64)) | |
name = db.Column(db.String(30)) | |
def __init__(self, username, email, password, name=''): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_from_today(cls, university): | |
def get_today_midnight(): | |
import datetime | |
now = datetime.datetime.now() | |
now -= datetime.timedelta(hours=now.hour, minutes=now.minute, seconds=now.second) | |
return now | |
session = DatabaseManager().get_session() | |
intersect_university = session.query(University).filter(University.name==u'공통')[0] | |
return session.query(Meeting).filter(db.or_(Meeting.university==university, Meeting.university==intersect_university), Meeting.meet_time>get_today_midnight()).order_by(Meeting.meet_time) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_from_today(cls, university): | |
def get_today_midnight(): | |
import datetime | |
now = datetime.datetime.now() | |
now -= datetime.timedelta(hours=now.hour, minutes=now.minute, seconds=now.second) | |
return now | |
session = DatabaseManager().get_session() | |
intersect_university = session.query(University).filter(University.name==u'공통')[0] | |
return session.query(Meeting).filter(db.or_(Meeting.university==university, Meeting.university==intersect_university), Meeting.meet_time>get_today_midnight()).order_by(Meeting.meet_time) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Meeting(Base): | |
__tablename__ = 'meeting_meeting' | |
id = db.Column(db.Integer, primary_key=True) | |
host = db.Column(db.String(100)) | |
university_id = db.Column(db.Integer, db.ForeignKey('meeting_university.id')) | |
name = db.Column(db.String(100)) | |
content= db.Column(db.Text) | |
board = db.Column(db.SmallInteger) | |
meet_time = db.Column(db.DateTime) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Meeting(models.Model): | |
def __str__(self): | |
return self.name.encode('utf8') | |
def __unicode__(self): | |
return self.name | |
host = models.CharField(max_length=100) | |
university = models.ForeignKey(University) | |
name = models.CharField(max_length=100) | |
content = models.TextField() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PyV8 | |
FLAG = 'dpdjzjsWkd' | |
ctx = PyV8.JSContext() | |
ctx.enter() | |
script = """ | |
check = | |
function(_password, _flag) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A(object): | |
def __init__(self, raw): | |
something = self._make_something(raw) | |
if not _is_valid_something(something): | |
raise | |
def _make_something(self, raw): | |
pass | |
return something | |
def _is_valid_something(self, something): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _update_result(self, item): | |
try: | |
response = json.loads(item) | |
except ValueError: | |
self.result['no_json_response'] = self.result.get('no_json_response') + item | |
else: | |
self.result.update(response) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestWSGIHandler(unittest.TestCase): | |
def test_call_application(self): | |
request = dict(meta=dict(ip='127.0.0.1', port=19234), | |
parameters=dict(url='/')) | |
environ, handler = Environ(request), WSGIHandler() | |
bson_binary = handler.call_application(various_status_application, | |
environ.get_dict()) | |
self.assertEqual(dict(status=dict(reason='OK', code='200')), | |
bson.loads(bson_binary)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_param(name, **kwargs): | |
value = request.values.get(name, **kwargs) | |
if value is None: | |
raise BadRequest() | |
return value | |
def get_params(name, **kwargs): | |
values = request.values.getlist(name, **kwargs) | |
if len(values) == 0: |
OlderNewer