[ckan-changes] commit/ckan: 4 new changesets
Bitbucket
commits-noreply at bitbucket.org
Fri Sep 2 08:57:19 UTC 2011
4 new changesets in ckan:
http://bitbucket.org/okfn/ckan/changeset/3f8dbccd0baa/
changeset: 3f8dbccd0baa
branch: feature-1271-cors
user: rgrp
date: 2011-09-01 15:45:22
summary: [merge,to-branch]: trivial merge from default into branch prior to doing more work.
affected #: 106 files (539.5 KB)
Diff too large to display.
http://bitbucket.org/okfn/ckan/changeset/ee1d9dd36c8f/
changeset: ee1d9dd36c8f
branch: feature-1271-cors
user: rgrp
date: 2011-09-01 16:03:46
summary: [cors,bugfix][s]: fix CORS to have empty response body for OPTIONS requests.
* OPTIONS requests must return no content but were returning content of GET.
affected #: 4 files (303 bytes)
--- a/ckan/config/routing.py Thu Sep 01 14:45:22 2011 +0100
+++ b/ckan/config/routing.py Thu Sep 01 15:03:46 2011 +0100
@@ -26,6 +26,8 @@
for plugin in routing_plugins:
map = plugin.before_map(map)
+ map.connect('*url', controller='home', action='cors_options',
+ conditions=dict(method=['OPTIONS']))
map.connect('home', '/', controller='home', action='index')
map.connect('guide', config.get('guide_url', 'http://wiki.okfn.org/ckan/doc/'), _static=True)
map.connect('license', '/license', controller='home', action='license')
--- a/ckan/controllers/home.py Thu Sep 01 14:45:22 2011 +0100
+++ b/ckan/controllers/home.py Thu Sep 01 15:03:46 2011 +0100
@@ -113,3 +113,7 @@
cache_.clear()
return 'Cleared caches: %s' % ', '.join(wui_caches)
+ def cors_options(self, url=None):
+ # just return 200 OK and empty data
+ return ''
+
--- a/ckan/lib/base.py Thu Sep 01 14:45:22 2011 +0100
+++ b/ckan/lib/base.py Thu Sep 01 15:03:46 2011 +0100
@@ -134,7 +134,7 @@
def _set_cors(self):
response.headers['Access-Control-Allow-Origin'] = "*"
- response.headers['Access-Control-Allow-Methods'] = "POST, PUT, GET, OPTIONS"
+ response.headers['Access-Control-Allow-Methods'] = "POST, PUT, GET, DELETE"
response.headers['Access-Control-Allow-Headers'] = "X-CKAN-API-KEY, Content-Type"
def _get_user(self, reference):
--- a/ckan/tests/functional/test_cors.py Thu Sep 01 14:45:22 2011 +0100
+++ b/ckan/tests/functional/test_cors.py Thu Sep 01 15:03:46 2011 +0100
@@ -8,12 +8,14 @@
self.ourapp = webtest.TestApp(self.wsgiapp)
out = self.ourapp.request('/', method='OPTIONS')
assert out.status_int == 200, out
+ print out
+ assert len(str(out.body)) == 0, 'OPTIONS must return no content'
def test_headers(self):
out = self.app.get('/')
headers = dict(out.headers)
print headers
assert headers['Access-Control-Allow-Origin'] == '*'
- assert headers['Access-Control-Allow-Methods'] == "POST, PUT, GET, OPTIONS"
+ assert headers['Access-Control-Allow-Methods'] == "POST, PUT, GET, DELETE"
assert headers['Access-Control-Allow-Headers'] == "X-CKAN-API-KEY, Content-Type"
http://bitbucket.org/okfn/ckan/changeset/e2d4a3ee5693/
changeset: e2d4a3ee5693
user: rgrp
date: 2011-09-01 16:04:46
summary: [merge,from-branch][s]: merge just done bugfix in cors branch.
affected #: 4 files (303 bytes)
--- a/ckan/config/routing.py Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/config/routing.py Thu Sep 01 15:04:46 2011 +0100
@@ -26,6 +26,8 @@
for plugin in routing_plugins:
map = plugin.before_map(map)
+ map.connect('*url', controller='home', action='cors_options',
+ conditions=dict(method=['OPTIONS']))
map.connect('home', '/', controller='home', action='index')
map.connect('guide', config.get('guide_url', 'http://wiki.okfn.org/ckan/doc/'), _static=True)
map.connect('license', '/license', controller='home', action='license')
--- a/ckan/controllers/home.py Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/controllers/home.py Thu Sep 01 15:04:46 2011 +0100
@@ -113,3 +113,7 @@
cache_.clear()
return 'Cleared caches: %s' % ', '.join(wui_caches)
+ def cors_options(self, url=None):
+ # just return 200 OK and empty data
+ return ''
+
--- a/ckan/lib/base.py Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/lib/base.py Thu Sep 01 15:04:46 2011 +0100
@@ -134,7 +134,7 @@
def _set_cors(self):
response.headers['Access-Control-Allow-Origin'] = "*"
- response.headers['Access-Control-Allow-Methods'] = "POST, PUT, GET, OPTIONS"
+ response.headers['Access-Control-Allow-Methods'] = "POST, PUT, GET, DELETE"
response.headers['Access-Control-Allow-Headers'] = "X-CKAN-API-KEY, Content-Type"
def _get_user(self, reference):
--- a/ckan/tests/functional/test_cors.py Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/tests/functional/test_cors.py Thu Sep 01 15:04:46 2011 +0100
@@ -8,12 +8,14 @@
self.ourapp = webtest.TestApp(self.wsgiapp)
out = self.ourapp.request('/', method='OPTIONS')
assert out.status_int == 200, out
+ print out
+ assert len(str(out.body)) == 0, 'OPTIONS must return no content'
def test_headers(self):
out = self.app.get('/')
headers = dict(out.headers)
print headers
assert headers['Access-Control-Allow-Origin'] == '*'
- assert headers['Access-Control-Allow-Methods'] == "POST, PUT, GET, OPTIONS"
+ assert headers['Access-Control-Allow-Methods'] == "POST, PUT, GET, DELETE"
assert headers['Access-Control-Allow-Headers'] == "X-CKAN-API-KEY, Content-Type"
http://bitbucket.org/okfn/ckan/changeset/612041cfd96f/
changeset: 612041cfd96f
user: rgrp
date: 2011-09-02 10:57:09
summary: [merge,in-default][s]: merge adria's recent changes into default with my recent changes.
affected #: 6 files (2.6 KB)
--- a/ckan/controllers/group_formalchemy.py Thu Sep 01 15:04:46 2011 +0100
+++ b/ckan/controllers/group_formalchemy.py Fri Sep 02 09:57:09 2011 +0100
@@ -16,10 +16,15 @@
from ckan.lib.base import ValidationException
from ckan.controllers.group import GroupController
+from ckan.plugins import PluginImplementations, IGroupController
+
log = logging.getLogger(__name__)
class GroupFormalchemyController(GroupController):
+ def __init__(self):
+ self.extensions = PluginImplementations(IGroupController)
+
def new(self):
record = model.Group
c.error = ''
--- a/ckan/controllers/package.py Thu Sep 01 15:04:46 2011 +0100
+++ b/ckan/controllers/package.py Fri Sep 02 09:57:09 2011 +0100
@@ -23,7 +23,6 @@
from ckan.lib.navl.dictization_functions import DataError, unflatten, validate
from ckan.logic import NotFound, NotAuthorized, ValidationError
from ckan.logic import tuplize_dict, clean_dict, parse_params, flatten_to_string_key
-from ckan.plugins import PluginImplementations, IPackageController
from ckan.lib.dictization import table_dictize
import ckan.forms
import ckan.authz
@@ -97,7 +96,6 @@
## end hooks
authorizer = ckan.authz.Authorizer()
- extensions = PluginImplementations(IPackageController)
def search(self):
try:
@@ -253,9 +251,6 @@
# used by disqus plugin
c.current_package_id = c.pkg.id
- for item in self.extensions:
- item.read(c.pkg)
-
#render the package
PackageSaver().render_package(c.pkg_dict)
return render('package/comments.html')
--- a/ckan/controllers/package_formalchemy.py Thu Sep 01 15:04:46 2011 +0100
+++ b/ckan/controllers/package_formalchemy.py Fri Sep 02 09:57:09 2011 +0100
@@ -9,11 +9,15 @@
from pylons.i18n import get_lang, _
from ckan.logic import check_access, NotAuthorized
+from ckan.plugins import PluginImplementations, IPackageController
log = logging.getLogger(__name__)
class PackageFormalchemyController(PackageController):
+ def __init__(self):
+ self.extensions = PluginImplementations(IPackageController)
+
def new(self):
c.error = ''
api_url = config.get('ckan.api_url', '/').rstrip('/')
--- a/ckan/lib/dictization/model_save.py Thu Sep 01 15:04:46 2011 +0100
+++ b/ckan/lib/dictization/model_save.py Fri Sep 02 09:57:09 2011 +0100
@@ -320,6 +320,9 @@
User = model.User
if user:
user_dict['id'] = user.id
+
+ if 'password' in user_dict and not len(user_dict['password']):
+ del user_dict['password']
user = table_dict_save(user_dict, User, context)
--- a/ckan/lib/mailer.py Thu Sep 01 15:04:46 2011 +0100
+++ b/ckan/lib/mailer.py Fri Sep 02 09:57:09 2011 +0100
@@ -44,8 +44,9 @@
server.sendmail(mail_from, [recipient_email], msg.as_string())
server.quit()
except Exception, e:
- log.exception(e)
- raise MailerException(e.message)
+ msg = '%r' % e
+ log.exception(msg)
+ raise MailerException(msg)
def mail_recipient(recipient_name, recipient_email, subject,
body, headers={}):
--- a/ckan/tests/functional/test_user.py Thu Sep 01 15:04:46 2011 +0100
+++ b/ckan/tests/functional/test_user.py Fri Sep 02 09:57:09 2011 +0100
@@ -416,6 +416,59 @@
main_res = self.main_div(res)
assert new_about in main_res, main_res
+ def test_user_edit_no_password(self):
+ # create user
+ username = 'testedit2'
+ about = u'Test About'
+ user = model.User.by_name(unicode(username))
+ if not user:
+ model.Session.add(model.User(name=unicode(username), about=about,
+ password='letmein'))
+ model.repo.commit_and_remove()
+ user = model.User.by_name(unicode(username))
+
+ old_password = user.password
+
+ # edit
+ new_about = u'Changed about'
+ offset = url_for(controller='user', action='edit', id=user.id)
+ res = self.app.get(offset, status=200, extra_environ={'REMOTE_USER':username})
+ main_res = self.main_div(res)
+ assert 'Edit User: ' in main_res, main_res
+ assert about in main_res, main_res
+ fv = res.forms['user-edit']
+ fv['about'] = new_about
+ fv['password1'] = ''
+ fv['password2'] = ''
+
+ res = fv.submit('preview', extra_environ={'REMOTE_USER':username})
+
+ # preview
+ main_res = self.main_div(res)
+ assert 'Edit User: testedit2' in main_res, main_res
+ in_preview = main_res[main_res.find('Preview'):]
+ assert new_about in in_preview, in_preview
+
+ # commit
+ res = fv.submit('save', extra_environ={'REMOTE_USER':username})
+ assert res.status == 302, self.main_div(res).encode('utf8')
+ res = res.follow()
+ main_res = self.main_div(res)
+ assert 'testedit2' in main_res, main_res
+ assert new_about in main_res, main_res
+
+ # read, not logged in
+ offset = url_for(controller='user', action='read', id=user.id)
+ res = self.app.get(offset, status=200)
+ main_res = self.main_div(res)
+ assert new_about in main_res, main_res
+
+ updated_user = model.User.by_name(unicode(username))
+ new_password = updated_user.password
+
+ # Ensure password has not changed
+ assert old_password == new_password
+
def test_user_edit_no_user(self):
offset = url_for(controller='user', action='edit', id=None)
res = self.app.get(offset, status=400)
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list