Skip to content

Commit

Permalink
Merge branch 'master' of github.com:okfn/ckan
Browse files Browse the repository at this point in the history
  • Loading branch information
rufuspollock committed Mar 16, 2012
2 parents 86d2bc5 + 5681ea8 commit e114345
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
4 changes: 1 addition & 3 deletions ckan/config/environment.py
Expand Up @@ -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)

Expand All @@ -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.')

Expand Down
1 change: 1 addition & 0 deletions ckan/config/routing.py
Expand Up @@ -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')

Expand Down
24 changes: 10 additions & 14 deletions ckan/controllers/package.py
Expand Up @@ -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])
Expand All @@ -234,7 +227,6 @@ def read(self, id):
'for_view': True}
data_dict = {'id': id}


# interpret @<revision_id> or @<date> suffix
split = id.split('@')
if len(split) == 2:
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions ckan/migration/versions/027_adjust_harvester.py
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions ckan/tests/functional/test_package.py
Expand Up @@ -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 '<dct:title>A Wonderful Story</dct:title>' in res, res
assert '<dct:title>A Wonderful Story</dct:title>' in res, res


def test_read_war(self):
Expand Down

0 comments on commit e114345

Please sign in to comment.