def save_questions(questions): with md.transaction(): for question in questions: md.SOAlertedQuestions.create( url = question["link"], log_date = datetime.date.today() ) log.debug("%d questions saved" % len(questions))
def transaction_create(): form = AddTransactionForm() if form.validate_on_submit(): transaction_db = model.transaction( user_key=auth.current_user_key(), ) transaction_db.put() return flask.redirect(flask.url_for('welcome')) return flask.render_template( 'transaction_create.html', html_class='transaction-create', title='Create Transaction', form=form, )
def collect(): log.debug("Star collecting") for page in range(1,10): log.debug("Page:%d" % page) end = False with md.transaction(): for rest_tag in so_Tags().get_items(pagesize = 100,page = page): log.debug("Tag:%s" % rest_tag) # Do we got to the end if rest_tag["count"] < 10000: log.info("END FOUND:%s" % rest_tag) end = True break md.SOTag.save_log( tag_name = rest_tag["name"], count = rest_tag["count"], log_date = datetime.date.today() ) if end: break log.debug("End collection")
import config import sys import urllib user = session.user() form = session.form() for check in ['Body', 'From', 'To']: if not form.getfirst(check): print "Status: 400 Bad Requeset\nContent-type: text/html\n\nMissing parameter: %s" % check sys.exit() inbox = control.getInbox(form, user, 'From') client = TwilioRestClient(user.twilio_sid, user.twilio_auth_token) with model.transaction(): body = form.getfirst('Body') try: message = client.messages.create( body=body, from_=form.getfirst('From'), to=form.getfirst('To'), status_callback=config.configuration['root-url'] + '/sms.py/outgoing') except twilio.TwilioRestException as e: print "Status: 400 Bad Request\nContent-type: text/html\n\n%s" % str(e) sys.exit() now = timeutil.getTime() try: