Adding a CMS to Your Pyramid Web App Transcripts
Chapter: Saving content to a database
Lecture: Concept: Query for a CMS object

Login or purchase this course to watch this video and the rest of the course contents.
0:00 once we have objects in the database. Well, hell, we want to get them out, and getting them out is pretty similar to what we have already done.
0:08 So here we're gonna again create a session and then the end, we're gonna close it.
0:12 But we want to make sure that the euro is also normalized the same way as what we put into the database with a lower case and stripped your l.
0:20 And then we just say, session dot query of the object we want to get.
0:24 So page the type name, then we filter, but in one or more constraints, so page dot your URL is equal to the earl they passed.
0:32 And because we want either one or none were going to say dot first and I'll give us if there's any records of the 1st 1 I get, which should be unique.
0:42 And then otherwise we'll just get none and say, you know, there was no page with this, your l and then finally used this.
0:48 Try finally block to close the session to make sure that it's cleaned up and gone. Everything's nice and put away. Now.
0:55 When we run this code, it's going to convert this to the database query language Select Star from pages where page or L equals Do some parameter where the parameter is.
1:05 Of course, what you pass in in this case were saying Maybe it was company slashed history for the value of the girl that got passed over. That's it.
1:14 We can now go and do queries for pages from the database.

Talk Python's Mastodon Michael Kennedy's Mastodon