diff --git a/ckan/config/environment.py b/ckan/config/environment.py index 173d838a62e..b4c79d9b8ca 100644 --- a/ckan/config/environment.py +++ b/ckan/config/environment.py @@ -113,9 +113,6 @@ def template_loaded(template): logging.getLogger("MARKDOWN").setLevel(logging.getLogger().level) # Create the Genshi TemplateLoader - # config['pylons.app_globals'].genshi_loader = TemplateLoader( - # paths['templates'], auto_reload=True) - # tmpl_options["genshi.loader_callback"] = template_loaded config['pylons.app_globals'].genshi_loader = TemplateLoader( template_paths, auto_reload=True, callback=template_loaded) @@ -126,6 +123,7 @@ def template_loaded(template): # Suppress a couple of sqlalchemy warnings warnings.filterwarnings('ignore', '^Unicode type received non-unicode bind param value', sqlalchemy.exc.SAWarning) warnings.filterwarnings('ignore', "^Did not recognize type 'BIGINT' of column 'size'", sqlalchemy.exc.SAWarning) + warnings.filterwarnings('ignore', "^Did not recognize type 'tsvector' of column 'search_vector'", sqlalchemy.exc.SAWarning) engine = sqlalchemy.engine_from_config(config, 'sqlalchemy.') diff --git a/ckan/config/routing.py b/ckan/config/routing.py index 96cd2071ef3..149c01bd2a7 100644 --- a/ckan/config/routing.py +++ b/ckan/config/routing.py @@ -184,6 +184,7 @@ def make_map(): 'history_ajax', ])) ) + m.connect('/dataset/{id}.{format}', action='read') m.connect('/dataset/{id}', action='read') m.connect('/dataset/{id}/resource/{resource_id}', action='resource_read') diff --git a/ckan/controllers/package.py b/ckan/controllers/package.py index 338814e51d9..a88d3510c7d 100644 --- a/ckan/controllers/package.py +++ b/ckan/controllers/package.py @@ -210,22 +210,15 @@ def _content_type_for_format(self, fmt): return None, "html", (types["html"][1]) - def read(self, id): - # Check if the request was for a different format than html, we have to do - # it this way because if we instead rely on _content_type_for_format failing - # for revisions (with . in the name) then we will have lost the ID by virtue - # of the routing splitting it up. - format = 'html' - if '.' in id: - pos = id.index('.') - format = id[pos+1:] - id = id[:pos] - + def read(self, id, format='html'): + # Check we know the content type, if not then it is likely a revision + # and therefore we should merge the format onto the end of id ctype,extension,loader = self._content_type_for_format(format) if not ctype: # Reconstitute the ID if we don't know what content type to use ctype = "text/html; charset=utf-8" id = "%s.%s" % (id, format) + format = 'html' response.headers['Content-Type'] = ctype package_type = self._get_package_type(id.split('@')[0]) @@ -234,7 +227,6 @@ def read(self, id): 'for_view': True} data_dict = {'id': id} - # interpret @ or @ suffix split = id.split('@') if len(split) == 2: @@ -286,7 +278,11 @@ def read(self, id): PackageSaver().render_package(c.pkg_dict, context) - return render( self._read_template( package_type ) ) + template = self._read_template( package_type ) + template = template[:template.index('.')+1] + format + + return render( template, loader_class=loader) + def comments(self, id): package_type = self._get_package_type(id) @@ -307,7 +303,7 @@ def comments(self, id): #render the package PackageSaver().render_package(c.pkg_dict) - return render('package/comments.html') + return render( self._comments_template( package_type ) ) def history(self, id): diff --git a/ckan/migration/versions/027_adjust_harvester.py b/ckan/migration/versions/027_adjust_harvester.py index 9f067733a0a..e902cd3d1a8 100644 --- a/ckan/migration/versions/027_adjust_harvester.py +++ b/ckan/migration/versions/027_adjust_harvester.py @@ -12,11 +12,11 @@ def upgrade(migrate_engine): harvested_document_table = Table('harvested_document', metadata, Column('url', UnicodeText, nullable=False), - Column('guid', UnicodeText, default=''), + Column('guid', UnicodeText, default=u''), Column('source_id', UnicodeText, ForeignKey('harvest_source.id')), Column('package_id', UnicodeText, ForeignKey('package.id')), ) - + harvested_document_table.c.url.drop() harvested_document_table.c.guid.create(harvested_document_table) harvested_document_table.c.source_id.create(harvested_document_table) diff --git a/ckan/tests/functional/test_package.py b/ckan/tests/functional/test_package.py index 218350b78cb..d03979b3942 100644 --- a/ckan/tests/functional/test_package.py +++ b/ckan/tests/functional/test_package.py @@ -309,8 +309,7 @@ def test_read_war_rdf(self): name = u'warandpeace' offset = url_for(controller='package', action='read', id=name + ".rdf") res = self.app.get(offset) - ##TODO Ross To Fix - #assert 'A Wonderful Story' in res, res + assert 'A Wonderful Story' in res, res def test_read_war(self):