notifyFrontend
This commit is contained in:
parent
7c1c01a756
commit
5a9fd08511
3 changed files with 20 additions and 4 deletions
|
|
@ -29,6 +29,7 @@ __connection__ = hub
|
|||
class Archive(SQLObject):
|
||||
name = UnicodeCol(length=255, alternateID=True)
|
||||
basePath = UnicodeCol()
|
||||
baseUrlFrontend = UnicodeCol(default = '')
|
||||
|
||||
def _get_basePath(self):
|
||||
basePath = self._SO_get_basePath()
|
||||
|
|
@ -37,6 +38,12 @@ class Archive(SQLObject):
|
|||
self.basePath = basePath
|
||||
return basePath
|
||||
|
||||
def notifyFrontend(self, action, md5sum):
|
||||
if self.baseUrlFrontend:
|
||||
url = "%s/%s?md5sum=%s" % (self.baseUrlFrontend, action, md5sum)
|
||||
result = read_url(url)
|
||||
print "Frontend:", result
|
||||
|
||||
def _get_files(self):
|
||||
q = ArchiveFile.select(ArchiveFile.q.archiveID == self.id)
|
||||
return [f for f in q]
|
||||
|
|
@ -110,6 +117,7 @@ class Archive(SQLObject):
|
|||
)
|
||||
ret = "added entry"
|
||||
f.updateMeta()
|
||||
self.notifyFrontend('add', f.md5sum)
|
||||
return ret
|
||||
|
||||
def removeFile(self, md5sum):
|
||||
|
|
@ -123,6 +131,7 @@ class Archive(SQLObject):
|
|||
if q.count() == 1:
|
||||
for i in q:
|
||||
ArchiveFile.delete(i.id)
|
||||
self.notifyFrontend('remove', f.md5sum)
|
||||
return dict(result="file removed")
|
||||
return dict(result="not in archive")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue