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

Django 1.3 support and project layout #17

Open
wants to merge 28 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
21 changes: 17 additions & 4 deletions README → README.rest
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
=========================================
ChiShop/DjangoPyPI
=========================================
:Version: 0.1
:Version: 0.3.0

Installation
============

Recommended to create a virtualenv for running this.

Install dependencies::

$ python bootstrap.py --distribute
Expand All @@ -15,9 +17,13 @@ Initial configuration
---------------------
::

$ $EDITOR chishop/settings.py
$ cp chishop/custom_settings.py.example chishop/custom_settings.py
$ $EDITOR chishop/custom_settings.py
$ ./bin/django syncdb

You are most likely interested in configuring MEDIA_ROOT and STATIC_ROOT,
although for development they should be fine.

Run the PyPI server
-------------------
::
Expand Down Expand Up @@ -58,10 +64,17 @@ Add the following to your ``~/.pypirc`` file::
Uploading a package: Python >=2.6
--------------------------------------------

To push the package to the local pypi::
To register the package with the local pypi::

$ python setup.py register -r local

To push the package (sdist, bdist_egg, upload executed sequentially) to the local pypi::
$ python setup.py sdist bdist_egg upload -r local

$ python setup.py register -r local sdist upload -r local
Note, ``bdist_egg`` will fail on old ``distutils``, you should use ``distribute`` that supports it. Otherwise you can stick to uploading ``sdist``.

And installing of course::
$ pip install -i http://localhost:8000 package

Uploading a package: Python <2.6
-------------------------------------------
Expand Down
7 changes: 6 additions & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ find-links = http://bitbucket.org/ubernostrum/django-registration/downloads/djan
unzip = true
eggs = pkginfo
django-registration==0.8-alpha-1
flup

[versions]
django = 1.3

[django]
recipe = djangorecipe
version = 1.1.1
settings = settings
eggs = ${buildout:eggs}
test = djangopypi
project = chishop
wsgi = true
fcgi = true

41 changes: 34 additions & 7 deletions chishop/conf/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,51 @@

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
here = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
here = os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))), '..')
MEDIA_ROOT = os.path.join(here, 'media')

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(here, 'static')

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/admin/media/'
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'w_#0r2hh)=!zbynb*gg&969@)sy#^-^ia3m*+sd4@lst$zyaxu'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.load_template_source',
)

Expand All @@ -84,11 +109,12 @@
ROOT_URLCONF = 'chishop.urls'

TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.auth",
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.request",
'django.core.context_processors.static',
)

TEMPLATE_DIRS = (
Expand All @@ -106,6 +132,7 @@
'django.contrib.admin',
'django.contrib.markup',
'django.contrib.admindocs',
'django.contrib.staticfiles',
'registration',
'djangopypi',
'chishop.djangopypi',
)
21 changes: 21 additions & 0 deletions chishop/custom_settings.py.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Custom configuration
# Copy as custom_settings.py and keep outside version control

import os

DEBUG = True
TEMPLATE_DEBUG = DEBUG
LOCAL_DEVELOPMENT = True

if LOCAL_DEVELOPMENT:
import sys
sys.path.append(os.path.dirname(__file__))

ADMINS = (
('chishop', '[email protected]'),
)

MANAGERS = ADMINS

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

2 changes: 1 addition & 1 deletion djangopypi/__init__.py → chishop/djangopypi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION = (0, 2, 0)
VERSION = (0, 3, 0)
__version__ = ".".join(map(str, VERSION))
2 changes: 1 addition & 1 deletion djangopypi/admin.py → chishop/djangopypi/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from djangopypi.models import Project, Release, Classifier
from chishop.djangopypi.models import Project, Release, Classifier

admin.site.register(Project)
admin.site.register(Release)
Expand Down
4 changes: 2 additions & 2 deletions djangopypi/forms.py → chishop/djangopypi/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from django import forms
from django.conf import settings
from djangopypi.models import Project, Classifier, Release
from chishop.djangopypi.models import Project, Classifier, Release
from django.utils.translation import ugettext_lazy as _


Expand All @@ -14,4 +14,4 @@ class Meta:
class ReleaseForm(forms.ModelForm):
class Meta:
model = Release
exclude = ['project']
exclude = ['project']
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import os.path

from django.core.management.base import BaseCommand
from djangopypi.models import Classifier
from chishop.djangopypi.models import Classifier

CLASSIFIERS_URL = "http://pypi.python.org/pypi?%3Aaction=list_classifiers"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from urlparse import urlsplit
from setuptools.package_index import PackageIndex
from django.contrib.auth.models import User
from djangopypi.models import Project, Release, Classifier
from chishop.djangopypi.models import Project, Release, Classifier



Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions djangopypi/tests.py → chishop/djangopypi/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
import StringIO
from djangopypi.views import parse_distutils_request, simple
from djangopypi.models import Project, Classifier
from chishop.djangopypi.views import parse_distutils_request, simple
from chishop.djangopypi.models import Project, Classifier
from django.test.client import Client
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
Expand Down Expand Up @@ -136,4 +136,4 @@ def test_user_registration_with_wrong_data(self):
response = simple(request)
self.assertEquals(400, response.status_code)



4 changes: 2 additions & 2 deletions djangopypi/urls.py → chishop/djangopypi/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import patterns, url, include

urlpatterns = patterns("djangopypi.views",
urlpatterns = patterns("chishop.djangopypi.views",
# Simple PyPI
url(r'^simple/$', "simple",
name="djangopypi-simple"),
Expand All @@ -21,4 +21,4 @@
name="djangopypi-pypi_show_links"),

url(r'^search','search',name='djangopypi-search')
)
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from django.shortcuts import render_to_response
from django.template import RequestContext

from djangopypi.models import Project, Release
from djangopypi.http import HttpResponseNotImplemented
from djangopypi.http import parse_distutils_request
from djangopypi.views.dists import register_or_upload
from djangopypi.views.users import create_user
from djangopypi.views.search import search
from chishop.djangopypi.models import Project, Release
from chishop.djangopypi.http import HttpResponseNotImplemented
from chishop.djangopypi.http import parse_distutils_request
from chishop.djangopypi.views.dists import register_or_upload
from chishop.djangopypi.views.users import create_user
from chishop.djangopypi.views.search import search


ACTIONS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth import login

from djangopypi.http import login_basic_auth, HttpResponseUnauthorized
from djangopypi.forms import ProjectForm, ReleaseForm
from djangopypi.models import Project, Release, Classifier, UPLOAD_TO
from chishop.djangopypi.http import login_basic_auth, HttpResponseUnauthorized
from chishop.djangopypi.forms import ProjectForm, ReleaseForm
from chishop.djangopypi.models import Project, Release, Classifier, UPLOAD_TO

ALREADY_EXISTS_FMT = _(
"A file named '%s' already exists for %s. Please create a new release.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.shortcuts import render_to_response
from django.db.models.query import Q

from djangopypi.models import Project
from chishop.djangopypi.models import Project


def _search_query(q):
Expand Down
File renamed without changes.
19 changes: 13 additions & 6 deletions chishop/production_example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from conf.default import *

# This imports from the raw settings.py, not Django-enabled settings object
from settings import *

import os

DEBUG = False
Expand All @@ -10,9 +14,12 @@

MANAGERS = ADMINS

DATABASE_ENGINE = 'postgresql_psycopg2'
DATABASE_NAME = 'chishop'
DATABASE_USER = 'chishop'
DATABASE_PASSWORD = 'chishop'
DATABASE_HOST = ''
DATABASE_PORT = ''
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
DATABASES['default']['NAME'] = 'chishop'
DATABASES['default']['USER'] = 'chishop'
DATABASES['default']['PASSWORD'] = 'chishop'

## These are most likely necessary to override for production
#MEDIA_ROOT = ''
#STATIC_ROOT = ''

30 changes: 22 additions & 8 deletions chishop/settings.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from conf.default import *
import os

DEBUG = True
DEBUG = False
TEMPLATE_DEBUG = DEBUG
LOCAL_DEVELOPMENT = True
LOCAL_DEVELOPMENT = False

if LOCAL_DEVELOPMENT:
import sys
Expand All @@ -15,9 +15,23 @@

MANAGERS = ADMINS

DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = os.path.join(here, 'devdatabase.db')
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''
DATABASE_PORT = ''
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': os.path.join(here, 'devdatabase.db'), # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}

## Easy overriding, eg:
# from settings import DATABASES
# DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
try:
# Keep custom_settings.py outside version control to keep things clean
from custom_settings import *
except ImportError, e:
pass

2 changes: 1 addition & 1 deletion chishop/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-au" xml:lang="en-au">
<head>
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/base.css{% endblock %}"/>
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}style/djangopypi.css"/>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}style/djangopypi.css"/>
{% block extrastyle %}{% endblock %}
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>{% block title %}{% endblock %}</title>
Expand Down
1 change: 1 addition & 0 deletions chishop/templates/djangopypi/search.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<form action='/search' method='post'>
{% csrf_token %}
<input type="text" name="search_term" id="search_term">
<input type='submit' value=' Search '/>
</form>
1 change: 1 addition & 0 deletions chishop/templates/registration/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

{% block content %}
<form method="post" action="">
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Login">
</form>
Expand Down
1 change: 1 addition & 0 deletions chishop/templates/registration/registration_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% block content %}
<h1>Register</h1>
<form method="post" action="">
{% csrf_token %}
{{form.as_p}}
<input type="submit" value="Register">
{% endblock %}
Loading