Merge branch 'master' into DAL-modular
* master: (58 commits) changed version number better types by default, given that we're on 2005 at least fix for StorageList and tests added improved coverage, fix bug with IS_LIST_OF and items not being strings fix cache.increment, added tests R-2.9.11 reverted simplejson R-2.9.10 upgraded memcache and markdown2 upgraded pypyodbc.py upgraded simplejson no more split in contains, thanks Niphlod fixed wording and bug on contains(), made smart_query use ilike instead of like ilike, thanks Niphlod CROSS JOIN, thanks jotbe added custom represent to GoogleDatastoreAdapter, thanks Alan postgresql: identifies what adapter auto-loads json values added more tests for json Field fixed typo in driver_auto_json Improve the graphing to show the name of the application. ... Conflicts: gluon/dal.py gluon/globals.py gluon/tests/test_dal.py
This commit is contained in:
commit
5c07c511fa
55 files changed
+2385
-1407
No files matched your search
@@ -1,10 +1,13 @@
|
||||
## 2.9.6
|
||||
## 2.9.6 - 2.9.10
|
||||
|
||||
- fixed support of GAE + SQL
|
||||
- fixed a typo in the license of some login_methods code. It is now LGPL consistently with the rest of the web2py code. This change applied to all previous web2py versions.
|
||||
- support for SAML2 (with pysaml2)
|
||||
- Sphinx documentation (thanks Niphlod)
|
||||
- improved scheduler (thanks Niphlod)
|
||||
- increased security
|
||||
- better cache.disk (thanks Leonel)
|
||||
- sessions are stored in subfolders for speed
|
||||
- postgres support for "INSERT ... RETURING ..."
|
||||
- ldap support for Certificate Authority (thanks Maggs and Shane)
|
||||
- improved support for S/Mime X.509 (thanks Gyuris)
|
||||
@@ -12,6 +15,8 @@
|
||||
- support for Collection+JSON Hypermedia API (RESTful self documenting API)
|
||||
- jQuery 1.11
|
||||
- codemirror 4.0.3
|
||||
- markdown2 2.2.3
|
||||
- memcache 1.53
|
||||
- support for the new janrain API
|
||||
- new "web2py.py -G config" to make GAE configuration easier
|
||||
- many small bug fixes
|
||||
|
||||
@@ -30,20 +30,20 @@ update:
|
||||
echo "remember that pymysql was tweaked"
|
||||
src:
|
||||
### Use semantic versioning
|
||||
echo 'Version 2.9.6-stable+timestamp.'`date +%Y.%m.%d.%H.%M.%S` > VERSION
|
||||
echo 'Version 2.10.0-beta+timestamp.'`date +%Y.%m.%d.%H.%M.%S` > VERSION
|
||||
### rm -f all junk files
|
||||
make clean
|
||||
### clean up baisc apps
|
||||
rm -f routes.py
|
||||
rm -f applications/*/sessions/*
|
||||
rm -f applications/*/errors/* | echo 'too many files'
|
||||
rm -f applications/*/cache/*
|
||||
rm -f applications/admin/databases/*
|
||||
rm -f applications/welcome/databases/*
|
||||
rm -f applications/examples/databases/*
|
||||
rm -f applications/admin/uploads/*
|
||||
rm -f applications/welcome/uploads/*
|
||||
rm -f applications/examples/uploads/*
|
||||
rm -rf applications/*/sessions/*
|
||||
rm -rf applications/*/errors/* | echo 'too many files'
|
||||
rm -rf applications/*/cache/*
|
||||
rm -rf applications/admin/databases/*
|
||||
rm -rf applications/welcome/databases/*
|
||||
rm -rf applications/examples/databases/*
|
||||
rm -rf applications/admin/uploads/*
|
||||
rm -rf applications/welcome/uploads/*
|
||||
rm -rf applications/examples/uploads/*
|
||||
### NO MORE make epydoc
|
||||
# make epydoc
|
||||
### make welcome layout and appadmin the default
|
||||
|
||||
+7
-2
@@ -6,7 +6,6 @@ It is written and programmable in Python. LGPLv3 License
|
||||
|
||||
Learn more at http://web2py.com
|
||||
|
||||
|
||||
## Google App Engine deployment
|
||||
|
||||
cp examples/app.yaml ./
|
||||
@@ -14,6 +13,10 @@ Learn more at http://web2py.com
|
||||
|
||||
Then edit ./app.yaml and replace "yourappname" with yourappname.
|
||||
|
||||
## Documentation (readthedocs.org)
|
||||
|
||||
[](http://web2py.rtfd.org/)
|
||||
|
||||
## Tests
|
||||
|
||||
[](https://travis-ci.org/web2py/web2py)
|
||||
@@ -36,7 +39,6 @@ That's it!!!
|
||||
VERSION > this web2py version
|
||||
web2py.py > the startup script
|
||||
anyserver.py > to run with third party servers
|
||||
wsgihandler.py > handler to connect to WSGI
|
||||
... > other handlers and example files
|
||||
gluon/ > the core libraries
|
||||
contrib/ > third party libraries
|
||||
@@ -64,6 +66,9 @@ That's it!!!
|
||||
examples/ > example config files, mv .. and customize
|
||||
extras/ > other files which are required for building web2py
|
||||
scripts/ > utility and installation scripts
|
||||
handlers/
|
||||
wsgihandler.py > handler to connect to WSGI
|
||||
... > handlers for Fast-CGI, SCGI, Gevent, etc
|
||||
site-packages/ > additional optional modules
|
||||
logs/ > log files will go in there
|
||||
deposit/ > a place where web2py stores apps temporarily
|
||||
|
||||
@@ -1 +1 @@
|
||||
Version 2.9.6-stable+timestamp.2014.09.02.10.10.07
|
||||
Version 2.10.0-beta+timestamp.2014.09.24.13.35.58
|
||||
@@ -582,7 +582,7 @@ def bg_graph_model():
|
||||
if hasattr(db[tablename],'_meta_graphmodel'):
|
||||
meta_graphmodel = db[tablename]._meta_graphmodel
|
||||
else:
|
||||
meta_graphmodel = dict(group='Undefined', color='#ECECEC')
|
||||
meta_graphmodel = dict(group=request.application, color='#ECECEC')
|
||||
|
||||
group = meta_graphmodel['group'].replace(' ', '')
|
||||
if not subgraphs.has_key(group):
|
||||
|
||||
+4
-5
@@ -1,5 +1,4 @@
|
||||
/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
|
||||
*/
|
||||
(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(eLine truncated
|
||||
}({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])whilLine truncated
|
||||
u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){nn(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(iLine truncated
|
||||
/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
|
||||
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"Line truncated
|
||||
if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=rLine truncated
|
||||
},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Zb.propHooks.scrollTop=Zb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Zb.prototype.init,m.fx.step={};var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[ic],ec={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bc.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bc.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fc(){return setTimeout(function(){$b=void 0}),$b=m.now()}function gc(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hc(a,b,c){for(var d,e=(ec[b]||[]).concat(ec["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ic(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fb(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fb(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ac.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fb(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hc(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jc(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kc(a,b,c){var d,e,f=0,g=dc.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$b||fc(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$b||fc(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jc(k,j.opts.specialEasing);g>f;f++)if(d=dc[f].call(j,a,k,j.opts))return d;return m.map(k,hc,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kc,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],ec[c]=ec[c]||[],ec[c].unshift(b)},prefilter:function(a,b){b?dc.unshift(a):dc.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fLine truncated
|
||||
@@ -545,8 +545,11 @@
|
||||
};
|
||||
$('[data-show-trigger]', target).each(function () {
|
||||
var name = $(this).attr('data-show-trigger');
|
||||
if(!triggers[name]) triggers[name] = [];
|
||||
triggers[name].push($(this).attr('id'));
|
||||
// The field exists only when creating/editing a row
|
||||
if ($('#' + name).length) {
|
||||
if(!triggers[name]) triggers[name] = [];
|
||||
triggers[name].push($(this).attr('id'));
|
||||
}
|
||||
});
|
||||
for(var name in triggers) {
|
||||
$('#' + name, target).change(show_if).keyup(show_if);
|
||||
|
||||
@@ -582,7 +582,7 @@ def bg_graph_model():
|
||||
if hasattr(db[tablename],'_meta_graphmodel'):
|
||||
meta_graphmodel = db[tablename]._meta_graphmodel
|
||||
else:
|
||||
meta_graphmodel = dict(group='Undefined', color='#ECECEC')
|
||||
meta_graphmodel = dict(group=request.application, color='#ECECEC')
|
||||
|
||||
group = meta_graphmodel['group'].replace(' ', '')
|
||||
if not subgraphs.has_key(group):
|
||||
|
||||
+4
-5
@@ -1,5 +1,4 @@
|
||||
/*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
|
||||
*/
|
||||
(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(eLine truncated
|
||||
}({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])whilLine truncated
|
||||
u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){nn(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(iLine truncated
|
||||
/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
|
||||
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"Line truncated
|
||||
if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=rLine truncated
|
||||
},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Zb.propHooks.scrollTop=Zb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Zb.prototype.init,m.fx.step={};var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[ic],ec={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bc.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bc.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fc(){return setTimeout(function(){$b=void 0}),$b=m.now()}function gc(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hc(a,b,c){for(var d,e=(ec[b]||[]).concat(ec["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ic(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fb(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fb(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ac.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fb(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hc(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jc(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kc(a,b,c){var d,e,f=0,g=dc.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$b||fc(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$b||fc(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jc(k,j.opts.specialEasing);g>f;f++)if(d=dc[f].call(j,a,k,j.opts))return d;return m.map(k,hc,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kc,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],ec[c]=ec[c]||[],ec[c].unshift(b)},prefilter:function(a,b){b?dc.unshift(a):dc.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fLine truncated
|
||||
@@ -545,8 +545,11 @@
|
||||
};
|
||||
$('[data-show-trigger]', target).each(function () {
|
||||
var name = $(this).attr('data-show-trigger');
|
||||
if(!triggers[name]) triggers[name] = [];
|
||||
triggers[name].push($(this).attr('id'));
|
||||
// The field exists only when creating/editing a row
|
||||
if ($('#' + name).length) {
|
||||
if(!triggers[name]) triggers[name] = [];
|
||||
triggers[name].push($(this).attr('id'));
|
||||
}
|
||||
});
|
||||
for(var name in triggers) {
|
||||
$('#' + name, target).change(show_if).keyup(show_if);
|
||||
|
||||
@@ -582,7 +582,7 @@ def bg_graph_model():
|
||||
if hasattr(db[tablename],'_meta_graphmodel'):
|
||||
meta_graphmodel = db[tablename]._meta_graphmodel
|
||||
else:
|
||||
meta_graphmodel = dict(group='Undefined', color='#ECECEC')
|
||||
meta_graphmodel = dict(group=request.application, color='#ECECEC')
|
||||
|
||||
group = meta_graphmodel['group'].replace(' ', '')
|
||||
if not subgraphs.has_key(group):
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
/*! jQuery v1.11.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
|
||||
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="".trim,l={},m="1.11.0",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(n.isPlainObject(c)||(b=n.isArray(c)))?(b?(b=!1,f=a&&n.isArray(a)?a:[]):f=a&&n.isPlainObject(a)?a:{},g[d]=n.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray||function(a){return"array"===n.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==n.type(a)||a.nodeType||n.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(l.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&n.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:k&&!k.call("\ufeff\xa0")?function(a){return null==a?"":k.call(a)}:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),n.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||n.guid++,e):void 0},now:function(){return+new Date},support:l}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s="sizzle"+-new Date,t=a.document,u=0,v=0,w=eb(),x=eb(),y=eb(),z=function(a,b){return a===b&&(j=!0),0},A="undefined",B=1<<31,C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=D.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",M=L.replace("w","w#"),N="\\["+K+"*("+L+Line truncated
|
||||
}}function S(a,b,c){if(n.acceptData(a)){var d,e,f=a.nodeType,g=f?n.cache:a,h=f?a[n.expando]:n.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){n.isArray(b)?b=b.concat(n.map(b,n.camelCase)):b in d?b=[b]:(b=n.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!Q(d):!n.isEmptyObject(d))return}(c||(delete g[h].data,Q(g[h])))&&(f?n.cleanData([a],!0):l.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}n.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?n.cache[a[n.expando]]:a[n.expando],!!a&&!Q(a)},data:function(a,b,c){return R(a,b,c)},removeData:function(a,b){return S(a,b)},_data:function(a,b,c){return R(a,b,c,!0)},_removeData:function(a,b){return S(a,b,!0)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=n.data(f),1===f.nodeType&&!n._data(f,"parsedAttrs"))){c=g.length;while(c--)d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d]));n._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){n.data(this,a)}):arguments.length>1?this.each(function(){n.data(this,a,b)}):f?P(f,a,n.data(f,a)):void 0},removeData:function(a){return this.each(function(){n.removeData(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=n._data(a,b),c&&(!d||n.isArray(c)?d=n._data(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return n._data(a,c)||n._data(a,c,{empty:n.Callbacks("once memory").add(function(){n._removeData(a,b+"queue"),n._removeData(a,c)})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?n.queue(this[0],a):void 0===b?this:this.each(function(){var c=n.queue(this,a,b);n._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&n.dequeue(this,a)})},dequeue:function(a){return this.each(function(){n.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=n.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=n._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var T=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,U=["Top","Right","Bottom","Left"],V=function(a,b){return a=b||a,"none"===n.css(a,"display")||!n.contains(a.ownerDocument,a)},W=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},X=/^(?:checkbox|radio)$/i;!function(){var a=z.createDocumentFragment(),b=z.createElement("div"),c=z.createElement("input");if(b.setAttribute("className","t"),b.innerHTML=" <link/><table></table><a href='/a'>a</a>",l.leadingWhitespace=3===b.firstChild.nodeType,l.tbody=!b.getElementsByTagName("tbody").length,l.htmlSerialize=!!b.getElementsByTagName("link").length,l.html5Clone="<:nav></:nav>"!==z.createElement("nav").cloneNode(!0).outerHTML,c.type="checkbox",c.checked=!0,a.appendChild(c),l.appendChecked=c.checked,b.innerHTML="<textarea>x</textarea>",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,a.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,l.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){l.noCloneEvent=!1}),b.cloneNode(!0).click()),null==l.deleteExpando){l.deleteExpando=!0;try{delete b.test}catch(d){l.deleteExpando=!1}}a=b=c=null}(),function(){var b,c,d=z.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(l[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),l[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var Y=/^(?:input|select|textarea)$/i,Z=/^key/,$=/^(?:mouse|contextmenu)|click/,_=/^(?:focusinfocus|focusoutblur)$/,ab=/^([^.]*)(?:\.(.+)|)$/;function bb(){return!0}function cb(){return!1}function db(){try{return z.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=n._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=n.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof n===L||a&&n.event.triggered===a.type?void 0:n.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(F)||[""],h=b.length;while(h--)f=ab.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=n.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=n.event.special[o]||{},l=nLine truncated
|
||||
},a,b,arguments.length>1)},show:function(){return Wb(this,!0)},hide:function(){return Wb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){V(this)?n(this).show():n(this).hide()})}});function $b(a,b,c,d,e){return new $b.prototype.init(a,b,c,d,e)}n.Tween=$b,$b.prototype={constructor:$b,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(n.cssNumber[c]?"":"px")},cur:function(){var a=$b.propHooks[this.prop];return a&&a.get?a.get(this):$b.propHooks._default.get(this)},run:function(a){var b,c=$b.propHooks[this.prop];return this.pos=b=this.options.duration?n.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):$b.propHooks._default.set(this),this}},$b.prototype.init.prototype=$b.prototype,$b.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=n.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){n.fx.step[a.prop]?n.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[n.cssProps[a.prop]]||n.cssHooks[a.prop])?n.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},$b.propHooks.scrollTop=$b.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},n.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},n.fx=$b.prototype.init,n.fx.step={};var _b,ac,bc=/^(?:toggle|show|hide)$/,cc=new RegExp("^(?:([+-])=|)("+T+")([a-z%]*)$","i"),dc=/queueHooks$/,ec=[jc],fc={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=cc.exec(b),f=e&&e[3]||(n.cssNumber[a]?"":"px"),g=(n.cssNumber[a]||"px"!==f&&+d)&&cc.exec(n.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,n.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function gc(){return setTimeout(function(){_b=void 0}),_b=n.now()}function hc(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=U[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function ic(a,b,c){for(var d,e=(fc[b]||[]).concat(fc["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function jc(a,b,c){var d,e,f,g,h,i,j,k,m=this,o={},p=a.style,q=a.nodeType&&V(a),r=n._data(a,"fxshow");c.queue||(h=n._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,m.always(function(){m.always(function(){h.unqueued--,n.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=n.css(a,"display"),k=Gb(a.nodeName),"none"===j&&(j=k),"inline"===j&&"none"===n.css(a,"float")&&(l.inlineBlockNeedsLayout&&"inline"!==k?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",l.shrinkWrapBlocks()||m.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],bc.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||n.style(a,d)}if(!n.isEmptyObject(o)){r?"hidden"in r&&(q=r.hidden):r=n._data(a,"fxshow",{}),f&&(r.hidden=!q),q?n(a).show():m.done(function(){n(a).hide()}),m.done(function(){var b;n._removeData(a,"fxshow");for(b in o)n.style(a,b,o[b])});for(d in o)g=ic(q?r[d]:0,d,m),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function kc(a,b){var c,d,e,f,g;for(c in a)if(d=n.camelCase(c),e=b[d],f=a[c],n.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=n.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function lc(a,b,c){var d,e,f=0,g=ec.length,h=n.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=_b||gc(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:n.extend({},b),opts:n.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:_b||gc(),duration:c.duration,tweens:[],createTween:function(b,c){var d=n.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(kc(k,j.opts.specialEasing);g>f;f++)if(d=ec[f].call(j,a,k,j.opts))return d;return n.map(k,ic,j),n.isFunction(j.opts.start)&&j.opts.start.call(a,j),n.fx.timer(n.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)Line truncated
|
||||
/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
|
||||
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"Line truncated
|
||||
if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=rLine truncated
|
||||
},cur:function(){var a=Zb.propHooks[this.prop];return a&&a.get?a.get(this):Zb.propHooks._default.get(this)},run:function(a){var b,c=Zb.propHooks[this.prop];return this.pos=b=this.options.duration?m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Zb.propHooks._default.set(this),this}},Zb.prototype.init.prototype=Zb.prototype,Zb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Zb.propHooks.scrollTop=Zb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Zb.prototype.init,m.fx.step={};var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[ic],ec={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bc.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bc.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fc(){return setTimeout(function(){$b=void 0}),$b=m.now()}function gc(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hc(a,b,c){for(var d,e=(ec[b]||[]).concat(ec["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ic(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fb(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fb(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ac.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fb(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hc(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jc(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kc(a,b,c){var d,e,f=0,g=dc.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$b||fc(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$b||fc(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jc(k,j.opts.specialEasing);g>f;f++)if(d=dc[f].call(j,a,k,j.opts))return d;return m.map(k,hc,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kc,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],ec[c]=ec[c]||[],ec[c].unshift(b)},prefilter:function(a,b){b?dc.unshift(a):dc.push(a)}}),m.speed=function(a,b,c){var d=a&&"object"==typeof a?m.extend({},a):{complete:c||!c&&b||m.isFunction(a)&&a,duration:a,easing:c&&b||b&&!m.isFunction(b)&&b};return d.duration=m.fLine truncated
|
||||
@@ -545,8 +545,11 @@
|
||||
};
|
||||
$('[data-show-trigger]', target).each(function () {
|
||||
var name = $(this).attr('data-show-trigger');
|
||||
if(!triggers[name]) triggers[name] = [];
|
||||
triggers[name].push($(this).attr('id'));
|
||||
// The field exists only when creating/editing a row
|
||||
if ($('#' + name).length) {
|
||||
if(!triggers[name]) triggers[name] = [];
|
||||
triggers[name].push($(this).attr('id'));
|
||||
}
|
||||
});
|
||||
for(var name in triggers) {
|
||||
$('#' + name, target).change(show_if).keyup(show_if);
|
||||
|
||||
+127
-95
@@ -20,20 +20,26 @@ caching will be provided by the GAE memcache
|
||||
(see gluon.contrib.gae_memcache)
|
||||
"""
|
||||
import time
|
||||
import portalocker
|
||||
import shelve
|
||||
import thread
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import re
|
||||
import hashlib
|
||||
import datetime
|
||||
import tempfile
|
||||
from gluon import recfile
|
||||
try:
|
||||
from gluon import settings
|
||||
have_settings = True
|
||||
except ImportError:
|
||||
have_settings = False
|
||||
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
import pickle
|
||||
|
||||
logger = logging.getLogger("web2py.cache")
|
||||
|
||||
__all__ = ['Cache', 'lazy_cache']
|
||||
@@ -122,7 +128,7 @@ class CacheAbstract(object):
|
||||
Auxiliary function called by `clear` to search and clear cache entries
|
||||
"""
|
||||
r = re.compile(regex)
|
||||
for (key, value) in storage.items():
|
||||
for key in storage:
|
||||
if r.match(str(key)):
|
||||
del storage[key]
|
||||
break
|
||||
@@ -242,7 +248,6 @@ class CacheOnDisk(CacheAbstract):
|
||||
|
||||
This is implemented as a shelve object and it is shared by multiple web2py
|
||||
processes (and threads) as long as they share the same filesystem.
|
||||
The file is locked when accessed.
|
||||
|
||||
Disk cache provides persistance when web2py is started/stopped but it slower
|
||||
than `CacheInRam`
|
||||
@@ -250,137 +255,164 @@ class CacheOnDisk(CacheAbstract):
|
||||
Values stored in disk cache must be pickable.
|
||||
"""
|
||||
|
||||
def _close_shelve_and_unlock(self):
|
||||
try:
|
||||
if self.storage:
|
||||
self.storage.close()
|
||||
except ValueError:
|
||||
pass
|
||||
finally:
|
||||
self.storage = None
|
||||
if self.locker and self.locked:
|
||||
portalocker.unlock(self.locker)
|
||||
self.locker.close()
|
||||
self.locked = False
|
||||
class PersistentStorage(object):
|
||||
"""
|
||||
Implements a key based storage in disk.
|
||||
"""
|
||||
def __init__(self, folder):
|
||||
self.folder = folder
|
||||
# Check the best way to do atomic file replacement.
|
||||
if sys.version_info >= (3, 3):
|
||||
self.replace = os.replace
|
||||
elif sys.platform == "win32":
|
||||
import ctypes
|
||||
from ctypes import wintypes
|
||||
ReplaceFile = ctypes.windll.kernel32.ReplaceFileW
|
||||
ReplaceFile.restype = wintypes.BOOL
|
||||
ReplaceFile.argtypes = [
|
||||
wintypes.LPWSTR,
|
||||
wintypes.LPWSTR,
|
||||
wintypes.LPWSTR,
|
||||
wintypes.DWORD,
|
||||
wintypes.LPVOID,
|
||||
wintypes.LPVOID,
|
||||
]
|
||||
|
||||
def _open_shelve_and_lock(self):
|
||||
"""Open and return a shelf object, obtaining an exclusive lock
|
||||
on self.locker first. Replaces the close method of the
|
||||
returned shelf instance with one that releases the lock upon
|
||||
closing."""
|
||||
def replace_windows(src, dst):
|
||||
if not ReplaceFile(dst, src, None, 0, 0, 0):
|
||||
os.rename(src, dst)
|
||||
|
||||
storage = None
|
||||
locker = None
|
||||
locked = False
|
||||
try:
|
||||
locker = locker = open(self.locker_name, 'a')
|
||||
portalocker.lock(locker, portalocker.LOCK_EX)
|
||||
locked = True
|
||||
self.replace = replace_windows
|
||||
else:
|
||||
# POSIX rename() is always atomic
|
||||
self.replace = os.rename
|
||||
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
tmp_name, tmp_path = tempfile.mkstemp(dir=self.folder)
|
||||
tmp = os.fdopen(tmp_name, 'wb')
|
||||
try:
|
||||
storage = shelve.open(self.shelve_name)
|
||||
except:
|
||||
logger.error('corrupted cache file %s, will try rebuild it'
|
||||
% self.shelve_name)
|
||||
storage = None
|
||||
if storage is None:
|
||||
if os.path.exists(self.shelve_name):
|
||||
os.unlink(self.shelve_name)
|
||||
storage = shelve.open(self.shelve_name)
|
||||
if not CacheAbstract.cache_stats_name in storage.keys():
|
||||
storage[CacheAbstract.cache_stats_name] = {
|
||||
'hit_total': 0, 'misses': 0}
|
||||
storage.sync()
|
||||
except Exception, e:
|
||||
if storage:
|
||||
storage.close()
|
||||
storage = None
|
||||
if locked:
|
||||
portalocker.unlock(locker)
|
||||
locker.close()
|
||||
locked = False
|
||||
raise RuntimeError(
|
||||
'unable to create/re-create cache file %s' % self.shelve_name)
|
||||
self.locker = locker
|
||||
self.locked = locked
|
||||
self.storage = storage
|
||||
return storage
|
||||
pickle.dump((time.time(), value), tmp, pickle.HIGHEST_PROTOCOL)
|
||||
finally:
|
||||
tmp.close()
|
||||
fullfilename = os.path.join(self.folder, recfile.generate(key))
|
||||
if not os.path.exists(os.path.dirname(fullfilename)):
|
||||
os.makedirs(os.path.dirname(fullfilename))
|
||||
self.replace(tmp_path, fullfilename)
|
||||
|
||||
|
||||
def __getitem__(self, key):
|
||||
if recfile.exists(key, path=self.folder):
|
||||
timestamp, value = pickle.load(recfile.open(key, 'rb', path=self.folder))
|
||||
return value
|
||||
else:
|
||||
raise KeyError
|
||||
|
||||
def __contains__(self, key):
|
||||
return recfile.exists(key, path=self.folder)
|
||||
|
||||
|
||||
def __delitem__(self, key):
|
||||
recfile.remove(key, path=self.folder)
|
||||
|
||||
|
||||
def __iter__(self):
|
||||
for dirpath, dirnames, filenames in os.walk(self.folder):
|
||||
for filename in filenames:
|
||||
yield filename
|
||||
|
||||
|
||||
def get(self, key, default=None):
|
||||
try:
|
||||
return self[key]
|
||||
except KeyError:
|
||||
return default
|
||||
|
||||
|
||||
def clear(self):
|
||||
for key in self:
|
||||
del self[key]
|
||||
|
||||
def __init__(self, request=None, folder=None):
|
||||
self.initialized = False
|
||||
self.request = request
|
||||
self.folder = folder
|
||||
self.storage = {}
|
||||
self.storage = None
|
||||
|
||||
|
||||
def initialize(self):
|
||||
if self.initialized:
|
||||
return
|
||||
else:
|
||||
self.initialized = True
|
||||
|
||||
folder = self.folder
|
||||
request = self.request
|
||||
|
||||
# Lets test if the cache folder exists, if not
|
||||
# we are going to create it
|
||||
folder = folder or os.path.join(request.folder, 'cache')
|
||||
folder = os.path.join(folder or request.folder, 'cache')
|
||||
|
||||
if not os.path.exists(folder):
|
||||
os.mkdir(folder)
|
||||
|
||||
### we need this because of a possible bug in shelve that may
|
||||
### or may not lock
|
||||
self.locker_name = os.path.join(folder, 'cache.lock')
|
||||
self.shelve_name = os.path.join(folder, 'cache.shelve')
|
||||
self.storage = CacheOnDisk.PersistentStorage(folder)
|
||||
|
||||
if not CacheAbstract.cache_stats_name in self.storage:
|
||||
self.storage[CacheAbstract.cache_stats_name] = {'hit_total': 0, 'misses': 0}
|
||||
|
||||
def clear(self, regex=None):
|
||||
self.initialize()
|
||||
storage = self._open_shelve_and_lock()
|
||||
try:
|
||||
if regex is None:
|
||||
storage.clear()
|
||||
else:
|
||||
self._clear(storage, regex)
|
||||
storage.sync()
|
||||
finally:
|
||||
self._close_shelve_and_unlock()
|
||||
|
||||
def __call__(self, key, f,
|
||||
time_expire=DEFAULT_TIME_EXPIRE):
|
||||
self.initialize()
|
||||
|
||||
dt = time_expire
|
||||
storage = self._open_shelve_and_lock()
|
||||
try:
|
||||
item = storage.get(key, None)
|
||||
storage[CacheAbstract.cache_stats_name]['hit_total'] += 1
|
||||
if item and f is None:
|
||||
del storage[key]
|
||||
storage.sync()
|
||||
now = time.time()
|
||||
if f is None:
|
||||
value = None
|
||||
elif item and (dt is None or item[0] > now - dt):
|
||||
value = item[1]
|
||||
else:
|
||||
value = f()
|
||||
storage[key] = (now, value)
|
||||
storage[CacheAbstract.cache_stats_name]['misses'] += 1
|
||||
storage.sync()
|
||||
finally:
|
||||
self._close_shelve_and_unlock()
|
||||
item = self.storage.get(key)
|
||||
self.storage[CacheAbstract.cache_stats_name]['hit_total'] += 1
|
||||
|
||||
if item and f is None:
|
||||
del self.storage[key]
|
||||
|
||||
if f is None:
|
||||
return None
|
||||
|
||||
now = time.time()
|
||||
|
||||
if item and ((dt is None) or (item[0] > now - dt)):
|
||||
value = item[1]
|
||||
else:
|
||||
value = f()
|
||||
self.storage[key] = (now, value)
|
||||
self.storage[CacheAbstract.cache_stats_name]['misses'] += 1
|
||||
|
||||
return value
|
||||
|
||||
def clear(self, regex=None):
|
||||
self.initialize()
|
||||
storage = self.storage
|
||||
if regex is None:
|
||||
storage.clear()
|
||||
else:
|
||||
self._clear(storage, regex)
|
||||
|
||||
if not CacheAbstract.cache_stats_name in storage:
|
||||
storage[CacheAbstract.cache_stats_name] = {
|
||||
'hit_total': 0, 'misses': 0}
|
||||
|
||||
|
||||
def increment(self, key, value=1):
|
||||
self.initialize()
|
||||
storage = self._open_shelve_and_lock()
|
||||
storage = self.storage
|
||||
try:
|
||||
if key in storage:
|
||||
value = storage[key][1] + value
|
||||
storage[key] = (time.time(), value)
|
||||
storage.sync()
|
||||
finally:
|
||||
self._close_shelve_and_unlock()
|
||||
except:
|
||||
pass
|
||||
return value
|
||||
|
||||
|
||||
|
||||
class CacheAction(object):
|
||||
def __init__(self, func, key, time_expire, cache, cache_model):
|
||||
self.__name__ = func.__name__
|
||||
|
||||
+2
-1
@@ -39,6 +39,7 @@ import marshal
|
||||
import shutil
|
||||
import imp
|
||||
import logging
|
||||
import types
|
||||
logger = logging.getLogger("web2py")
|
||||
from gluon import rewrite
|
||||
from custom_import import custom_import_install
|
||||
@@ -212,7 +213,7 @@ def LOAD(c=None, f='index', args=None, vars=None,
|
||||
request.env.path_info
|
||||
other_request.cid = target
|
||||
other_request.env.http_web2py_component_element = target
|
||||
other_request.restful = request.restful # Needed when you call LOAD() on a controller who has some actions decorates with @request.restful()
|
||||
other_request.restful = types.MethodType(request.restful.im_func, other_request) # A bit nasty but needed to use LOAD on action decorates with @request.restful()
|
||||
other_response.view = '%s/%s.%s' % (c, f, other_request.extension)
|
||||
|
||||
other_environment = copy.copy(current.globalenv) # NASTY
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
# fix response
|
||||
|
||||
import re
|
||||
import os
|
||||
import cPickle
|
||||
import gluon.serializers
|
||||
from gluon import current, HTTP
|
||||
from gluon.html import markmin_serializer, TAG, HTML, BODY, UL, XML, H1
|
||||
from gluon.contenttype import contenttype
|
||||
from gluon.contrib.fpdf import FPDF, HTMLMixin
|
||||
from gluon.sanitizer import sanitize
|
||||
from gluon.contrib.markmin.markmin2latex import markmin2latex
|
||||
|
||||
+699
-224
File diff suppressed because it is too large.
Load diff
+676
-448
File diff suppressed because it is too large.
Load diff
+196
-87
@@ -4,7 +4,7 @@
|
||||
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2013 Henry Zhou <jiangwen365@gmail.com> and PyPyODBC contributors
|
||||
# Copyright (c) 2014 Henry Zhou <jiangwen365@gmail.com> and PyPyODBC contributors
|
||||
# Copyright (c) 2004 Michele Petrazzo
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
@@ -16,7 +16,7 @@
|
||||
# of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO #EVENT SHALL THE
|
||||
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
@@ -25,7 +25,7 @@ pooling = True
|
||||
apilevel = '2.0'
|
||||
paramstyle = 'qmark'
|
||||
threadsafety = 1
|
||||
version = '1.2.0'
|
||||
version = '1.3.0'
|
||||
lowercase=True
|
||||
|
||||
DEBUG = 0
|
||||
@@ -592,38 +592,38 @@ if sys.platform == 'cli':
|
||||
# http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.sdk_12.5.1.aseodbc/html/aseodbc/CACFDIGH.htm
|
||||
|
||||
SQL_data_type_dict = { \
|
||||
#SQL Data TYPE 0.Python Data Type 1.Default Output Converter 2.Buffer Type 3.Buffer Allocator 4.Default Buffer Size
|
||||
SQL_TYPE_NULL : (None, lambda x: None, SQL_C_CHAR, create_buffer, 2 ),
|
||||
SQL_CHAR : (str, lambda x: x, SQL_C_CHAR, create_buffer, 2048 ),
|
||||
SQL_NUMERIC : (Decimal, Decimal_cvt, SQL_C_CHAR, create_buffer, 150 ),
|
||||
SQL_DECIMAL : (Decimal, Decimal_cvt, SQL_C_CHAR, create_buffer, 150 ),
|
||||
SQL_INTEGER : (int, int, SQL_C_CHAR, create_buffer, 150 ),
|
||||
SQL_SMALLINT : (int, int, SQL_C_CHAR, create_buffer, 150 ),
|
||||
SQL_FLOAT : (float, float, SQL_C_CHAR, create_buffer, 150 ),
|
||||
SQL_REAL : (float, float, SQL_C_CHAR, create_buffer, 150 ),
|
||||
SQL_DOUBLE : (float, float, SQL_C_CHAR, create_buffer, 200 ),
|
||||
SQL_DATE : (datetime.date, dt_cvt, SQL_C_CHAR , create_buffer, 30 ),
|
||||
SQL_TIME : (datetime.time, tm_cvt, SQL_C_CHAR, create_buffer, 20 ),
|
||||
SQL_SS_TIME2 : (datetime.time, tm_cvt, SQL_C_CHAR, create_buffer, 20 ),
|
||||
SQL_TIMESTAMP : (datetime.datetime, dttm_cvt, SQL_C_CHAR, create_buffer, 30 ),
|
||||
SQL_VARCHAR : (str, lambda x: x, SQL_C_CHAR, create_buffer, 2048 ),
|
||||
SQL_LONGVARCHAR : (str, lambda x: x, SQL_C_CHAR, create_buffer, 20500 ),
|
||||
SQL_BINARY : (bytearray, bytearray_cvt, SQL_C_BINARY, create_buffer, 5120 ),
|
||||
SQL_VARBINARY : (bytearray, bytearray_cvt, SQL_C_BINARY, create_buffer, 5120 ),
|
||||
SQL_LONGVARBINARY : (bytearray, bytearray_cvt, SQL_C_BINARY, create_buffer, 20500 ),
|
||||
SQL_BIGINT : (long, long, SQL_C_CHAR, create_buffer, 150 ),
|
||||
SQL_TINYINT : (int, int, SQL_C_CHAR, create_buffer, 150 ),
|
||||
SQL_BIT : (bool, lambda x:x == BYTE_1, SQL_C_CHAR, create_buffer, 2 ),
|
||||
SQL_WCHAR : (unicode, lambda x: x, SQL_C_WCHAR, create_buffer_u, 2048 ),
|
||||
SQL_WVARCHAR : (unicode, lambda x: x, SQL_C_WCHAR, create_buffer_u, 2048 ),
|
||||
SQL_GUID : (str, str, SQL_C_CHAR, create_buffer, 50 ),
|
||||
SQL_WLONGVARCHAR : (unicode, lambda x: x, SQL_C_WCHAR, create_buffer_u, 20500 ),
|
||||
SQL_TYPE_DATE : (datetime.date, dt_cvt, SQL_C_CHAR, create_buffer, 30 ),
|
||||
SQL_TYPE_TIME : (datetime.time, tm_cvt, SQL_C_CHAR, create_buffer, 20 ),
|
||||
SQL_TYPE_TIMESTAMP : (datetime.datetime, dttm_cvt, SQL_C_CHAR, create_buffer, 30 ),
|
||||
SQL_SS_VARIANT : (str, lambda x: x, SQL_C_CHAR, create_buffer, 2048 ),
|
||||
SQL_SS_XML : (unicode, lambda x: x, SQL_C_WCHAR, create_buffer_u, 20500 ),
|
||||
SQL_SS_UDT : (bytearray, bytearray_cvt, SQL_C_BINARY, create_buffer, 5120 ),
|
||||
#SQL Data TYPE 0.Python Data Type 1.Default Output Converter 2.Buffer Type 3.Buffer Allocator 4.Default Size 5.Variable Length
|
||||
SQL_TYPE_NULL : (None, lambda x: None, SQL_C_CHAR, create_buffer, 2 , False ),
|
||||
SQL_CHAR : (str, lambda x: x, SQL_C_CHAR, create_buffer, 2048 , False ),
|
||||
SQL_NUMERIC : (Decimal, Decimal_cvt, SQL_C_CHAR, create_buffer, 150 , False ),
|
||||
SQL_DECIMAL : (Decimal, Decimal_cvt, SQL_C_CHAR, create_buffer, 150 , False ),
|
||||
SQL_INTEGER : (int, int, SQL_C_CHAR, create_buffer, 150 , False ),
|
||||
SQL_SMALLINT : (int, int, SQL_C_CHAR, create_buffer, 150 , False ),
|
||||
SQL_FLOAT : (float, float, SQL_C_CHAR, create_buffer, 150 , False ),
|
||||
SQL_REAL : (float, float, SQL_C_CHAR, create_buffer, 150 , False ),
|
||||
SQL_DOUBLE : (float, float, SQL_C_CHAR, create_buffer, 200 , False ),
|
||||
SQL_DATE : (datetime.date, dt_cvt, SQL_C_CHAR, create_buffer, 30 , False ),
|
||||
SQL_TIME : (datetime.time, tm_cvt, SQL_C_CHAR, create_buffer, 20 , False ),
|
||||
SQL_SS_TIME2 : (datetime.time, tm_cvt, SQL_C_CHAR, create_buffer, 20 , False ),
|
||||
SQL_TIMESTAMP : (datetime.datetime, dttm_cvt, SQL_C_CHAR, create_buffer, 30 , False ),
|
||||
SQL_VARCHAR : (str, lambda x: x, SQL_C_CHAR, create_buffer, 2048 , False ),
|
||||
SQL_LONGVARCHAR : (str, lambda x: x, SQL_C_CHAR, create_buffer, 20500 , True ),
|
||||
SQL_BINARY : (bytearray, bytearray_cvt, SQL_C_BINARY, create_buffer, 5120 , True ),
|
||||
SQL_VARBINARY : (bytearray, bytearray_cvt, SQL_C_BINARY, create_buffer, 5120 , True ),
|
||||
SQL_LONGVARBINARY : (bytearray, bytearray_cvt, SQL_C_BINARY, create_buffer, 20500 , True ),
|
||||
SQL_BIGINT : (long, long, SQL_C_CHAR, create_buffer, 150 , False ),
|
||||
SQL_TINYINT : (int, int, SQL_C_CHAR, create_buffer, 150 , False ),
|
||||
SQL_BIT : (bool, lambda x:x == BYTE_1, SQL_C_CHAR, create_buffer, 2 , False ),
|
||||
SQL_WCHAR : (unicode, lambda x: x, SQL_C_WCHAR, create_buffer_u, 2048 , False ),
|
||||
SQL_WVARCHAR : (unicode, lambda x: x, SQL_C_WCHAR, create_buffer_u, 2048 , False ),
|
||||
SQL_GUID : (str, str, SQL_C_CHAR, create_buffer, 2048 , False ),
|
||||
SQL_WLONGVARCHAR : (unicode, lambda x: x, SQL_C_WCHAR, create_buffer_u, 20500 , True ),
|
||||
SQL_TYPE_DATE : (datetime.date, dt_cvt, SQL_C_CHAR, create_buffer, 30 , False ),
|
||||
SQL_TYPE_TIME : (datetime.time, tm_cvt, SQL_C_CHAR, create_buffer, 20 , False ),
|
||||
SQL_TYPE_TIMESTAMP : (datetime.datetime, dttm_cvt, SQL_C_CHAR, create_buffer, 30 , False ),
|
||||
SQL_SS_VARIANT : (str, lambda x: x, SQL_C_CHAR, create_buffer, 2048 , True ),
|
||||
SQL_SS_XML : (unicode, lambda x: x, SQL_C_WCHAR, create_buffer_u, 20500 , True ),
|
||||
SQL_SS_UDT : (bytearray, bytearray_cvt, SQL_C_BINARY, create_buffer, 5120 , True ),
|
||||
}
|
||||
|
||||
|
||||
@@ -645,6 +645,7 @@ SQLRETURN -> ctypes.c_short
|
||||
funcs_with_ret = [
|
||||
"SQLAllocHandle",
|
||||
"SQLBindParameter",
|
||||
"SQLBindCol",
|
||||
"SQLCloseCursor",
|
||||
"SQLColAttribute",
|
||||
"SQLColumns",
|
||||
@@ -1175,6 +1176,8 @@ class Cursor:
|
||||
"""prepare a query"""
|
||||
|
||||
#self._free_results(FREE_STATEMENT)
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
if type(query_string) == unicode:
|
||||
c_query_string = wchar_pointer(UCS_buf(query_string))
|
||||
@@ -1231,6 +1234,8 @@ class Cursor:
|
||||
def _BindParams(self, param_types, pram_io_list = []):
|
||||
"""Create parameter buffers based on param types, and bind them to the statement"""
|
||||
# Clear the old Parameters
|
||||
if not self.connection:
|
||||
self.close()
|
||||
#self._free_results(NO_FREE_STATEMENT)
|
||||
|
||||
# Get the number of query parameters judged by database.
|
||||
@@ -1414,7 +1419,7 @@ class Cursor:
|
||||
dec_num, ADDR(ParameterBuffer), BufferLen,ADDR(LenOrIndBuf))
|
||||
if ret != SQL_SUCCESS:
|
||||
check_success(self, ret)
|
||||
# Append the value buffer and the lenth buffer to the array
|
||||
# Append the value buffer and the length buffer to the array
|
||||
ParamBufferList.append((ParameterBuffer,LenOrIndBuf,sql_type))
|
||||
|
||||
self._last_param_types = param_types
|
||||
@@ -1426,6 +1431,9 @@ class Cursor:
|
||||
If parameters are provided, the query would first be prepared, then executed with parameters;
|
||||
If parameters are not provided, only th query sting, it would be executed directly
|
||||
"""
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
self._free_stmt(SQL_CLOSE)
|
||||
if params:
|
||||
# If parameters exist, first prepare the query then executed with parameters
|
||||
@@ -1549,7 +1557,7 @@ class Cursor:
|
||||
c_buf_len = len(c_char_buf)
|
||||
|
||||
elif param_types[col_num][0] == 'bi':
|
||||
c_char_buf = str(param_val)
|
||||
c_char_buf = str_8b(param_val)
|
||||
c_buf_len = len(c_char_buf)
|
||||
|
||||
else:
|
||||
@@ -1587,6 +1595,8 @@ class Cursor:
|
||||
|
||||
|
||||
def _SQLExecute(self):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
ret = SQLExecute(self.stmt_h)
|
||||
if ret != SQL_SUCCESS:
|
||||
check_success(self, ret)
|
||||
@@ -1594,6 +1604,9 @@ class Cursor:
|
||||
|
||||
def execdirect(self, query_string):
|
||||
"""Execute a query directly"""
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
self._free_stmt()
|
||||
self._last_param_types = None
|
||||
self.statement = None
|
||||
@@ -1611,6 +1624,8 @@ class Cursor:
|
||||
|
||||
|
||||
def callproc(self, procname, args):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
raise Warning('', 'Still not fully implemented')
|
||||
self._pram_io_list = [row[4] for row in self.procedurecolumns(procedure = procname).fetchall() if row[4] not in (SQL_RESULT_COL, SQL_RETURN_VALUE)]
|
||||
|
||||
@@ -1637,6 +1652,9 @@ class Cursor:
|
||||
|
||||
|
||||
def executemany(self, query_string, params_list = [None]):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
for params in params_list:
|
||||
self.execute(query_string, params, many_mode = True)
|
||||
self._NumOfRows()
|
||||
@@ -1647,28 +1665,38 @@ class Cursor:
|
||||
|
||||
|
||||
def _CreateColBuf(self):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
self._free_stmt(SQL_UNBIND)
|
||||
NOC = self._NumOfCols()
|
||||
self._ColBufferList = []
|
||||
bind_data = True
|
||||
for col_num in range(NOC):
|
||||
col_name = self.description[col_num][0]
|
||||
|
||||
col_size = self.description[col_num][2]
|
||||
col_sql_data_type = self._ColTypeCodeList[col_num]
|
||||
|
||||
target_type = SQL_data_type_dict[col_sql_data_type][2]
|
||||
dynamic_length = SQL_data_type_dict[col_sql_data_type][5]
|
||||
# set default size base on the column's sql data type
|
||||
total_buf_len = SQL_data_type_dict[col_sql_data_type][4]
|
||||
# over-write if there's preset size value for "large columns"
|
||||
if total_buf_len >= 20500:
|
||||
|
||||
# over-write if there's pre-set size value for "large columns"
|
||||
if total_buf_len > 20500:
|
||||
total_buf_len = self._outputsize.get(None,total_buf_len)
|
||||
# over-write if there's preset size value for the "col_num" column
|
||||
# over-write if there's pre-set size value for the "col_num" column
|
||||
total_buf_len = self._outputsize.get(col_num, total_buf_len)
|
||||
|
||||
# if the size of the buffer is very long, do not bind
|
||||
# because a large buffer decrease performance, and sometimes you only get a NULL value.
|
||||
# in that case use sqlgetdata instead.
|
||||
if col_size >= 1024:
|
||||
dynamic_length = True
|
||||
|
||||
alloc_buffer = SQL_data_type_dict[col_sql_data_type][3](total_buf_len)
|
||||
|
||||
used_buf_len = c_ssize_t()
|
||||
|
||||
target_type = SQL_data_type_dict[col_sql_data_type][2]
|
||||
force_unicode = self.connection.unicode_results
|
||||
|
||||
if force_unicode and col_sql_data_type in (SQL_CHAR,SQL_VARCHAR,SQL_LONGVARCHAR):
|
||||
@@ -1676,14 +1704,22 @@ class Cursor:
|
||||
alloc_buffer = create_buffer_u(total_buf_len)
|
||||
|
||||
buf_cvt_func = self.connection.output_converter[self._ColTypeCodeList[col_num]]
|
||||
ADDR(alloc_buffer)
|
||||
ADDR(used_buf_len)
|
||||
self._ColBufferList.append([col_name, target_type, used_buf_len, ADDR(used_buf_len), alloc_buffer, ADDR(alloc_buffer), total_buf_len, buf_cvt_func])
|
||||
|
||||
if bind_data:
|
||||
if dynamic_length:
|
||||
bind_data = False
|
||||
self._ColBufferList.append([col_name, target_type, used_buf_len, ADDR(used_buf_len), alloc_buffer, ADDR(alloc_buffer), total_buf_len, buf_cvt_func, bind_data])
|
||||
|
||||
if bind_data:
|
||||
ret = ODBC_API.SQLBindCol(self.stmt_h, col_num + 1, target_type, ADDR(alloc_buffer), total_buf_len, ADDR(used_buf_len))
|
||||
if ret != SQL_SUCCESS:
|
||||
check_success(self, ret)
|
||||
|
||||
def _UpdateDesc(self):
|
||||
"Get the information of (name, type_code, display_size, internal_size, col_precision, scale, null_ok)"
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
force_unicode = self.connection.unicode_results
|
||||
if force_unicode:
|
||||
Cname = create_buffer_u(1024)
|
||||
@@ -1739,6 +1775,9 @@ class Cursor:
|
||||
|
||||
def _NumOfRows(self):
|
||||
"""Get the number of rows"""
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
NOR = c_ssize_t()
|
||||
ret = SQLRowCount(self.stmt_h, ADDR(NOR))
|
||||
if ret != SQL_SUCCESS:
|
||||
@@ -1749,6 +1788,9 @@ class Cursor:
|
||||
|
||||
def _NumOfCols(self):
|
||||
"""Get the number of cols"""
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
NOC = c_short()
|
||||
ret = SQLNumResultCols(self.stmt_h, ADDR(NOC))
|
||||
if ret != SQL_SUCCESS:
|
||||
@@ -1757,6 +1799,9 @@ class Cursor:
|
||||
|
||||
|
||||
def fetchall(self):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
rows = []
|
||||
while True:
|
||||
row = self.fetchone()
|
||||
@@ -1767,6 +1812,9 @@ class Cursor:
|
||||
|
||||
|
||||
def fetchmany(self, num = None):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
if num is None:
|
||||
num = self.arraysize
|
||||
rows = []
|
||||
@@ -1780,58 +1828,66 @@ class Cursor:
|
||||
|
||||
|
||||
def fetchone(self):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
ret = SQLFetch(self.stmt_h)
|
||||
if ret == SQL_SUCCESS:
|
||||
|
||||
if ret in (SQL_SUCCESS,SQL_SUCCESS_WITH_INFO):
|
||||
'''Bind buffers for the record set columns'''
|
||||
|
||||
value_list = []
|
||||
col_num = 1
|
||||
for col_name, target_type, used_buf_len, ADDR_used_buf_len, alloc_buffer, ADDR_alloc_buffer, total_buf_len, buf_cvt_func in self._ColBufferList:
|
||||
|
||||
blocks = []
|
||||
for col_name, target_type, used_buf_len, ADDR_used_buf_len, alloc_buffer, ADDR_alloc_buffer, total_buf_len, buf_cvt_func, bind_data in self._ColBufferList:
|
||||
raw_data_parts = []
|
||||
while 1:
|
||||
ret = SQLGetData(self.stmt_h, col_num, target_type, ADDR_alloc_buffer, total_buf_len, ADDR_used_buf_len)
|
||||
if bind_data:
|
||||
ret = SQL_SUCCESS
|
||||
else:
|
||||
ret = SQLGetData(self.stmt_h, col_num, target_type, ADDR_alloc_buffer, total_buf_len, ADDR_used_buf_len)
|
||||
if ret == SQL_SUCCESS:
|
||||
if used_buf_len.value == SQL_NULL_DATA:
|
||||
value_list.append(None)
|
||||
else:
|
||||
if blocks == []:
|
||||
if raw_data_parts == []:
|
||||
# Means no previous data, no need to combine
|
||||
if target_type == SQL_C_BINARY:
|
||||
value_list.append(buf_cvt_func(alloc_buffer.raw[:used_buf_len.value]))
|
||||
elif target_type == SQL_C_WCHAR:
|
||||
value_list.append(buf_cvt_func(from_buffer_u(alloc_buffer)))
|
||||
else:
|
||||
#print col_name, target_type, alloc_buffer.value
|
||||
value_list.append(buf_cvt_func(alloc_buffer.value))
|
||||
else:
|
||||
# There are previous fetched raw data to combine
|
||||
if target_type == SQL_C_BINARY:
|
||||
blocks.append(alloc_buffer.raw[:used_buf_len.value])
|
||||
raw_data_parts.append(alloc_buffer.raw[:used_buf_len.value])
|
||||
elif target_type == SQL_C_WCHAR:
|
||||
blocks.append(from_buffer_u(alloc_buffer))
|
||||
raw_data_parts.append(from_buffer_u(alloc_buffer))
|
||||
else:
|
||||
#print col_name, target_type, alloc_buffer.value
|
||||
blocks.append(alloc_buffer.value)
|
||||
raw_data_parts.append(alloc_buffer.value)
|
||||
break
|
||||
|
||||
elif ret == SQL_SUCCESS_WITH_INFO:
|
||||
# Means the data is only partial
|
||||
if target_type == SQL_C_BINARY:
|
||||
blocks.append(alloc_buffer.raw)
|
||||
raw_data_parts.append(alloc_buffer.raw)
|
||||
else:
|
||||
blocks.append(alloc_buffer.value)
|
||||
raw_data_parts.append(alloc_buffer.value)
|
||||
|
||||
elif ret == SQL_NO_DATA:
|
||||
# Means all data has been transmitted
|
||||
break
|
||||
else:
|
||||
check_success(self, ret)
|
||||
|
||||
if blocks != []:
|
||||
if raw_data_parts != []:
|
||||
if py_v3:
|
||||
if target_type != SQL_C_BINARY:
|
||||
raw_value = ''.join(blocks)
|
||||
raw_value = ''.join(raw_data_parts)
|
||||
else:
|
||||
raw_value = BLANK_BYTE.join(blocks)
|
||||
raw_value = BLANK_BYTE.join(raw_data_parts)
|
||||
else:
|
||||
raw_value = ''.join(blocks)
|
||||
raw_value = ''.join(raw_data_parts)
|
||||
|
||||
value_list.append(buf_cvt_func(raw_value))
|
||||
col_num += 1
|
||||
@@ -1840,12 +1896,13 @@ class Cursor:
|
||||
|
||||
else:
|
||||
if ret == SQL_NO_DATA_FOUND:
|
||||
|
||||
return None
|
||||
else:
|
||||
check_success(self, ret)
|
||||
|
||||
def __next__(self):
|
||||
self.next()
|
||||
return self.next()
|
||||
|
||||
def next(self):
|
||||
row = self.fetchone()
|
||||
@@ -1858,6 +1915,9 @@ class Cursor:
|
||||
|
||||
|
||||
def skip(self, count = 0):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
for i in range(count):
|
||||
ret = ODBC_API.SQLFetchScroll(self.stmt_h, SQL_FETCH_NEXT, 0)
|
||||
if ret != SQL_SUCCESS:
|
||||
@@ -1867,6 +1927,9 @@ class Cursor:
|
||||
|
||||
|
||||
def nextset(self):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
ret = ODBC_API.SQLMoreResults(self.stmt_h)
|
||||
if ret not in (SQL_SUCCESS, SQL_NO_DATA):
|
||||
check_success(self, ret)
|
||||
@@ -1882,6 +1945,9 @@ class Cursor:
|
||||
|
||||
|
||||
def _free_stmt(self, free_type = None):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
if not self.connection.connected:
|
||||
raise ProgrammingError('HY000','Attempt to use a closed connection.')
|
||||
|
||||
@@ -1903,6 +1969,9 @@ class Cursor:
|
||||
|
||||
|
||||
def getTypeInfo(self, sqlType = None):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
if sqlType is None:
|
||||
type = SQL_ALL_TYPES
|
||||
else:
|
||||
@@ -1917,6 +1986,9 @@ class Cursor:
|
||||
|
||||
def tables(self, table=None, catalog=None, schema=None, tableType=None):
|
||||
"""Return a list with all tables"""
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
l_catalog = l_schema = l_table = l_tableType = 0
|
||||
|
||||
if unicode in [type(x) for x in (table, catalog, schema,tableType)]:
|
||||
@@ -1962,6 +2034,9 @@ class Cursor:
|
||||
|
||||
def columns(self, table=None, catalog=None, schema=None, column=None):
|
||||
"""Return a list with all columns"""
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
l_catalog = l_schema = l_table = l_column = 0
|
||||
|
||||
if unicode in [type(x) for x in (table, catalog, schema,column)]:
|
||||
@@ -2004,6 +2079,9 @@ class Cursor:
|
||||
|
||||
|
||||
def primaryKeys(self, table=None, catalog=None, schema=None):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
l_catalog = l_schema = l_table = 0
|
||||
|
||||
if unicode in [type(x) for x in (table, catalog, schema)]:
|
||||
@@ -2044,6 +2122,9 @@ class Cursor:
|
||||
|
||||
|
||||
def foreignKeys(self, table=None, catalog=None, schema=None, foreignTable=None, foreignCatalog=None, foreignSchema=None):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
l_catalog = l_schema = l_table = l_foreignTable = l_foreignCatalog = l_foreignSchema = 0
|
||||
|
||||
if unicode in [type(x) for x in (table, catalog, schema,foreignTable,foreignCatalog,foreignSchema)]:
|
||||
@@ -2092,6 +2173,9 @@ class Cursor:
|
||||
|
||||
|
||||
def procedurecolumns(self, procedure=None, catalog=None, schema=None, column=None):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
l_catalog = l_schema = l_procedure = l_column = 0
|
||||
if unicode in [type(x) for x in (procedure, catalog, schema,column)]:
|
||||
string_p = lambda x:wchar_pointer(UCS_buf(x))
|
||||
@@ -2132,6 +2216,9 @@ class Cursor:
|
||||
|
||||
|
||||
def procedures(self, procedure=None, catalog=None, schema=None):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
l_catalog = l_schema = l_procedure = 0
|
||||
|
||||
if unicode in [type(x) for x in (procedure, catalog, schema)]:
|
||||
@@ -2170,6 +2257,9 @@ class Cursor:
|
||||
|
||||
|
||||
def statistics(self, table, catalog=None, schema=None, unique=False, quick=True):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
l_table = l_catalog = l_schema = 0
|
||||
|
||||
if unicode in [type(x) for x in (table, catalog, schema)]:
|
||||
@@ -2217,15 +2307,23 @@ class Cursor:
|
||||
|
||||
|
||||
def commit(self):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
self.connection.commit()
|
||||
|
||||
def rollback(self):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
self.connection.rollback()
|
||||
|
||||
def setoutputsize(self, size, column = None):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
self._outputsize[column] = size
|
||||
|
||||
def setinputsizes(self, sizes):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
self._inputsizers = [size for size in sizes]
|
||||
|
||||
|
||||
@@ -2234,35 +2332,31 @@ class Cursor:
|
||||
# ret = ODBC_API.SQLCloseCursor(self.stmt_h)
|
||||
# check_success(self, ret)
|
||||
#
|
||||
ret = ODBC_API.SQLFreeStmt(self.stmt_h, SQL_CLOSE)
|
||||
check_success(self, ret)
|
||||
if self.connection.connected:
|
||||
ret = ODBC_API.SQLFreeStmt(self.stmt_h, SQL_CLOSE)
|
||||
check_success(self, ret)
|
||||
|
||||
ret = ODBC_API.SQLFreeStmt(self.stmt_h, SQL_UNBIND)
|
||||
check_success(self, ret)
|
||||
ret = ODBC_API.SQLFreeStmt(self.stmt_h, SQL_UNBIND)
|
||||
check_success(self, ret)
|
||||
|
||||
ret = ODBC_API.SQLFreeStmt(self.stmt_h, SQL_RESET_PARAMS)
|
||||
check_success(self, ret)
|
||||
ret = ODBC_API.SQLFreeStmt(self.stmt_h, SQL_RESET_PARAMS)
|
||||
check_success(self, ret)
|
||||
|
||||
ret = ODBC_API.SQLFreeHandle(SQL_HANDLE_STMT, self.stmt_h)
|
||||
check_success(self, ret)
|
||||
|
||||
ret = ODBC_API.SQLFreeHandle(SQL_HANDLE_STMT, self.stmt_h)
|
||||
check_success(self, ret)
|
||||
|
||||
self.closed = True
|
||||
|
||||
|
||||
|
||||
def __del__(self):
|
||||
if not self.closed:
|
||||
#if DEBUG:print 'auto closing cursor: ',
|
||||
try:
|
||||
self.close()
|
||||
except:
|
||||
#if DEBUG:print 'failed'
|
||||
pass
|
||||
else:
|
||||
#if DEBUG:print 'succeed'
|
||||
pass
|
||||
self.close()
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
if not self.connection:
|
||||
self.close()
|
||||
|
||||
if value:
|
||||
self.rollback()
|
||||
else:
|
||||
@@ -2291,7 +2385,7 @@ class Connection:
|
||||
self.autocommit = autocommit
|
||||
self.readonly = False
|
||||
self.timeout = 0
|
||||
self._cursors = []
|
||||
# self._cursors = []
|
||||
for key, value in list(kargs.items()):
|
||||
connectString = connectString + key + '=' + value + ';'
|
||||
self.connectString = connectString
|
||||
@@ -2425,7 +2519,7 @@ class Connection:
|
||||
if not self.connected:
|
||||
raise ProgrammingError('HY000','Attempt to use a closed connection.')
|
||||
cur = Cursor(self, row_type_callable=row_type_callable)
|
||||
self._cursors.append(cur)
|
||||
# self._cursors.append(cur)
|
||||
return cur
|
||||
|
||||
def update_db_special_info(self):
|
||||
@@ -2436,6 +2530,7 @@ class Connection:
|
||||
SQL_SS_TIME2,
|
||||
):
|
||||
cur = Cursor(self)
|
||||
|
||||
try:
|
||||
info_tuple = cur.getTypeInfo(sql_type)
|
||||
if info_tuple is not None:
|
||||
@@ -2534,10 +2629,10 @@ class Connection:
|
||||
def close(self):
|
||||
if not self.connected:
|
||||
raise ProgrammingError('HY000','Attempt to close a closed connection.')
|
||||
for cur in self._cursors:
|
||||
if not cur is None:
|
||||
if not cur.closed:
|
||||
cur.close()
|
||||
# for cur in self._cursors:
|
||||
# if not cur is None:
|
||||
# if not cur.closed:
|
||||
# cur.close()
|
||||
|
||||
if self.connected:
|
||||
#if DEBUG:print 'disconnect'
|
||||
@@ -2681,3 +2776,17 @@ def dataSources():
|
||||
else:
|
||||
dsn_list[dsn.value] = desc.value
|
||||
return dsn_list
|
||||
|
||||
|
||||
def monkey_patch_for_gevent():
|
||||
import functools, gevent
|
||||
apply_e = gevent.get_hub().threadpool.apply_e
|
||||
def monkey_patch(func):
|
||||
@functools.wraps(func)
|
||||
def wrap(*args, **kwargs):
|
||||
#if DEBUG:print('%s called with %s %s' % (func, args, kwargs))
|
||||
return apply_e(Exception, func, args, kwargs)
|
||||
return wrap
|
||||
for attr in dir(ODBC_API):
|
||||
if attr.startswith('SQL') and hasattr(getattr(ODBC_API, attr), 'argtypes'):
|
||||
setattr(ODBC_API, attr, monkey_patch(getattr(ODBC_API, attr)))
|
||||
@@ -6,7 +6,10 @@ import redis
|
||||
from redis.exceptions import ConnectionError
|
||||
from gluon import current
|
||||
from gluon.cache import CacheAbstract
|
||||
import cPickle as pickle
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
import pickle
|
||||
import time
|
||||
import re
|
||||
import logging
|
||||
@@ -165,7 +168,7 @@ class RedisClient(object):
|
||||
expireat = int(time.time() + time_expire) + 120
|
||||
bucket_key = "%s:%s" % (cache_set_key, expireat / 60)
|
||||
value = f()
|
||||
value_ = pickle.dumps(value)
|
||||
value_ = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
|
||||
if time_expire == 0:
|
||||
time_expire = 1
|
||||
self.r_server.setex(key, value_, time_expire)
|
||||
|
||||
@@ -3,12 +3,9 @@ Developed by niphlod@gmail.com
|
||||
"""
|
||||
|
||||
import redis
|
||||
from redis.exceptions import ConnectionError
|
||||
from gluon import current
|
||||
from gluon.storage import Storage
|
||||
import cPickle as pickle
|
||||
import time
|
||||
import re
|
||||
import logging
|
||||
import thread
|
||||
|
||||
|
||||
@@ -31,12 +31,13 @@ An interactive, stateful AJAX shell that runs Python code on the server.
|
||||
|
||||
import logging
|
||||
import new
|
||||
import os
|
||||
import cPickle
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
import pickle
|
||||
import sys
|
||||
import traceback
|
||||
import types
|
||||
import wsgiref.handlers
|
||||
import StringIO
|
||||
import threading
|
||||
locker = threading.RLock()
|
||||
@@ -100,7 +101,7 @@ class History:
|
||||
name: the name of the global to remove
|
||||
value: any picklable value
|
||||
"""
|
||||
blob = cPickle.dumps(value)
|
||||
blob = pickle.dumps(value, pickle.HIGHEST_PROTOCOL)
|
||||
|
||||
if name in self.global_names:
|
||||
index = self.global_names.index(name)
|
||||
@@ -159,7 +160,7 @@ def represent(obj):
|
||||
code below to determine whether the object changes over time.
|
||||
"""
|
||||
try:
|
||||
return cPickle.dumps(obj)
|
||||
return pickle.dumps(obj, pickle.HIGHEST_PROTOCOL)
|
||||
except:
|
||||
return repr(obj)
|
||||
|
||||
@@ -258,7 +259,7 @@ def run(history, statement, env={}):
|
||||
if not name.startswith('__'):
|
||||
try:
|
||||
history.set_global(name, val)
|
||||
except (TypeError, cPickle.PicklingError), ex:
|
||||
except (TypeError, pickle.PicklingError), ex:
|
||||
UNPICKLABLE_TYPES.append(type(val))
|
||||
history.add_unpicklable(statement, new_globals.keys())
|
||||
|
||||
|
||||
+3
-1
@@ -20,7 +20,7 @@ import datetime
|
||||
import logging
|
||||
from http import HTTP
|
||||
from gzip import open as gzopen
|
||||
|
||||
from recfile import generate
|
||||
|
||||
__all__ = [
|
||||
'parse_version',
|
||||
@@ -400,6 +400,8 @@ def get_session(request, other_application='admin'):
|
||||
session_id = request.cookies['session_id_' + other_application].value
|
||||
session_filename = os.path.join(
|
||||
up(request.folder), other_application, 'sessions', session_id)
|
||||
if not os.path.exists(session_filename):
|
||||
session_filename = generate(session_filename)
|
||||
osession = storage.load_storage(session_filename)
|
||||
except Exception, e:
|
||||
osession = storage.Storage()
|
||||
|
||||
+19
-11
@@ -25,15 +25,19 @@ from gluon.serializers import json, custom_json
|
||||
import gluon.settings as settings
|
||||
from gluon.utils import web2py_uuid, secure_dumps, secure_loads
|
||||
from gluon.settings import global_settings
|
||||
from gluon.dal import Field
|
||||
from gluon import recfile
|
||||
import hashlib
|
||||
import portalocker
|
||||
import cPickle
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
import pickle
|
||||
from pickle import Pickler, MARK, DICT, EMPTY_DICT
|
||||
from types import DictionaryType
|
||||
import cStringIO
|
||||
import datetime
|
||||
import re
|
||||
import copy_reg
|
||||
import Cookie
|
||||
import os
|
||||
import sys
|
||||
@@ -166,7 +170,6 @@ class Request(Storage):
|
||||
- is_local
|
||||
- is_https
|
||||
- restful()
|
||||
- settings
|
||||
"""
|
||||
|
||||
def __init__(self, env):
|
||||
@@ -826,11 +829,11 @@ class Session(Storage):
|
||||
'sessions', response.session_id)
|
||||
try:
|
||||
response.session_file = \
|
||||
open(response.session_filename, 'rb+')
|
||||
recfile.open(response.session_filename, 'rb+')
|
||||
portalocker.lock(response.session_file,
|
||||
portalocker.LOCK_EX)
|
||||
response.session_locked = True
|
||||
self.update(cPickle.load(response.session_file))
|
||||
self.update(pickle.load(response.session_file))
|
||||
response.session_file.seek(0)
|
||||
oc = response.session_filename.split('/')[-1].split('-')[0]
|
||||
if check_client and response.session_client != oc:
|
||||
@@ -895,7 +898,7 @@ class Session(Storage):
|
||||
if row:
|
||||
# rows[0].update_record(locked=True)
|
||||
# Unpickle the data
|
||||
session_data = cPickle.loads(row.session_data)
|
||||
session_data = pickle.loads(row.session_data)
|
||||
self.update(session_data)
|
||||
response.session_new = False
|
||||
else:
|
||||
@@ -925,7 +928,7 @@ class Session(Storage):
|
||||
response.cookies[response.session_id_name]['expires'] = \
|
||||
cookie_expires.strftime(FMT)
|
||||
|
||||
session_pickled = cPickle.dumps(self)
|
||||
session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
|
||||
response.session_hash = hashlib.md5(session_pickled).hexdigest()
|
||||
|
||||
if self.flash:
|
||||
@@ -1084,7 +1087,7 @@ class Session(Storage):
|
||||
return True
|
||||
|
||||
def _unchanged(self, response):
|
||||
session_pickled = cPickle.dumps(self)
|
||||
session_pickled = pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
|
||||
response.session_pickled = session_pickled
|
||||
session_hash = hashlib.md5(session_pickled).hexdigest()
|
||||
return response.session_hash == session_hash
|
||||
@@ -1111,7 +1114,7 @@ class Session(Storage):
|
||||
else:
|
||||
unique_key = response.session_db_unique_key
|
||||
|
||||
session_pickled = response.session_pickled or cPickle.dumps(self)
|
||||
session_pickled = response.session_pickled or pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
|
||||
|
||||
dd = dict(locked=False,
|
||||
client_ip=response.session_client,
|
||||
@@ -1148,11 +1151,11 @@ class Session(Storage):
|
||||
session_folder = os.path.dirname(response.session_filename)
|
||||
if not os.path.exists(session_folder):
|
||||
os.mkdir(session_folder)
|
||||
response.session_file = open(response.session_filename, 'wb')
|
||||
response.session_file = recfile.open(response.session_filename, 'wb')
|
||||
portalocker.lock(response.session_file, portalocker.LOCK_EX)
|
||||
response.session_locked = True
|
||||
if response.session_file:
|
||||
session_pickled = response.session_pickled or cPickle.dumps(self)
|
||||
session_pickled = response.session_pickled or pickle.dumps(self, pickle.HIGHEST_PROTOCOL)
|
||||
response.session_file.write(session_pickled)
|
||||
response.session_file.truncate()
|
||||
finally:
|
||||
@@ -1177,3 +1180,8 @@ class Session(Storage):
|
||||
del response.session_file
|
||||
except:
|
||||
pass
|
||||
|
||||
def pickle_session(s):
|
||||
return Session, (dict(s),)
|
||||
|
||||
copy_reg.pickle(Session, pickle_session)
|
||||
+16
-3
@@ -21,7 +21,10 @@ import sanitizer
|
||||
import itertools
|
||||
import decoder
|
||||
import copy_reg
|
||||
import cPickle
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
import pickle
|
||||
import marshal
|
||||
|
||||
from HTMLParser import HTMLParser
|
||||
@@ -31,6 +34,7 @@ from gluon.storage import Storage
|
||||
from gluon.utils import web2py_uuid, simple_hash, compare
|
||||
from gluon.highlight import highlight
|
||||
|
||||
|
||||
regex_crlf = re.compile('\r|\n')
|
||||
|
||||
join = ''.join
|
||||
@@ -43,6 +47,7 @@ entitydefs.setdefault('apos', u"'".encode('utf-8'))
|
||||
|
||||
__all__ = [
|
||||
'A',
|
||||
'ASSIGNJS',
|
||||
'B',
|
||||
'BEAUTIFY',
|
||||
'BODY',
|
||||
@@ -1240,13 +1245,13 @@ class CAT(DIV):
|
||||
|
||||
|
||||
def TAG_unpickler(data):
|
||||
return cPickle.loads(data)
|
||||
return pickle.loads(data)
|
||||
|
||||
|
||||
def TAG_pickler(data):
|
||||
d = DIV()
|
||||
d.__dict__ = data.__dict__
|
||||
marshal_dump = cPickle.dumps(d)
|
||||
marshal_dump = pickle.dumps(d, pickle.HIGHEST_PROTOCOL)
|
||||
return (TAG_unpickler, (marshal_dump,))
|
||||
|
||||
|
||||
@@ -2825,6 +2830,14 @@ class MARKMIN(XmlComponent):
|
||||
def __str__(self):
|
||||
return self.xml()
|
||||
|
||||
def ASSIGNJS(**kargs):
|
||||
from gluon.serializers import json
|
||||
s = ""
|
||||
for key, value in kargs.items():
|
||||
s+='var %s = %s;\n' % (key, json(value))
|
||||
return XML(s)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
+8
-5
@@ -21,7 +21,10 @@ import datetime
|
||||
import platform
|
||||
import portalocker
|
||||
import fileutils
|
||||
import cPickle
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
import pickle
|
||||
from gluon.settings import global_settings
|
||||
|
||||
logger = logging.getLogger("web2py.cron")
|
||||
@@ -139,7 +142,7 @@ class Token(object):
|
||||
ret = None
|
||||
portalocker.lock(self.master, portalocker.LOCK_EX)
|
||||
try:
|
||||
(start, stop) = cPickle.load(self.master)
|
||||
(start, stop) = pickle.load(self.master)
|
||||
except:
|
||||
(start, stop) = (0, 1)
|
||||
if startup or self.now - start > locktime:
|
||||
@@ -149,7 +152,7 @@ class Token(object):
|
||||
logger.warning('WEB2PY CRON: Stale cron.master detected')
|
||||
logger.debug('WEB2PY CRON: Acquiring lock')
|
||||
self.master.seek(0)
|
||||
cPickle.dump((self.now, 0), self.master)
|
||||
pickle.dump((self.now, 0), self.master)
|
||||
self.master.flush()
|
||||
finally:
|
||||
portalocker.unlock(self.master)
|
||||
@@ -166,10 +169,10 @@ class Token(object):
|
||||
portalocker.lock(self.master, portalocker.LOCK_EX)
|
||||
logger.debug('WEB2PY CRON: Releasing cron lock')
|
||||
self.master.seek(0)
|
||||
(start, stop) = cPickle.load(self.master)
|
||||
(start, stop) = pickle.load(self.master)
|
||||
if start == self.now: # if this is my lock
|
||||
self.master.seek(0)
|
||||
cPickle.dump((self.now, time.time()), self.master)
|
||||
pickle.dump((self.now, time.time()), self.master)
|
||||
portalocker.unlock(self.master)
|
||||
self.master.close()
|
||||
|
||||
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
import os, uuid
|
||||
|
||||
def generate(filename, depth=2, base=512):
|
||||
if os.path.sep in filename:
|
||||
path, filename = os.path.split(filename)
|
||||
else:
|
||||
path = None
|
||||
dummyhash = sum(ord(c)*256**(i % 4) for i,c in enumerate(filename)) % base**depth
|
||||
folders = []
|
||||
for level in range(depth-1,-1,-1):
|
||||
code, dummyhash = divmod(dummyhash, base**level)
|
||||
folders.append("%03x" % code)
|
||||
folders.append(filename)
|
||||
if path:
|
||||
folders.insert(0,path)
|
||||
return os.path.join(*folders)
|
||||
|
||||
def exists(filename, path=None):
|
||||
if os.path.exists(filename):
|
||||
return True
|
||||
if path is None:
|
||||
path, filename = os.path.split(filename)
|
||||
fullfilename = os.path.join(path, generate(filename))
|
||||
if os.path.exists(fullfilename):
|
||||
return True
|
||||
return False
|
||||
|
||||
def remove(filename, path=None):
|
||||
if os.path.exists(filename):
|
||||
return os.unlink(filename)
|
||||
if path is None:
|
||||
path, filename = os.path.split(filename)
|
||||
fullfilename = os.path.join(path, generate(filename))
|
||||
if os.path.exists(fullfilename):
|
||||
return os.unlink(fullfilename)
|
||||
raise IOError
|
||||
|
||||
def open(filename, mode="r", path=None):
|
||||
if not path:
|
||||
path, filename = os.path.split(filename)
|
||||
fullfilename = None
|
||||
if not mode.startswith('w'):
|
||||
fullfilename = os.path.join(path, filename)
|
||||
if not os.path.exists(fullfilename):
|
||||
fullfilename = None
|
||||
if not fullfilename:
|
||||
fullfilename = os.path.join(path, generate(filename))
|
||||
if mode.startswith('w') and not os.path.exists(os.path.dirname(fullfilename)):
|
||||
os.makedirs(os.path.dirname(fullfilename))
|
||||
return file(fullfilename, mode)
|
||||
|
||||
def test():
|
||||
if not os.path.exists('tests'):
|
||||
os.mkdir('tests')
|
||||
for k in range(20):
|
||||
filename = os.path.join('tests',str(uuid.uuid4())+'.test')
|
||||
open(filename, "w").write('test')
|
||||
assert open(filename, "r").read()=='test'
|
||||
if exists(filename):
|
||||
remove(filename)
|
||||
|
||||
if __name__ == '__main__':
|
||||
test()
|
||||
+8
-5
@@ -11,7 +11,10 @@ Restricted environment to execute application's code
|
||||
"""
|
||||
|
||||
import sys
|
||||
import cPickle
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
import pickle
|
||||
import traceback
|
||||
import types
|
||||
import os
|
||||
@@ -55,7 +58,7 @@ class TicketStorage(Storage):
|
||||
try:
|
||||
table = self._get_table(self.db, self.tablename, request.application)
|
||||
table.insert(ticket_id=ticket_id,
|
||||
ticket_data=cPickle.dumps(ticket_data),
|
||||
ticket_data=pickle.dumps(ticket_data, pickle.HIGHEST_PROTOCOL),
|
||||
created_datetime=request.now)
|
||||
self.db.commit()
|
||||
message = 'In FILE: %(layer)s\n\n%(traceback)s\n'
|
||||
@@ -68,7 +71,7 @@ class TicketStorage(Storage):
|
||||
def _store_on_disk(self, request, ticket_id, ticket_data):
|
||||
ef = self._error_file(request, ticket_id, 'wb')
|
||||
try:
|
||||
cPickle.dump(ticket_data, ef)
|
||||
pickle.dump(ticket_data, ef)
|
||||
finally:
|
||||
ef.close()
|
||||
|
||||
@@ -103,13 +106,13 @@ class TicketStorage(Storage):
|
||||
except IOError:
|
||||
return {}
|
||||
try:
|
||||
return cPickle.load(ef)
|
||||
return pickle.load(ef)
|
||||
finally:
|
||||
ef.close()
|
||||
else:
|
||||
table = self._get_table(self.db, self.tablename, app)
|
||||
rows = self.db(table.ticket_id == ticket_id).select()
|
||||
return cPickle.loads(rows[0].ticket_data) if rows else {}
|
||||
return pickle.loads(rows[0].ticket_data) if rows else {}
|
||||
|
||||
|
||||
class RestrictedError(Exception):
|
||||
|
||||
+7
-4
@@ -96,7 +96,7 @@ IDENTIFIER = "%s#%s" % (socket.gethostname(),os.getpid())
|
||||
logger = logging.getLogger('web2py.scheduler.%s' % IDENTIFIER)
|
||||
|
||||
from gluon import DAL, Field, IS_NOT_EMPTY, IS_IN_SET, IS_NOT_IN_DB
|
||||
from gluon import IS_INT_IN_RANGE, IS_DATETIME
|
||||
from gluon import IS_INT_IN_RANGE, IS_DATETIME, IS_IN_DB
|
||||
from gluon.utils import web2py_uuid
|
||||
from gluon.storage import Storage
|
||||
|
||||
@@ -671,7 +671,10 @@ class Scheduler(MetaScheduler):
|
||||
db.define_table(
|
||||
'scheduler_task_deps',
|
||||
Field('job_name', default='job_0'),
|
||||
Field('task_parent', 'reference scheduler_task'),
|
||||
Field('task_parent', 'integer',
|
||||
requires=IS_IN_DB(db, 'scheduler_task.id',
|
||||
'%(task_name)s')
|
||||
),
|
||||
Field('task_child', 'reference scheduler_task'),
|
||||
Field('can_visit', 'boolean', default=False),
|
||||
migrate=self.__get_migrate('scheduler_task_deps', migrate)
|
||||
@@ -1311,7 +1314,7 @@ class Scheduler(MetaScheduler):
|
||||
"""
|
||||
from gluon.dal import Query
|
||||
sr, st = self.db.scheduler_run, self.db.scheduler_task
|
||||
if isinstance(ref, int):
|
||||
if isinstance(ref, (int, long)):
|
||||
q = st.id == ref
|
||||
elif isinstance(ref, str):
|
||||
q = st.uuid == ref
|
||||
@@ -1362,7 +1365,7 @@ class Scheduler(MetaScheduler):
|
||||
Experimental
|
||||
"""
|
||||
st, sw = self.db.scheduler_task, self.db.scheduler_worker
|
||||
if isinstance(ref, int):
|
||||
if isinstance(ref, (int, long)):
|
||||
q = st.id == ref
|
||||
elif isinstance(ref, str):
|
||||
q = st.uuid == ref
|
||||
|
||||
@@ -163,15 +163,18 @@ def ics(events, title=None, link=None, timeshift=0, calname=True,
|
||||
def rss(feed):
|
||||
if not 'entries' in feed and 'items' in feed:
|
||||
feed['entries'] = feed['items']
|
||||
def safestr(obj, key, default=''):
|
||||
return str(obj[key]).encode('utf-8', 'replace') if key in obj else default
|
||||
|
||||
now = datetime.datetime.now()
|
||||
rss = rss2.RSS2(title=str(feed.get('title', '(notitle)').encode('utf-8', 'replace')),
|
||||
link=str(feed.get('link', None).encode('utf-8', 'replace')),
|
||||
description=str(feed.get('description', '').encode('utf-8', 'replace')),
|
||||
rss = rss2.RSS2(title=safestr(feed,'title'),
|
||||
link=safestr(feed,'link'),
|
||||
description=safestr(feed,'description'),
|
||||
lastBuildDate=feed.get('created_on', now),
|
||||
items=[rss2.RSSItem(
|
||||
title=str(entry.get('title', '(notitle)').encode('utf-8', 'replace')),
|
||||
link=str(entry.get('link', None).encode('utf-8', 'replace')),
|
||||
description=str(entry.get('description', '').encode('utf-8', 'replace')),
|
||||
title=safestr(entry,'title','(notitle)'),
|
||||
link=safestr(entry,'link'),
|
||||
description=safestr(entry,'description'),
|
||||
pubDate=entry.get('created_on', now)
|
||||
) for entry in feed.get('entries', [])])
|
||||
return rss.to_xml(encoding='utf-8')
|
||||
|
||||
+4
-2
@@ -655,7 +655,7 @@ class AutocompleteWidget(object):
|
||||
if settings and settings.global_settings.web2py_runtime_gae:
|
||||
rows = self.db(field.__ge__(self.request.vars[self.keyword]) & field.__lt__(self.request.vars[self.keyword] + u'\ufffd')).select(orderby=self.orderby, limitby=self.limitby, *(self.fields+self.help_fields))
|
||||
else:
|
||||
rows = self.db(field.like(self.request.vars[self.keyword] + '%')).select(orderby=self.orderby, limitby=self.limitby, distinct=self.distinct, *(self.fields+self.help_fields))
|
||||
rows = self.db(field.like(self.request.vars[self.keyword] + '%', case_sensitive=False)).select(orderby=self.orderby, limitby=self.limitby, distinct=self.distinct, *(self.fields+self.help_fields))
|
||||
if rows:
|
||||
if self.is_reference:
|
||||
id_field = self.fields[1]
|
||||
@@ -1292,7 +1292,7 @@ class SQLFORM(FORM):
|
||||
xfields.append(
|
||||
(self.FIELDKEY_DELETE_RECORD + SQLFORM.ID_ROW_SUFFIX,
|
||||
LABEL(
|
||||
T(delete_label), separator,
|
||||
T(delete_label), sep,
|
||||
_for=self.FIELDKEY_DELETE_RECORD,
|
||||
_id=self.FIELDKEY_DELETE_RECORD + \
|
||||
SQLFORM.ID_LABEL_SUFFIX),
|
||||
@@ -2114,6 +2114,8 @@ class SQLFORM(FORM):
|
||||
field_id = groupby #take the field passed as groupby
|
||||
elif groupby and isinstance(groupby, Expression):
|
||||
field_id = groupby.first #take the first groupby field
|
||||
while not(isinstance(field_id, Field)): # Navigate to the first Field of the expression
|
||||
field_id = field_id.first
|
||||
table = field_id.table
|
||||
tablename = table._tablename
|
||||
if not any(str(f) == str(field_id) for f in fields):
|
||||
|
||||
+15
-5
@@ -12,7 +12,11 @@ Provides:
|
||||
- Storage; like dictionary allowing also for `obj.foo` for `obj['foo']`
|
||||
"""
|
||||
|
||||
import cPickle
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
import pickle
|
||||
import copy_reg
|
||||
import gluon.portalocker as portalocker
|
||||
|
||||
__all__ = ['List', 'Storage', 'Settings', 'Messages',
|
||||
@@ -129,6 +133,12 @@ class Storage(dict):
|
||||
values = self.getlist(key)
|
||||
return values[-1] if values else default
|
||||
|
||||
|
||||
def pickle_storage(s):
|
||||
return Storage, (dict(s),)
|
||||
|
||||
copy_reg.pickle(Storage, pickle_storage)
|
||||
|
||||
PICKABLE = (str, int, long, float, bool, list, dict, tuple, set)
|
||||
|
||||
|
||||
@@ -141,10 +151,10 @@ class StorageList(Storage):
|
||||
|
||||
def __getattr__(self, key):
|
||||
if key in self:
|
||||
return getattr(self, key)
|
||||
return self.get(key)
|
||||
else:
|
||||
r = []
|
||||
setattr(self, key, r)
|
||||
self[key] = r
|
||||
return r
|
||||
|
||||
|
||||
@@ -152,7 +162,7 @@ def load_storage(filename):
|
||||
fp = None
|
||||
try:
|
||||
fp = portalocker.LockedFile(filename, 'rb')
|
||||
storage = cPickle.load(fp)
|
||||
storage = pickle.load(fp)
|
||||
finally:
|
||||
if fp:
|
||||
fp.close()
|
||||
@@ -163,7 +173,7 @@ def save_storage(storage, filename):
|
||||
fp = None
|
||||
try:
|
||||
fp = portalocker.LockedFile(filename, 'wb')
|
||||
cPickle.dump(dict(storage), fp)
|
||||
pickle.dump(dict(storage), fp)
|
||||
finally:
|
||||
if fp:
|
||||
fp.close()
|
||||
|
||||
+10
-6
@@ -279,15 +279,19 @@ class TemplateParser(object):
|
||||
self.context = context
|
||||
|
||||
# allow optional alternative delimiters
|
||||
if delimiters is None:
|
||||
delimiters = context.get('response', {})\
|
||||
.get('app_settings',{}).get('template_delimiters')
|
||||
|
||||
if delimiters != self.default_delimiters:
|
||||
escaped_delimiters = (escape(elimiters[0]),
|
||||
escaped_delimiters = (escape(delimiters[0]),
|
||||
escape(delimiters[1]))
|
||||
self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters, DOTALL)
|
||||
else:
|
||||
delimiters = self.default_delimiters
|
||||
elif hasattr(context.get('response', None), 'delimiters'):
|
||||
if context['response'].delimiters != self.default_delimiters:
|
||||
delimiters = context['response'].delimiters
|
||||
escaped_delimiters = (
|
||||
escape(delimiters[0]),
|
||||
escape(delimiters[1]))
|
||||
self.r_tag = compile(r'(%s.*?%s)' % escaped_delimiters,
|
||||
DOTALL)
|
||||
self.delimiters = delimiters
|
||||
|
||||
# Create a root level Content that everything will go into.
|
||||
|
||||
+11
-8
@@ -2,14 +2,8 @@ import os, sys
|
||||
|
||||
from test_http import *
|
||||
from test_cache import *
|
||||
|
||||
NOSQL = any([name in (os.getenv("DB") or "")
|
||||
for name in ("datastore", "mongodb", "imap")])
|
||||
if NOSQL:
|
||||
from test_dal_nosql import *
|
||||
else:
|
||||
from test_dal import *
|
||||
|
||||
from test_contenttype import *
|
||||
from test_fileutils import *
|
||||
from test_html import *
|
||||
from test_is_url import *
|
||||
from test_languages import *
|
||||
@@ -25,3 +19,12 @@ from test_web import *
|
||||
|
||||
if sys.version[:3] == '2.7':
|
||||
from test_old_doctests import *
|
||||
|
||||
|
||||
NOSQL = any([name in (os.getenv("DB") or "")
|
||||
for name in ("datastore", "mongodb", "imap")])
|
||||
|
||||
if NOSQL:
|
||||
from test_dal_nosql import *
|
||||
else:
|
||||
from test_dal import *
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import sys
|
||||
|
||||
def fix_sys_path(current_path):
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(current_path))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
+41
-31
@@ -4,43 +4,15 @@
|
||||
"""
|
||||
Unit tests for gluon.cache
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
from storage import Storage
|
||||
from cache import CacheInRam, CacheOnDisk
|
||||
from cache import CacheInRam, CacheOnDisk, Cache
|
||||
|
||||
oldcwd = None
|
||||
|
||||
@@ -76,6 +48,20 @@ class TestCache(unittest.TestCase):
|
||||
cache.clear()
|
||||
self.assertEqual(cache('a', lambda: 3, 100), 3)
|
||||
self.assertEqual(cache('a', lambda: 4, 0), 4)
|
||||
#test singleton behaviour
|
||||
cache = CacheInRam()
|
||||
cache.clear()
|
||||
self.assertEqual(cache('a', lambda: 3, 100), 3)
|
||||
self.assertEqual(cache('a', lambda: 4, 0), 4)
|
||||
#test key deletion
|
||||
cache('a', None)
|
||||
self.assertEqual(cache('a', lambda: 5, 100), 5)
|
||||
#test increment
|
||||
self.assertEqual(cache.increment('a'), 6)
|
||||
self.assertEqual(cache('a', lambda: 1, 100), 6)
|
||||
cache.increment('b')
|
||||
self.assertEqual(cache('b', lambda: 'x', 100), 1)
|
||||
|
||||
|
||||
def testCacheOnDisk(self):
|
||||
|
||||
@@ -93,6 +79,30 @@ class TestCache(unittest.TestCase):
|
||||
cache.clear()
|
||||
self.assertEqual(cache('a', lambda: 3, 100), 3)
|
||||
self.assertEqual(cache('a', lambda: 4, 0), 4)
|
||||
#test singleton behaviour
|
||||
cache = CacheOnDisk(s)
|
||||
cache.clear()
|
||||
self.assertEqual(cache('a', lambda: 3, 100), 3)
|
||||
self.assertEqual(cache('a', lambda: 4, 0), 4)
|
||||
#test key deletion
|
||||
cache('a', None)
|
||||
self.assertEqual(cache('a', lambda: 5, 100), 5)
|
||||
#test increment
|
||||
self.assertEqual(cache.increment('a'), 6)
|
||||
self.assertEqual(cache('a', lambda: 1, 100), 6)
|
||||
cache.increment('b')
|
||||
self.assertEqual(cache('b', lambda: 'x', 100), 1)
|
||||
|
||||
def testCacheWithPrefix(self):
|
||||
s = Storage({'application': 'admin',
|
||||
'folder': 'applications/admin'})
|
||||
cache = Cache(s)
|
||||
prefix = cache.with_prefix(cache.ram,'prefix')
|
||||
self.assertEqual(prefix('a', lambda: 1, 0), 1)
|
||||
self.assertEqual(prefix('a', lambda: 2, 100), 1)
|
||||
self.assertEqual(cache.ram('prefixa', lambda: 2, 100), 1)
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Unit tests for gluon.contenttype
|
||||
"""
|
||||
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from contenttype import contenttype
|
||||
|
||||
|
||||
class TestContentType(unittest.TestCase):
|
||||
|
||||
def testTypeRecognition(self):
|
||||
rtn = contenttype('.png')
|
||||
self.assertEqual(rtn, 'image/png')
|
||||
rtn = contenttype('.gif')
|
||||
self.assertEqual(rtn, 'image/gif')
|
||||
rtn = contenttype('.tar.bz2')
|
||||
self.assertEqual(rtn, 'application/x-bzip-compressed-tar')
|
||||
# test overrides and additions
|
||||
mapping = {
|
||||
'.load': 'text/html; charset=utf-8',
|
||||
'.json': 'application/json',
|
||||
'.jsonp': 'application/jsonp',
|
||||
'.pickle': 'application/python-pickle',
|
||||
'.w2p': 'application/w2p',
|
||||
'.md': 'text/x-markdown; charset=utf-8'
|
||||
}
|
||||
for k, v in mapping.iteritems():
|
||||
self.assertEqual(contenttype(k), v)
|
||||
|
||||
# test without dot extension
|
||||
rtn = contenttype('png')
|
||||
self.assertEqual(rtn, 'text/plain; charset=utf-8')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -3,37 +3,10 @@
|
||||
|
||||
""" Unit tests for contribs """
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
from utils import md5_hash
|
||||
|
||||
+23
-32
@@ -15,42 +15,20 @@ try:
|
||||
except:
|
||||
from io import StringIO
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
fix_sys_path(__file__)
|
||||
|
||||
#for travis-ci
|
||||
DEFAULT_URI = os.environ.get('DB', 'sqlite:memory')
|
||||
DEFAULT_URI = os.getenv('DB', 'sqlite:memory')
|
||||
|
||||
print 'Testing against %s engine (%s)' % (DEFAULT_URI.partition(':')[0], DEFAULT_URI)
|
||||
|
||||
from dal import DAL, Field
|
||||
from dal.objects import Table
|
||||
from dal.helpers.classes import SQLALL
|
||||
from dal import DAL, Field, Table, SQLALL
|
||||
from gluon.cache import CacheInRam
|
||||
|
||||
ALLOWED_DATATYPES = [
|
||||
'string',
|
||||
@@ -131,6 +109,7 @@ class TestFields(unittest.TestCase):
|
||||
isinstance(f.formatter(datetime.datetime.now()), str)
|
||||
|
||||
def testRun(self):
|
||||
"""Test all field types and their return values"""
|
||||
db = DAL(DEFAULT_URI, check_reserved=['all'])
|
||||
for ft in ['string', 'text', 'password', 'upload', 'blob']:
|
||||
db.define_table('tt', Field('aa', ft, default=''))
|
||||
@@ -150,8 +129,22 @@ class TestFields(unittest.TestCase):
|
||||
self.assertEqual(db().select(db.tt.aa)[0].aa, True)
|
||||
db.tt.drop()
|
||||
db.define_table('tt', Field('aa', 'json', default={}))
|
||||
self.assertEqual(db.tt.insert(aa={}), 1)
|
||||
self.assertEqual(db().select(db.tt.aa)[0].aa, {})
|
||||
# test different python objects for correct serialization in json
|
||||
objs = [
|
||||
{'a' : 1, 'b' : 2},
|
||||
[1, 2, 3],
|
||||
'abc',
|
||||
True,
|
||||
False,
|
||||
None,
|
||||
11,
|
||||
14.3,
|
||||
long(11)
|
||||
]
|
||||
for obj in objs:
|
||||
rtn_id = db.tt.insert(aa=obj)
|
||||
rtn = db(db.tt.id == rtn_id).select().first().aa
|
||||
self.assertEqual(obj, rtn)
|
||||
db.tt.drop()
|
||||
db.define_table('tt', Field('aa', 'date',
|
||||
default=datetime.date.today()))
|
||||
@@ -551,9 +544,8 @@ class TestMinMaxSumAvg(unittest.TestCase):
|
||||
db.tt.drop()
|
||||
|
||||
|
||||
class TestCache(unittest.TestCase):
|
||||
class TestCacheSelect(unittest.TestCase):
|
||||
def testRun(self):
|
||||
from cache import CacheInRam
|
||||
cache = CacheInRam()
|
||||
db = DAL(DEFAULT_URI, check_reserved=['all'])
|
||||
db.define_table('tt', Field('aa'))
|
||||
@@ -1446,7 +1438,6 @@ class TestQuoting(unittest.TestCase):
|
||||
db._adapter.types[key]=db._adapter.types[key].replace(
|
||||
'%(on_delete_action)s','NO ACTION')
|
||||
|
||||
|
||||
t0 = db.define_table('t0',
|
||||
Field('f', 'string'))
|
||||
t1 = db.define_table('b',
|
||||
|
||||
@@ -19,34 +19,9 @@ try:
|
||||
except:
|
||||
from io import StringIO
|
||||
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
fix_sys_path(__file__)
|
||||
|
||||
#for travis-ci
|
||||
DEFAULT_URI = os.environ.get('DB', 'sqlite:memory')
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import unittest
|
||||
import datetime
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from fileutils import parse_version
|
||||
|
||||
|
||||
class TestFileUtils(unittest.TestCase):
|
||||
|
||||
def testParseVersion(self):
|
||||
rtn = parse_version('Version 1.99.0-rc.1+timestamp.2011.09.19.08.23.26')
|
||||
self.assertEqual(rtn, (1, 99, 0, 'rc.1', datetime.datetime(2011, 9, 19, 8, 23, 26)))
|
||||
rtn = parse_version('Version 2.9.11-stable+timestamp.2014.09.15.18.31.17')
|
||||
self.assertEqual(rtn, (2, 9, 11, 'stable', datetime.datetime(2014, 9, 15, 18, 31, 17)))
|
||||
rtn = parse_version('Version 1.99.0 (2011-09-19 08:23:26)')
|
||||
self.assertEqual(rtn, (1, 99, 0, 'dev', datetime.datetime(2011, 9, 19, 8, 23, 26)))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -5,37 +5,10 @@
|
||||
Unit tests for gluon.html
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from html import *
|
||||
from storage import Storage
|
||||
|
||||
@@ -3,38 +3,10 @@
|
||||
|
||||
"""Unit tests for http.py """
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
from http import HTTP, defined_status
|
||||
@@ -68,8 +40,5 @@ class TestHTTP(unittest.TestCase):
|
||||
|
||||
# test wrong call detection
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -4,42 +4,14 @@
|
||||
Unit tests for IS_URL()
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
|
||||
|
||||
from validators import IS_URL, IS_HTTP_URL, IS_GENERIC_URL, \
|
||||
unicode_to_ascii_authority
|
||||
from validators import IS_URL, IS_HTTP_URL, IS_GENERIC_URL
|
||||
from validators import unicode_to_ascii_authority
|
||||
|
||||
|
||||
class TestIsUrl(unittest.TestCase):
|
||||
|
||||
@@ -7,38 +7,11 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
import tempfile
|
||||
import threading
|
||||
import logging
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
fix_sys_path(__file__)
|
||||
|
||||
#support skipif also in python 2.6
|
||||
def _skipIf(cond, message=''):
|
||||
@@ -55,7 +28,6 @@ else:
|
||||
skipIf = _skipIf
|
||||
|
||||
import languages
|
||||
from storage import Storage
|
||||
MP_WORKING = 0
|
||||
try:
|
||||
import multiprocessing
|
||||
@@ -76,6 +48,7 @@ def read_write(args):
|
||||
languages.write_dict(filename, content)
|
||||
return True
|
||||
|
||||
|
||||
class TestLanguagesParallel(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
@@ -108,6 +81,7 @@ class TestLanguagesParallel(unittest.TestCase):
|
||||
for result in results:
|
||||
self.assertTrue(result)
|
||||
|
||||
|
||||
class TestTranslations(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
@@ -147,4 +121,3 @@ class TestTranslations(unittest.TestCase):
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -7,41 +7,15 @@
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
import doctest
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
|
||||
def load_tests(loader, tests, ignore):
|
||||
|
||||
|
||||
tests.addTests(
|
||||
doctest.DocTestSuite('html')
|
||||
)
|
||||
|
||||
+70
-31
@@ -3,40 +3,14 @@
|
||||
|
||||
""" Unit tests for storage.py """
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
|
||||
from storage import Storage
|
||||
from storage import Storage, StorageList, List
|
||||
from http import HTTP
|
||||
import pickle
|
||||
|
||||
|
||||
class TestStorage(unittest.TestCase):
|
||||
@@ -97,5 +71,70 @@ class TestStorage(unittest.TestCase):
|
||||
self.assertEquals(s['a'], None)
|
||||
self.assertTrue('a' in s)
|
||||
|
||||
def test_pickling(self):
|
||||
""" Test storage pickling """
|
||||
s = Storage(a=1)
|
||||
sd = pickle.dumps(s, pickle.HIGHEST_PROTOCOL)
|
||||
news = pickle.loads(sd)
|
||||
self.assertEqual(news.a, 1)
|
||||
|
||||
def test_getlist(self):
|
||||
# usually used with request.vars
|
||||
a = Storage()
|
||||
a.x = 'abc'
|
||||
a.y = ['abc', 'def']
|
||||
self.assertEqual(a.getlist('x'), ['abc'])
|
||||
self.assertEqual(a.getlist('y'), ['abc', 'def'])
|
||||
self.assertEqual(a.getlist('z'), [])
|
||||
|
||||
def test_getfirst(self):
|
||||
# usually with request.vars
|
||||
a = Storage()
|
||||
a.x = 'abc'
|
||||
a.y = ['abc', 'def']
|
||||
self.assertEqual(a.getfirst('x'), 'abc')
|
||||
self.assertEqual(a.getfirst('y'), 'abc')
|
||||
self.assertEqual(a.getfirst('z'), None)
|
||||
|
||||
def test_getlast(self):
|
||||
# usually with request.vars
|
||||
a = Storage()
|
||||
a.x = 'abc'
|
||||
a.y = ['abc', 'def']
|
||||
self.assertEqual(a.getlast('x'), 'abc')
|
||||
self.assertEqual(a.getlast('y'), 'def')
|
||||
self.assertEqual(a.getlast('z'), None)
|
||||
|
||||
|
||||
class TestStorageList(unittest.TestCase):
|
||||
""" Tests storage.StorageList """
|
||||
|
||||
def test_attribute(self):
|
||||
s = StorageList(a=1)
|
||||
|
||||
self.assertEqual(s.a, 1)
|
||||
self.assertEqual(s['a'], 1)
|
||||
self.assertEqual(s.b, [])
|
||||
s.b.append(1)
|
||||
self.assertEqual(s.b, [1])
|
||||
|
||||
|
||||
class TestList(unittest.TestCase):
|
||||
""" Tests Storage.List (fast-check for request.args()) """
|
||||
|
||||
def test_listcall(self):
|
||||
a = List((1, 2, 3))
|
||||
self.assertEqual(a(1), 2)
|
||||
self.assertEqual(a(-1), 3)
|
||||
self.assertEqual(a(-5), None)
|
||||
self.assertEqual(a(-5, default='x'), 'x')
|
||||
self.assertEqual(a(-3, cast=str), '1')
|
||||
a.append('1234')
|
||||
self.assertEqual(a(3), '1234')
|
||||
self.assertEqual(a(3, cast=int), 1234)
|
||||
a.append('x')
|
||||
self.assertRaises(HTTP, a, 4, cast=int)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -4,38 +4,10 @@
|
||||
Unit tests for gluon.template
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from template import render
|
||||
|
||||
|
||||
@@ -3,38 +3,10 @@
|
||||
|
||||
""" Unit tests for utils.py """
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from utils import md5_hash
|
||||
|
||||
|
||||
+151
-33
@@ -3,43 +3,17 @@
|
||||
|
||||
"""Unit tests for http.py """
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
|
||||
import datetime
|
||||
import decimal
|
||||
from gluon.validators import *
|
||||
import re
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
fix_sys_path(__file__)
|
||||
|
||||
|
||||
from gluon.validators import *
|
||||
|
||||
|
||||
class TestValidators(unittest.TestCase):
|
||||
|
||||
@@ -114,6 +88,19 @@ class TestValidators(unittest.TestCase):
|
||||
self.assertEqual(rtn, (datetime.date(2008, 3, 3), None))
|
||||
rtn = v(datetime.date(2010,3,3))
|
||||
self.assertEqual(rtn, (datetime.date(2010, 3, 3), 'oops'))
|
||||
v = IS_DATE_IN_RANGE(maximum=datetime.date(2009,12,31),
|
||||
format="%m/%d/%Y")
|
||||
rtn = v('03/03/2010')
|
||||
self.assertEqual(rtn, ('03/03/2010', 'Enter date on or before 12/31/2009'))
|
||||
v = IS_DATE_IN_RANGE(minimum=datetime.date(2008,1,1),
|
||||
format="%m/%d/%Y")
|
||||
rtn = v('03/03/2007')
|
||||
self.assertEqual(rtn, ('03/03/2007', 'Enter date on or after 01/01/2008'))
|
||||
v = IS_DATE_IN_RANGE(minimum=datetime.date(2008,1,1),
|
||||
maximum=datetime.date(2009,12,31),
|
||||
format="%m/%d/%Y")
|
||||
rtn = v('03/03/2007')
|
||||
self.assertEqual(rtn, ('03/03/2007', 'Enter date in range 01/01/2008 12/31/2009'))
|
||||
|
||||
def test_IS_DATE(self):
|
||||
v = IS_DATE(format="%m/%d/%Y",error_message="oops")
|
||||
@@ -135,6 +122,19 @@ class TestValidators(unittest.TestCase):
|
||||
self.assertEquals(rtn, (datetime.datetime(2008, 3, 3, 0, 0), None))
|
||||
rtn = v(datetime.datetime(2010,3,3,0,0))
|
||||
self.assertEquals(rtn, (datetime.datetime(2010, 3, 3, 0, 0), 'oops'))
|
||||
v = IS_DATETIME_IN_RANGE(maximum=datetime.datetime(2009,12,31,12,20),
|
||||
format='%m/%d/%Y %H:%M:%S')
|
||||
rtn = v('03/03/2010 12:20:00')
|
||||
self.assertEqual(rtn, ('03/03/2010 12:20:00', 'Enter date and time on or before 12/31/2009 12:20:00'))
|
||||
v = IS_DATETIME_IN_RANGE(minimum=datetime.datetime(2008,1,1,12,20),
|
||||
format='%m/%d/%Y %H:%M:%S')
|
||||
rtn = v('03/03/2007 12:20:00')
|
||||
self.assertEqual(rtn, ('03/03/2007 12:20:00', 'Enter date and time on or after 01/01/2008 12:20:00'))
|
||||
v = IS_DATETIME_IN_RANGE(minimum=datetime.datetime(2008,1,1,12,20),
|
||||
maximum=datetime.datetime(2009,12,31,12,20),
|
||||
format='%m/%d/%Y %H:%M:%S')
|
||||
rtn = v('03/03/2007 12:20:00')
|
||||
self.assertEqual(rtn, ('03/03/2007 12:20:00', 'Enter date and time in range 01/01/2008 12:20:00 12/31/2009 12:20:00'))
|
||||
|
||||
def test_IS_DATETIME(self):
|
||||
v = IS_DATETIME(format="%m/%d/%Y %H:%M",error_message="oops")
|
||||
@@ -186,6 +186,8 @@ class TestValidators(unittest.TestCase):
|
||||
self.assertEqual(rtn, ('6,5', 'Enter a number'))
|
||||
rtn = IS_DECIMAL_IN_RANGE(dot=',')('6.5')
|
||||
self.assertEqual(rtn, (decimal.Decimal('6.5'), None))
|
||||
rtn = IS_DECIMAL_IN_RANGE(1,5)(decimal.Decimal('4'))
|
||||
self.assertEqual(rtn, (decimal.Decimal('4'), None))
|
||||
|
||||
def test_IS_EMAIL(self):
|
||||
rtn = IS_EMAIL()('a@b.com')
|
||||
@@ -242,6 +244,16 @@ class TestValidators(unittest.TestCase):
|
||||
self.assertEqual(rtn, ('Ima Fool@example.com', 'Enter a valid email address'))
|
||||
rtn = IS_EMAIL()('localguy@localhost') # localhost as domain
|
||||
self.assertEqual(rtn, ('localguy@localhost', None))
|
||||
# test for banned
|
||||
rtn = IS_EMAIL(banned='^.*\.com(|\..*)$')('localguy@localhost') # localhost as domain
|
||||
self.assertEqual(rtn, ('localguy@localhost', None))
|
||||
rtn = IS_EMAIL(banned='^.*\.com(|\..*)$')('abc@example.com')
|
||||
self.assertEqual(rtn, ('abc@example.com', 'Enter a valid email address'))
|
||||
# test for forced
|
||||
rtn = IS_EMAIL(forced='^.*\.edu(|\..*)$')('localguy@localhost')
|
||||
self.assertEqual(rtn, ('localguy@localhost', 'Enter a valid email address'))
|
||||
rtn = IS_EMAIL(forced='^.*\.edu(|\..*)$')('localguy@example.edu')
|
||||
self.assertEqual(rtn, ('localguy@example.edu', None))
|
||||
|
||||
def test_IS_LIST_OF_EMAILS(self):
|
||||
emails = ['localguy@localhost', '_Yosemite.Sam@example.com']
|
||||
@@ -255,6 +267,19 @@ class TestValidators(unittest.TestCase):
|
||||
rtn = IS_LIST_OF_EMAILS()(';'.join(emails))
|
||||
self.assertEqual(rtn, ('localguy@localhost;_Yosemite.Sam@example.com;a', 'Invalid emails: a'))
|
||||
|
||||
def test_IS_LIST_OF(self):
|
||||
values = [0,1,2,3,4]
|
||||
rtn = IS_LIST_OF(IS_INT_IN_RANGE(0, 10))(values)
|
||||
self.assertEqual(rtn, (values, None))
|
||||
values.append(11)
|
||||
rtn = IS_LIST_OF(IS_INT_IN_RANGE(0, 10))(values)
|
||||
self.assertEqual(rtn, (values, 'Enter an integer between 0 and 9'))
|
||||
rtn = IS_LIST_OF(IS_INT_IN_RANGE(0, 10))(1)
|
||||
self.assertEqual(rtn, ([1], None))
|
||||
rtn = IS_LIST_OF(IS_INT_IN_RANGE(0, 10), minimum=10)([1,2])
|
||||
self.assertEqual(rtn, ([1, 2], 'Enter between 10 and 100 values'))
|
||||
rtn = IS_LIST_OF(IS_INT_IN_RANGE(0, 10), maximum=2)([1,2,3])
|
||||
self.assertEqual(rtn, ([1, 2, 3], 'Enter between 0 and 2 values'))
|
||||
|
||||
def test_IS_EMPTY_OR(self):
|
||||
rtn = IS_EMPTY_OR(IS_EMAIL())('abc@def.com')
|
||||
@@ -515,8 +540,46 @@ class TestValidators(unittest.TestCase):
|
||||
self.assertEqual(rtn, (None, 'Enter from 1 to 255 characters'))
|
||||
rtn = IS_LENGTH(minsize=1)([])
|
||||
self.assertEqual(rtn, ([], 'Enter from 1 to 255 characters'))
|
||||
rtn = IS_LENGTH(minsize=1)([1, 2])
|
||||
self.assertEqual(rtn, ([1, 2], None))
|
||||
rtn = IS_LENGTH(minsize=1)([1])
|
||||
self.assertEqual(rtn, ([1], None))
|
||||
# test unicode
|
||||
rtn = IS_LENGTH(2)(u'°2')
|
||||
self.assertEqual(rtn, ('\xc2\xb02', None))
|
||||
rtn = IS_LENGTH(2)(u'°12')
|
||||
self.assertEqual(rtn, (u'\xb012', 'Enter from 0 to 2 characters'))
|
||||
# test automatic str()
|
||||
rtn = IS_LENGTH(minsize=1)(1)
|
||||
self.assertEqual(rtn, ('1', None))
|
||||
rtn = IS_LENGTH(minsize=2)(1)
|
||||
self.assertEqual(rtn, (1, 'Enter from 2 to 255 characters'))
|
||||
# test FieldStorage
|
||||
import cgi
|
||||
from StringIO import StringIO
|
||||
a = cgi.FieldStorage()
|
||||
a.file = StringIO('abc')
|
||||
rtn = IS_LENGTH(minsize=4)(a)
|
||||
self.assertEqual(rtn, (a, 'Enter from 4 to 255 characters'))
|
||||
urlencode_data = "key2=value2x&key3=value3&key4=value4"
|
||||
urlencode_environ = {
|
||||
'CONTENT_LENGTH': str(len(urlencode_data)),
|
||||
'CONTENT_TYPE': 'application/x-www-form-urlencoded',
|
||||
'QUERY_STRING': 'key1=value1&key2=value2y',
|
||||
'REQUEST_METHOD': 'POST',
|
||||
}
|
||||
fake_stdin = StringIO(urlencode_data)
|
||||
fake_stdin.seek(0)
|
||||
a = cgi.FieldStorage(fp=fake_stdin, environ=urlencode_environ)
|
||||
rtn = IS_LENGTH(minsize=6)(a)
|
||||
self.assertEqual(rtn, (a, 'Enter from 6 to 255 characters'))
|
||||
a = cgi.FieldStorage()
|
||||
rtn = IS_LENGTH(minsize=6)(a)
|
||||
self.assertEqual(rtn, (a, 'Enter from 6 to 255 characters'))
|
||||
rtn = IS_LENGTH(6)(a)
|
||||
self.assertEqual(rtn, (a, None))
|
||||
|
||||
|
||||
|
||||
def test_IS_LOWER(self):
|
||||
rtn = IS_LOWER()('ABC')
|
||||
@@ -545,10 +608,14 @@ class TestValidators(unittest.TestCase):
|
||||
self.assertEqual(rtn, ('hellas', 'Invalid expression'))
|
||||
rtn = IS_MATCH('hell$', strict=True)('hellas')
|
||||
self.assertEqual(rtn, ('hellas', 'Invalid expression'))
|
||||
rtn = IS_MATCH('^.hell$', strict=True)('shell')
|
||||
self.assertEqual(rtn, ('shell', None))
|
||||
rtn = IS_MATCH(u'hell', is_unicode=True)('àòè')
|
||||
self.assertEqual(rtn, ('\xc3\xa0\xc3\xb2\xc3\xa8', 'Invalid expression'))
|
||||
rtn = IS_MATCH(u'hell', is_unicode=True)(u'hell')
|
||||
self.assertEqual(rtn, (u'hell', None))
|
||||
rtn = IS_MATCH('hell', is_unicode=True)(u'hell')
|
||||
self.assertEqual(rtn, (u'hell', None))
|
||||
|
||||
|
||||
def test_IS_EQUAL_TO(self):
|
||||
@@ -718,6 +785,57 @@ class TestValidators(unittest.TestCase):
|
||||
rtn = IS_JSON()('spam1234')
|
||||
self.assertEqual(rtn, ('spam1234', 'Invalid json'))
|
||||
|
||||
def test_IS_UPLOAD_FILENAME(self):
|
||||
import cgi
|
||||
from StringIO import StringIO
|
||||
def gen_fake(filename):
|
||||
formdata_file_data = """
|
||||
---123
|
||||
Content-Disposition: form-data; name="key2"
|
||||
|
||||
value2y
|
||||
---123
|
||||
Content-Disposition: form-data; name="file_attach"; filename="%s"
|
||||
Content-Type: text/plain
|
||||
|
||||
this is the content of the fake file
|
||||
|
||||
---123--
|
||||
""" % filename
|
||||
formdata_file_environ = {
|
||||
'CONTENT_LENGTH': str(len(formdata_file_data)),
|
||||
'CONTENT_TYPE': 'multipart/form-data; boundary=-123',
|
||||
'QUERY_STRING': 'key1=value1&key2=value2x',
|
||||
'REQUEST_METHOD': 'POST',
|
||||
}
|
||||
return cgi.FieldStorage(fp=StringIO(formdata_file_data), environ=formdata_file_environ)['file_attach']
|
||||
|
||||
fake = gen_fake('example.pdf')
|
||||
rtn = IS_UPLOAD_FILENAME(extension='pdf')(fake)
|
||||
self.assertEqual(rtn, (fake, None))
|
||||
fake = gen_fake('example.gif')
|
||||
rtn = IS_UPLOAD_FILENAME(extension='pdf')(fake)
|
||||
self.assertEqual(rtn, (fake, 'Enter valid filename'))
|
||||
fake = gen_fake('backup2014.tar.gz')
|
||||
rtn = IS_UPLOAD_FILENAME(filename='backup.*', extension='tar.gz', lastdot=False)(fake)
|
||||
self.assertEqual(rtn, (fake, None))
|
||||
fake = gen_fake('README')
|
||||
rtn = IS_UPLOAD_FILENAME(filename='^README$', extension='^$', case=0)(fake)
|
||||
self.assertEqual(rtn, (fake, None))
|
||||
fake = gen_fake('readme')
|
||||
rtn = IS_UPLOAD_FILENAME(filename='^README$', extension='^$', case=0)(fake)
|
||||
self.assertEqual(rtn, (fake, 'Enter valid filename'))
|
||||
fake = gen_fake('readme')
|
||||
rtn = IS_UPLOAD_FILENAME(filename='README', case=2)(fake)
|
||||
self.assertEqual(rtn, (fake, None))
|
||||
fake = gen_fake('README')
|
||||
rtn = IS_UPLOAD_FILENAME(filename='README', case=2)(fake)
|
||||
self.assertEqual(rtn, (fake, None))
|
||||
rtn = IS_UPLOAD_FILENAME(extension='pdf')('example.pdf')
|
||||
self.assertEqual(rtn, ('example.pdf', 'Enter valid filename'))
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+2
-27
@@ -13,34 +13,9 @@ import subprocess
|
||||
import time
|
||||
import signal
|
||||
|
||||
from fix_path import fix_sys_path
|
||||
|
||||
def fix_sys_path():
|
||||
"""
|
||||
logic to have always the correct sys.path
|
||||
'', web2py/gluon, web2py/site-packages, web2py/ ...
|
||||
"""
|
||||
|
||||
def add_path_first(path):
|
||||
sys.path = [path] + [p for p in sys.path if (
|
||||
not p == path and not p == (path + '/'))]
|
||||
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if not os.path.isfile(os.path.join(path,'web2py.py')):
|
||||
i = 0
|
||||
while i<10:
|
||||
i += 1
|
||||
if os.path.exists(os.path.join(path,'web2py.py')):
|
||||
break
|
||||
path = os.path.abspath(os.path.join(path, '..'))
|
||||
|
||||
paths = [path,
|
||||
os.path.abspath(os.path.join(path, 'site-packages')),
|
||||
os.path.abspath(os.path.join(path, 'gluon')),
|
||||
'']
|
||||
[add_path_first(path) for path in paths]
|
||||
|
||||
fix_sys_path()
|
||||
fix_sys_path(__file__)
|
||||
|
||||
from contrib.webclient import WebClient
|
||||
from urllib2 import HTTPError
|
||||
|
||||
+15
-8
@@ -11,7 +11,10 @@ Auth, Mail, PluginManager and various utilities
|
||||
"""
|
||||
|
||||
import base64
|
||||
import cPickle
|
||||
try:
|
||||
import cPickle as pickle
|
||||
except:
|
||||
import pickle
|
||||
import datetime
|
||||
import thread
|
||||
import logging
|
||||
@@ -2710,7 +2713,8 @@ class Auth(object):
|
||||
extra_fields = [
|
||||
Field("password_two", "password", requires=IS_EQUAL_TO(
|
||||
request.post_vars.get(passfield,None),
|
||||
error_message=self.messages.mismatched_password))]
|
||||
error_message=self.messages.mismatched_password),
|
||||
label=current.T("Confirm Password"))]
|
||||
else:
|
||||
extra_fields = []
|
||||
form = SQLFORM(table_user,
|
||||
@@ -3187,11 +3191,14 @@ class Auth(object):
|
||||
if log is DEFAULT:
|
||||
log = self.messages['change_password_log']
|
||||
passfield = self.settings.password_field
|
||||
is_crypt = copy.copy([t for t in table_user[passfield].requires
|
||||
if isinstance(t,CRYPT)][0])
|
||||
is_crypt.min_length = 0
|
||||
requires = table_user[passfield].requires
|
||||
if not isinstance(requires,(list, tuple)):
|
||||
requires = [requires]
|
||||
requires = filter(lambda t:isinstance(t,CRYPT), requires)
|
||||
if requires:
|
||||
requires[0].min_length = 0
|
||||
form = SQLFORM.factory(
|
||||
Field('old_password', 'password', requires=[is_crypt],
|
||||
Field('old_password', 'password', requires=requires,
|
||||
label=self.messages.old_password),
|
||||
Field('new_password', 'password',
|
||||
label=self.messages.new_password,
|
||||
@@ -3326,7 +3333,7 @@ class Auth(object):
|
||||
user = table_user(user_id)
|
||||
if not user:
|
||||
raise HTTP(401, "Not Authorized")
|
||||
auth.impersonator = cPickle.dumps(session)
|
||||
auth.impersonator = pickle.dumps(session, pickle.HIGHEST_PROTOCOL)
|
||||
auth.user.update(
|
||||
table_user._filter_fields(user, True))
|
||||
self.user = auth.user
|
||||
@@ -3337,7 +3344,7 @@ class Auth(object):
|
||||
elif user_id in (0, '0'):
|
||||
if self.is_impersonating():
|
||||
session.clear()
|
||||
session.update(cPickle.loads(auth.impersonator))
|
||||
session.update(pickle.loads(auth.impersonator))
|
||||
self.user = session.auth.user
|
||||
self.update_groups()
|
||||
self.run_login_onaccept()
|
||||
|
||||
+1
-2
@@ -23,7 +23,6 @@ import logging
|
||||
import socket
|
||||
import base64
|
||||
import zlib
|
||||
import types
|
||||
|
||||
_struct_2_long_long = struct.Struct('=QQ')
|
||||
|
||||
@@ -160,7 +159,7 @@ def pad(s, n=32, padchar=' '):
|
||||
def secure_dumps(data, encryption_key, hash_key=None, compression_level=None):
|
||||
if not hash_key:
|
||||
hash_key = sha1(encryption_key).hexdigest()
|
||||
dump = pickle.dumps(data)
|
||||
dump = pickle.dumps(data, pickle.HIGHEST_PROTOCOL)
|
||||
if compression_level:
|
||||
dump = zlib.compress(dump, compression_level)
|
||||
key = pad(encryption_key[:32])
|
||||
|
||||
+7
-6
@@ -372,14 +372,18 @@ class IS_JSON(Validator):
|
||||
if self.native_json:
|
||||
simplejson.loads(value) # raises error in case of malformed json
|
||||
return (value, None) # the serialized value is not passed
|
||||
return (simplejson.loads(value), None)
|
||||
else:
|
||||
return (simplejson.loads(value), None)
|
||||
except JSONErrors:
|
||||
return (value, translate(self.error_message))
|
||||
|
||||
def formatter(self,value):
|
||||
if value is None:
|
||||
return None
|
||||
return simplejson.dumps(value)
|
||||
if self.native_json:
|
||||
return value
|
||||
else:
|
||||
return simplejson.dumps(value)
|
||||
|
||||
|
||||
class IS_IN_SET(Validator):
|
||||
@@ -1164,11 +1168,8 @@ class IS_LIST_OF_EMAILS(object):
|
||||
|
||||
def __call__(self, value):
|
||||
bad_emails = []
|
||||
emails = []
|
||||
f = IS_EMAIL()
|
||||
for email in self.split_emails.findall(value):
|
||||
if not email in emails:
|
||||
emails.append(email)
|
||||
error = f(email)[1]
|
||||
if error and not email in bad_emails:
|
||||
bad_emails.append(email)
|
||||
@@ -2516,7 +2517,7 @@ class IS_LIST_OF(Validator):
|
||||
if not isinstance(other, (list,tuple)):
|
||||
other = [other]
|
||||
for item in ivalue:
|
||||
if item.strip():
|
||||
if str(item).strip():
|
||||
v = item
|
||||
for validator in other:
|
||||
(v, e) = validator(v)
|
||||
|
||||
@@ -29,6 +29,12 @@ Typical usage:
|
||||
"""
|
||||
|
||||
from __future__ import with_statement
|
||||
|
||||
import sys
|
||||
import os
|
||||
print os.path.join(*__file__.split(os.sep)[:-2] or ['.'])
|
||||
sys.path.append(os.path.join(*__file__.split(os.sep)[:-2] or ['.']))
|
||||
|
||||
from gluon import current
|
||||
from gluon.storage import Storage
|
||||
from optparse import OptionParser
|
||||
@@ -37,6 +43,7 @@ import datetime
|
||||
import os
|
||||
import stat
|
||||
import time
|
||||
import glob
|
||||
|
||||
EXPIRATION_MINUTES = 60
|
||||
SLEEP_MINUTES = 5
|
||||
@@ -157,6 +164,9 @@ class SessionFile(object):
|
||||
def delete(self):
|
||||
try:
|
||||
os.unlink(self.filename)
|
||||
path = os.path.dirname(filename)
|
||||
if not path.endswith('sessions') and len(os.listdir(path))==0:
|
||||
os.rmdir(path)
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -191,10 +201,11 @@ def single_loop(expiration=None, force=False, verbose=False):
|
||||
except:
|
||||
expiration = EXPIRATION_MINUTES * 60
|
||||
|
||||
set_db = SessionSetDb(expiration, force, verbose)
|
||||
set_files = SessionSetFiles(expiration, force, verbose)
|
||||
set_db.trash()
|
||||
set_files.trash()
|
||||
set_db = SessionSetDb(expiration, force, verbose)
|
||||
set_db.trash()
|
||||
|
||||
|
||||
def main():
|
||||
"""Main processing."""
|
||||
|
||||
Reference in new issue
Block a user