Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Twisted 9.0.0 compatibility

Also:
- Small improvements in OpManager
- Bug in Analytics code fixed
  • Loading branch information...
commit 98c16b087e6b060d4d0de5c90b41bfd5f4af3d1e 1 parent ffd3f6e
@p2k p2k authored
View
37 pygowave-web.tac
@@ -26,7 +26,13 @@
import os, sys, pkg_resources
from twisted.application import service, internet
-pkg_resources.require("twisted==8.2.0") # Specific workarounds needed
+new_twisted = False
+
+try:
+ pkg_resources.require("twisted>=9.0.0")
+ new_twisted = True
+except pkg_resources.VersionConflict:
+ pkg_resources.require("twisted==8.2.0") # Specific workarounds needed
def addOrbitedService(site):
# Duplicates functionality of orbited's start script
@@ -61,18 +67,24 @@ def addOrbitedService(site):
def setupDjangoService():
pkg_resources.require("django>=1.1")
- from twisted.web import wsgi, resource, server, static, error
+ from twisted.web import wsgi, resource, server, static
from twisted.python.threadpool import ThreadPool
from django.core.handlers.wsgi import WSGIHandler
from twisted.internet import reactor
import copy
+ if new_twisted:
+ from twisted.web.resource import NoResource
+ else:
+ from twisted.web.error import NoResource
+
wsgiThreadPool = ThreadPool()
wsgiThreadPool.start()
reactor.addSystemEventTrigger('after', 'shutdown', wsgiThreadPool.stop)
root = resource.Resource()
root.putChild('media', static.File("media"))
+ root.putChild('official', static.File("official"))
root.putChild('admin_media', static.File(pkg_resources.resource_filename("django", os.path.join("contrib", "admin", "media"))))
class CombinedWSGISite(server.Site):
@@ -83,22 +95,27 @@ def setupDjangoService():
def getResourceFor(self, request):
saved_path = (copy.copy(request.prepath), copy.copy(request.postpath))
ret = server.Site.getResourceFor(self, request)
- if isinstance(ret, error.NoResource):
+ if isinstance(ret, NoResource):
request.prepath, request.postpath = saved_path
- request.content.seek(0,0) # Note: May be removed on newer versions of Twisted
+ if not new_twisted:
+ request.content.seek(0,0)
return resource.getChildForRequest(self.wsgi_resource, request)
return ret
def __repr__(self):
return "CombinedWSGISite"
- def WSGIScriptNamePatch(handler): # Note: May be removed on newer versions of Twisted
- def call(environ, start_response):
- environ["SCRIPT_NAME"] = ""
- return handler(environ, start_response)
- return call
+ h = WSGIHandler()
+
+ if not new_twisted:
+ def WSGIScriptNamePatch(handler):
+ def call(environ, start_response):
+ environ["SCRIPT_NAME"] = ""
+ return handler(environ, start_response)
+ return call
+ h = WSGIScriptNamePatch(h)
- wsgi_resource = wsgi.WSGIResource(reactor, wsgiThreadPool, WSGIScriptNamePatch(WSGIHandler()))
+ wsgi_resource = wsgi.WSGIResource(reactor, wsgiThreadPool, h)
return CombinedWSGISite(root, wsgi_resource)
View
11 pygowave_server/common/operations.py
@@ -413,10 +413,15 @@ def transform(self, input_op):
else:
self.fireEvent("operationChanged", i)
else: # op.index + op.length() > end
- myop.resize(myop.length() - (end - op.index))
- self.fireEvent("operationChanged", i)
op.resize(op.length() - (end - op.index))
op.index = myop.index
+ myop.resize(myop.length() - (end - op.index))
+ if myop.isNull():
+ self.removeOperation(i)
+ i -= 1
+ break
+ else:
+ self.fireEvent("operationChanged", i)
elif op.isDelete() and myop.isInsert():
if op.index < myop.index:
@@ -842,7 +847,7 @@ def waveletAddParticipant(self, id):
def waveletRemoveParticipant(self, id):
"""
- Requests to remove a Participant to the Wavelet.
+ Requests to remove a Participant from the Wavelet.
@function {public} waveletRemoveParticipant
@param {String} id ID of the Participant to remove
View
2  pygowave_server/templatetags/analytics.py
@@ -40,7 +40,7 @@ def tracker_code():
return """<!-- Begin Google Analytics Code-->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
-document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+document.write(unescape("%%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%%3E%%3C/script%%3E"));
</script>
<script type="text/javascript">
try {
Please sign in to comment.
Something went wrong with that request. Please try again.