--- a/.hgtags Wed Apr 10 16:46:18 2013 +0200
+++ b/.hgtags Mon Apr 15 13:18:01 2013 +0200
@@ -286,3 +286,8 @@
853237d1daf6710af94cc2ec8ee12aa7dba16934 cubicweb-debian-version-3.16.0-1
d95cbb7349f01b9e02e5da65d55a92582bbee6db cubicweb-version-3.16.1
84fbcdc8021c9c198fef3c6a9ad90c298ee12566 cubicweb-debian-version-3.16.1-1
+a2b4f245aa57013cf8bbcfa2f3d021ee04bccfa0 cubicweb-version-3.16.2
+b3c1ad0cbf001883058ab82be9474544a31b5294 cubicweb-debian-version-3.16.2-1
+ee860c51f56bd65c4f6ea363462c02700d1dab5a cubicweb-version-3.16.3
+ee860c51f56bd65c4f6ea363462c02700d1dab5a cubicweb-debian-version-3.16.3-1
+ee860c51f56bd65c4f6ea363462c02700d1dab5a cubicweb-centos-version-3.16.3-1
--- a/__pkginfo__.py Wed Apr 10 16:46:18 2013 +0200
+++ b/__pkginfo__.py Mon Apr 15 13:18:01 2013 +0200
@@ -22,7 +22,7 @@
modname = distname = "cubicweb"
-numversion = (3, 16, 1)
+numversion = (3, 16, 3)
version = '.'.join(str(num) for num in numversion)
description = "a repository of entities / relations for knowledge management"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb.spec Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,56 @@
+%if 0%{?el5}
+%define python python26
+%define __python /usr/bin/python2.6
+%else
+%define python python
+%define __python /usr/bin/python
+%endif
+
+Name: cubicweb
+Version: 3.16.3
+Release: logilab.1%{?dist}
+Summary: CubicWeb is a semantic web application framework
+Source0: http://download.logilab.org/pub/cubicweb/cubicweb-%{version}.tar.gz
+License: LGPLv2+
+Group: Development/Languages/Python
+Vendor: Logilab <contact@logilab.fr>
+Url: http://www.cubicweb.org/project/cubicweb
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
+BuildArch: noarch
+
+Requires: %{python}
+Requires: %{python}-logilab-common >= 0.59.0
+Requires: %{python}-logilab-mtconverter >= 0.8.0
+Requires: %{python}-rql >= 0.31.2
+Requires: %{python}-yams >= 0.36.0
+Requires: %{python}-logilab-database >= 1.9.0
+Requires: %{python}-passlib
+Requires: %{python}-lxml
+Requires: %{python}-twisted-web
+# the schema view uses `dot'; at least on el5, png output requires graphviz-gd
+Requires: graphviz-gd
+Requires: gettext
+
+BuildRequires: %{python}
+
+%description
+a repository of entities / relations for knowledge management
+
+%prep
+%setup -q
+%if 0%{?el5}
+# change the python version in shebangs
+find . -name '*.py' -type f -print0 | xargs -0 sed -i '1,3s;^#!.*python.*$;#! /usr/bin/python2.6;'
+%endif
+
+%install
+NO_SETUPTOOLS=1 %{__python} setup.py --quiet install --no-compile --prefix=%{_prefix} --root="$RPM_BUILD_ROOT"
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-, root, root)
+/*
+
--- a/debian/changelog Wed Apr 10 16:46:18 2013 +0200
+++ b/debian/changelog Mon Apr 15 13:18:01 2013 +0200
@@ -1,3 +1,15 @@
+cubicweb (3.16.3-1) unstable; urgency=low
+
+ * New upstream release
+
+ -- David Douard <david.douard@logilab.fr> Wed, 10 Apr 2013 10:37:37 +0200
+
+cubicweb (3.16.2-1) unstable; urgency=low
+
+ * New upstream release
+
+ -- David Douard <david.douard@logilab.fr> Mon, 08 Apr 2013 19:29:33 +0200
+
cubicweb (3.16.1-1) squeeze; urgency=low
* New upstream release
--- a/devtools/cwwindmill.py Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,160 +0,0 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
-# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
-#
-# This file is part of CubicWeb.
-#
-# CubicWeb is free software: you can redistribute it and/or modify it under the
-# terms of the GNU Lesser General Public License as published by the Free
-# Software Foundation, either version 2.1 of the License, or (at your option)
-# any later version.
-#
-# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-# details.
-#
-# You should have received a copy of the GNU Lesser General Public License along
-# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
-"""this module contains base classes for windmill integration
-
-:todo:
-
- * import CubicWeb session object into windmill scope to be able to run RQL
- * manage command line option from pytest to run specific use tests only
-"""
-
-
-import os, os.path as osp
-from logging import getLogger, ERROR
-import sys
-
-# imported by default to simplify further import statements
-from logilab.common.testlib import TestCase, unittest_main, Tags
-
-try:
- import windmill
- from windmill.dep import functest
- from windmill.bin.admin_lib import configure_global_settings, setup, teardown
-except ImportError:
- windmill = None
-
-from cubicweb.devtools.httptest import CubicWebServerTC, CubicWebServerConfig
-
-if windmill is None:
- class CubicWebWindmillUseCase(CubicWebServerTC):
- tags = CubicWebServerTC.tags & Tags(('windmill',))
-
- def testWindmill(self):
- self.skipTest("can't import windmill")
-else:
- # Excerpt from :ref:`windmill.authoring.unit`
- class UnitTestReporter(functest.reports.FunctestReportInterface):
- def summary(self, test_list, totals_dict, stdout_capture):
- self.test_list = test_list
-
- unittestreporter = UnitTestReporter()
- functest.reports.register_reporter(unittestreporter)
-
- class CubicWebWindmillUseCase(CubicWebServerTC):
- """basic class for Windmill use case tests
-
- If you want to change cubicweb test server parameters, define a new
- :class:`CubicWebServerConfig` and override the :var:`configcls`
- attribute:
-
- configcls = CubicWebServerConfig
-
- From Windmill configuration:
-
- .. attribute:: browser
- identification string (firefox|ie|safari|chrome) (firefox by default)
- .. attribute :: edit_test
- load and edit test for debugging (False by default)
- .. attribute:: test_dir (optional)
- testing file path or directory (windmill directory under your unit case
- file by default)
-
- Examples:
-
- browser = 'firefox'
- test_dir = osp.join(__file__, 'windmill')
- edit_test = False
-
- If you prefer, you can put here the use cases recorded by windmill GUI
- (services transformer) instead of the windmill sub-directory
- You can change `test_dir` as following:
-
- test_dir = __file__
-
- Instead of toggle `edit_test` value, try `python <test script> -f`
- """
- browser = 'firefox'
-
- edit_test = "-i" in sys.argv # detection for pytest invocation
- # Windmill use case are written with no anonymous user
- anonymous_allowed = False
-
- tags = CubicWebServerTC.tags & Tags(('windmill',))
-
- def _test_dir(self):
- """access to class attribute if possible or make assumption
- of expected directory"""
- try:
- return getattr(self, 'test_dir')
- except AttributeError:
- if os.path.basename(sys.argv[0]) == "pytest":
- test_dir = os.getcwd()
- else:
- import inspect
- test_dir = os.path.dirname(inspect.stack()[-1][1])
- return osp.join(test_dir, 'windmill')
-
- def setUp(self):
- # Start CubicWeb session before running the server to populate self.vreg
- CubicWebServerTC.setUp(self)
- # XXX reduce log output (should be done in a cleaner way)
- # windmill fu** up our logging configuration
- for logkey in ('windmill', 'logilab', 'cubicweb'):
- getLogger(logkey).setLevel(ERROR)
- self.test_dir = self._test_dir()
- msg = "provide a valid 'test_dir' as the given test file/dir (current: %s)"
- assert os.path.exists(self.test_dir), (msg % self.test_dir)
- # windmill setup
- windmill.stdout, windmill.stdin = sys.stdout, sys.stdin
- configure_global_settings()
- windmill.settings['TEST_URL'] = self.config['base-url']
- if hasattr(self,"windmill_settings"):
- for (setting,value) in self.windmill_settings.iteritems():
- windmill.settings[setting] = value
- self.windmill_shell_objects = setup()
-
- def tearDown(self):
- teardown(self.windmill_shell_objects)
- CubicWebServerTC.tearDown(self)
-
- def testWindmill(self):
- if self.edit_test:
- # see windmill.bin.admin_options.Firebug
- windmill.settings['INSTALL_FIREBUG'] = 'firebug'
- windmill.settings.setdefault('MOZILLA_PLUGINS', []).extend(
- ['/usr/share/mozilla-extensions/',
- '/usr/share/xul-ext/'])
- controller = self.windmill_shell_objects['start_' + self.browser]()
- self.windmill_shell_objects['do_test'](self.test_dir,
- load=self.edit_test,
- threaded=False)
- # set a breakpoint to be able to debug windmill test
- if self.edit_test:
- import pdb; pdb.set_trace()
- return
-
- # reporter
- for test in unittestreporter.test_list:
- msg = ""
- self._testMethodDoc = getattr(test, "__doc__", None)
- self._testMethodName = test.__name__
- # try to display a better message in case of failure
- if hasattr(test, "tb"):
- msg = '\n'.join(test.tb)
- self.assertEqual(test.result, True, msg=msg)
-
--- a/devtools/data/xvfb-run.sh Wed Apr 10 16:46:18 2013 +0200
+++ b/devtools/data/xvfb-run.sh Mon Apr 15 13:18:01 2013 +0200
@@ -86,6 +86,7 @@
error "problem while cleaning up temporary directory"
exit 5
fi
+ XVFB_RUN_TMPDIR=
fi
if [ -n "$XVFBPID" ]; then
kill "$XVFBPID"
--- a/devtools/qunit.py Wed Apr 10 16:46:18 2013 +0200
+++ b/devtools/qunit.py Mon Apr 15 13:18:01 2013 +0200
@@ -70,7 +70,8 @@
stderr = TemporaryFile()
self.firefox_cmd = ['firefox', '-no-remote']
if os.name == 'posix':
- self.firefox_cmd = [osp.join(osp.dirname(__file__), 'data', 'xvfb-run.sh'), '-a'] + self.firefox_cmd
+ self.firefox_cmd = [osp.join(osp.dirname(__file__), 'data', 'xvfb-run.sh'),
+ '-a', '-s', '-noreset -screen 0 640x480x8'] + self.firefox_cmd
try:
home = osp.expanduser('~')
user = getlogin()
--- a/predicates.py Wed Apr 10 16:46:18 2013 +0200
+++ b/predicates.py Mon Apr 15 13:18:01 2013 +0200
@@ -190,7 +190,7 @@
from logilab.common.compat import all, any
from logilab.common.interface import implements as implements_iface
-from logilab.common.registry import Predicate, objectify_predicate
+from logilab.common.registry import Predicate, objectify_predicate, yes
from yams.schema import BASE_TYPES, role_name
from rql.nodes import Function
@@ -201,6 +201,9 @@
from cubicweb.uilib import eid_param
from cubicweb.schema import split_expression
+# remember, these imports are there for bw compat only
+__BACKWARD_COMPAT_IMPORTS = (yes,)
+
def score_interface(etypesreg, eclass, iface):
"""Return XXX if the give object (maybe an instance or class) implements
the interface.
--- a/server/repository.py Wed Apr 10 16:46:18 2013 +0200
+++ b/server/repository.py Mon Apr 15 13:18:01 2013 +0200
@@ -898,8 +898,12 @@
self.threaded_task(task)
else:
self.info('calling service %s synchronously', regid)
- service = session.vreg['services'].select(regid, session, **kwargs)
- return service.call(**kwargs)
+ session.set_cnxset()
+ try:
+ service = session.vreg['services'].select(regid, session, **kwargs)
+ return service.call(**kwargs)
+ finally:
+ session.free_cnxset()
def user_info(self, sessionid, props=None):
"""this method should be used by client to:
--- a/server/test/unittest_repository.py Wed Apr 10 16:46:18 2013 +0200
+++ b/server/test/unittest_repository.py Mon Apr 15 13:18:01 2013 +0200
@@ -42,9 +42,6 @@
from cubicweb.server.hook import Hook
from cubicweb.server.sources import native
-# start name server anyway, process will fail if already running
-os.system('pyro-ns >/dev/null 2>/dev/null &')
-
class RepositoryTC(CubicWebTC):
""" singleton providing access to a persistent storage for entities
@@ -350,10 +347,12 @@
import Pyro
Pyro.config.PYRO_MULTITHREADED = 0
done = []
- # the client part has to be in the thread due to sqlite limitations
- t = threading.Thread(target=self._pyro_client, args=(done,))
+ self.repo.config.global_set_option('pyro-ns-host', 'NO_PYRONS')
+ daemon = self.repo.pyro_register()
try:
- daemon = self.repo.pyro_register()
+ uri = self.repo.pyro_uri.replace('PYRO', 'pyroloc')
+ # the client part has to be in the thread due to sqlite limitations
+ t = threading.Thread(target=self._pyro_client, args=(uri, done))
t.start()
while not done:
daemon.handleRequests(1.0)
@@ -366,8 +365,8 @@
pyro_ext._DAEMONS.clear()
- def _pyro_client(self, done):
- cnx = connect('pyro:///'+self.repo.config.appid,
+ def _pyro_client(self, uri, done):
+ cnx = connect(uri,
u'admin', password='gingkow',
initlog=False) # don't reset logging configuration
try:
--- a/server/utils.py Wed Apr 10 16:46:18 2013 +0200
+++ b/server/utils.py Mon Apr 15 13:18:01 2013 +0200
@@ -219,9 +219,6 @@
def add_looping_task(self, interval, func, *args):
"""register a function to be called every `interval` seconds.
-
- looping tasks can only be registered during repository initialization,
- once done this method will fail.
"""
task = LoopTask(self, interval, func, args)
if self.running:
--- a/testfunc/test/jstests/ajax_url0.html Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-<div id="ajaxroot">
- <h1>Hello</h1>
-</div>
--- a/testfunc/test/jstests/ajax_url1.html Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-<div id="ajaxroot">
- <div class="ajaxHtmlHead">
- <script src="http://foo.js" type="text/javascript"> </script>
- </div>
- <h1>Hello</h1>
-</div>
--- a/testfunc/test/jstests/ajax_url2.html Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-<div id="ajaxroot">
- <div class="ajaxHtmlHead">
- <script src="http://foo.js" type="text/javascript"> </script>
- <link rel="stylesheet" type="text/css" media="all" href="qunit.css" />
- </div>
- <h1>Hello</h1>
-</div>
--- a/testfunc/test/jstests/ajaxresult.json Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-['foo', 'bar']
--- a/testfunc/test/jstests/test_ajax.html Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-<html>
- <head>
- <!-- dependencies -->
- <script type="text/javascript" src="../../data/jquery.js"></script>
- <script src="../../data/cubicweb.python.js" type="text/javascript"></script>
- <script src="../../data/cubicweb.js" type="text/javascript"></script>
- <script src="../../data/cubicweb.compat.js" type="text/javascript"></script>
- <script src="../../data/cubicweb.dom.js" type="text/javascript"></script>
- <script src="../../data/cubicweb.htmlhelpers.js" type="text/javascript"></script>
- <script src="../../data/cubicweb.ajax.js" type="text/javascript"></script>
- <!-- qunit files -->
- <script type="text/javascript" src="../../../devtools/data/qunit.js"></script>
- <link rel="stylesheet" type="text/css" media="all" href="../../../devtools/data/qunit.css" />
- <!-- test suite -->
- <script src="cwmock.js" type="text/javascript"></script>
- <script src="test_ajax.js" type="text/javascript"></script>
- </head>
- <body>
- <div id="main"> </div>
- <h1 id="qunit-header">cubicweb.ajax.js functions tests</h1>
- <h2 id="qunit-banner"></h2>
- <ol id="qunit-tests">
- </body>
-</html>
--- a/testfunc/test/jstests/test_ajax.js Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,244 +0,0 @@
-$(document).ready(function() {
-
- module("ajax", {
- setup: function() {
- this.scriptsLength = $('head script[src]').length-1;
- this.cssLength = $('head link[rel=stylesheet]').length-1;
- // re-initialize cw loaded cache so that each tests run in a
- // clean environment, have a lookt at _loadAjaxHtmlHead implementation
- // in cubicweb.ajax.js for more information.
- cw.loaded_src = [];
- cw.loaded_href = [];
- },
- teardown: function() {
- $('head script[src]:gt(' + this.scriptsLength + ')').remove();
- $('head link[rel=stylesheet]:gt(' + this.cssLength + ')').remove();
- }
- });
-
- function jsSources() {
- return $.map($('head script[src]'), function(script) {
- return script.getAttribute('src');
- });
- }
-
- test('test simple h1 inclusion (ajax_url0.html)', function() {
- expect(3);
- equals(jQuery('#main').children().length, 0);
- stop();
- jQuery('#main').loadxhtml('/../ajax_url0.html', {
- callback: function() {
- equals(jQuery('#main').children().length, 1);
- equals(jQuery('#main h1').html(), 'Hello');
- start();
- }
- });
- });
-
- test('test simple html head inclusion (ajax_url1.html)', function() {
- expect(6);
- var scriptsIncluded = jsSources();
- equals(jQuery.inArray('http://foo.js', scriptsIncluded), - 1);
- stop();
- jQuery('#main').loadxhtml('/../ajax_url1.html', {
- callback: function() {
- var origLength = scriptsIncluded.length;
- scriptsIncluded = jsSources();
- // check that foo.js has been *appended* to <head>
- equals(scriptsIncluded.length, origLength + 1);
- equals(scriptsIncluded[origLength].indexOf('http://foo.js'), 0);
- // check that <div class="ajaxHtmlHead"> has been removed
- equals(jQuery('#main').children().length, 1);
- equals(jQuery('div.ajaxHtmlHead').length, 0);
- equals(jQuery('#main h1').html(), 'Hello');
- start();
- }
- });
- });
-
- test('test addCallback', function() {
- expect(3);
- equals(jQuery('#main').children().length, 0);
- stop();
- var d = jQuery('#main').loadxhtml('/../ajax_url0.html');
- d.addCallback(function() {
- equals(jQuery('#main').children().length, 1);
- equals(jQuery('#main h1').html(), 'Hello');
- start();
- });
- });
-
- test('test callback after synchronous request', function() {
- expect(1);
- var deferred = new Deferred();
- var result = jQuery.ajax({
- url: './ajax_url0.html',
- async: false,
- beforeSend: function(xhr) {
- deferred._req = xhr;
- },
- success: function(data, status) {
- deferred.success(data);
- }
- });
- stop();
- deferred.addCallback(function() {
- // add an assertion to ensure the callback is executed
- ok(true, "callback is executed");
- start();
- });
- });
-
- test('test addCallback with parameters', function() {
- expect(3);
- equals(jQuery('#main').children().length, 0);
- stop();
- var d = jQuery('#main').loadxhtml('/../ajax_url0.html');
- d.addCallback(function(data, req, arg1, arg2) {
- equals(arg1, 'Hello');
- equals(arg2, 'world');
- start();
- },
- 'Hello', 'world');
- });
-
- test('test callback after synchronous request with parameters', function() {
- var deferred = new Deferred();
- var result = jQuery.ajax({
- url: '/../ajax_url0.html',
- async: false,
- beforeSend: function(xhr) {
- deferred._req = xhr;
- },
- success: function(data, status) {
- deferred.success(data);
- }
- });
- deferred.addCallback(function(data, req, arg1, arg2) {
- // add an assertion to ensure the callback is executed
- ok(true, "callback is executed");
- equals(arg1, 'Hello');
- equals(arg2, 'world');
- },
- 'Hello', 'world');
- });
-
- test('test addErrback', function() {
- expect(1);
- stop();
- var d = jQuery('#main').loadxhtml('/../ajax_url0.html');
- d.addCallback(function() {
- // throw an exception to start errback chain
- throw new Error();
- });
- d.addErrback(function() {
- ok(true, "errback is executed");
- start();
- });
- });
-
- test('test callback / errback execution order', function() {
- expect(4);
- var counter = 0;
- stop();
- var d = jQuery('#main').loadxhtml('/../ajax_url0.html', {
- callback: function() {
- equals(++counter, 1); // should be executed first
- start();
- }
- });
- d.addCallback(function() {
- equals(++counter, 2); // should be executed and break callback chain
- throw new Error();
- });
- d.addCallback(function() {
- // should not be executed since second callback raised an error
- ok(false, "callback is executed");
- });
- d.addErrback(function() {
- // should be executed after the second callback
- equals(++counter, 3);
- });
- d.addErrback(function() {
- // should be executed after the first errback
- equals(++counter, 4);
- });
- });
-
- test('test already included resources are ignored (ajax_url1.html)', function() {
- expect(10);
- var scriptsIncluded = jsSources();
- // NOTE:
- equals(jQuery.inArray('http://foo.js', scriptsIncluded), -1);
- equals(jQuery('head link').length, 1);
- /* use endswith because in pytest context we have an absolute path */
- ok(jQuery('head link').attr('href').endswith('/qunit.css'));
- stop();
- jQuery('#main').loadxhtml('/../ajax_url1.html', {
- callback: function() {
- var origLength = scriptsIncluded.length;
- scriptsIncluded = jsSources();
- try {
- // check that foo.js has been inserted in <head>
- equals(scriptsIncluded.length, origLength + 1);
- equals(scriptsIncluded[origLength].indexOf('http://foo.js'), 0);
- // check that <div class="ajaxHtmlHead"> has been removed
- equals(jQuery('#main').children().length, 1);
- equals(jQuery('div.ajaxHtmlHead').length, 0);
- equals(jQuery('#main h1').html(), 'Hello');
- // qunit.css is not added twice
- equals(jQuery('head link').length, 1);
- /* use endswith because in pytest context we have an absolute path */
- ok(jQuery('head link').attr('href').endswith('/qunit.css'));
- } finally {
- start();
- }
- }
- });
- });
-
- test('test synchronous request loadRemote', function() {
- var res = loadRemote('/../ajaxresult.json', {},
- 'GET', true);
- same(res, ['foo', 'bar']);
- });
-
- test('test event on CubicWeb', function() {
- expect(1);
- stop();
- var events = null;
- jQuery(CubicWeb).bind('server-response', function() {
- // check that server-response event on CubicWeb is triggered
- events = 'CubicWeb';
- });
- jQuery('#main').loadxhtml('/../ajax_url0.html', {
- callback: function() {
- equals(events, 'CubicWeb');
- start();
- }
- });
- });
-
- test('test event on node', function() {
- expect(3);
- stop();
- var nodes = [];
- jQuery('#main').bind('server-response', function() {
- nodes.push('node');
- });
- jQuery(CubicWeb).bind('server-response', function() {
- nodes.push('CubicWeb');
- });
- jQuery('#main').loadxhtml('/../ajax_url0.html', {
- callback: function() {
- equals(nodes.length, 2);
- // check that server-response event on CubicWeb is triggered
- // only once and event server-response on node is triggered
- equals(nodes[0], 'CubicWeb');
- equals(nodes[1], 'node');
- start();
- }
- });
- });
-});
-
--- a/testfunc/test/jstests/test_htmlhelpers.html Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-<html>
- <head>
- <script type="text/javascript" src="../../data/jquery.js"></script>
- <script src="../../data/cubicweb.js" type="text/javascript"></script>
- <script src="../../data/cubicweb.compat.js" type="text/javascript"></script>
- <script src="../../data/cubicweb.python.js" type="text/javascript"></script>
- <script src="../../data/cubicweb.htmlhelpers.js" type="text/javascript"></script>
- <script type="text/javascript" src="qunit.js"></script>
- <link rel="stylesheet" type="text/css" media="all" href="qunit.css" />
- <script src="cwmock.js" type="text/javascript"></script>
- <script src="test_htmlhelpers.js" type="text/javascript"></script>
- </head>
- <body>
- <div id="main">
- </div>
- <h1 id="qunit-header">cubicweb.htmlhelpers.js functions tests</h1>
- <h2 id="qunit-banner"></h2>
- <h2 id="qunit-userAgent"></h2>
- <ol id="qunit-tests">
- </body>
-</html>
--- a/testfunc/test/jstests/test_htmlhelpers.js Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-$(document).ready(function() {
-
- module("module2", {
- setup: function() {
- $('#main').append('<select id="theselect" multiple="multiple" size="2">' +
- '</select>');
- }
- });
-
- test("test first selected", function() {
- $('#theselect').append('<option value="foo">foo</option>' +
- '<option selected="selected" value="bar">bar</option>' +
- '<option value="baz">baz</option>' +
- '<option selected="selecetd"value="spam">spam</option>');
- var selected = firstSelected(document.getElementById("theselect"));
- equals(selected.value, 'bar');
- });
-
- test("test first selected 2", function() {
- $('#theselect').append('<option value="foo">foo</option>' +
- '<option value="bar">bar</option>' +
- '<option value="baz">baz</option>' +
- '<option value="spam">spam</option>');
- var selected = firstSelected(document.getElementById("theselect"));
- equals(selected, null);
- });
-
- module("visibilty");
- test('toggleVisibility', function() {
- $('#main').append('<div id="foo"></div>');
- toggleVisibility('foo');
- ok($('#foo').hasClass('hidden'), 'check hidden class is set');
- });
-
-});
-
--- a/testfunc/test/jstests/test_utils.html Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-<html>
- <head>
- <script type="text/javascript" src="../../data/jquery.js"></script>
- <script src="../../data/jquery.corner.js" type="text/javascript"></script>
- <script src="../../data/cubicweb.js" type="text/javascript"></script>
- <script src="../../data/cubicweb.python.js" type="text/javascript"></script>
- <script src="../../data/cubicweb.compat.js" type="text/javascript"></script>
- <script src="utils.js" type="text/javascript"></script>
- <script type="text/javascript" src="qunit.js"></script>
- <link rel="stylesheet" type="text/css" media="all" href="qunit.css" />
- <script src="cwmock.js" type="text/javascript"></script>
- <script src="test_utils.js" type="text/javascript"></script>
- </head>
- <body>
- <div id="main">
- </div>
- <h1 id="qunit-header">cw.utils functions tests</h1>
- <h2 id="qunit-banner"></h2>
- <h2 id="qunit-userAgent"></h2>
- <ol id="qunit-tests">
- </body>
-</html>
--- a/testfunc/test/jstests/test_utils.js Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-$(document).ready(function() {
-
- module("datetime");
-
- test("test full datetime", function() {
- equals(cw.utils.toISOTimestamp(new Date(1986, 3, 18, 10, 30, 0, 0)),
- '1986-04-18 10:30:00');
- });
-
- test("test only date", function() {
- equals(cw.utils.toISOTimestamp(new Date(1986, 3, 18)), '1986-04-18 00:00:00');
- });
-
- test("test null", function() {
- equals(cw.utils.toISOTimestamp(null), null);
- });
-
- module("parsing");
- test("test basic number parsing", function() {
- var d = strptime('2008/08/08', '%Y/%m/%d');
- same(datetuple(d), [2008, 8, 8, 0, 0]);
- d = strptime('2008/8/8', '%Y/%m/%d');
- same(datetuple(d), [2008, 8, 8, 0, 0]);
- d = strptime('8/8/8', '%Y/%m/%d');
- same(datetuple(d), [8, 8, 8, 0, 0]);
- d = strptime('0/8/8', '%Y/%m/%d');
- same(datetuple(d), [0, 8, 8, 0, 0]);
- d = strptime('-10/8/8', '%Y/%m/%d');
- same(datetuple(d), [-10, 8, 8, 0, 0]);
- d = strptime('-35000', '%Y');
- same(datetuple(d), [-35000, 1, 1, 0, 0]);
- });
-
- test("test custom format parsing", function() {
- var d = strptime('2008-08-08', '%Y-%m-%d');
- same(datetuple(d), [2008, 8, 8, 0, 0]);
- d = strptime('2008 - ! 08: 08', '%Y - ! %m: %d');
- same(datetuple(d), [2008, 8, 8, 0, 0]);
- d = strptime('2008-08-08 12:14', '%Y-%m-%d %H:%M');
- same(datetuple(d), [2008, 8, 8, 12, 14]);
- d = strptime('2008-08-08 1:14', '%Y-%m-%d %H:%M');
- same(datetuple(d), [2008, 8, 8, 1, 14]);
- d = strptime('2008-08-08 01:14', '%Y-%m-%d %H:%M');
- same(datetuple(d), [2008, 8, 8, 1, 14]);
- });
-
- module("sliceList");
- test("test slicelist", function() {
- var list = ['a', 'b', 'c', 'd', 'e', 'f'];
- same(sliceList(list, 2), ['c', 'd', 'e', 'f']);
- same(sliceList(list, 2, -2), ['c', 'd']);
- same(sliceList(list, -3), ['d', 'e', 'f']);
- same(sliceList(list, 0, -2), ['a', 'b', 'c', 'd']);
- same(sliceList(list), list);
- });
-
- module("formContents", {
- setup: function() {
- $('#main').append('<form id="test-form"></form>');
- }
- });
- // XXX test fckeditor
- test("test formContents", function() {
- $('#test-form').append('<input name="input-text" ' +
- 'type="text" value="toto" />');
- $('#test-form').append('<textarea rows="10" cols="30" '+
- 'name="mytextarea">Hello World!</textarea> ');
- $('#test-form').append('<input name="choice" type="radio" ' +
- 'value="yes" />');
- $('#test-form').append('<input name="choice" type="radio" ' +
- 'value="no" checked="checked"/>');
- $('#test-form').append('<input name="check" type="checkbox" ' +
- 'value="yes" />');
- $('#test-form').append('<input name="check" type="checkbox" ' +
- 'value="no" checked="checked"/>');
- $('#test-form').append('<select id="theselect" name="theselect" ' +
- 'multiple="multiple" size="2"></select>');
- $('#theselect').append('<option selected="selected" ' +
- 'value="foo">foo</option>' +
- '<option value="bar">bar</option>');
- //Append an unchecked radio input : should not be in formContents list
- $('#test-form').append('<input name="unchecked-choice" type="radio" ' +
- 'value="one" />');
- $('#test-form').append('<input name="unchecked-choice" type="radio" ' +
- 'value="two"/>');
- same(formContents($('#test-form')[0]), [
- ['input-text', 'mytextarea', 'choice', 'check', 'theselect'],
- ['toto', 'Hello World!', 'no', 'no', 'foo']
- ]);
- });
-});
-
--- a/testfunc/test/jstests/utils.js Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-function datetuple(d) {
- return [d.getFullYear(), d.getMonth()+1, d.getDate(),
- d.getHours(), d.getMinutes()];
-}
-
-function pprint(obj) {
- print('{');
- for(k in obj) {
- print(' ' + k + ' = ' + obj[k]);
- }
- print('}');
-}
-
-function arrayrepr(array) {
- return '[' + array.join(', ') + ']';
-}
-
-function assertArrayEquals(array1, array2) {
- if (array1.length != array2.length) {
- throw new crosscheck.AssertionFailure(array1.join(', ') + ' != ' + array2.join(', '));
- }
- for (var i=0; i<array1.length; i++) {
- if (array1[i] != array2[i]) {
-
- throw new crosscheck.AssertionFailure(arrayrepr(array1) + ' and ' + arrayrepr(array2)
- + ' differs at index ' + i);
- }
- }
-}
--- a/testfunc/test/test_jscript.py Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-from cubicweb.devtools.qunit import QUnitTestCase, unittest_main
-
-from os import path as osp
-
-
-class JScript(QUnitTestCase):
-
- all_js_tests = (
- ("jstests/test_utils.js", (
- "../../web/data/cubicweb.js",
- "../../web/data/cubicweb.compat.js",
- "../../web/data/cubicweb.python.js",
- "jstests/utils.js",
- ),
- ),
-
- ("jstests/test_htmlhelpers.js", (
- "../../web/data/cubicweb.js",
- "../../web/data/cubicweb.compat.js",
- "../../web/data/cubicweb.python.js",
- "../../web/data/cubicweb.htmlhelpers.js",
- ),
- ),
-
- ("jstests/test_ajax.js", (
- "../../web/data/cubicweb.python.js",
- "../../web/data/cubicweb.js",
- "../../web/data/cubicweb.compat.js",
- "../../web/data/cubicweb.htmlhelpers.js",
- "../../web/data/cubicweb.ajax.js",
- ), (
- "jstests/ajax_url0.html",
- "jstests/ajax_url1.html",
- "jstests/ajax_url2.html",
- "jstests/ajaxresult.json",
- ),
- ),
- )
-
-
-if __name__ == '__main__':
- unittest_main()
--- a/testfunc/test/test_windmill.py Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-# Run all scenarii found in windmill directory
-from os.path import join, dirname
-from cubicweb.devtools.cwwindmill import (CubicWebWindmillUseCase,
- unittest_main)
-
-class CubicWebWindmillUseCase(CubicWebWindmillUseCase):
- #test_dir = join(dirname(__file__), "windmill/test_edit_relation.py")
- pass
-
-
-if __name__ == '__main__':
- unittest_main()
--- a/testfunc/test/windmill/test_connexion.py Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-from cubicweb.devtools import DEFAULT_SOURCES
-LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].itervalues()
-
-# Generated by the windmill services transformer
-from windmill.authoring import WindmillTestClient
-
-def test_connect():
- client = WindmillTestClient(__name__)
-
- client.open(url=u'/')
- client.waits.forPageLoad(timeout=u'20000')
- client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
- client.type(text=LOGIN, id=u'__login')
- client.type(text=PASSWORD, id=u'__password')
-
- client.execJS(js=u"$('#loginForm').submit()")
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.sleep(milliseconds=u'5000')
- client.asserts.assertJS(js=u'$(\'.message\').text() == "welcome %s !"' % LOGIN)
- client.open(url=u'/logout')
- client.waits.forPageLoad(timeout=u'20000')
- client.open(url=u'/')
- client.waits.forPageLoad(timeout=u'20000')
- client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
-
-
-def test_wrong_connect():
- client = WindmillTestClient(__name__)
-
- client.open(url=u'/')
- # XXX windmill wants to use its proxy internally on 403 :-(
- #client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
- #client.type(text=LOGIN, id=u'__login')
- #client.type(text=u'novalidpassword', id=u'__password')
- #client.click(value=u'log in')
- client.open(url=u'/?__login=user&__password=nopassword')
- client.waits.forPageLoad(timeout=u'20000')
- client.asserts.assertTextIn(validator=u'authentication failure', id=u'loginBox')
- client.open(url=u'/')
- client.waits.forPageLoad(timeout=u'20000')
- client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
--- a/testfunc/test/windmill/test_creation.py Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-from cubicweb.devtools import DEFAULT_SOURCES
-LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].itervalues()
-
-# Generated by the windmill services transformer
-from windmill.authoring import WindmillTestClient
-
-def test_creation():
- client = WindmillTestClient(__name__)
-
- client.open(url=u'/')
- client.waits.forPageLoad(timeout=u'8000')
- client.type(text=LOGIN, id=u'__login')
- client.type(text=PASSWORD, id=u'__password')
- client.click(value=u'log in')
- client.waits.forPageLoad(timeout=u'20000')
-
- # pre-condition
- client.open(url=u'/cwuser/myuser')
- client.asserts.assertJS(js=u'$(\'#contentmain h1\').text() == "this resource does not exist"')
- client.open(url=u'/?rql=Any U WHERE U is CWUser, U login "myuser"')
- client.asserts.assertJS(js=u'$(\'.searchMessage strong\').text() == "No result matching query"')
-
- client.open(url=u'/manage')
- client.open(url=u'/add/CWUser')
- client.type(text=u'myuser', id=u'login-subject:A')
- client.type(text=u'myuser', id=u'upassword-subject:A')
- client.type(text=u'myuser', name=u'upassword-subject-confirm:A')
- client.type(text=u'myuser', id=u'firstname-subject:A')
- client.select(option=u'managers', id=u'from_in_group-subject:A')
- client.click(id=u'cwinoutadd')
- client.waits.forPageLoad(timeout=u'20000')
- client.click(id=u'adduse_email:Alink')
- client.waits.forPageLoad(timeout=u'20000')
- client.type(text=u'myuser@logilab.fr', id=u'address-subject:B')
- client.waits.forPageLoad(timeout=u'20000')
- client.click(value=u'button_ok')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.sleep(milliseconds=u'5000')
- client.asserts.assertJS(js=u'$(\'.message\').text() == "entity created"')
- client.open(url=u'/?rql=Any U WHERE U is CWUser, U login "myuser"')
- client.waits.forPageLoad(timeout=u'20000')
- client.asserts.assertJS(js=u'$(\'#contentmain h1\').text() == "myuser"')
- client.waits.forPageLoad(timeout=u'8000')
- client.open(url=u'/cwuser/myuser?vid=sameetypelist')
- client.waits.forPageLoad(timeout=u'8000')
- client.asserts.assertJS(js=u'$(\'#contentmain a\').text() == "myuser"')
- client.open(url=u'/cwuser/myuser?vid=text')
- client.waits.forPageLoad(timeout=u'8000')
- client.asserts.assertJS(js=u'$(\'#contentmain\').text() == "\\nmyuser"')
- client.open(url=u'/cwuser/myuser?vid=deleteconf')
- client.waits.forElement(timeout=u'8000', value=u'button_delete')
- client.click(value=u'button_delete')
- client.waits.forPageLoad(timeout=u'8000')
- client.open(url=u'/cwuser/myuser')
- client.asserts.assertJS(js=u'$(\'#contentmain h1\').text() == "this resource does not exist"')
- client.open(url=u'/?rql=Any U WHERE U is CWUser, U login "myuser"')
- client.asserts.assertJS(js=u'$(\'.searchMessage strong\').text() == "No result matching query"')
-
--- a/testfunc/test/windmill/test_edit_relation.py Wed Apr 10 16:46:18 2013 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-from cubicweb.devtools import DEFAULT_SOURCES
-LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].itervalues()
-
-# Generated by the windmill services transformer
-from windmill.authoring import WindmillTestClient
-
-
-def test_edit_relation():
- client = WindmillTestClient(__name__)
-
- client.open(url=u'/logout')
- client.open(url=u'/')
- client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
- client.type(text=LOGIN, id=u'__login')
- client.type(text=PASSWORD, id=u'__password')
- client.execJS(js=u"$('#loginForm').submit()")
- client.waits.forPageLoad(timeout=u'20000')
- client.open(url=u'/add/Folder')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.forElement(timeout=u'8000', id=u'name-subject:A')
- client.click(id=u'name-subject:A')
- client.type(text=u'folder1', id=u'name-subject:A')
- client.click(value=u'button_ok')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.forElement(link=u'add add Folder filed_under Folder object', timeout=u'8000')
- client.click(link=u'add add Folder filed_under Folder object')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.forElement(timeout=u'8000', id=u'name-subject:A')
- client.click(id=u'name-subject:A')
- client.type(text=u'subfolder1', id=u'name-subject:A')
- client.click(value=u'button_ok')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.forElement(link=u'more actions', timeout=u'8000')
- client.click(link=u'more actions')
- client.click(link=u'copy')
- client.waits.forPageLoad(timeout=u'20000')
- client.type(text=u'folder2', id=u'name-subject:A')
- client.click(value=u'button_ok')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.forElement(link=u'modify', timeout=u'8000')
- client.click(link=u'modify')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.forElement(timeout=u'8000', id=u'footer')
- client.click(link=u'x')
- client.click(value=u'button_ok')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.forElement(link=u'add add Folder filed_under Folder object', timeout=u'8000')
- client.click(link=u'add add Folder filed_under Folder object')
- client.waits.forPageLoad(timeout=u'20000')
- client.type(text=u'subfolder2', id=u'name-subject:A')
- client.click(value=u'button_ok')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.forElement(link=u'subfolder2', timeout=u'8000')
- client.click(link=u'subfolder2')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.forElement(link=u'modify', timeout=u'8000')
- client.click(link=u'modify')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.forElement(timeout=u'8000', id=u'footer')
- client.click(link=u'x')
- client.select(xpath=u'//select', index=u'1')
- #client.execJQuery(jquery=u'("select").trigger(\'change\')') # BUGGY freeze UI..
- client.execJS(js=u'$("select").trigger(\'change\')')
- client.waits.sleep(milliseconds=u'2000')
- client.select(jquery=u'(\'select:contains("Search")\')[0]', option=u'Search for folder')
- client.waits.forPageLoad(timeout=u'20000')
- client.click(link=u'folder1')
- client.waits.forPageLoad(timeout=u'20000')
- client.waits.forElement(timeout=u'8000', value=u'button_ok')
- client.click(value=u'button_ok')
- client.waits.forPageLoad(timeout=u'20000')
- client.asserts.assertText(xpath=u'//h1', validator=u'subfolder2')
- client.waits.forElement(link=u'folder_plural', timeout=u'8000')
- client.click(link=u'folder_plural')
- client.waits.forPageLoad(timeout=u'20000')
- client.asserts.assertText(jquery=u"('#contentmain div a')[0]", validator=u'folder1')
- client.asserts.assertText(jquery=u"('#contentmain div a')[1]", validator=u'folder2')
- client.asserts.assertText(jquery=u"('#contentmain div a')[2]", validator=u'subfolder1')
- client.asserts.assertText(jquery=u"('#contentmain div a')[3]", validator=u'subfolder2')
- client.click(link=u'subfolder2')
- client.click(link=u'modify')
- client.click(link=u'folder1')
--- a/web/data/cubicweb.ajax.js Wed Apr 10 16:46:18 2013 +0200
+++ b/web/data/cubicweb.ajax.js Mon Apr 15 13:18:01 2013 +0200
@@ -80,7 +80,8 @@
var callback = this._onFailure[i][0];
var args = [error, this._req];
jQuery.merge(args, this._onFailure[i][1]);
- callback.apply(null, args);
+ if (callback !== undefined)
+ callback.apply(null, args);
}
}
--- a/web/data/cubicweb.css Wed Apr 10 16:46:18 2013 +0200
+++ b/web/data/cubicweb.css Mon Apr 15 13:18:01 2013 +0200
@@ -545,16 +545,6 @@
padding-left: 2em;
}
-/* actions around tables */
-.tableactions span {
- padding: 0 18px;
- height: 24px;
- background: #F8F8F8;
- border: 1px solid #DFDFDF;
- border-bottom: none;
- border-radius: 4px 4px 0 0;
-}
-
/* custom boxes */
.search_box div.boxBody {
--- a/web/data/cubicweb.old.css Wed Apr 10 16:46:18 2013 +0200
+++ b/web/data/cubicweb.old.css Mon Apr 15 13:18:01 2013 +0200
@@ -899,16 +899,6 @@
padding-left: 0.5em;
}
-/* actions around tables */
-.tableactions span {
- padding: 0 18px;
- height: 24px;
- background: #F8F8F8;
- border: 1px solid #DFDFDF;
- border-bottom: none;
- border-radius: 4px 4px 0 0;
-}
-
/***************************************/
/* error view (views/management.py) */
/***************************************/
--- a/web/request.py Wed Apr 10 16:46:18 2013 +0200
+++ b/web/request.py Mon Apr 15 13:18:01 2013 +0200
@@ -101,11 +101,13 @@
self.uiprops = None
#: url for serving datadir (vary with https) (see :ref:`resources`)
self.datadir_url = None
- if https:
+ if https and vreg.config.https_uiprops is not None:
self.uiprops = vreg.config.https_uiprops
+ else:
+ self.uiprops = vreg.config.uiprops
+ if https and vreg.config.https_datadir_url is not None:
self.datadir_url = vreg.config.https_datadir_url
else:
- self.uiprops = vreg.config.uiprops
self.datadir_url = vreg.config.datadir_url
#: raw html headers that can be added from any view
self.html_headers = HTMLHead(self)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/jstests/ajax_url0.html Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,3 @@
+<div id="ajaxroot">
+ <h1>Hello</h1>
+</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/jstests/ajax_url1.html Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,6 @@
+<div id="ajaxroot">
+ <div class="ajaxHtmlHead">
+ <script src="http://foo.js" type="text/javascript"> </script>
+ </div>
+ <h1>Hello</h1>
+</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/jstests/ajax_url2.html Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,7 @@
+<div id="ajaxroot">
+ <div class="ajaxHtmlHead">
+ <script src="http://foo.js" type="text/javascript"> </script>
+ <link rel="stylesheet" type="text/css" media="all" href="qunit.css" />
+ </div>
+ <h1>Hello</h1>
+</div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/jstests/ajaxresult.json Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,1 @@
+['foo', 'bar']
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/jstests/test_ajax.html Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,26 @@
+<html>
+ <head>
+ <!-- dependencies -->
+ <script type="text/javascript">
+ var JSON_BASE_URL = '';
+ </script>
+ <script type="text/javascript" src="../../data/jquery.js"></script>
+ <script src="../../data/cubicweb.js" type="text/javascript"></script>
+ <script src="../../data/cubicweb.htmlhelpers.js" type="text/javascript"></script>
+ <script src="../../data/cubicweb.python.js" type="text/javascript"></script>
+ <script src="../../data/cubicweb.compat.js" type="text/javascript"></script>
+ <script src="../../data/cubicweb.ajax.js" type="text/javascript"></script>
+ <!-- qunit files -->
+ <script type="text/javascript" src="../../../devtools/data/qunit.js"></script>
+ <link rel="stylesheet" type="text/css" media="all" href="../../../devtools/data/qunit.css" />
+ <!-- test suite -->
+ <script src="cwmock.js" type="text/javascript"></script>
+ <script src="test_ajax.js" type="text/javascript"></script>
+ </head>
+ <body>
+ <div id="main"> </div>
+ <h1 id="qunit-header">cubicweb.ajax.js functions tests</h1>
+ <h2 id="qunit-banner"></h2>
+ <ol id="qunit-tests">
+ </body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/jstests/test_ajax.js Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,289 @@
+$(document).ready(function() {
+
+ module("ajax", {
+ setup: function() {
+ this.scriptsLength = $('head script[src]').length-1;
+ this.cssLength = $('head link[rel=stylesheet]').length-1;
+ // re-initialize cw loaded cache so that each tests run in a
+ // clean environment, have a lookt at _loadAjaxHtmlHead implementation
+ // in cubicweb.ajax.js for more information.
+ cw.loaded_src = [];
+ cw.loaded_href = [];
+ },
+ teardown: function() {
+ $('head script[src]:gt(' + this.scriptsLength + ')').remove();
+ $('head link[rel=stylesheet]:gt(' + this.cssLength + ')').remove();
+ }
+ });
+
+ function jsSources() {
+ return $.map($('head script[src]'), function(script) {
+ return script.getAttribute('src');
+ });
+ }
+
+ test('test simple h1 inclusion (ajax_url0.html)', function() {
+ expect(3);
+ equals(jQuery('#main').children().length, 0);
+ stop();
+ jQuery('#main').loadxhtml('/../ajax_url0.html', {
+ callback: function() {
+ try {
+ equals(jQuery('#main').children().length, 1);
+ equals(jQuery('#main h1').html(), 'Hello');
+ } finally {
+ start();
+ };
+ }
+ });
+ });
+
+ test('test simple html head inclusion (ajax_url1.html)', function() {
+ expect(6);
+ var scriptsIncluded = jsSources();
+ equals(jQuery.inArray('http://foo.js', scriptsIncluded), - 1);
+ stop();
+ jQuery('#main').loadxhtml('/../ajax_url1.html', {
+ callback: function() {
+ try {
+ var origLength = scriptsIncluded.length;
+ scriptsIncluded = jsSources();
+ // check that foo.js has been *appended* to <head>
+ equals(scriptsIncluded.length, origLength + 1);
+ equals(scriptsIncluded[origLength].indexOf('http://foo.js'), 0);
+ // check that <div class="ajaxHtmlHead"> has been removed
+ equals(jQuery('#main').children().length, 1);
+ equals(jQuery('div.ajaxHtmlHead').length, 0);
+ equals(jQuery('#main h1').html(), 'Hello');
+ } finally {
+ start();
+ };
+ }
+ });
+ });
+
+ test('test addCallback', function() {
+ expect(3);
+ equals(jQuery('#main').children().length, 0);
+ stop();
+ var d = jQuery('#main').loadxhtml('/../ajax_url0.html');
+ d.addCallback(function() {
+ try {
+ equals(jQuery('#main').children().length, 1);
+ equals(jQuery('#main h1').html(), 'Hello');
+ } finally {
+ start();
+ };
+ });
+ });
+
+ test('test callback after synchronous request', function() {
+ expect(1);
+ var deferred = new Deferred();
+ var result = jQuery.ajax({
+ url: './ajax_url0.html',
+ async: false,
+ beforeSend: function(xhr) {
+ deferred._req = xhr;
+ },
+ success: function(data, status) {
+ deferred.success(data);
+ }
+ });
+ stop();
+ deferred.addCallback(function() {
+ try {
+ // add an assertion to ensure the callback is executed
+ ok(true, "callback is executed");
+ } finally {
+ start();
+ };
+ });
+ });
+
+ test('test addCallback with parameters', function() {
+ expect(3);
+ equals(jQuery('#main').children().length, 0);
+ stop();
+ var d = jQuery('#main').loadxhtml('/../ajax_url0.html');
+ d.addCallback(function(data, req, arg1, arg2) {
+ try {
+ equals(arg1, 'Hello');
+ equals(arg2, 'world');
+ } finally {
+ start();
+ };
+ },
+ 'Hello', 'world');
+ });
+
+ test('test callback after synchronous request with parameters', function() {
+ expect(2);
+ var deferred = new Deferred();
+ deferred.addCallback(function(data, req, arg1, arg2) {
+ // add an assertion to ensure the callback is executed
+ try {
+ ok(true, "callback is executed");
+ equals(arg1, 'Hello');
+ equals(arg2, 'world');
+ } finally {
+ start();
+ };
+ },
+ 'Hello', 'world');
+ deferred.addErrback(function() {
+ // throw an exception to start errback chain
+ try {
+ throw this._error;
+ } finally {
+ start();
+ };
+ });
+ stop();
+ var result = jQuery.ajax({
+ url: '/../ajax_url0.html',
+ async: false,
+ beforeSend: function(xhr) {
+ deferred._req = xhr;
+ },
+ success: function(data, status) {
+ deferred.success(data);
+ }
+ });
+ });
+
+ test('test addErrback', function() {
+ expect(1);
+ stop();
+ var d = jQuery('#main').loadxhtml('/../ajax_url0.html');
+ d.addCallback(function() {
+ // throw an exception to start errback chain
+ try {
+ throw new Error();
+ } finally {
+ start();
+ };
+ });
+ d.addErrback(function() {
+ try {
+ ok(true, "errback is executed");
+ } finally {
+ start();
+ };
+ });
+ });
+
+ test('test callback / errback execution order', function() {
+ expect(4);
+ var counter = 0;
+ stop();
+ var d = jQuery('#main').loadxhtml('/../ajax_url0.html', {
+ callback: function() {
+ try {
+ equals(++counter, 1); // should be executed first
+ } finally {
+ start();
+ };
+ }
+ });
+ d.addCallback(function() {
+ equals(++counter, 2); // should be executed and break callback chain
+ throw new Error();
+ });
+ d.addCallback(function() {
+ // should not be executed since second callback raised an error
+ ok(false, "callback is executed");
+ });
+ d.addErrback(function() {
+ // should be executed after the second callback
+ equals(++counter, 3);
+ });
+ d.addErrback(function() {
+ // should be executed after the first errback
+ equals(++counter, 4);
+ });
+ });
+
+ test('test already included resources are ignored (ajax_url1.html)', function() {
+ expect(10);
+ var scriptsIncluded = jsSources();
+ // NOTE:
+ equals(jQuery.inArray('http://foo.js', scriptsIncluded), -1);
+ equals(jQuery('head link').length, 1);
+ /* use endswith because in pytest context we have an absolute path */
+ ok(jQuery('head link').attr('href').endswith('/qunit.css'));
+ stop();
+ jQuery('#main').loadxhtml('/../ajax_url1.html', {
+ callback: function() {
+ var origLength = scriptsIncluded.length;
+ scriptsIncluded = jsSources();
+ try {
+ // check that foo.js has been inserted in <head>
+ equals(scriptsIncluded.length, origLength + 1);
+ equals(scriptsIncluded[origLength].indexOf('http://foo.js'), 0);
+ // check that <div class="ajaxHtmlHead"> has been removed
+ equals(jQuery('#main').children().length, 1);
+ equals(jQuery('div.ajaxHtmlHead').length, 0);
+ equals(jQuery('#main h1').html(), 'Hello');
+ // qunit.css is not added twice
+ equals(jQuery('head link').length, 1);
+ /* use endswith because in pytest context we have an absolute path */
+ ok(jQuery('head link').attr('href').endswith('/qunit.css'));
+ } finally {
+ start();
+ }
+ }
+ });
+ });
+
+ test('test synchronous request loadRemote', function() {
+ var res = loadRemote('/../ajaxresult.json', {},
+ 'GET', true);
+ same(res, ['foo', 'bar']);
+ });
+
+ test('test event on CubicWeb', function() {
+ expect(1);
+ stop();
+ var events = null;
+ jQuery(CubicWeb).bind('server-response', function() {
+ // check that server-response event on CubicWeb is triggered
+ events = 'CubicWeb';
+ });
+ jQuery('#main').loadxhtml('/../ajax_url0.html', {
+ callback: function() {
+ try {
+ equals(events, 'CubicWeb');
+ } finally {
+ start();
+ };
+ }
+ });
+ });
+
+ test('test event on node', function() {
+ expect(3);
+ stop();
+ var nodes = [];
+ jQuery('#main').bind('server-response', function() {
+ nodes.push('node');
+ });
+ jQuery(CubicWeb).bind('server-response', function() {
+ nodes.push('CubicWeb');
+ });
+ jQuery('#main').loadxhtml('/../ajax_url0.html', {
+ callback: function() {
+ try {
+ equals(nodes.length, 2);
+ // check that server-response event on CubicWeb is triggered
+ // only once and event server-response on node is triggered
+ equals(nodes[0], 'CubicWeb');
+ equals(nodes[1], 'node');
+ } finally {
+ start();
+ };
+ }
+ });
+ });
+});
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/jstests/test_htmlhelpers.html Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,22 @@
+<html>
+ <head>
+ <!-- dependencies -->
+ <script type="text/javascript" src="../../data/jquery.js"></script>
+ <script src="../../data/cubicweb.python.js" type="text/javascript"></script>
+ <script src="../../data/cubicweb.js" type="text/javascript"></script>
+ <script src="../../data/cubicweb.compat.js" type="text/javascript"></script>
+ <script src="../../data/cubicweb.htmlhelpers.js" type="text/javascript"></script>
+ <!-- qunit files -->
+ <script type="text/javascript" src="../../../devtools/data/qunit.js"></script>
+ <link rel="stylesheet" type="text/css" media="all" href="../../../devtools/data/qunit.css" />
+ <!-- test suite -->
+ <script src="cwmock.js" type="text/javascript"></script>
+ <script src="test_htmlhelpers.js" type="text/javascript"></script>
+ </head>
+ <body>
+ <div id="main"> </div>
+ <h1 id="qunit-header">cubicweb.htmlhelpers.js functions tests</h1>
+ <h2 id="qunit-banner"></h2>
+ <ol id="qunit-tests">
+ </body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/jstests/test_htmlhelpers.js Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,36 @@
+$(document).ready(function() {
+
+ module("module2", {
+ setup: function() {
+ $('#main').append('<select id="theselect" multiple="multiple" size="2">' +
+ '</select>');
+ }
+ });
+
+ test("test first selected", function() {
+ $('#theselect').append('<option value="foo">foo</option>' +
+ '<option selected="selected" value="bar">bar</option>' +
+ '<option value="baz">baz</option>' +
+ '<option selected="selecetd"value="spam">spam</option>');
+ var selected = firstSelected(document.getElementById("theselect"));
+ equals(selected.value, 'bar');
+ });
+
+ test("test first selected 2", function() {
+ $('#theselect').append('<option value="foo">foo</option>' +
+ '<option value="bar">bar</option>' +
+ '<option value="baz">baz</option>' +
+ '<option value="spam">spam</option>');
+ var selected = firstSelected(document.getElementById("theselect"));
+ equals(selected, null);
+ });
+
+ module("visibilty");
+ test('toggleVisibility', function() {
+ $('#main').append('<div id="foo"></div>');
+ toggleVisibility('foo');
+ ok($('#foo').hasClass('hidden'), 'check hidden class is set');
+ });
+
+});
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/jstests/test_utils.html Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,22 @@
+<html>
+ <head>
+ <!-- dependencies -->
+ <script type="text/javascript" src="utils.js"></script>
+ <script type="text/javascript" src="../../data/jquery.js"></script>
+ <script src="../../data/cubicweb.python.js" type="text/javascript"></script>
+ <script src="../../data/cubicweb.js" type="text/javascript"></script>
+ <script src="../../data/cubicweb.compat.js" type="text/javascript"></script>
+ <!-- qunit files -->
+ <script type="text/javascript" src="../../../devtools/data/qunit.js"></script>
+ <link rel="stylesheet" type="text/css" media="all" href="../../../devtools/data/qunit.css" />
+ <!-- test suite -->
+ <script src="cwmock.js" type="text/javascript"></script>
+ <script src="test_utils.js" type="text/javascript"></script>
+ </head>
+ <body>
+ <div id="main"> </div>
+ <h1 id="qunit-header">cw.utils functions tests</h1>
+ <h2 id="qunit-banner"></h2>
+ <ol id="qunit-tests">
+ </body>
+</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/jstests/test_utils.js Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,92 @@
+$(document).ready(function() {
+
+ module("datetime");
+
+ test("test full datetime", function() {
+ equals(cw.utils.toISOTimestamp(new Date(1986, 3, 18, 10, 30, 0, 0)),
+ '1986-04-18 10:30:00');
+ });
+
+ test("test only date", function() {
+ equals(cw.utils.toISOTimestamp(new Date(1986, 3, 18)), '1986-04-18 00:00:00');
+ });
+
+ test("test null", function() {
+ equals(cw.utils.toISOTimestamp(null), null);
+ });
+
+ module("parsing");
+ test("test basic number parsing", function() {
+ var d = strptime('2008/08/08', '%Y/%m/%d');
+ same(datetuple(d), [2008, 8, 8, 0, 0]);
+ d = strptime('2008/8/8', '%Y/%m/%d');
+ same(datetuple(d), [2008, 8, 8, 0, 0]);
+ d = strptime('8/8/8', '%Y/%m/%d');
+ same(datetuple(d), [8, 8, 8, 0, 0]);
+ d = strptime('0/8/8', '%Y/%m/%d');
+ same(datetuple(d), [0, 8, 8, 0, 0]);
+ d = strptime('-10/8/8', '%Y/%m/%d');
+ same(datetuple(d), [-10, 8, 8, 0, 0]);
+ d = strptime('-35000', '%Y');
+ same(datetuple(d), [-35000, 1, 1, 0, 0]);
+ });
+
+ test("test custom format parsing", function() {
+ var d = strptime('2008-08-08', '%Y-%m-%d');
+ same(datetuple(d), [2008, 8, 8, 0, 0]);
+ d = strptime('2008 - ! 08: 08', '%Y - ! %m: %d');
+ same(datetuple(d), [2008, 8, 8, 0, 0]);
+ d = strptime('2008-08-08 12:14', '%Y-%m-%d %H:%M');
+ same(datetuple(d), [2008, 8, 8, 12, 14]);
+ d = strptime('2008-08-08 1:14', '%Y-%m-%d %H:%M');
+ same(datetuple(d), [2008, 8, 8, 1, 14]);
+ d = strptime('2008-08-08 01:14', '%Y-%m-%d %H:%M');
+ same(datetuple(d), [2008, 8, 8, 1, 14]);
+ });
+
+ module("sliceList");
+ test("test slicelist", function() {
+ var list = ['a', 'b', 'c', 'd', 'e', 'f'];
+ same(sliceList(list, 2), ['c', 'd', 'e', 'f']);
+ same(sliceList(list, 2, -2), ['c', 'd']);
+ same(sliceList(list, -3), ['d', 'e', 'f']);
+ same(sliceList(list, 0, -2), ['a', 'b', 'c', 'd']);
+ same(sliceList(list), list);
+ });
+
+ module("formContents", {
+ setup: function() {
+ $('#main').append('<form id="test-form"></form>');
+ }
+ });
+ // XXX test fckeditor
+ test("test formContents", function() {
+ $('#test-form').append('<input name="input-text" ' +
+ 'type="text" value="toto" />');
+ $('#test-form').append('<textarea rows="10" cols="30" '+
+ 'name="mytextarea">Hello World!</textarea> ');
+ $('#test-form').append('<input name="choice" type="radio" ' +
+ 'value="yes" />');
+ $('#test-form').append('<input name="choice" type="radio" ' +
+ 'value="no" checked="checked"/>');
+ $('#test-form').append('<input name="check" type="checkbox" ' +
+ 'value="yes" />');
+ $('#test-form').append('<input name="check" type="checkbox" ' +
+ 'value="no" checked="checked"/>');
+ $('#test-form').append('<select id="theselect" name="theselect" ' +
+ 'multiple="multiple" size="2"></select>');
+ $('#theselect').append('<option selected="selected" ' +
+ 'value="foo">foo</option>' +
+ '<option value="bar">bar</option>');
+ //Append an unchecked radio input : should not be in formContents list
+ $('#test-form').append('<input name="unchecked-choice" type="radio" ' +
+ 'value="one" />');
+ $('#test-form').append('<input name="unchecked-choice" type="radio" ' +
+ 'value="two"/>');
+ same(formContents($('#test-form')[0]), [
+ ['input-text', 'mytextarea', 'choice', 'check', 'theselect'],
+ ['toto', 'Hello World!', 'no', 'no', 'foo']
+ ]);
+ });
+});
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/jstests/utils.js Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,29 @@
+function datetuple(d) {
+ return [d.getFullYear(), d.getMonth()+1, d.getDate(),
+ d.getHours(), d.getMinutes()];
+}
+
+function pprint(obj) {
+ print('{');
+ for(k in obj) {
+ print(' ' + k + ' = ' + obj[k]);
+ }
+ print('}');
+}
+
+function arrayrepr(array) {
+ return '[' + array.join(', ') + ']';
+}
+
+function assertArrayEquals(array1, array2) {
+ if (array1.length != array2.length) {
+ throw new crosscheck.AssertionFailure(array1.join(', ') + ' != ' + array2.join(', '));
+ }
+ for (var i=0; i<array1.length; i++) {
+ if (array1[i] != array2[i]) {
+
+ throw new crosscheck.AssertionFailure(arrayrepr(array1) + ' and ' + arrayrepr(array2)
+ + ' differs at index ' + i);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/test/test_jscript.py Mon Apr 15 13:18:01 2013 +0200
@@ -0,0 +1,42 @@
+from cubicweb.devtools.qunit import QUnitTestCase, unittest_main
+
+from os import path as osp
+
+
+class JScript(QUnitTestCase):
+
+ all_js_tests = (
+ ("jstests/test_utils.js", (
+ "../../web/data/cubicweb.js",
+ "../../web/data/cubicweb.compat.js",
+ "../../web/data/cubicweb.python.js",
+ "jstests/utils.js",
+ ),
+ ),
+
+ ("jstests/test_htmlhelpers.js", (
+ "../../web/data/cubicweb.js",
+ "../../web/data/cubicweb.compat.js",
+ "../../web/data/cubicweb.python.js",
+ "../../web/data/cubicweb.htmlhelpers.js",
+ ),
+ ),
+
+ ("jstests/test_ajax.js", (
+ "../../web/data/cubicweb.python.js",
+ "../../web/data/cubicweb.js",
+ "../../web/data/cubicweb.compat.js",
+ "../../web/data/cubicweb.htmlhelpers.js",
+ "../../web/data/cubicweb.ajax.js",
+ ), (
+ "jstests/ajax_url0.html",
+ "jstests/ajax_url1.html",
+ "jstests/ajax_url2.html",
+ "jstests/ajaxresult.json",
+ ),
+ ),
+ )
+
+
+if __name__ == '__main__':
+ unittest_main()
--- a/web/views/tableview.py Wed Apr 10 16:46:18 2013 +0200
+++ b/web/views/tableview.py Mon Apr 15 13:18:01 2013 +0200
@@ -290,17 +290,20 @@
return attrs
def render_actions(self, w, actions):
- w(u'<div class="tableactions">')
+ box = MenuWidget('', '', _class='tableActionsBox', islist=False)
+ label = tags.span(self._cw._('action menu'))
+ menu = PopupBoxMenu(label, isitem=False, link_class='actionsBox',
+ ident='%sActions' % self.view.domid)
+ box.append(menu)
for action in actions:
- w(u'<span>')
- action.render(w)
- w(u'</span>')
- w(u'</div>')
+ menu.append(action)
+ box.render(w=w)
+ w(u'<div class="clear"></div>')
def show_hide_filter_actions(self, currentlydisplayed=False):
divid = self.view.domid
showhide = u';'.join(toggle_action('%s%s' % (divid, what))[11:]
- for what in ('Form', 'Actions'))
+ for what in ('Form', 'Show', 'Hide', 'Actions'))
showhide = 'javascript:' + showhide
self._cw.add_onload(u'''\
$(document).ready(function() {
@@ -310,8 +313,10 @@
$('#%(id)sShow').attr('class', 'hidden');
}
});''' % {'id': divid})
- showlabel = self._cw._('toggle filter')
- return [component.Link(showhide, showlabel, id='%sToggle' % divid)]
+ showlabel = self._cw._('show filter form')
+ hidelabel = self._cw._('hide filter form')
+ return [component.Link(showhide, showlabel, id='%sShow' % divid),
+ component.Link(showhide, hidelabel, id='%sHide' % divid)]
class AbstractColumnRenderer(object):
--- a/web/webconfig.py Wed Apr 10 16:46:18 2013 +0200
+++ b/web/webconfig.py Mon Apr 15 13:18:01 2013 +0200
@@ -81,7 +81,6 @@
"""
cubicweb_appobject_path = CubicWebConfiguration.cubicweb_appobject_path | set([join('web', 'views')])
cube_appobject_path = CubicWebConfiguration.cube_appobject_path | set(['views'])
- uiprops = {'FCKEDITOR_PATH': ''}
options = merge_options(CubicWebConfiguration.options + (
('repository-uri',
@@ -244,8 +243,17 @@
}),
))
+ def __init__(self, *args, **kwargs):
+ super(WebConfiguration, self).__init__(*args, **kwargs)
+ self.uiprops = None
+ self.https_uiprops = None
+ self.datadir_url = None
+ self.https_datadir_url = None
+
def fckeditor_installed(self):
- return exists(self.uiprops['FCKEDITOR_PATH'])
+ if self.uiprops is None:
+ return False
+ return exists(self.uiprops.get('FCKEDITOR_PATH', ''))
def cwproperty_definitions(self):
for key, pdef in super(WebConfiguration, self).cwproperty_definitions():