Commit 20681cf9 authored by Arthur Lutz's avatar Arthur Lutz
Browse files

resolve eid in a more appropriate/generic way

parent 5725545efb43
......@@ -22,6 +22,9 @@ from import previous_month, first_day, date_range, last_day
from logilab.common.shellutils import ProgressBar
from cubicweb.req import FindEntityError
from cubicweb.web import NotFound
from psycopg2 import DataError
# commented sections are not usefull to view
......@@ -135,25 +138,22 @@ def extract_stats_dict(filepath):
section_name = None
return stats_dict
def eid_from_url(session, value):
def eid_from_url(req, value):
''' return an eid from an url '''
# FIXME - should use url_resolver for a more serious guess
# FIXME - BNF specific right now
#url_resolver = session.vreg['components'].select('urlpublisher',
# vreg=session.vreg)
#req = session
#req.form = {}
#pmid, rset = url_resolver.process(session, value)
#print value, pmid, rset
for pattern in ['/(\d+)/(.*?)/',
match =, value)
if match and
return int(
url_resolver = req.vreg['components'].select('urlpublisher',
req.url = lambda includeparams: value
req.relative_path = lambda includeparams: value[1:]
pmid, rset = url_resolver.process(req, value)
if rset and len(rset) == 1:
return rset[0][0]
elif req.form.get('rql'):
rset = req.execute(req.form.get('rql'))
if rset and len(rset) == 1:
return rset[0][0]
except (NotFound, DataError):
def get_or_create_statperiod(session, start, stop, stats_report={}):
rql = 'Any P WHERE P is StatPeriod, P start "%(start_date)s", P stop "%(end_date)s"'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment