Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade pypress with Flask 0.10.* #2

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
A team blog based on [Flask](http://flask.pocoo.org/)
===

This project isn't supported at the moment, please see a newer [pypress-tornado](https://github.com/laoqiu/pypress-tornado)
This project is forked form [pypress](https://github.com/laoqiu/pypress) by laoqiu

Thanks for flask_website and newsmeme at [http://flask.pocoo.org/community/poweredby/]
A very good sample for newbie of Flask which come from newsmeme

Purpose of this fork is to make this project relive

#Version road map

## Version 0.1.0

Use blueprint instead of older module for Flask 0.10.* and newer

Fixed bug of Upload

## Version 0.1.1

Convert to to Sina Appliaction Engine

1. Storage - OS
2. Mail - SAE mail
3. MySQL configure

# Version 0.1.*

Please post issue or suggestion on github to route the development

===

##Install

Expand Down
19 changes: 11 additions & 8 deletions pypress/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

:license: BSD, see LICENSE for more details.
"""
__author__ "Laoqiu,lomatus"
__version__ "0.1.0"

import os
import logging
import datetime
Expand All @@ -16,10 +19,10 @@

from flask import Flask, g, session, request, flash, redirect, jsonify, url_for

from flaskext.babel import Babel, gettext as _
from flaskext.themes import setup_themes
from flaskext.principal import Principal, RoleNeed, UserNeed, identity_loaded
from flaskext.uploads import configure_uploads
from flask.ext.babel import Babel, gettext as _
from flask.ext.themes import setup_themes
from flask.ext.principal import Principal, RoleNeed, UserNeed, identity_loaded
from flask.ext.uploads import configure_uploads

from pypress import views, helpers
from pypress.models import User, Post, Tag, Link, Comment
Expand All @@ -28,7 +31,7 @@

DEFAULT_APP_NAME = 'pypress'

DEFAULT_MODULES = (
DEFAULT_BLUEPRINT = (
(views.frontend, ""),
(views.post, "/post"),
(views.comment, "/comment"),
Expand All @@ -40,7 +43,7 @@
def create_app(config=None, modules=None):

if modules is None:
modules = DEFAULT_MODULES
modules = DEFAULT_BLUEPRINT

app = Flask(DEFAULT_APP_NAME)

Expand Down Expand Up @@ -223,8 +226,8 @@ def server_error(error):
def configure_modules(app, modules):

for module, url_prefix in modules:
app.register_module(module, url_prefix=url_prefix)

app.register_blueprint( module,url_prefix=url_prefix )
#break

def configure_logging(app):

Expand Down
4 changes: 2 additions & 2 deletions pypress/forms/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

:license: BSD, see LICENSE for more details.
"""
from flaskext.wtf import Form, TextAreaField, HiddenField, BooleanField, \
from flask.ext.wtf import Form, TextAreaField, HiddenField, BooleanField, \
PasswordField, SubmitField, TextField, ValidationError, \
required, email, equal_to, regexp

from flaskext.babel import gettext, lazy_gettext as _
from flask.ext.babel import gettext, lazy_gettext as _

from pypress.extensions import db
from pypress.models import User
Expand Down
4 changes: 2 additions & 2 deletions pypress/forms/blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

:license: BSD, see LICENSE for more details.
"""
from flaskext.wtf import Form, TextAreaField, SubmitField, TextField, \
from flask.ext.wtf import Form, TextAreaField, SubmitField, TextField, \
ValidationError, required, email, url, optional

from flaskext.babel import gettext, lazy_gettext as _
from flask.ext.babel import gettext, lazy_gettext as _

from pypress.helpers import slugify
from pypress.extensions import db
Expand Down
4 changes: 2 additions & 2 deletions pypress/forms/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

:license: BSD, see LICENSE for more details.
"""
from flaskext.wtf import regexp
from flask.ext.wtf import regexp

from flaskext.babel import lazy_gettext as _
from flask.ext.babel import lazy_gettext as _

USERNAME_RE = r'^[\w.+-]+$'

Expand Down
6 changes: 3 additions & 3 deletions pypress/models/blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

from flask import abort, current_app, url_for, Markup

from flaskext.babel import gettext as _
from flaskext.sqlalchemy import BaseQuery
from flaskext.principal import RoleNeed, UserNeed, Permission
from flask.ext.babel import gettext as _
from flask.ext.sqlalchemy import BaseQuery
from flask.ext.principal import RoleNeed, UserNeed, Permission

from pypress import signals
from pypress.helpers import storage, slugify, markdown
Expand Down
9 changes: 6 additions & 3 deletions pypress/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

from flask import abort, current_app

from flaskext.sqlalchemy import BaseQuery
from flaskext.principal import RoleNeed, UserNeed, Permission
from flask.ext.sqlalchemy import BaseQuery
from flask.ext.principal import RoleNeed, UserNeed, Permission

from pypress.extensions import db, cache
from pypress.permissions import admin
Expand All @@ -35,7 +35,10 @@ def from_identity(self, identity):
"""

try:
user = self.get(int(identity.name))
if identity.id != None:
user = self.get(int(identity.id))
else:
user = None
except ValueError:
user = None

Expand Down
2 changes: 1 addition & 1 deletion pypress/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#!/usr/bin/env pythonfrom .frontend import frontendfrom .post import postfrom .account import accountfrom .comment import commentfrom .link import linkfrom .feeds import feeds
#!/usr/bin/env pythonfrom .frontend import frontendfrom .post import postfrom .account import accountfrom .comment import commentfrom .link import linkfrom .feeds import feeds
Expand Down
9 changes: 5 additions & 4 deletions pypress/views/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

import oauth2 as oauth

from flask import Module, Response, request, flash, jsonify, g, current_app,\
from flask import Blueprint, Response, request, flash, jsonify, g, current_app,\
abort, redirect, url_for, session

from flaskext.babel import gettext as _
from flaskext.principal import identity_changed, Identity, AnonymousIdentity
from flask.ext.babel import gettext as _
from flask.ext.principal import identity_changed, Identity, AnonymousIdentity

from pypress.helpers import render_template, cached
from pypress.permissions import auth, admin
Expand All @@ -31,8 +31,9 @@
from pypress.forms import LoginForm, SignupForm

from pypress import twitter
from pypress import weibo

account = Module(__name__)
account = Blueprint('account', __name__ )

REQUEST_TOKEN_URL = 'https://api.twitter.com/oauth/request_token'
ACCESS_TOKEN_URL = 'https://api.twitter.com/oauth/access_token'
Expand Down
6 changes: 3 additions & 3 deletions pypress/views/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
:license: BSD, see LICENSE for more details.
"""

from flask import Module, Response, request, flash, jsonify, g, current_app,\
from flask import Blueprint, Response, request, flash, jsonify, g, current_app,\
abort, redirect, url_for, session, send_file, send_from_directory

from flaskext.babel import gettext as _
from flask.ext.babel import gettext as _

from pypress import signals
from pypress.helpers import render_template, cached
from pypress.permissions import auth
from pypress.extensions import db
from pypress.models import Comment

comment = Module(__name__)
comment = Blueprint('comment', __name__ )

@comment.route("/<int:comment_id>/delete/", methods=("POST",))
@auth.require(401)
Expand Down
8 changes: 4 additions & 4 deletions pypress/views/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

from werkzeug.contrib.atom import AtomFeed

from flask import Module, request, url_for
from flask import Blueprint, request, url_for

from pypress.helpers import cached

from pypress.models import User, Post, Tag

feeds = Module(__name__)
feeds = Blueprint('feeds', __name__ )

class PostFeed(AtomFeed):

Expand All @@ -35,7 +35,7 @@ def add_post(self, post):
@feeds.route("/")
@cached()
def index():
feed = PostFeed("laoqiu blog - lastest",
feed = PostFeed("pypress - lastest",
feed_url=request.url,
url=request.url_root)

Expand All @@ -53,7 +53,7 @@ def tag(slug):

tag = Tag.query.filter_by(slug=slug).first_or_404()

feed = PostFeed("laoqiu blog - %s" % tag,
feed = PostFeed("pypress - %s" % tag,
feed_url=request.url,
url=request.url_root)

Expand Down
7 changes: 4 additions & 3 deletions pypress/views/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

import datetime
import os
import json

from flask import Module, Response, request, flash, jsonify, g, current_app,\
from flask import Blueprint, Response, request, flash, jsonify, g, current_app,\
abort, redirect, url_for, session, send_file, send_from_directory

from flaskext.babel import gettext as _
from flask.ext.babel import gettext as _

from pypress.helpers import render_template, cached
from pypress.permissions import auth, admin
Expand All @@ -21,7 +22,7 @@
from pypress.models import User, Post, Comment, Tag
from pypress.forms import CommentForm, TemplateForm, TwitterForm

frontend = Module(__name__)
frontend = Blueprint('frontend', __name__ )

@frontend.route("/")
@frontend.route("/page/<int:page>/")
Expand Down
6 changes: 3 additions & 3 deletions pypress/views/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
:license: BSD, see LICENSE for more details.
"""

from flask import Module, Response, request, flash, jsonify, g, current_app,\
from flask import Blueprint, Response, request, flash, jsonify, g, current_app,\
abort, redirect, url_for, session

from flaskext.babel import gettext as _
from flask.ext.babel import gettext as _

from pypress.helpers import render_template, cached
from pypress.permissions import auth, admin
Expand All @@ -18,7 +18,7 @@
from pypress.models import Link
from pypress.forms import LinkForm

link = Module(__name__)
link = Blueprint('link', __name__ )

@link.route("/")
@link.route("/page/<int:page>/")
Expand Down
8 changes: 4 additions & 4 deletions pypress/views/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import os
import json

from flask import Module, Response, request, flash, jsonify, g, current_app, \
from flask import Blueprint, Response, request, flash, jsonify, g, current_app, \
abort, redirect, url_for, session

from flaskext.mail import Message
from flaskext.babel import gettext as _
from flask.ext.mail import Message
from flask.ext.babel import gettext as _

from pypress import signals
from pypress.helpers import render_template, cached, ip2long
Expand All @@ -24,7 +24,7 @@
from pypress.models import User, Post, Comment
from pypress.forms import PostForm, CommentForm

post = Module(__name__)
post = Blueprint('post', __name__ )


@post.route("/", methods=("GET","POST"))
Expand Down