summaryrefslogtreecommitdiffstats
path: root/main/utils.py
AgeCommit message (Collapse)AuthorFilesLines
2012-09-04Add a 'format_http_headers' methodDan McGee1-0/+10
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-07-25Remove custom utc_now() function, use django.utils.timezone.now()Dan McGee1-7/+2
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-09Don't log package updates in Python when we have DB trigger supportDan McGee1-0/+11
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-05-20Ensure we use last_modified date from News in headersDan McGee1-3/+4
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-03-24Make all datetime objects fully timezone awareDan McGee1-3/+9
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-24PEP8 cleanup with blank linesDan McGee1-0/+9
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-24Use python hashlib directlyDan McGee1-2/+2
Django hashcompat is now deprecated. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05Recent updates refactorDan McGee1-0/+35
Pull out a few helpful objects and functions for use later elsewhere. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05Move set_created_field() to shared utils classDan McGee1-0/+10
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-08Consolidate caching black magicDan McGee1-9/+25
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>
2010-10-14Connect post_save signals where they will always be triggeredDan McGee1-1/+23
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-14Add ability to clear a cached function resultDan McGee1-4/+13
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-08Move import to top levelDan McGee1-2/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-07-10Make the cache_function key a bit more descriptiveDan McGee1-0/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-06-21Add utility cache_functionDan McGee1-0/+35
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>
2008-10-12separate copyrighted middleware from my additionsDusty Phillips1-16/+0
2008-10-11use RequestContext because its standardDusty Phillips1-4/+0
2008-10-07need better than ids for optionsDusty Phillips1-0/+3
2008-09-17drop a bunch of stuff not necessary for django 1.0Dusty Phillips1-17/+0
2008-03-08Moved models aroundeliott1-0/+36