Development reference documentation

Top level module apps

Module containing the django applications that together make up the packaginator site.

All of the modules listed below are the sub-applications.

apiv1 - restful API

Restful api for the packaginator, based on django-tastypie (docs | pypi | repo).

This module consists of two components - module api and the resource definition module resources.

The api urls are exposed in project’s main urls.py file

apiv1.api

The Api definition module

class apps.apiv1.api.Api(api_name='v1')[source]

A sub-class of TastyPieApi - the actual Api class

top_level(request, api_name=None)[source]

A view that returns a serialized list of all resources registered to the Api. Useful for the resource discovery.

apiv1.resources

core - Kernal bits

core.fields

class apps.core.fields.CreationDateTimeField(*args, **kwargs)[source]
south_field_triple()[source]

Returns a suitable description of this field for South.

class apps.core.fields.ModificationDateTimeField(*args, **kwargs)[source]
south_field_triple()[source]

Returns a suitable description of this field for South.

core.models

class apps.core.models.BaseModel(*args, **kwargs)[source]

Base abstract base class to give creation and modified times

feeds - RSS and Atom feeds

This application defines RSS and Atom feeds that are made available to the users of the packaginator

feeds.urls

url patterns for the feeds

feeds.feeds

Contains classes for the feeds

class apps.feeds.feeds.AtomLatestPackagesFeed[source]

Atom feed for the packages

class apps.feeds.feeds.RssLatestPackagesFeed[source]

RSS Feed for the packages

item_description(item)[source]

Get description of the repository

item_pubdate(item)[source]

Get publication date

item_title(item)[source]

Get title of the repository

items()[source]

Returns 15 most recently created repositories

grid - package grid app

Grid application - displays and manipulates the package grid

grid.views

views for the apps.grid app

grid.views.add_feature(request, *args, **kwargs)[source]

Adds a feature to the grid, accepts GET and POST requests.

Requires user to be logged in

Template context:

grid.views.add_grid(request, *args, **kwargs)[source]

Creates a new grid, requires user to be logged in. Works for both GET and POST request methods

Template context:

  • form - an instance of GridForm
grid.views.add_grid_package(request, *args, **kwargs)[source]

Add an existing package to this grid.

grid.views.add_new_grid_package(request, *args, **kwargs)[source]

Add a package to a grid that isn’t yet represented on the site.

grid.views.ajax_grid_list(request, template_name='grid/ajax_grid_list.html')[source]
grid.views.build_element_map(elements)[source]
grid.views.delete_feature(request, *args, **kwargs)[source]
grid.views.delete_grid(request, *args, **kwargs)[source]

Deletes a grid, requires user to be logged in.

grid.views.delete_grid_package(request, id, template_name='grid/edit_feature.html')[source]

Deletes package from the grid, id is the id of the grid.models.GridPackage instance

Requires permission grid.delete_gridpackage.

Redirects to grid.views.grid_detail().

grid.views.edit_element(request, *args, **kwargs)[source]
grid.views.edit_feature(request, *args, **kwargs)[source]

edits feature on a grid - this view has the same semantics as grid.views.add_feature().

Requires the user to be logged in.

grid.views.edit_grid(request, *args, **kwargs)[source]

View to modify the grid, handles GET and POST requests. This view requires user to be logged in.

Template context:

grid.views.grid_detail(request, slug, template_name='grid/grid_detail.html')[source]

displays a grid in detail

Template context:

  • grid - the grid object
  • elements - elements of the grid
  • features - feature set used in the grid
  • grid_packages - packages involved in the current grid
grid.views.grid_detail_feature(request, slug, feature_id, bogus_slug, template_name='grid/grid_detail_feature.html')[source]

a slightly more focused view than grid.views.grid_detail() shows comparison for only one feature, and does not show the basic grid parameters

Template context is the same as in grid.views.grid_detail()

grid.views.grids(request, template_name='grid/grids.html')[source]

lists grids

Template context:

  • grids - all grid objects

grid.models

class grid.models.Element(*args, **kwargs)[source]

The individual cells on the grid. The Element grid attributes are:

  • grid_package - foreign key to GridPackage
  • feature - foreign key to Feature
  • text - the actual contents of the grid cell
class grid.models.Feature(*args, **kwargs)[source]

These are the features measured against a grid. Feature has the following attributes:

  • grid - the grid to which the feature is assigned
  • title - name of the feature (100 chars is max)
  • description - plain-text description
class grid.models.Grid(*args, **kwargs)[source]

Grid object, inherits form package.models.BaseModel. Attributes:

  • title - grid title
  • slug - grid slug for SEO
  • description - description of the grid with line breaks and urlized links
  • is_locked - boolean field accessible to moderators
  • packages - many-to-many relation with :class:~`grid.models.GridPackage` objects
grid_packages[source]

Gets all the packages and orders them for views and other things

class grid.models.GridPackage(*args, **kwargs)[source]

Grid package. This model describes packages listed on one side of the grids and explicitly defines the many-to-many relationship between grids and the packages (i.e - allows any given package to be assigned to several grids at once).

Attributes:

  • grid - the Grid to which the package is assigned
  • package - the Package

grid.forms

Forms for the grid app

class grid.forms.ElementForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=':', empty_permitted=False, instance=None)[source]

collects data for a new grid element - a ModelForm for grid.models.Element

class grid.forms.FeatureForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=':', empty_permitted=False, instance=None)[source]

collects data for the feature - a ModelForm for grid.models.Feature

class grid.forms.GridForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=':', empty_permitted=False, instance=None)[source]

collects data for the new grid - a django ModelForm for grid.models.Grid

clean_slug()[source]

returns lower-cased slug

class grid.forms.GridPackageForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.util.ErrorList'>, label_suffix=':', empty_permitted=False, instance=None)[source]

collects data for a new package - a ModelForm for grid.models.GridPackage

profiles - profiles app

Manages user profiles

profiles.models

class profiles.models.Profile(*args, **kwargs)[source]

Profile(id, created, modified, user_id, github_account, github_url, bitbucket_url, google_code_url, email)

my_packages()[source]

Return a list of all packages the user contributes to.

List is sorted by package name.

save(**kwargs)[source]

Override save to always populate email changes to auth.user model

url_for_repo(repo)[source]

Return the profile’s URL for a given repo.

If url doesn’t exist return None.

profiles.context_processors

profiles.context_processors.lazy_profile(request)[source]

Returns context variables required by templates that assume a profile on each request

pypi - pypi app

All connection points with PyPI

pypi.slurper

PyPI interface (see http://wiki.python.org/moin/PyPiXmlRpc)

class pypi.slurper.Slurper(package)[source]

Fetches data from PyPI

get_latest_version_number(package_name, versions=None)[source]

Returns the latest version number for a package

get_or_create_package(package_name, version)[source]

pypi.versioning

pypi.versioning.compare_versions(version1, version2)[source]

Determines the order of versions

pypi.versioning.highest_version(versions)[source]

returns the highest version

searchv2 - searchv2 app

searchv2.views

searchv2.views.search(request, template_name='searchv2/search.html')[source]

Searches in Grids and Packages

searchv2.views.search_function(q)[source]

TODO - make generic title searches have lower weight

searchv2.views.search_packages_autocomplete(request)[source]

Searches in Packages