コード例 #1
0
def handle_unsubscribe_request(sub_req) :
    try:
        email = get_email(subscriber)
    except invalidEmailSpecified:
        raise

    try :
        subscriber_db = Subscriber.objects.get(email=email)
    except :
        print "Exception getting obj from db for subscriber: " + email
    else :
        print "unsubscribing : " + email

    # now let's go through the highways for subscriber
    try :
        hwy_sub = HighwaySubscriptions.objects.get(highway=highway,start_time=email_delivery_time)
    except HighwaySubscriptions.DoesNotExist:
        # we don't have an entry in db, let's add one
        hwy_sub = HighwaySubscriptions(highway=highway,
                                       start_time=email_delivery_time)
        hwy_sub.save()
    except:
        print "Exception getting obj from db for hwy: " + highway
    else:
        print "Added obj db for hwy: " + highway
コード例 #2
0
def handle_unsubscribe_request(sub_req):
    try:
        email = get_email(subscriber)
    except invalidEmailSpecified:
        raise

    try:
        subscriber_db = Subscriber.objects.get(email=email)
    except:
        print "Exception getting obj from db for subscriber: " + email
    else:
        print "unsubscribing : " + email

    # now let's go through the highways for subscriber
    try:
        hwy_sub = HighwaySubscriptions.objects.get(
            highway=highway, start_time=email_delivery_time)
    except HighwaySubscriptions.DoesNotExist:
        # we don't have an entry in db, let's add one
        hwy_sub = HighwaySubscriptions(highway=highway,
                                       start_time=email_delivery_time)
        hwy_sub.save()
    except:
        print "Exception getting obj from db for hwy: " + highway
    else:
        print "Added obj db for hwy: " + highway
コード例 #3
0
def add_highway_subscription(highway,subscriber,location) :
    """
    {u'subscriber': [{u'name': u'subscriber_email', u'value': u'*****@*****.**'},
                     {u'name': u'email_delivery_time', u'value': ''}],
    """
    try:
        email = get_email(subscriber)
    except invalidEmailSpecified:
        raise

    try :
        subscriber_db = Subscriber.objects.get(email=email)
    except Subscriber.DoesNotExist:
        # a new subscriber
        subscriber_db = Subscriber(email=email)
        subscriber_db.save()
    except :
        print "Exception getting obj from db for subscriber: " + email
    else :
        print "Got/create db object for: " + email

    email_delivery_time = get_delivery_time(subscriber)
    # now let's go through the highways
    try :
        hwy_sub = HighwaySubscriptions.objects.get(highway=highway,
                    start_time=email_delivery_time)
    except HighwaySubscriptions.DoesNotExist:
        # we don't have an entry in db, let's add one
        hwy_sub = HighwaySubscriptions(highway=highway,
                                       start_time=email_delivery_time)
        hwy_sub.save()
    except:
        print "Exception getting obj from db for hwy: " + highway
    else:
        print "Added obj db for hwy: " + highway

    hwy_sub.subscribers.add(subscriber_db)
    task_id = add_traffic_task(highway,email,email_delivery_time,location)
コード例 #4
0
def add_highway_subscription(highway, subscriber, location):
    """
    {u'subscriber': [{u'name': u'subscriber_email', u'value': u'*****@*****.**'},
                     {u'name': u'email_delivery_time', u'value': ''}],
    """
    try:
        email = get_email(subscriber)
    except invalidEmailSpecified:
        raise

    try:
        subscriber_db = Subscriber.objects.get(email=email)
    except Subscriber.DoesNotExist:
        # a new subscriber
        subscriber_db = Subscriber(email=email)
        subscriber_db.save()
    except:
        print "Exception getting obj from db for subscriber: " + email
    else:
        print "Got/create db object for: " + email

    email_delivery_time = get_delivery_time(subscriber)
    # now let's go through the highways
    try:
        hwy_sub = HighwaySubscriptions.objects.get(
            highway=highway, start_time=email_delivery_time)
    except HighwaySubscriptions.DoesNotExist:
        # we don't have an entry in db, let's add one
        hwy_sub = HighwaySubscriptions(highway=highway,
                                       start_time=email_delivery_time)
        hwy_sub.save()
    except:
        print "Exception getting obj from db for hwy: " + highway
    else:
        print "Added obj db for hwy: " + highway

    hwy_sub.subscribers.add(subscriber_db)
    task_id = add_traffic_task(highway, email, email_delivery_time, location)