Pass current site to publisher callback
This commit is contained in:
parent
92dbe597ea
commit
c486e9fa1a
1 changed files with 7 additions and 8 deletions
|
@ -333,12 +333,12 @@ class UiWebsocket(object):
|
||||||
|
|
||||||
event_name = "publish %s %s" % (self.site.address, inner_path)
|
event_name = "publish %s %s" % (self.site.address, inner_path)
|
||||||
called_instantly = RateLimit.isAllowed(event_name, 30)
|
called_instantly = RateLimit.isAllowed(event_name, 30)
|
||||||
thread = RateLimit.callAsync(event_name, 30, self.doSitePublish, inner_path) # Only publish once in 30 seconds
|
thread = RateLimit.callAsync(event_name, 30, self.doSitePublish, self.site, inner_path) # Only publish once in 30 seconds
|
||||||
notification = "linked" not in dir(thread) # Only display notification on first callback
|
notification = "linked" not in dir(thread) # Only display notification on first callback
|
||||||
thread.linked = True
|
thread.linked = True
|
||||||
if called_instantly: # Allowed to call instantly
|
if called_instantly: # Allowed to call instantly
|
||||||
# At the end callback with request id and thread
|
# At the end callback with request id and thread
|
||||||
thread.link(lambda thread: self.cbSitePublish(to, thread, notification, callback=notification))
|
thread.link(lambda thread: self.cbSitePublish(to, self.site, thread, notification, callback=notification))
|
||||||
else:
|
else:
|
||||||
self.cmd(
|
self.cmd(
|
||||||
"notification",
|
"notification",
|
||||||
|
@ -346,15 +346,14 @@ class UiWebsocket(object):
|
||||||
)
|
)
|
||||||
self.response(to, "ok")
|
self.response(to, "ok")
|
||||||
# At the end display notification
|
# At the end display notification
|
||||||
thread.link(lambda thread: self.cbSitePublish(to, thread, notification, callback=False))
|
thread.link(lambda thread: self.cbSitePublish(to, self.site, thread, notification, callback=False))
|
||||||
|
|
||||||
def doSitePublish(self, inner_path):
|
def doSitePublish(self, site, inner_path):
|
||||||
diffs = self.site.content_manager.getDiffs(inner_path)
|
diffs = site.content_manager.getDiffs(inner_path)
|
||||||
return self.site.publish(limit=5, inner_path=inner_path, diffs=diffs)
|
return site.publish(limit=5, inner_path=inner_path, diffs=diffs)
|
||||||
|
|
||||||
# Callback of site publish
|
# Callback of site publish
|
||||||
def cbSitePublish(self, to, thread, notification=True, callback=True):
|
def cbSitePublish(self, to, site, thread, notification=True, callback=True):
|
||||||
site = self.site
|
|
||||||
published = thread.value
|
published = thread.value
|
||||||
if published > 0: # Successfully published
|
if published > 0: # Successfully published
|
||||||
if notification:
|
if notification:
|
||||||
|
|
Loading…
Reference in a new issue