ebpub¶
ebpub Package¶
Publishing system for block-specific news, as used by EveryBlock.com.
Before you dive in, it's highly recommend you spend a little bit of time browsing around EveryBlock.com to get a feel for what this software does.
Also, for a light conceptual background on some of this, particularly the data storage aspect, watch the video "Behind the scenes of EveryBlock.com" here: http://blip.tv/file/1957362
Settings¶
ebpub requires a smorgasbord of eb-specific settings in your settings file. If you follow the Creating a Custom Site Based on OpenBlock or Installing and Setting Up the Demo Site directions, they provide suitable settings files that you can adjust as needed. Otherwise, you might just start with the file ebpub/settings.py and tweak that (or import from it in your own settings file). The application won't work until you set the following:
DATABASES
SHORT_NAME
PASSWORD_CREATE_SALT
PASSWORD_RESET_SALT
METRO_LIST
MEDIA_ROOT
MEDIA_URL
EB_DOMAIN
DEFAULT_MAP_CENTER_LON
DEFAULT_MAP_CENTER_LAT
DEFAULT_MAP_ZOOM
Models¶
Broadly speaking, the system requires two different types of data: geographic boundaries (Locations, Streets, Blocks and Intersections) and news (Schemas and NewsItems).
For news-related models, see ebpub.db.models.
For geographic models, see ebpub.streets.models, and ebpub.db.models.Location, and also Loading Geographic Data.
E-mail alerts¶
Users can sign up for e-mail alerts via a form on the place_detail pages. To send the e-mail alerts, just run the send_all() function in ebpub/alerts/sending.py. You probably want to do this regularly by Running Scrapers.
Accounts¶
OpenBlock uses a customized version of Django's User objects and authentication infrastructure. ebpub.accounts comes with its own User object and Django middleware that sets request.user to the User if somebody's logged in.
See the package's docstrings for more detail.
FilterChains: Searching NewsItems, Making URLs for Searches¶
Since searching NewsItems according to some schema, and building URLs that represent those searches, are so important to OpenBlock, these features have been encapsulated in the ebpub.db.schemafilters package. It provides a FilterChain class, which you can treat as an ordered collection of filters to apply to a NewsItem query. Each filter is represented by a subclass of NewsItemFilter and represents filtering according to one criteria, eg. a date search, or a search for some values of a SchemaField.
Given a FilterChain, you can generate a URL to the schema_filter view with those parameters by calling filterchain.get_url(). There is also a {% filter_url %} template tag in ebpub.db.templatetags.eb_filter which you can use in templates.
See the schemafilter package's docstrings for more detail. Most of the views in ebpub.db.views make use of a FilterChain.
Template Tags¶
ebpub provides a number of custom tags for use in templates. If you are customizing templates, you will want to peruse the docstrings of all the modules under ebpub.db.templatetags.
constants Module¶
geoadmin Module¶
Admin UI classes and Widgets with maps customized for OpenBlock, based on django-olwidget.
- class ebpub.geoadmin.OBMapField(fields=None, options=None, layer_names=None, template=None, **kwargs)¶
Bases: olwidget.fields.MapField
A FormField just like olwidget's MapField but the default widget is OBMapWidget, with our default options.
monkeypatches Module¶
This file contains monkey-patches for upstream code that we don't wish to fork, eg. core Django features that haven't landed in the version of Django we need, etc.
These patches were developed against Django 1.3. If/when upgrading DJango to 1.4 or later, this file will need a full audit.
- ebpub.monkeypatches.Deserializer(object_list, **options)¶
Deserialize simple Python objects back into Django ORM instances.
It's expected that you pass the Python objects themselves (instead of a stream or a string) to the constructor
- ebpub.monkeypatches.build_instance(Model, data, db)¶
Build a model instance.
If the model instance doesn't have a primary key and the model supports natural keys, try to retrieve it from the database.
- ebpub.monkeypatches.start_object(self, obj)¶
Called as each object is handled.
settings_default Module¶
This file should rarely need editing; if it does, you might want to move the setting in question into settings.py (and settings.py.in)
Known required settings are: ['DEBUG', 'DATABASES', 'DEFAULT_LOCTYPE_SLUG', 'EB_DOMAIN', 'SHORT_NAME', 'PASSWORD_CREATE_SALT', 'PASSWORD_RESET_SALT', 'METRO_LIST', 'DEFAULT_DAYS', 'SCRAPER_LOGFILE_NAME', 'SCRAPER_LOG_DO_EMAIL_ERRORS', 'STAFF_COOKIE_NAME', 'STAFF_COOKIE_VALUE', 'GENERIC_EMAIL_SENDER', 'DEFAULT_MAP_CENTER_LON', 'DEFAULT_MAP_CENTER_LAT', 'DEFAULT_MAP_ZOOM', 'MAP_BASELAYER_TYPE', 'STATIC_ROOT', 'MEDIA_ROOT', 'STATIC_URL', 'MEDIA_URL', 'EBPUB_CACHE_GEOCODER']
Subpackages¶
- accounts Package
- alerts Package
- db Package
- db Package
- admin Module
- breadcrumbs Module
- constants Module
- context_processors Module
- feeds Module
- fields Module
- forms Module
- models Module
- schemafilters Module
- urlresolvers Module
- utils Module
- views Module
- Subpackages
- geocoder Package
- metros Package
- moderation Package
- neighbornews Package
- openblockapi Package
- petitions Package
- preferences Package
- richmaps Package
- savedplaces Package
- streets Package
- utils Package
- widgets Package