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


Python Service.put方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
    def post(self, version):
        logging.debug("ServicesListHandler#post")

        if (self.valid_version(version)):
            
            name = self.request.get('name', default_value=None)
            description = self.request.get('description', default_value=None)
            region = self.request.get('region', default_value=None)
            
            if name and description and region:
                slug = Service.slugify(name, region)
                existing_s = Service.get_by_slug(slug)

                # Update existing resource
                if existing_s:
                    existing_s.description = description
                    if region:
                        existing_s.region = Region.get_by_name(region)
                        existing_s.slug = Service.slugify(name, region)
                    existing_s.put()
                    self.json(existing_s.rest(self.base_url(version)))
                # Create new service
                else:
                    region = Region.get_by_name(region)
                    s = Service(name=name, slug=slug, description=description, region=region)
                    s.put()
                    self.json(s.rest(self.base_url(version)))
            else:
                self.error(400, "Bad Data: Name: %s, Description: %s, Region: %s" % (name, description, region))
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:samn,项目名称:stashboard,代码行数:33,代码来源:api.py

示例2: post

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

        name = self.request.get('name', default_value=None)
        description = self.request.get('description', default_value=None)

        if not name or not description:
            self.error(400, "Bad Data: Name: %s, Description: %s" \
                           % (name, description))
            return

        slug = slugify.slugify(name)
        existing_s = Service.get_by_slug(slug)

        if existing_s:
            self.error(404, "A sevice with this name already exists")
            return

        s = Service(name=name, slug=slug, description=description)
        s.put()

        invalidate_cache()

        self.response.set_status(201)
        self.json(s.rest(self.base_url(version)))
开发者ID:BillTheBest,项目名称:stashboard,代码行数:29,代码来源:api.py

示例3: tnx

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
 def tnx(service_data, country_data, user):
     service = Service(key_name = u"<%s>" % service_data["id"])
     service.id = service_data["id"]
     service.user = user
     service.countries = json.dumps(country_data)
     service.put()
     pointer_to_service["service"] = service
开发者ID:andris9,项目名称:VoteSMS,代码行数:9,代码来源:main.py

示例4: post

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
    def post(self, version):
        logging.debug("ServicesListHandler#post")

        if (self.valid_version(version)):
            
            name = self.request.get('name', default_value=None)
            description = self.request.get('description', default_value=None)
            serviceurl = self.request.get('serviceurl', default_value=None)
            pattern = self.request.get('pattern', default_value=None)
            freq = self.request.get('freq', default_value=None)
            
            if name and description:
                slug = slugify.slugify(name)
                existing_s = Service.get_by_slug(slug)

                # Update existing resource
                if existing_s:
                    existing_s.description = description
                    existing_s.serviceurl = serviceurl
                    existing_s.pattern = pattern
                    existing_s.freq = freq
                    existing_s.put()
                    self.json(existing_s.rest(self.base_url(version)))
                # Create new service
                else:
                    s = Service(name=name, slug=slug, description=description, serviceurl=serviceurl)
                    s.put()
                    self.json(s.rest(self.base_url(version)))
            else:
                self.error(400, "Bad Data: Name: %s, Description: %s" % (name, description))
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:johnclarkemills,项目名称:stashboard,代码行数:34,代码来源:api.py

示例5: addservice_command

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
    def addservice_command(self, message=None):
        """Create a new service"""

        service_name = message.body.split(' ')[1]
        service = Service(key_name=service_name, name=service_name)
        service.put()

        message.reply("Added service %s" % service_name)
开发者ID:feczo,项目名称:splashmon,代码行数:10,代码来源:xmpp.py

示例6: ServiceInstanceTest

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
class ServiceInstanceTest(StashboardTest):

    def setUp(self):
        super(ServiceInstanceTest, self).setUp()
        self.service = Service(name="Foo", slug="foo", description="foo")
        self.service.put()

    @patch("handlers.api.invalidate_cache")
    def test_delete_service(self, mock):
        response = self.delete("/admin/api/v1/services/foo")
        self.assertEquals(response.status_code, 200)

    def test_delete_wrong_service(self):
        response = self.delete("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_delete_wrong_version(self):
        response = self.delete("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_service(self):
        response = self.post("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_version(self):
        response = self.post("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_update_desc(self):
        response = self.post("/admin/api/v1/services/foo",
                data={"description": "hello"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = Service.get(self.service.key())
        self.assertEquals(service.description, "hello")

    def test_post_update(self):
        response = self.post("/admin/api/v1/services/foo",
            data={"name": "bar"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = Service.get(self.service.key())
        self.assertEquals(service.name, "bar")

    def test_get_wrong_service(self):
        response = self.get("/admin/api/v1/services/bar")
        self.assertEquals(response.status_code, 404)

    def test_get_wrong_version(self):
        response = self.get("/admin/api/foo/services/foo")
        self.assertEquals(response.status_code, 404)

    def test_get_service(self):
        response = self.get("/admin/api/v1/services/foo")
        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.headers["Content-Type"], "application/json")
开发者ID:BillTheBest,项目名称:stashboard,代码行数:60,代码来源:test_services.py

示例7: test_create_event

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
    def test_create_event(self):
        s = Service(slug=u"hey", name=u"you", description=u"lol")
        s.put()

        stat = Status(name=u"you", slug=u"leave", description=u"why",
                      image=u"cry")
        stat.put()

        e = Event(status=stat, service=s, message=u"¨¥¨œ∑´æ")
        e.put()

        data = e.rest("/api")
开发者ID:2do,项目名称:stashboard,代码行数:14,代码来源:test_unicode.py

示例8: post

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
 def post(self):
     data = self.request.body
     temp = data
     s = Service()
     try:            
         s.category = temp['category']
         s.desc = temp['desc'] 
         s.extras = temp['extras']
         s.location = db.GeoPtProperty(temp['location'])
         s.mode = temp['mode']
         s.title = temp['title']            
     except:
         self.response.out.write('not registered due to technical difficulties')
     if s:
         s.put()
         self.restponse.out.write(s.title)
开发者ID:e911miri,项目名称:adroid,代码行数:18,代码来源:api.py

示例9: post

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
    def post(self, version):
        if self.valid_version(version):

            name = self.request.get("name", default_value=None)
            description = self.request.get("description", default_value=None)

            if name and description:
                slug = slugify.slugify(name)
                existing_s = Service.get_by_slug(slug)

                # Update existing resource
                if not existing_s:
                    s = Service(name=name, slug=slug, description=description)
                    s.put()
                    self.json(s.rest(self.base_url(version)))
                else:
                    self.error(404, "A sevice with this name already exists")
            else:
                self.error(400, "Bad Data: Name: %s, Description: %s" % (name, description))
        else:
            self.error(404, "API Version %s not supported" % version)
开发者ID:kyleconroy,项目名称:stashboard,代码行数:23,代码来源:api.py

示例10: post

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

        name = self.request.get('name', default_value=None)
        description = self.request.get('description', default_value=None)
        slist = self.request.get('list', default_value=None)
        l = None

        if slist:
            l = List.all().filter("slug =", slist).get()

        if not name:
            self.error(400, "Bad name: %s" % name)
            return

        if not description:
            self.error(400, "Bad description: %s" % description)
            return

        if slist and not l:
            self.error(400, "Bad list slug: %s" % slist)
            return

        slug = slugify.slugify(name)
        existing_s = Service.get_by_slug(slug)

        if existing_s:
            self.error(404, "A sevice with this name already exists")
            return

        s = Service(name=name, slug=slug, description=description, list=l)
        s.put()

        invalidate_cache()

        self.response.set_status(201)
        self.json(s.rest(self.base_url(version)))
开发者ID:Tradeshift,项目名称:stashboard,代码行数:41,代码来源:api.py

示例11: ServiceListInstanceTest

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
class ServiceListInstanceTest(StashboardTest):

    def setUp(self):
        super(ServiceListInstanceTest, self).setUp()
        self.service_list = List(slug="foo", name="Foo", description="Bar")
        self.service_list.put()
        self.service = Service(list=self.service_list, name="Foo", slug="foo",
                               description="foo")
        self.service.put()

    def test_resource_url(self):
        service_list = List(slug="foo", name="Foo", description="Bar")
        self.assertEquals(service_list.resource_url(), "/service-lists/foo")

    def test_url(self):
        service_list = List(slug="foo", name="Foo", description="Bar")
        self.assertEquals(service_list.url(), "/service-lists/foo")

    def test_delete_wrong_service(self):
        response = self.delete("/admin/api/v1/service-lists/bar")
        self.assertEquals(response.status_code, 404)

    def test_delete_wrong_version(self):
        response = self.delete("/admin/api/foo/service-lists/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_service(self):
        response = self.post("/admin/api/v1/service-lists/bar")
        self.assertEquals(response.status_code, 404)

    def test_post_wrong_version(self):
        response = self.post("/admin/api/foo/service-lists/foo")
        self.assertEquals(response.status_code, 404)

    def test_post_update_desc(self):
        response = self.post("/admin/api/v1/service-lists/foo",
                data={"description": "hello"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = List.get(self.service_list.key())
        self.assertEquals(service.description, "hello")

    def test_post_update(self):
        response = self.post("/admin/api/v1/service-lists/foo",
                    data={"name": "bar"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = List.get(self.service_list.key())
        self.assertEquals(service.name, "bar")

    def test_get_wrong_service(self):
        response = self.get("/admin/api/v1/service-lists/bar")
        self.assertEquals(response.status_code, 404)

    def test_get_wrong_version(self):
        response = self.get("/admin/api/foo/service-lists/foo")
        self.assertEquals(response.status_code, 404)

    def test_get_service_list(self):
        response = self.get("/admin/api/v1/service-lists/foo")
        self.assertEquals(response.status_code, 200)
        self.assertEquals(response.headers["Content-Type"], "application/json")
开发者ID:2do,项目名称:stashboard,代码行数:66,代码来源:test_service_lists.py

示例12: Region

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
# THE SOFTWARE.

from google.appengine.ext import db
from models import Status, Service, Event, Region
from datetime import datetime, timedelta, date

na = Region(name="North America")
na.put()

emea = Region(name="EMEA")
emea.put()

foo = Service(name="Service Foo", slug="service-foo", region=na,
              description="Scalable and reliable foo service across the globe")
foo.slug = Service.slugify(foo.name, foo.region.name)
foo.put()

bar = Service(name="Service Bar", slug="service-bar", region=emea,
             description="Scalable and reliable foo service")
bar.slug = Service.slugify(bar.name, bar.region.name)
bar.put()

delete = Service(name="Delete Me", slug="delete", region=na,
                description="Delete Me Please")
delete.slug = Service.slugify(delete.name, delete.region.name)
delete.put()

bar = Service.get_by_slug("emea-service-bar")
cat = Status.get_by_slug("down")        

dates = [
开发者ID:samn,项目名称:stashboard,代码行数:33,代码来源:install_data.py

示例13: test_create_service

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
 def test_create_service(self):
     s = Service(slug=u"Ð", name=u"µ", description=u"À")
     s.put()
     data = s.rest("/api")
开发者ID:2do,项目名称:stashboard,代码行数:6,代码来源:test_unicode.py

示例14: Service

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
from google.appengine.ext import db
from models import Status, Service, Event
from datetime import datetime, timedelta, date

# Create the default statuses
Status.install_defaults()

# Create Services
service = {
    "name": "Service Foo",
    "slug": "service-foo",
    "description": "Scalable and reliable foo service across the globe",
    }

services = []
for i in "ABCDEFGHIJ":
    foo = Service(name=service["name"] + i, slug=service["slug"] + i,
                  description=service["description"])
    foo.put()
    services.append(foo)


# Given one service a bunch of events
foo = services[0]

bad = Status.get_by_slug("down")

for i in range(10):
    Event(service=foo, status=bad, message="Event %s" % i).put()
开发者ID:kyleconroy,项目名称:stashboard,代码行数:31,代码来源:install_data.py

示例15: HistoryTest

# 需要导入模块: from models import Service [as 别名]
# 或者: from models.Service import put [as 别名]
class HistoryTest(TestbedTest):

    def setUp(self):
        super(HistoryTest, self).setUp()
        Status.load_defaults()
        self.service = Service(slug="account", name="Account",
                               description="The BEST SERVICE")
        self.service.put()

    def test_history_order(self):
        start = date(2011, 4, 13)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)
        self.assertEquals(len(history), 5)

        history_days = [ h["day"] for h in history ]
        expected = [
            date(2011, 4, 12),
            date(2011, 4, 11),
            date(2011, 4, 10),
            date(2011, 4, 9),
            date(2011, 4, 8),
            ]

        self.assertEquals(history_days, expected)

    def test_history_order_early_month(self):
        start = date(2011, 4, 2)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)

        history_days = [ h["day"] for h in history ]
        expected = [
            date(2011, 4, 1),
            date(2011, 3, 31),
            date(2011, 3, 30),
            date(2011, 3, 29),
            date(2011, 3, 28),
            ]

        self.assertEquals(history_days, expected)

        for h in history:
            self.assertFalse(h["information"])


    def test_history_order_late_month(self):
        start = date(2011, 4, 5)
        up = Status.get_by_slug("up")
        history = self.service.history(5, up, start=start)

        history_days = [ h["day"] for h in history ]
        expected = [
            date(2011, 4, 4),
            date(2011, 4, 3),
            date(2011, 4, 2),
            date(2011, 4, 1),
            date(2011, 3, 31),
            ]

        self.assertEquals(history_days, expected)

    def test_history_no_errors_boundary(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 4, 5)
        event = Event(status=down, service=self.service, start=now, message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))
        self.assertEquals(history[0]["information"], False)

    def test_history_one_error(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 4, 4, 12)
        event = Event(status=down, service=self.service, start=now, message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))

        self.assertEquals(history[0]["information"], True)
        self.assertEquals(history[0]["name"], "information")

    def test_history_one_error_boundary(self):
        down = Status.get_by_slug("down")
        up = Status.get_by_slug("up")

        now = datetime(2011, 3, 31)
        event = Event(status=down, service=self.service, start=now, message="HEY")
        event.put()

        history = self.service.history(5, up, start=date(2011, 4, 5))

        self.assertEquals(history[4]["information"], True)
        self.assertEquals(history[4]["name"], "information")

    def test_history_count(self):
#.........这里部分代码省略.........
开发者ID:2do,项目名称:stashboard,代码行数:103,代码来源:test_history.py


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