Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Pyramid

2,183 views

Published on

  • Be the first to comment

Pyramid

  1. 1. Pyramid Tiny and powerful python web framework
  2. 2. Main Features Traversal / URLDispatch ZODB/SQLAlchemy/ NoSQL LDAP/who/security Chameleon/Mako/Jinja2 Deform2 Testing
  3. 3. Traversal / URL dispatch config.add_route(‘route1’, ‘{var1}/{var2}’) config.add_view(‘module.views.view1’, route_name=‘route1’) /foo/bar Object based traversal with a route object config.add_view(‘module.views.view1’, route_name=‘route1’) /a/b/c/route1 class Resource(object): def __init__(self, subobjects): self.subobjects = subobjects ! config.add_route('home', '{foo}/{bar}/*traverse', factory=‘mypackage.routes.root_factory') /my/first/a/b/c/route1 ! def __getitem__(self, name): return self.subobjects[name] root = Resource( {'a': Resource({'b': Resource({'c': Resource({})})})} ) ! def root_factory(request): return root
  4. 4. Strong add-ons Cornice - REST web services Kotti - CMS Kombu/pika - RabbitMQ integration Pyramid_soquetio - SoquetIO integration pymongo/mongopersist - MongoDB integration SubstanceD - App server
  5. 5. MongoPersist class Person(persistent.Persistent, ReprMixin): ... ... def __init__(self, name, phone=None, address=None, friends=None, ... visited=(), birthday=None): ... self.name = name ... self.address = address ... self.friends = friends or {} ... self.visited = visited ... self.phone = phone ... self.birthday = birthday ... self.today = datetime.datetime.now() ... ... def __str__(self): ... return self.name
  6. 6. Cornice users = Service(name='users', path='/users', description=“Users") ! @users.get(validators=valid_token) def get_users(request): """Returns a list of all users.""" return {'users': _USERS.keys()} ! @users.post(validators=unique) def create_user(request): """Adds a new user.""" user = request.validated['user'] _USERS[user['name']] = user['token'] return {'token': '%s-%s' % (user['name'], user['token'])}
  7. 7. “How to write a modern app with Pyramid” With modern JS Frameworks
  8. 8. MONGODB PYRAMID ANGULART/BACKBONE PYRAMID CORNICE REST Tempus
  9. 9. Questions ? Ramon Navarro Bosch - r.navarro@iskra.cat

×