Exemplo n.º 1
0
def start(info):
    """ Starts a session. Remember not to redirect after this. """
    session_id = _new_session_id()
    session_key = SESSION_DIR + session_id
    info = Storage(info)
    info.id = session_id
    info.added =  time.time()
    info.referer = web.ctx.environ.get("HTTP_REFERER", "")
    info.entry = request_uri()
    file_storage.setItem(session_key, info)
    web.setcookie(COOKIE_NAME, session_id)
    web.ctx.current_session_id = session_id
    # !!!TODO: session own log? (take care of UM instances with shared fsstorage)
    return info
Exemplo n.º 2
0
def start(info):
    """ Starts a session. Remember not to redirect after this. """
    session_id = _new_session_id()
    session_key = SESSION_DIR + session_id
    info = Storage(info)
    info.id = session_id
    info.added = time.time()
    info.referer = web.ctx.environ.get("HTTP_REFERER", "")
    info.entry = request_uri()
    file_storage.setItem(session_key, info)
    web.setcookie(COOKIE_NAME, session_id)
    web.ctx.current_session_id = session_id
    # !!!TODO: session own log? (take care of UM instances with shared fsstorage)
    return info
Exemplo n.º 3
0
def point_from_message(rfcmessage):
    msg = getAttachements(rfcmessage)
    sender = msg.sender[0][1]  #!!!
    point = Storage(
        _recepients=msg.recepients,
        author=sender,
        author_name=msg.sender[0][0],
        id=msg.message_id,
        uuid="mail " + msg.message_id,
    )
    attachments = []
    lmxpoints = []
    for ct, name, payload in msg.container:
        if "nokia.landmark" in ct or "text/xml" in ct:
            try:
                lmxfile = StringIO.StringIO(payload)
                lmxpoints = lmx_parser.parse_lmx(lmxfile)
            except:
                continue
        else:
            attachment = Storage(
                content=payload,
                content_type=ct,
                filename=name,
                author=sender,
            )
            attachments.append(attachment)

    try:
        point.update(lmxpoints[0])
    except:
        point.lat = point.lon = 0.0  # !!! not a point?
    point.attachments = attachments
    point.added = util.now()  #!!!?

    if msg.subject.strip():
        point.title = msg.subject
    # else title comes from landmark's name
    return point
Exemplo n.º 4
0
def point_from_message(rfcmessage):
    msg = getAttachements(rfcmessage)
    sender = msg.sender[0][1]   #!!!
    point = Storage(_recepients=msg.recepients,
                    author=sender,
                    author_name=msg.sender[0][0],
                    id=msg.message_id,
                    uuid="mail " + msg.message_id,
                    )
    attachments = []
    lmxpoints = []
    for ct, name, payload in msg.container:
        if "nokia.landmark" in ct or "text/xml" in ct:
            try:
                lmxfile = StringIO.StringIO(payload)
                lmxpoints = lmx_parser.parse_lmx(lmxfile)
            except:
                continue
        else:
            attachment = Storage(
                content=payload,
                content_type=ct,
                filename=name,
                author=sender,
            )
            attachments.append(attachment)

    try:
        point.update(lmxpoints[0])
    except:
        point.lat = point.lon = 0.0   # !!! not a point?
    point.attachments = attachments
    point.added = util.now()   #!!!?

    if msg.subject.strip():
        point.title = msg.subject
    # else title comes from landmark's name
    return point