def contribution_detail_html(context=None, request=None, **kw): if context.id == 's4': raise HTTPFound(request.route_url('genealogy')) c = context.description if '<body>' in c: c = c.split('<body>')[1].split('</body>')[0] adapter = get_adapter(IRepresentation, Feature(), request, ext='snippet.html') fids = [ m.group('fid') for m in re.finditer('__values_(?P<fid>[0-9A-Z]+)__', c) ] for feature in DBSession.query(Feature)\ .filter(Feature.id.in_(fids))\ .options(joinedload(Feature.domain)): counts = DBSession.query(Value.domainelement_pk, func.count(Value.pk))\ .filter(Value.domainelement_pk.in_([de.pk for de in feature.domain]))\ .group_by(Value.domainelement_pk) feature.counts = dict(counts) table = soup(adapter.render(feature, request)) values = '\n'.join('%s' % table.find(tag).extract() for tag in ['thead', 'tbody']) c = c.replace('__values_%s__' % feature.id, values) return {'text': c.replace('http://wals.info', request.application_url)}
def info(request): feature = Feature.get(request.matchdict['id']) return { 'name': feature.name, 'values': [{'name': d.name, 'number': i + 1} for i, d in enumerate(feature.domain)], }
def info(request): feature = Feature.get(request.matchdict['id']) return { 'name': feature.name, 'values': [{ 'name': d.name, 'number': i + 1 } for i, d in enumerate(feature.domain)], }
def contribution_detail_html(context=None, request=None, **kw): if context.id == 's4': raise HTTPFound(request.route_url('genealogy')) p = path(wals3.__file__).dirname().joinpath('static', 'descriptions', str(context.id), 'body.xhtml') c = codecs.open(p, encoding='utf8').read() adapter = get_adapter(IRepresentation, Feature(), request, ext='snippet.html') for feature in DBSession.query(Feature)\ .filter(Feature.contribution_pk == context.pk)\ .options(joinedload_all(Feature.domain, DomainElement.values)): table = soup(adapter.render(feature, request)) values = '\n'.join('%s' % table.find(tag).extract() for tag in ['thead', 'tbody']) c = c.replace('__values_%s__' % feature.id, values) return {'text': c.replace('http://wals.info', request.application_url)}