PyCon 2014

Desarrollando una aplicación con SQLAlchemy

Mike Bayer  · 

Presentación

Vídeo

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

good afternoon everyone it's my pleasure to welcome Michael Baer a longtime speaker at PyCon and the creator of sequel alchemy he's going to be talking to us today about building apps web apps in seek welcome let's give him a big round of applause

hi um I want to thank us we need Selina Declan and Jason Myers for doing great talks on psycho alchemy and el limbic right before me so we can pray for them it set me up to do the a the final talk for sequel alchemy um so it is called it's on the screen

there look at that it's really big writing the app what does this talk about so this is about writing larger longer-lived applications with relational databases and sequel alchemy and how sequel alchemy deals with that kind of issue the foundation is what

we call the the code that we write when we first plug in our foundation our frameworks and libraries so when you first start to write your app before you begin writing your use cases you have this thing that I call the foundation like your your data types

that are special and other things to do with constraints and ORM patterns I think that having a healthy amount not too much of upfront code is a good thing rather than a failure of libraries and frameworks to do everything possible sequel alchemy is designed

with being able to write these foundations in mind so how do we define what a foundation is and is not the foundation includes the technologies we're using like we're using flask or pyramid you know what libraries frameworks how we structure our directories

name our files what kinds of architectural patterns we're going to be using how we build it out if we're using integrated testing configuration so the decisions we make when we do the foundation will determine when a new developer comes in the project

what does that developer going to need to understand in order to add new features to your and it will kind of determine exactly what it's like when you start with hey the customer wants this new feature where do we start where do we do the middle and where

do we end so here the italics around is or the foundation is it's the source files at the base of our application it's the the basis for patterns and idioms that we're going to repeat throughout the app it might be reusable in other applications

and it represents kind of the way that we've adapted the frameworks and libraries we're using to the the task at hand is specific to what we're doing so the foundation is not a replacement for frameworks or libraries it's not the start of our

company's new app platform it's not like we're writing our own amazing system that we're going to publish it's really meant to be specific to what you'll get what you're getting done it's about practicality versus trying to

make some bigger thing not a reinvention of the wheel unless the wheels you have are terrible pretty obvious right so let's see a foundation and actually this slide is the plug for the pyramid web framework woohoo because we don't have any pyramid

talks this year and then we have three sequel can we talk which is great but just I feel guilty that we have so many talks in pyramid has none so I actually like pyramid and the sample app we have here is a pyramid app I like about pyramid I really love the

view renderer model this will you make up your View Function has a little decorator that says this view will talk to this template this kind of template you can actually have several renderer decorators I think that's really cool I think it's opinionated

in the right places I like its emphasis on testability attention to detail and of course when I work with pyramid nothing ever works nothing ever breaks nothing ever does what you don't expect cuz pyramids components are like super duper industrial rock-solid

and I always trust them 100% so which is really great and pyramid is of course curmudgeonly like me and then of course you don't have to use pyramid you know if you can write a foundation in any framework meaning you could also use flask all right so this

is the link that I met just made public on bitbucket and hopefully that works so if you want to go so basically this talk if you want to go to this application everything I'm talking about is going to be in this app and you can download the app and you

can run it and play with it and I'm going to have it up on the sequel alchemy site is kind of like the beginning of actually having sample apps like the pyramid tutorial has a sample app and this will be another one so I'm going to go to the next slide

if you just go to my bit bucket Zeke you guys know the Zeke name right okay so an overview of what I'm going to try to cover the meta folder conventions and recipes session scoping which is the part that makes me nervous to talk about constraint naming

a little bit on migrations not too much and then some thoughts I have on testing the meta folder is something that I got from first working with pylons when pylons would build out a project they'd have this file called meta py and I actually break it out

into several files and I just from the from the minute I write the app I know there's going to be a metaphor which will have the foundation it'll have various files that are going to deal with the kinds of things I know that my app needs to worry about

so the name of the app is HTM craf and it'll be like a model folder and then inside of model the first thing I put there is meta which is we're going to deal with database stuff in the abstract in there we have init py which provides names to import

from the outside base py is fundamental units like your session your declarative base object relational mapping helpers a schema generation and definition helpers and then things to do with special datatypes so the first bars conventions / recipes I can't

quite figure out the difference between a convention or recipe so they're kind of interchangeable the goal of a convention / recipe is to reduce as much repetition as possible in day to day code without taking it too far things we use for recipes or Python

functions mix-ins sequel alchemy events compiles recipes custom types sequel alchemy is really oriented towards this kind of programming and constantly trying to make this system work better and more predictably it wasn't there in version 1 or 2 but as

we've gone through version 7 8 9 it's getting more and more mature and predictable some recipes conventions become sequel alchemy features lots of them do why aren't these conventions in recipes part of sequel alchemy to start with well one place

that we often draw the line is with naming things sequel alchemy really doesn't ever want to name anything it doesn't want to name your tables or your columns or your constraints so things to do with naming are typically not out of the box you've

got to come up with some way to come up with names some conventions do become features or at least partially the project tries to uh you know we like features but we like to start with making something as a composable set of components that you can kind of

build mix and match different things out of them rather than just a flag like do this we'd rather you come up with a recipe for like do this thing or maybe this or someone else could adapt it do that we think that's more flexible and open ended and

the fullest the philosophy here is if you you know the famous proverb give someone a fish and feed them for a day or give someone an event listens for a fish available hook and then you can fish for all the applications you want or something like that more

[ ... ]

Nota: se han omitido las otras 3.824 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.