dejaqt more
chat log
This commit is contained in:
parent
18b157972b
commit
c7b8dce545
@ -27,11 +27,16 @@ class DejaNetworkAccessManager(QtNetwork.QNetworkAccessManager):
|
|||||||
'''
|
'''
|
||||||
The Deja Network Access Manager provides access to two new protocols:
|
The Deja Network Access Manager provides access to two new protocols:
|
||||||
- page:/// tries to resolve a page internally via a django test client.
|
- 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.
|
Note, if page does not find the page, a res:/// attempt is made automatically.
|
||||||
This has to be expanded!
|
This has to be expanded!
|
||||||
|
|
||||||
|
Note2: not sure if cookies and sessions will work this way!
|
||||||
'''
|
'''
|
||||||
USE_NETWORK = False
|
USE_NETWORK = False
|
||||||
def __init__(self, parent=None, basedir=None):
|
def __init__(self, parent=None, basedir=None):
|
||||||
@ -112,9 +117,9 @@ class PageReply(BasePageReply):
|
|||||||
def initialize_content(self, url, operation):
|
def initialize_content(self, url, operation):
|
||||||
c = Client()
|
c = Client()
|
||||||
print "Response for %s, method %s" % (url.path(), operation)
|
print "Response for %s, method %s" % (url.path(), operation)
|
||||||
if operation == LocalNetworkAccessManager.GetOperation:
|
if operation == DejaNetworkAccessManager.GetOperation:
|
||||||
response = c.get(unicode(url.path()), )
|
response = c.get(unicode(url.path()), )
|
||||||
elif operation == LocalNetworkAccessManager.PostOperation:
|
elif operation == DejaNetworkAccessManager.PostOperation:
|
||||||
response = c.post(unicode(url.path()))
|
response = c.post(unicode(url.path()))
|
||||||
# response code
|
# response code
|
||||||
print "Response Status: %s" % response.status_code
|
print "Response Status: %s" % response.status_code
|
||||||
@ -132,18 +137,23 @@ class NoNetworkReply(BasePageReply):
|
|||||||
</html>
|
</html>
|
||||||
'''
|
'''
|
||||||
|
|
||||||
class ImageReply(BasePageReply):
|
class ResourceReply(BasePageReply):
|
||||||
content_type = 'image/png'
|
content_type = 'image/png'
|
||||||
|
|
||||||
def __init__(self, parent, url, operation, basedir):
|
def __init__(self, parent, url, operation, basedir):
|
||||||
self.basedir = basedir
|
self.basedir = basedir
|
||||||
BasePageReply.__init__(self, parent, url, operation)
|
BasePageReply.__init__(self, parent, url, operation)
|
||||||
|
|
||||||
|
def determine_content_type(self, path):
|
||||||
|
return self.content_type
|
||||||
|
|
||||||
def initialize_content(self, url, operation):
|
def initialize_content(self, url, operation):
|
||||||
path = os.path.join(self.basedir, unicode(url.path()).lstrip('/'))
|
path = os.path.join(self.basedir, unicode(url.path()).lstrip('/'))
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
logging.error('Image does not exist: %s' % path)
|
logging.error('Image does not exist: %s' % path)
|
||||||
return ''
|
return ''
|
||||||
h = url.host()
|
#h = url.host()
|
||||||
|
# @todo: host checks?
|
||||||
try:
|
try:
|
||||||
f = open(path, 'rb')
|
f = open(path, 'rb')
|
||||||
return f.read()
|
return f.read()
|
||||||
|
@ -80,3 +80,7 @@ USE_TZ = True
|
|||||||
# https://docs.djangoproject.com/en/1.6/howto/static-files/
|
# https://docs.djangoproject.com/en/1.6/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
DEJAQT_DIRS = {
|
||||||
|
STATIC_URL: '',
|
||||||
|
}
|
0
logs/chat.py
Normal file
0
logs/chat.py
Normal file
Loading…
Reference in New Issue
Block a user