Permalink
Browse files

Bit cleanup

  • Loading branch information...
1 parent 768349a commit 5e575467de264134bf4af3559c5567bd436acc84 @baijum committed Feb 4, 2011
Showing with 22 additions and 26 deletions.
  1. +6 −12 py3k/captcha.py
  2. +4 −0 py3k/config.py
  3. +5 −5 py3k/feedback_helper.py
  4. +1 −2 py3k/main.py
  5. +2 −4 py3k/nonpypi.py
  6. +4 −3 py3k/packages.py
View
@@ -26,27 +26,18 @@
import os
import random
-from flask import render_template
-from .application import app
-from .application import db
-
-from .model import Distribution
-#from .model import User
-from .model import Comment
-from .utils import get_status, pretty_date
-from flask import g, session
-from flask import send_file
-from cStringIO import StringIO
from flask import Response
from werkzeug import Headers
import captchaimage
import cStringIO
from PIL import Image
+from .application import app
+
all_keys = {}
-# Black text on white background
+
def get_captcha_image(code):
size_y = 32
image_data = captchaimage.create_image(
@@ -57,6 +48,7 @@ def get_captcha_image(code):
file, "JPEG", quality = 30)
return file.getvalue()
+
@app.route('/captcha/<key>')
def captcha(key):
global all_keys
@@ -65,6 +57,7 @@ def captcha(key):
headers.add("Content-Type", "image/jpeg")
return Response(img, headers=headers)
+
def verify_captcha(key, value):
global all_keys
if key not in all_keys:
@@ -86,6 +79,7 @@ def randomword():
final_word_list.append(text[pos])
return ''.join(final_word_list)
+
def get_captcha_key():
global all_keys
import uuid
View
@@ -24,21 +24,25 @@
# authors and should not be interpreted as representing official policies, either expressed
# or implied, of Baiju M <baiju.m.mail@gmail.com>.
+
class Config(object):
DEBUG = False
TESTING = False
SQLALCHEMY_DATABASE_URI = 'sqlite:////var/tmp/getpython3.db'
OPENID_FS_STORE_PATH = '/var/tmp/getpython3openid'
+
class ProductionConfig(Config):
#SQLALCHEMY_DATABASE_URI = 'mysql://user:passwd@localhost/db'
pass
+
class DevelopmentConfig(Config):
DEBUG = True
SECRET_KEY = 'secret'
SQLALCHEMY_ECHO = True
+
class TestinConfig(Config):
TESTING = True
SQLALCHEMY_DATABASE_URI = 'sqlite://:memory:'
View
@@ -4,16 +4,16 @@
architecture = "Architecture : "+platform.architecture()[0]
#get the distro and version
-distro=[]
+distro = []
#Contains all the distro related details
distro.append("Distro Name : "+platform.linux_distribution()[0])
distro.append("Distro Version : "+platform.linux_distribution()[1])
#get python details
-python_details=[]
+python_details = []
#Contains all the python related details
python_details.append("Python Branch : "+platform.python_branch())
-python_details.append("Python Revision :"+platform.python_revision())
+python_details.append("Python Revision : "+platform.python_revision())
python_details.append("Python Compiled Using : "+ platform.python_compiler())
python_details.append("Python Implementation : "+platform.python_implementation())
python_details.append("Python Version : "+platform.python_version())
@@ -23,7 +23,7 @@
print architecture
for i in distro:
- print i
+ print i
for i in python_details:
- print i
+ print i
View
@@ -24,7 +24,7 @@
# authors and should not be interpreted as representing official policies, either expressed
# or implied, of Baiju M <baiju.m.mail@gmail.com>.
-from flask import render_template, request, redirect, url_for
+from flask import render_template, request
from urlparse import urljoin
from werkzeug.contrib.atom import AtomFeed
@@ -33,7 +33,6 @@
from .application import db
from .model import Distribution
-#from .model import User
from .model import Comment
from .utils import get_status, pretty_date
View
@@ -31,9 +31,6 @@
from sqlalchemy.exc import IntegrityError
from .model import Distribution
-#from .model import User
-from .model import Comment
-from .utils import get_status, pretty_date
from .captcha import get_captcha_key
from .captcha import verify_captcha
@@ -67,7 +64,7 @@ def save_new_project():
except IntegrityError:
db.session.rollback()
return "Cannot create"
- return "A page exist in PyPI"
+ return "A page exist in PyPI"
home_page = request.form['home_page']
author = request.form['author']
summary = request.form['summary']
@@ -85,6 +82,7 @@ def save_new_project():
db.session.commit()
return redirect(url_for('packages_details', name=name))
+
@app.route('/nonpypi')
def nonpypipkg():
return render_template('nonpypi_package.html', captcha_key=get_captcha_key())
View
@@ -26,9 +26,8 @@
import datetime
from flask import render_template, request, redirect, url_for
-#from flask import session
+
from .model import Distribution
-#from .model import User
from .model import Comment
from .application import app
@@ -67,6 +66,7 @@ def recent_project_comment_feed(name):
published=comment.datetime)
return feed.get_response()
+
@app.route('/project/<name>/add_comment', methods=['POST'])
def add_comment(name):
fullname = request.form['fullname'].strip() or 'Anonymous'
@@ -93,11 +93,13 @@ def add_comment(name):
db.session.commit()
return redirect(url_for('packages_details', name=name))
+
@app.route('/search/<name>/+<int:page>')
def search_package(name, page=1):
result = Distribution.query.filter(Distribution.name.like("%%%s%%"%name)).paginate(page)
return render_template('search_package.html', page_obj=result, searchname=name)
+
@app.route('/project/<name>')
def packages_details(name):
result = Distribution.query.filter_by(name=name).first()
@@ -112,7 +114,6 @@ def packages_details(name):
captcha_key=get_captcha_key())
-
@app.route('/project', methods=['GET', 'POST'])
@app.route('/project/+<int:page>')
def packages(page=1):

0 comments on commit 5e57546

Please sign in to comment.