[ckan-changes] commit/ckan: 5 new changesets

Bitbucket commits-noreply at bitbucket.org
Wed Jul 6 17:58:54 UTC 2011


5 new changesets in ckan:

http://bitbucket.org/okfn/ckan/changeset/3f0b51409df6/
changeset:   3f0b51409df6
branch:      feature-1141-moderated-edits-ajax
user:        dread
date:        2011-07-04 19:03:58
summary:     [lib]: Fix problem with request.POST being mangled by looking at request.body. This problem was introduced in WebOb 1.0.8 compared with 1.0.
affected #:  1 file (5 bytes)

--- a/ckan/lib/base.py	Mon Jul 04 23:12:48 2011 +0100
+++ b/ckan/lib/base.py	Mon Jul 04 18:03:58 2011 +0100
@@ -146,7 +146,7 @@
         '''
         cls.log.debug('Retrieving request params: %r' % request.params)
         cls.log.debug('Retrieving request POST: %r' % request.POST)
-        cls.log.debug('Retrieving request POST body: %r' % request.body)
+
         if request.POST:
             try:
                 request_data = request.POST.keys() or request.body
@@ -156,6 +156,7 @@
                 raise ValueError, msg
             request_data = request_data[0]
         elif request.body:
+            cls.log.debug('Retrieving request POST body: %r' % request.body)
             try:
                 request_data = request.body
             except Exception, inst:


http://bitbucket.org/okfn/ckan/changeset/e04f90b1523a/
changeset:   e04f90b1523a
branch:      feature-1141-moderated-edits-ajax
user:        dread
date:        2011-07-06 19:43:45
summary:     [model][s]: Changed import of datetime, as per default, for better compatibility with extensions using datetime.
affected #:  6 files (642 bytes)

--- a/ckan/model/authorization_group.py	Mon Jul 04 18:03:58 2011 +0100
+++ b/ckan/model/authorization_group.py	Wed Jul 06 18:43:45 2011 +0100
@@ -8,7 +8,7 @@
 authorization_group_table = Table('authorization_group', metadata,
     Column('id', UnicodeText, primary_key=True, default=make_uuid),
     Column('name', UnicodeText),
-    Column('created', DateTime, default=datetime.now),
+    Column('created', DateTime, default=datetime.datetime.now),
     )
 
 authorization_group_user_table = Table('authorization_group_user', metadata,


--- a/ckan/model/group.py	Mon Jul 04 18:03:58 2011 +0100
+++ b/ckan/model/group.py	Wed Jul 06 18:43:45 2011 +0100
@@ -26,7 +26,7 @@
     Column('name', UnicodeText, nullable=False, unique=True),
     Column('title', UnicodeText),
     Column('description', UnicodeText),
-    Column('created', DateTime, default=datetime.now),
+    Column('created', DateTime, default=datetime.datetime.now),
     )
 
 vdm.sqlalchemy.make_table_stateful(group_table)


--- a/ckan/model/meta.py	Mon Jul 04 18:03:58 2011 +0100
+++ b/ckan/model/meta.py	Wed Jul 06 18:43:45 2011 +0100
@@ -1,4 +1,4 @@
-from datetime import datetime
+import datetime
 """SQLAlchemy Metadata and Session object"""
 from sqlalchemy import MetaData, __version__ as sqav
 from sqlalchemy.orm import scoped_session, sessionmaker
@@ -51,7 +51,7 @@
 
             ## when a normal active transaction happens
             if 'pending' not in obj.state:
-                revision.approved_timestamp = datetime.now()
+                revision.approved_timestamp = datetime.datetime.now()
                 old = session.query(revision_cls).filter_by(
                     current='1',
                     id = obj.id
@@ -61,7 +61,7 @@
                     session.add(old)
 
             q = session.query(revision_cls)
-            q = q.filter_by(expired_timestamp=datetime(9999, 12, 31), id=obj.id)
+            q = q.filter_by(expired_timestamp=datetime.datetime(9999, 12, 31), id=obj.id)
             results = q.all()
 
             for rev_obj in results:


--- a/ckan/model/rating.py	Mon Jul 04 18:03:58 2011 +0100
+++ b/ckan/model/rating.py	Wed Jul 06 18:43:45 2011 +0100
@@ -12,7 +12,7 @@
                      Column('user_ip_address', UnicodeText), # alternative to user_id if not logged in
                      Column('package_id', UnicodeText, ForeignKey('package.id')),
                      Column('rating', Float),
-                     Column('created', DateTime, default=datetime.now),
+                     Column('created', DateTime, default=datetime.datetime.now),
                      )
 
 class Rating(DomainObject):


--- a/ckan/model/user.py	Mon Jul 04 18:03:58 2011 +0100
+++ b/ckan/model/user.py	Wed Jul 06 18:43:45 2011 +0100
@@ -17,7 +17,7 @@
         Column('fullname', UnicodeText),
         Column('email', UnicodeText),
         Column('apikey', UnicodeText, default=make_uuid),
-        Column('created', DateTime, default=datetime.now),
+        Column('created', DateTime, default=datetime.datetime.now),
         Column('about', UnicodeText),
         )
 


--- a/ckan/tests/functional/api/model/test_package.py	Mon Jul 04 18:03:58 2011 +0100
+++ b/ckan/tests/functional/api/model/test_package.py	Wed Jul 06 18:43:45 2011 +0100
@@ -103,6 +103,17 @@
         assert package
         self.assert_equal(package.title, self.package_fixture_data['title'])
         
+    def test_register_post_bad_content_type(self):
+        assert not self.get_package_by_name(self.package_fixture_data['name'])
+        offset = self.package_offset()
+        data = self.dumps(self.package_fixture_data)
+        res = self.post_body(offset, data, content_type='something/unheard_of',
+                             status=self.STATUS_400_BAD_REQUEST,
+                             extra_environ=self.extra_environ)
+        # Check there is no database record.
+        self.remove()
+        package = self.get_package_by_name(self.package_fixture_data['name'])
+        assert not package
 
     def test_register_post_bad_request(self):
         test_params = {


http://bitbucket.org/okfn/ckan/changeset/7ee4ca22e5ae/
changeset:   7ee4ca22e5ae
branch:      feature-1141-moderated-edits-ajax
user:        dread
date:        2011-07-06 19:45:25
summary:     [doc][s]: Added note on alternative buildbot apache config from old eu8.
affected #:  1 file (331 bytes)

--- a/doc/buildbot.rst	Wed Jul 06 18:43:45 2011 +0100
+++ b/doc/buildbot.rst	Wed Jul 06 18:45:25 2011 +0100
@@ -144,6 +144,20 @@
        ProxyPreserveHost On
   </VirtualHost>
 
+or the old one had::
+
+  <VirtualHost *:80>
+      ServerAdmin sysadmin at okfn.org
+      ServerName buildbot.okfn.org
+      DocumentRoot /var/www/
+      <Location />
+          Order allow,deny
+          allow from all
+      </Location>
+      RewriteEngine On   
+      RewriteRule /(.*) http://localhost:8010/$1 [P,L]
+  </VirtualHost>
+
 Then::
 
   sudo apt-get install libapache2-mod-proxy-html


http://bitbucket.org/okfn/ckan/changeset/8f6ba8ef63f3/
changeset:   8f6ba8ef63f3
branch:      feature-1141-moderated-edits-ajax
user:        dread
date:        2011-07-06 19:48:53
summary:     [lib/base]: #1210 Fix application/json errors associated with newer WebOb.
affected #:  2 files (655 bytes)

--- a/ckan/lib/base.py	Wed Jul 06 18:45:25 2011 +0100
+++ b/ckan/lib/base.py	Wed Jul 06 18:48:53 2011 +0100
@@ -146,22 +146,25 @@
         '''
         cls.log.debug('Retrieving request params: %r' % request.params)
         cls.log.debug('Retrieving request POST: %r' % request.POST)
-
+        request_data = None
         if request.POST:
             try:
-                request_data = request.POST.keys() or request.body
+                request_data = request.POST.keys()
             except Exception, inst:
                 msg = _("Could not find the POST data: %r : %s") % \
                       (request.POST, inst)
                 raise ValueError, msg
             request_data = request_data[0]
-        elif request.body:
-            cls.log.debug('Retrieving request POST body: %r' % request.body)
+        else:
             try:
                 request_data = request.body
             except Exception, inst:
-                msg = _("Could not find the POST data: %r : %s") % \
-                      (request.POST, inst)
+                msg = _("Could not extract request body data: %s") % \
+                      (inst)
+                raise ValueError, msg
+            cls.log.debug('Retrieved request body: %r' % request.body)
+            if not request_data:
+                msg = _("No request body data")
                 raise ValueError, msg
         if request_data:
             request_data = json.loads(request_data, encoding='utf8')


--- a/ckan/tests/functional/api/base.py	Wed Jul 06 18:45:25 2011 +0100
+++ b/ckan/tests/functional/api/base.py	Wed Jul 06 18:48:53 2011 +0100
@@ -312,9 +312,21 @@
         application/x-www-form-urlencoded)
 
         '''
+        return self.post_body(offset, data, content_type='application/json',
+                              content_length=len(data),
+                              status=status, extra_environ=extra_environ)
+
+    def post_body(self, offset, data, content_type, content_length=None,
+                  status=None, extra_environ=None):
+        ''' Posts data in the body in a user-specified format.
+        (rather than Paste Fixture\'s default Content-Type of
+        application/x-www-form-urlencoded)
+
+        '''
         environ = self.app._make_environ()
-        environ['CONTENT_TYPE'] = 'application/json'
-        environ['CONTENT_LENGTH'] = str(len(data))
+        environ['CONTENT_TYPE'] = content_type
+        if content_length is not None:
+            environ['CONTENT_LENGTH'] = str(content_length)
         environ['REQUEST_METHOD'] = 'POST'
         environ['wsgi.input'] = StringIO(data)
         if extra_environ:


http://bitbucket.org/okfn/ckan/changeset/c3c2b910a05f/
changeset:   c3c2b910a05f
user:        dread
date:        2011-07-05 18:16:08
summary:     [cli][s]: Syntax for user list and sysadmin list are now similar. Add password to sysadmin creation.
affected #:  1 file (194 bytes)

--- a/ckan/lib/cli.py	Wed Jul 06 17:21:44 2011 +0100
+++ b/ckan/lib/cli.py	Tue Jul 05 17:16:08 2011 +0100
@@ -298,7 +298,8 @@
     '''Gives sysadmin rights to a named user
 
     Usage:
-      sysadmin list (default)       - lists sysadmins
+      sysadmin                      - lists sysadmins
+      sysadmin list                 - lists sysadmins
       sysadmin add <user-name>      - add a user as a sysadmin
       sysadmin remove <user-name>   - removes user from sysadmins
     '''
@@ -347,8 +348,10 @@
             print 'User "%s" not found' % username
             makeuser = raw_input('Create new user: %s? [y/n]' % username)
             if makeuser == 'y':
+                password = UserCmd.password_prompt()
                 print('Creating %s user' % username)
-                user = model.User(name=unicode(username))
+                user = model.User(name=unicode(username),
+                                  password=password)
             else:
                 print 'Exiting ...'
                 return
@@ -377,6 +380,7 @@
 
     Usage:
       user                            - lists users
+      user list                       - lists users
       user <user-name>                - shows user properties
       user add <user-name> [<apikey>] - add a user (prompts for password)
       user setpass <user-name>        - set user password (prompts)
@@ -404,6 +408,8 @@
                 self.search()
             elif cmd == 'setpass':
                 self.setpass()
+            elif cmd == 'list':
+                self.list()
             else:
                 self.show()
 
@@ -416,7 +422,8 @@
     def list(self):
         from ckan import model
         print 'Users:'
-        users = model.Session.query(model.User).all()
+        users = model.Session.query(model.User)
+        print 'count = %i' % users.count()        
         for user in users:
             print self.get_user_str(user)
 
@@ -429,7 +436,6 @@
 
     def setpass(self):
         from ckan import model
-        import getpass
         
         if len(self.args) < 2:
             print 'Need name of the user.'
@@ -438,14 +444,8 @@
         user = model.User.get(username)
         print('Editing user: %r' % user.name)
 
-        password1 = None
-        while not password1:
-            password1 = getpass.getpass('Password: ')
-        password2 = getpass.getpass('Confirm password: ')
-        if password1 != password2:
-            print 'Passwords do not match'
-            sys.exit(1)
-        user.password = password1
+        password = self.password_prompt()
+        user.password = password
         model.repo.commit_and_remove()
         print 'Done'
 
@@ -462,22 +462,9 @@
         for user in query.all():
             print self.get_user_str(user)
 
-    def add(self):
-        from ckan import model
+    @classmethod
+    def password_prompt(cls):
         import getpass
-        
-        if len(self.args) < 2:
-            print 'Need name of the user.'
-            return
-        username = self.args[1]
-        apikey = self.args[2] if len(self.args) > 2 else None
-
-        user = model.User.by_name(unicode(username))
-        if user:
-            print 'User "%s" already found' % username
-            sys.exit(1)
-        
-        print('Creating user: %r' % username)
         password1 = None
         while not password1:
             password1 = getpass.getpass('Password: ')
@@ -485,8 +472,27 @@
         if password1 != password2:
             print 'Passwords do not match'
             sys.exit(1)
+        return password1
+
+    def add(self):
+        from ckan import model
+        
+        if len(self.args) < 2:
+            print 'Need name of the user.'
+            return
+        username = self.args[1]
+        apikey = self.args[2] if len(self.args) > 2 else None
+        password = self.password_prompt()
+        user = model.User.by_name(unicode(username))
+        if user:
+            print 'User "%s" already found' % username
+            sys.exit(1)
+        
+        print('Creating user: %r' % username)
+
+        
         user_params = {'name': unicode(username),
-                   'password': password1}
+                       'password': password}
         if apikey:
             user_params['apikey'] = unicode(apikey)
         user = model.User(**user_params)

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