Commit Graph

20 Commits

Author SHA1 Message Date
Dan McGee
5df83a3828 Add a 'format_http_headers' method
This takes a HttpRequest object and grabs the HTTP headers out of it and
pretty-prints them in a familiar format. This will come in handy if we
want to log these when creating package FlagRequests, releng Tests, etc.
in addition to already logging the IP address of the user posting the
request.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-09-04 08:53:39 -05:00
Dan McGee
c0bf9e2066 Remove custom utc_now() function, use django.utils.timezone.now()
This was around from the time when we handled timezones sanely and
Django did not; now that we are on 1.4 we no longer need our own code to
handle this.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-24 19:57:20 -05:00
Dan McGee
26a00cadce Don't log package updates in Python when we have DB trigger support
This adds a helper method to find the database engine in use, and then
skips code we shouldn't execute if we are doing this another way.

Note that this helper method could be useful for backend-specific code
paths elsewhere, such as custom SQL being called or lack of StdDev() in
sqlite3 out of the box.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-08 21:08:04 -05:00
Dan McGee
d685d51e8c Ensure we use last_modified date from News in headers
We were actually using the postdate attribute rather than last_modified,
which means any News objects that get edited would not trigger an update
of the feed.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-20 13:21:59 -05:00
Dan McGee
90e08b4863 Make all datetime objects fully timezone aware
This is most of the transition to Django 1.4 `USE_TZ = True`. We need to
ensure we don't mix aware and non-aware datetime objects when dealing
with datetimes in the code. Add a utc_now() helper method that we can
use most places, and ensure there is always a timezone attached when
necessary.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-23 19:54:40 -05:00
Dan McGee
bc1ba4e95a PEP8 cleanup with blank lines
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-23 19:54:40 -05:00
Dan McGee
6218ccc570 Use python hashlib directly
Django hashcompat is now deprecated.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-23 19:54:40 -05:00
Dan McGee
c5308b7583 Recent updates refactor
Pull out a few helpful objects and functions for use later elsewhere.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 09:48:10 -05:00
Dan McGee
5e85c5ac9e Move set_created_field() to shared utils class
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 09:44:45 -05:00
Dan McGee
77842a6c76 Consolidate caching black magic
Get the stuff used to retrieve and refresh the latest date values all in
the same place, and make it a bit more beautiful by refactoring it all
into a common set of methods.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-07 17:03:13 -05:00
Dan McGee
97d1e4164b Connect post_save signals where they will always be triggered
We need to do this in the models.py files, otherwise the post_save signal
might not be connected right away on launch of the application. Move them
over there, add a dispatch_uid so it only gets hooked up once, and do some
other function moving around so we don't have circular imports.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-13 18:11:28 -05:00
Dan McGee
0c65360e6c Add ability to clear a cached function result
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-13 18:10:55 -05:00
Dan McGee
2016a9d6f7 Move import to top level
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-07 19:45:09 -05:00
Dan McGee
6b4c8e63b3 Make the cache_function key a bit more descriptive
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-07-10 16:23:36 -05:00
Dan McGee
8ba6ad8521 Add utility cache_function
This allows caching the results of an arbitrary function and its arguments
in the Django-managed cache, e.g. memcached in production.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-06-21 00:50:19 -05:00
Dusty Phillips
5acf6c46f2 separate copyrighted middleware from my additions 2008-10-11 19:52:51 -04:00
Dusty Phillips
f260843deb use RequestContext because its standard 2008-10-10 18:51:21 -04:00
Dusty Phillips
92ae5b3f0b need better than ids for options 2008-10-07 14:53:56 -04:00
Dusty Phillips
4fd05e721e drop a bunch of stuff not necessary for django 1.0 2008-09-16 21:12:50 -04:00
eliott
9b7b512254 Moved models around 2008-03-08 00:13:41 -08:00