- archives have hashes too

This commit is contained in:
j 2007-04-03 16:04:32 +00:00
commit 9022ed674b
4 changed files with 24 additions and 7 deletions

View file

@ -51,7 +51,7 @@ class ArchiveItem(SQLObject):
authorSort = UnicodeCol(default = '')
description = UnicodeCol() # text(for rss)
html = UnicodeCol() #(for page, contains javascript)
text = UnicodeCol() #Fulltext
text = UnicodeCol(length = 2**25) #Fulltext
relDate = DateTimeCol() #timestamp (item released)
pubDate = DateTimeCol() #timestamp (item published)
modDate = DateTimeCol() #timestamp (item published)
@ -137,6 +137,9 @@ class Archive(SQLObject):
hashId = UnicodeCol(alternateID = True, length=128)
def setHashId(self):
self.hashId = md5.new("%s" % self.id).hexdigest()
def _get_pubDateTimestamp(self):
if self.initialized:
return int(time.mktime(self.pubDate.timetuple()))
@ -168,19 +171,24 @@ class Archive(SQLObject):
def update(self):
result = simplejson.loads(read_url(self.files_url))
if result.has_key('css'):
if result and result.has_key('css'):
self.css = read_url(self.full_url(result['css']))
else:
self.css = ''
if result.has_key('js'):
if result and result.has_key('js'):
self.js = read_url(self.full_url(result['js']))
else:
self.js = ''
result = simplejson.loads(read_url(self.update_url))
items = result.get('items', [])
print len(items)
for id in items:
print "updating / adding ", id
data = jsonLoadArchiveItem(read_url(self.data_url(id)))
try:
data = read_url(self.data_url(id))
data = jsonLoadArchiveItem(data)
except:
print "failed to load ", id, "from ", self.data_url(id)
continue
q = ArchiveItem.select(AND(
ArchiveItem.q.archiveItemId == id,
ArchiveItem.q.archiveID == self.id))