GAE: плюсы, минусы, подводные камни Я - Егор Назаркин Обычно - пишу на Python под GAE (и не только) Email: nimnull@gmail.com Twitter: @nimnull

Презентация:



Advertisements
Похожие презентации
Work with databases in Java. JDBC Tutorial for students of universities Author: Dudnik Oxana.
Advertisements

WiseImage Open Architecture Lessons Mission Impossible.
USB Download Manual (v1.3) (GP2 Year 2010) LG Electronics/ LCD TV Division Feb. 17 th, Applied Models & Notice - File Copy - User Download Mode.
Copyright ® 2000 MSC.Software Results S17-1 PAT301, Section 17, October 2003 SECTION 17 FILE MANAGEMENT.
Пример реализации приложения Программа отправки и анализа SMS-сообщений (через с WEB-интерфейсом.
WinCC Работа и мониторинг Siemens AG All rights reserved.© TC Nbg.-M Date: File: E02OFFe.PPT Catalog: NWINCC Открытость и способность.
© 2005, Cisco Systems, Inc. All rights reserved. IPS v Lesson 4 Using IPS Device Manager.
Что такое Google App Engine Сервис хостинга сайтов и web-приложений в инфраструктуре Google. PaaS Оплата только ресурсов Простота использования, поддержки.
S15-1 PAT318, Section 15, March 2005 SECTION 15 MSC.PATRAN FILES.
MSC.Patran 2005 R2 Patran Thermal Enhancements January, 2005.
vPower Еще возможности VEX Requirements: Access to EDB back-up. VEX Steps: 1. Find backup storing EDB restore point and double click. 2. Browse or search.
© 2006 Avaya Inc. All rights reserved. Using File Management and SD-Card Handling.
2 Web applications are easier to create than ever!
© 2009 Avaya Inc. All rights reserved.1 Chapter Four, UMS Web Services Module Two – IMAP Service.
WORKSHOP 20 SINDA TRANSLATION OF A PWB MODEL. WS20-2 PAT312, Workshop 20, December 2006 Copyright 2007 MSC.Software Corporation.
© 2005 Cisco Systems, Inc. All rights reserved. IPTX v Configuring Cisco Unity Express Automated Attendant and Voice Mail Understanding Cisco Unity.
Understanding Record and Table Locking In OpenEdge ® SQL Applications Jeff Owen Principle Software Engineer, OESQL Progress Software Session 132.
© 2009 Avaya Inc. All rights reserved.1 Chapter Nine, Voic Pro in SCN Module Four – Distributed Voic Pro.
S11-1 PAT318, Section 11, March 2005 SECTION 11 ANALYSIS SETUP.
Comparison of Lotus Notes Designer, Domino Workflow Architect and AdHoc Workflow Builder 2003 (c) AdHoc.
Транксрипт:

GAE: плюсы, минусы, подводные камни Я - Егор Назаркин Обычно - пишу на Python под GAE (и не только)

GAE - что за неведомая фигня?

GAE это... PaaS Cloud Platform Webapp hosting managed automatic scaling BigTable Go JAVA Python

GAE это... Игровая площадка Гвидо

Ограничения GAE Время выполнения запроса - 60 секунд (лучше - 30) Данные на FS - только чтение Сохранение файлов - Google Datastore Связь с внешними хостами - только AppEngine URL Fetch Квоты: Безопасность Платные OverQuotaError

Алиасы модулей: logging Django 1.2 jinja2 2.6 lxml 2.3 MarkupSafe 0.15 NumPy PyCrypto 2.3 PyYAML 3.10 Python Imaging Library (PIL) setuptools 0.6c11 webapp2 2.3 WebOb 1.1. cPickle => pickle cStringIO => StringIO marshal, imp, ftplib, tempfile => None Библиотеки:

MVC? model view controller

Backends нет ограничений на время обработки ручная конфигурация памяти/CPU собственный поддомен резидентность приватные по умолчанию API доступа

Datastore ORM GQL Schemaless Транзакции Метаданные Статистика Асинхронность

ORM class Rate(db.Model): price = db.IntegerProperty() user = db.UserProperty(required=True) uptime = db.DateTimeProperty(auto_now=True) trade_unit = db.ReferenceProperty(TradeUnit, required=False) def put(self): q = Rate.all().filter('trade_unit = ', self.trade_unit.key()) q.order("-price") previous_rate = q.get() previous_price = previous_rate.price if previous_rate else 0 price = previous_price + self.trade_unit.increase_rate if self.price < price: self.price = price super(Rate, self).put()

GQL SELECT [* | __key__] FROM WHERE [AND...] ORDER BY [ASC | DESC ] [, [ASC | DESC]... ] LIMIT [, ] ] OFFSET DATETIME(year, month, day, hour, minute, s econd) DATE(year, month, day) TIME(hour, minute, second) KEY ('encoded key') USER (' address') GEOPT ('lat', 'long')

Transactions class Rate(db.Model): price = db.IntegerProperty(default=0) user = db.UserProperty(required=True) uptime = db.DateTimeProperty(auto_now=True) trade_unit = db.ReferenceProperty(TradeUnit, required=False) def put_with_next_price(self, price=None): def in_transaction(rate, next_price=None): q = Rate.all().filter('trade_unit = ', rate.trade_unit.key()) q.order("-price") previous_rate = q.get() previous_price = previous_rate.price if previous_rate else next_price price = previous_price + rate.trade_unit.increase_rate if rate.price < price: rate.price = price rate.put() db.run_in_transaction(in_transaction, self, price)

Entities and Keys Key: Kind - объединяет по признаку (classname) ID - генерируется Datastore или задаётся вручную Key.from_path(kind, id_or_name, parent=none, namespace=None, **kwds) item = TradeUnit() item.put() rate = Rate(parent=item) # rate = Rate(parent=item.key())

Async get put delete *_async() # выполняем какую-то работу....get_result() q = Model1.filter(...).run() for e in q:...

NDB Расширенное описание полей Дополнительные типы полей db.Model Вменяемый синтаксис запросов Кэширование Триггеры (hooks) class Contact(Model): name = StringProperty() addresses = StructuredProperty(Address, repeated=True) guido = Contact(name='Guido', addresses=[ Address(type='home', city='Amsterdam'), Address(type='work', city='SF', street='Spear St'), ]) qry = Article.query(Article.tags.IN(['python', 'GAE', 'ndb']))

Google Cloud SQL from google.appengine.api import rdbms Google SQL Service поддерживает DB-API 2.0DB-API 2.0 etc...

Батарейки в комплекте: Mail Memcached Message channels Cloud storage Images Blobstore Task queues OAuth URL fetch MapReduce

MapReduce:

Cloud storage: Сервис общего назначения (используется в google) AppEngine - RESTful API Может использоваться разными приложениями Trial-only для бесплатной подписки file-like доступ

Channel API: JS View (coffee-script sample) _sock = = _sock.open() # bind socket = = (evt) => console.log "realtime: ", = (evt) = = = [{}, null, null] Python back-end: key = str(uuid.uuid4()) def subscribe(request): token = channel.create_channel(request.user.id + key) return { 'token': token, } def send_message(request): channel.send_message(request.user.id + key, 'message')

На этом всё

Вопросы?