From c7b8dce5456f60cb0cd3f7ccb3fd2fb235458d99 Mon Sep 17 00:00:00 2001 From: Gabor Guzmics Date: Fri, 6 Jun 2014 16:53:51 +0200 Subject: [PATCH] dejaqt more chat log --- dejaqt/qweb.py | 22 ++++++++++++++++------ dj/settings.py | 4 ++++ logs/chat.py | 0 3 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 logs/chat.py diff --git a/dejaqt/qweb.py b/dejaqt/qweb.py index f6c0bb2..f7eda9d 100644 --- a/dejaqt/qweb.py +++ b/dejaqt/qweb.py @@ -27,11 +27,16 @@ class DejaNetworkAccessManager(QtNetwork.QNetworkAccessManager): ''' The Deja Network Access Manager provides access to two new protocols: - page:/// tries to resolve a page internally via a django test client. - - res:/// access to a resource. + - res:/// direct access to a resource. + + USE_NETWORK delegates to other network access manager protocols, if False, it will not + allow any requests outside these two protocols + (hopefully disabling network access for your internal browser) Note, if page does not find the page, a res:/// attempt is made automatically. This has to be expanded! - + + Note2: not sure if cookies and sessions will work this way! ''' USE_NETWORK = False def __init__(self, parent=None, basedir=None): @@ -112,9 +117,9 @@ class PageReply(BasePageReply): def initialize_content(self, url, operation): c = Client() print "Response for %s, method %s" % (url.path(), operation) - if operation == LocalNetworkAccessManager.GetOperation: + if operation == DejaNetworkAccessManager.GetOperation: response = c.get(unicode(url.path()), ) - elif operation == LocalNetworkAccessManager.PostOperation: + elif operation == DejaNetworkAccessManager.PostOperation: response = c.post(unicode(url.path())) # response code print "Response Status: %s" % response.status_code @@ -132,18 +137,23 @@ class NoNetworkReply(BasePageReply): ''' -class ImageReply(BasePageReply): +class ResourceReply(BasePageReply): content_type = 'image/png' + def __init__(self, parent, url, operation, basedir): self.basedir = basedir BasePageReply.__init__(self, parent, url, operation) + + def determine_content_type(self, path): + return self.content_type def initialize_content(self, url, operation): path = os.path.join(self.basedir, unicode(url.path()).lstrip('/')) if not os.path.exists(path): logging.error('Image does not exist: %s' % path) return '' - h = url.host() + #h = url.host() + # @todo: host checks? try: f = open(path, 'rb') return f.read() diff --git a/dj/settings.py b/dj/settings.py index 13e99e7..f6c3a61 100644 --- a/dj/settings.py +++ b/dj/settings.py @@ -80,3 +80,7 @@ USE_TZ = True # https://docs.djangoproject.com/en/1.6/howto/static-files/ STATIC_URL = '/static/' + +DEJAQT_DIRS = { + STATIC_URL: '', + } \ No newline at end of file diff --git a/logs/chat.py b/logs/chat.py new file mode 100644 index 0000000..e69de29