当前位置: 首页>>代码示例>>Python>>正文


Python Event.get方法代码示例

本文整理汇总了Python中models.Event.get方法的典型用法代码示例。如果您正苦于以下问题:Python Event.get方法的具体用法?Python Event.get怎么用?Python Event.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Event的用法示例。


在下文中一共展示了Event.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
 def get(self, event_id):
     logging.info('Get event with %s id' % event_id)
     logging.info(EventModel.objects)
     event = EventModel.get(event_id)
     if not event:
         abort(400)
     return event.to_json()
开发者ID:MichalJagiello,项目名称:android_todo_backend,代码行数:9,代码来源:views.py

示例2: delete

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
    def delete(self, version, service_slug, sid):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        service = Service.get_by_slug(service_slug)

        if not service:
            self.error(404, "Service %s not found" % service_slug)
            return

 
        try:
            event = Event.get(db.Key(sid))
        except datastore_errors.BadKeyError:
            self.error(404, "Event %s not found" % sid)
            return

        if not event or service.key() != event.service.key():
            self.error(404, "No event for Service %s with sid = %s" \
                           % (service_slug, sid))
            return

        event.delete()
        invalidate_cache()

        # Why not JSON?
        self.success(event.rest(self.base_url(version)))
开发者ID:Tradeshift,项目名称:stashboard,代码行数:30,代码来源:api.py

示例3: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
 def get(self, eventkey):
     event = Event.get(eventkey)
     if event is not None:
         showings = db.Query(Showing).ancestor(event).filter("start >=", date.today()).order("start")   # TODO - cache this
         path = os.path.join(os.path.dirname(__file__), 'templates', 'event.html')
         self.response.out.write(template.render(path, {"event": event, "showings": showings,}))
     else:
         self.error(404)
开发者ID:benburry,项目名称:bfical,代码行数:10,代码来源:main.py

示例4: get_user_event

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
def get_user_event(user_id, event_id):
    """Return heart rate data for user during event

    Fields:
    time (list)
    heartrate (list)
    """
    time, heartrate = get_user_event_data(User.get(id=user_id), Event.get(id=event_id))
    return json.jsonify(time=time, heartrate=heartrate)
开发者ID:kevinyu,项目名称:bearded-octo-robot,代码行数:11,代码来源:api.py

示例5: post

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
    def post(self):
        org = self.request.get("organization")
        eventname = self.request.get("event")
        date_str = self.request.get("datetime")
        datetime = datetimefuncs.datetime.strptime(date_str, dtformat)

        key_name = ".".join([org, eventname, date_str])
        key = db.Key.from_path("Event", key_name)

        action = self.request.get("action")
        event = Event.get(key)
        if action == "create":
            newpassword = hashlib.sha256(self.request.get("newpassword")).hexdigest()

            if event is None:
                event = Event(key=key, name=eventname, organization=org, datetime=datetime, password=newpassword)
                event.put()

                path = "../static/html/signin.html"
                template_values = {"organization": org, "event": eventname, "datetime": date_str}
                self.response.out.write(template.render(path, template_values, True))
            else:
                self.response.out.write("Event already exist. \nDid you mean to login to the event?")
        elif action == "login":
            password = hashlib.sha256(self.request.get("password")).hexdigest()

            if event is None:  # Event does not exist
                header = (
                    "Event does not exist. \nDid you mean to create it?"
                    + " Did you type in all the information correctly:\n"
                )
                eventinfo = "\nOrganization: %s \nEvent: %s \nDate/Time: %s" % (org, eventname, date_str)

                self.response.headers.add_header("Content-Type", "text/plain")
                self.response.out.write(header + eventinfo)
            elif password == event.password:  # Event exist; correct password
                path = "../static/html/signin.html"
                template_values = {
                    "organization": org,
                    "event": eventname,
                    "datetime": date_str,
                    "users": event.user_set,
                }
                self.response.out.write(template.render(path, template_values, True))
            else:  # Event exist; wrong password
                self.response.out.write("Bad Event/Password Combination.")

        else:  # action malformed, show error
            self.response.out.write("Server Error. Please try again. (Invalid " + 'value for "action": %s' % action)
开发者ID:andrewiggins,项目名称:EventSignIn,代码行数:51,代码来源:signin.py

示例6: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
 def get(self, event_key):
   """collect new purchase of event whose key is `event_key'
   """
   event = Event.get(event_key)
   if not event:
     self.error(404)
   self.generate('put_order.html',
                 {'vendor':event.vendor,
                  'purchases':event.purchases})
开发者ID:tchaikov,项目名称:beanfs,代码行数:11,代码来源:order.py

示例7: get_latest_event_id

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
def get_latest_event_id():
    """
    Get the latest event id.

    :returns: The ID of latest event.
    :rtype: Integer

    """
    event = Event.get('last')
    return event.id
开发者ID:diwa-aalto,项目名称:diwacs,代码行数:12,代码来源:session.py

示例8: put

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
 def put(self, event_id):
     logging.info('Update an event with %s id' % event_id)
     if not request.form or \
        not request.form.get('title') or \
        not request.form.get('time'):
         logging.error("Invalid data parameters")
         abort(400)
     event = EventModel.get(event_id)
     if not event:
         abort(400)
     event['title'] = request.form.get('title')
     event['time'] = datetime.fromtimestamp(int(request.form.get('time')))
     event['description'] = request.form.get('description')
     event.save()
     return event.to_json()
开发者ID:MichalJagiello,项目名称:android_todo_backend,代码行数:17,代码来源:views.py

示例9: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
    def get(self, version, service_slug, sid):
        logging.debug("EventInstanceHandler#get sid=%s" % sid)
        
        if (self.valid_version(version)):
            service = Service.get_by_slug(service_slug)

            if (service):
                event = Event.get(db.Key(sid))
                if (event and service.key() == event.service.key()):
                    self.json(event.rest(self.base_url(version))) 
                else:
                    self.error(404, "No event for Service %s with sid = %s" % (service_slug,sid))
            else:
                self.error(404, "Service %s not found" % service_slug)
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:samn,项目名称:stashboard,代码行数:18,代码来源:api.py

示例10: provide_list

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
    def provide_list(cls, model):
        assert model == cls.model

        relatives_of_id = request.values.get('relatives_of')
        by_event_id = request.values.get('by_event')
        by_namegroup = request.values.get('by_namegroup')

        if relatives_of_id:
            central_person = model.get(relatives_of_id)
            return central_person.related_people
        elif by_event_id:
            event = Event.get(by_event_id)
            return model.references_to(event)
        elif by_namegroup:
            xs = super().provide_list(model)
            return (p for p in xs if p.group_name == by_namegroup)
        else:
            return super().provide_list(model)
开发者ID:daleathan,项目名称:wtfamily,代码行数:20,代码来源:restful.py

示例11: get

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
 def get(self):
     org = self.request.get('organization')
     eventname = self.request.get('event')
     datetime = self.request.get('datetime')
     key_name = '.'.join([org, eventname, datetime])
     key = db.Key.from_path('Event', key_name)
     
     event = Event.get(key)
     users = event.user_set
     
     output = StringIO.StringIO()
     output.write('%s,%s,%s\n' % (org, eventname, datetime))
     output.write('%s, %s, %s\n' % ('Name', 'Email', 'Signin Time'))
     for user in users:
         output.write("%s, %s, %s\n" % (user.name, user.email, user.signin_time))
     
     filename = "%s - %s SignIn.csv" % (org.title(), eventname.title())
     self.response.headers['Content-Type'] = 'text/csv'
     self.response.headers['Content-Disposition'] = 'attachment; filename="%s"' % filename
     
     self.response.out.write(output.getvalue())
开发者ID:andrewiggins,项目名称:EventSignIn,代码行数:23,代码来源:download.py

示例12: event_detail

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
def event_detail(obj_id):
    obj = Event.get(obj_id)
    if not obj:
        abort(404)
    return render_template('event_detail.html', obj=obj)
开发者ID:daleathan,项目名称:wtfamily,代码行数:7,代码来源:web.py

示例13: plot_user_event

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
def plot_user_event(user_id, event_id):
    from things import get_user_event_data
    t, h = get_user_event_data(User.get(id=user_id), Event.get(id=event_id))
    plt.plot(map(lambda x: x / 3600.0, t), h)
    plt.show()
    return
开发者ID:kevinyu,项目名称:bearded-octo-robot,代码行数:8,代码来源:visualize.py

示例14: get_event

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
def get_event(event_id):
    """Return a specific event
    """
    return json.jsonify(**Event.get(id=event_id).serialized())
开发者ID:kevinyu,项目名称:bearded-octo-robot,代码行数:6,代码来源:api.py

示例15: event_with_id

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get [as 别名]
 def event_with_id(self, event_id):
     return Event.get(Event.id == event_id)
开发者ID:dmwesterhoff,项目名称:givingtree-api,代码行数:4,代码来源:eventrequests.py


注:本文中的models.Event.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。