Ejemplo n.º 1
0
def index(req, **params):

    DBMgr.getInstance().startRequest()
    Factory.getDALManager().connect()

    ################### checking protection ###################

    # check if it is a machine that belongs to the CERN domain
    cernDomain = DomainHolder().getById(0) # id 0 means CERN
    if not cernDomain.belongsTo(get_remote_ip(req)):
        return "Only CERN users can access to this export resource"

    ################### checking params ###################
    if not (params.has_key("sd") and params.has_key("ed") and params.has_key("r")):
        return """Missing parameters. The request should be like this: http://indico.cern.ch/exportReservations.py?sd=2010-09-24&ed=2010-09-25&r=1,18,114,42"""

    try:
        sd = parseDate(params.get("sd"), "%Y-%m-%d")
        ed = parseDate(params.get("ed"), "%Y-%m-%d")
    except ValueError, e:
        return """The format for the dates (sd and ed) must be like this: YYYY-MM-DD"""
Ejemplo n.º 2
0
def index(req, **params):

    DBMgr.getInstance().startRequest()
    Factory.getDALManager().connect()

    ################### checking protection ###################

    # check if it is a machine that belongs to the CERN domain
    cernDomain = DomainHolder().getById(0)  # id 0 means CERN
    if not cernDomain.belongsTo(_get_remote_ip(req)):
        return "Only CERN users can access to this export resource"

    ################### checking params ###################
    if not (params.has_key("sd") and params.has_key("ed")
            and params.has_key("r")):
        return """Missing parameters. The request should be like this: http://indico.cern.ch/exportReservations.py?sd=2010-09-24&ed=2010-09-25&r=1,18,114,42"""

    try:
        sd = parseDate(params.get("sd"), "%Y-%m-%d")
        ed = parseDate(params.get("ed"), "%Y-%m-%d")
    except ValueError, e:
        return """The format for the dates (sd and ed) must be like this: YYYY-MM-DD"""
Ejemplo n.º 3
0
        except socket.gaierror, e:
            # in case host resolution fails
            raise HostnameResolveError("Error resolving host '%s' : %s" % (host, e))


    # check if it is a machine that belongs to the CERN domain
    cernDomain = DomainHolder().getById(0) # id 0 means CERN
    if not cernDomain.belongsTo(getHostIP(req)):
        return "Only CERN users can access to this export resource"

    ################### checking params ###################
    if not (params.has_key("sd") and params.has_key("ed") and params.has_key("r")):
        return """Missing parameters. The request should be like this: http://indico.cern.ch/exportReservations.py?sd=2010-09-24&ed=2010-09-25&r=1,18,114,42"""

    try:
        sd = parseDate(params.get("sd"), "%Y-%m-%d")
        ed = parseDate(params.get("ed"), "%Y-%m-%d")
    except ValueError, e:
        return """The format for the dates (sd and ed) must be like this: YYYY-MM-DD"""
    if sd > ed:
        return """'sd' must be <= than 'ed'"""
    if ed - sd > timedelta(35):
        return """One can only export 3 days at most"""


    roomIDs = params.get("r").strip().split(",")
    if roomIDs == "":
        return """At least one roomID must be specified (http://....?r=1,42,14,...)"""
    try:
        roomIDs = map(lambda x: int(x), roomIDs)
    except ValueError: