1
0
Fork 0

Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel

This commit is contained in:
Michael Hackstein 2014-06-23 14:08:34 +02:00
commit a496978622
4 changed files with 50 additions and 15 deletions

View File

@ -31,15 +31,20 @@ def example_content(filepath, fh, tag):
""" Fetches an example file and inserts it using code """ Fetches an example file and inserts it using code
""" """
first = True
arangosh = False arangosh = False
showdots = True curl = False
first = True
lastline = None lastline = None
short = ""
shortLines = 0
long = "" long = ""
longLines = 0 longLines = 0
short = ""
shortLines = 0
shortable = False shortable = False
showdots = True
CURL_STATE_CMD = 1
CURL_STATE_HEADER = 2
CURL_STATE_BODY = 3
# read in the context, split into long and short # read in the context, split into long and short
infile = open(filepath, 'r') infile = open(filepath, 'r')
@ -47,6 +52,7 @@ def example_content(filepath, fh, tag):
for line in infile: for line in infile:
if first: if first:
arangosh = line.startswith("arangosh>") arangosh = line.startswith("arangosh>")
curl = line.startswith("shell> curl")
first = False first = False
if arangosh: if arangosh:
@ -57,11 +63,15 @@ def example_content(filepath, fh, tag):
lastline = None lastline = None
short = short + line short = short + line
shortLines = shortLines + 1
showdots = True showdots = True
else: else:
if showdots: if showdots:
if lastline == None: if lastline == None:
lastline = line # lastline = line
shortable = True
showdots = False
lastline = None
else: else:
# short = short + "~~~hidden~~~\n" # short = short + "~~~hidden~~~\n"
# shortLines = shortLines + 1 # shortLines = shortLines + 1
@ -69,12 +79,26 @@ def example_content(filepath, fh, tag):
showdots = False showdots = False
lastline = None lastline = None
if curl:
if line.startswith("shell> curl"):
curlState = CURL_STATE_CMD
elif curlState == CURL_STATE_CMD and line.startswith("HTTP/1.1 "):
curlState = CURL_STATE_HEADER
elif curlState == CURL_STATE_HEADER and line.startswith("{"):
curlState = CURL_STATE_BODY
if curlState == CURL_STATE_CMD or curlState == CURL_STATE_HEADER:
short = short + line
shortLines = shortLines + 1
else:
shortable = True
long = long + line long = long + line
longLines = longLines + 1 longLines = longLines + 1
# if lastline != None: if lastline != None:
# short = short + lastline short = short + lastline
# shortLines = shortLines + 1 shortLines = shortLines + 1
infile.close() infile.close()
@ -109,7 +133,14 @@ def example_content(filepath, fh, tag):
fh.write("```\n") fh.write("```\n")
fh.write("%s" % short) fh.write("%s" % short)
fh.write("```\n") fh.write("```\n")
fh.write("</pre><div class=\"example_show_button\">show execution results</div>\n")
if arangosh:
fh.write("</pre><div class=\"example_show_button\">show execution results</div>\n")
elif curl:
fh.write("</pre><div class=\"example_show_button\">show response body</div>\n")
else:
fh.write("</pre><div class=\"example_show_button\">show</div>\n")
fh.write("</div>\n") fh.write("</div>\n")
fh.write("</div>\n") fh.write("</div>\n")

View File

@ -160,10 +160,12 @@
var i; var i;
if (typeof body !== 'string') { if (typeof body !== 'string') {
body = JSON.stringify(body); internal.startCaptureMode();
print(body);
body = internal.stopCaptureMode();
} }
curl = "unix> curl "; curl = "shell> curl ";
if (method === 'POST') { if (method === 'POST') {
response = internal.arango.POST_RAW(url, body, headers); response = internal.arango.POST_RAW(url, body, headers);

View File

@ -160,10 +160,12 @@
var i; var i;
if (typeof body !== 'string') { if (typeof body !== 'string') {
body = JSON.stringify(body); internal.startCaptureMode();
print(body);
body = internal.stopCaptureMode();
} }
curl = "unix> curl "; curl = "shell> curl ";
if (method === 'POST') { if (method === 'POST') {
response = internal.arango.POST_RAW(url, body, headers); response = internal.arango.POST_RAW(url, body, headers);

View File

@ -102,6 +102,7 @@ Model = function (attributes) {
this.attributes = whitelistProperties(attributes, this.constructor.attributes, true); this.attributes = whitelistProperties(attributes, this.constructor.attributes, true);
this.attributes = fillInDefaults(this.attributes, this.constructor.attributes); this.attributes = fillInDefaults(this.attributes, this.constructor.attributes);
this.whitelistedAttributes = whitelistProperties(this.attributes, this.constructor.attributes);
}; };
Model.fromClient = function (attributes) { Model.fromClient = function (attributes) {
@ -269,8 +270,7 @@ _.extend(Model.prototype, {
forClient: function () { forClient: function () {
'use strict'; 'use strict';
var result = whitelistProperties(this.attributes, this.constructor.attributes); return this.whitelistedAttributes;
return result;
} }
}); });