Adding a CMS to Your Pyramid Web App Transcripts
Chapter: Advanced Markdown templates
Lecture: Marking pages as shared (DB level)

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Well, we have this working pretty well from a functionality perspective, but not from an admin back in nice editing experience over here.
0:09 When we go to our pages, I would like to see here are your top level pages and here is a piece that can be reused.
0:15 And I'd like to see his little name and stuff like that in order for us to do that.
0:19 Though, remember, this is all just a bunch of page objects in the database to seek. Welcome me.
0:24 We need some way to indicate on that page object whether or not it's shared so we could go give that a shot.
0:32 Being come down here and we can say is shared. It's going to be a Boolean who has a default value false. That seems totally reasonable, right?
0:42 And yes, this is how we put it in here. Let's run the code and see how well this works.
0:46 By refresh this page are we don't get a great air message here because we turned off on the bug Tobar. But it doesn't matter. Let's just go down here.
0:54 And what is it going to say that that ah, it's doing some sort of query. No such column is shared. Yikes, that's not good. What's happening?
1:04 Well, the database has this stuff in it and the way sequel alchemy works, it will generate new table.
1:10 So if I made a new class, it would go and create that right away. However, what it will not do is it will not update an existing table.
1:18 It won't add columns to an existing table. Do it's not gonna make this change here.
1:24 In order for us to do that, we have to apply migrations and the tool for sequel coming to do that is a limbic.
1:30 We're gonna do a quick little bit of work with Olympic. To make this change, go across this common this out for a second. So it's in sync to start now.
1:39 There's some older migrations that we don't need to apply here, and I don't think they're properly in the database.
1:46 We haven't been using migrations so far because we haven't needed them. And because we weren't careful, these were kind of out of sync.
1:52 So I'm just going toe, save us some trouble and delete those two files, OK, and the other thing we need to do is make sure limbic is installed.
1:59 So I put that here and weaken. Just pip the requirement, Steph. And get that to install Olympic. All right, Good. Now let's ask which Olympic good?
2:15 It's the one out of our virtual environment that's very good.
2:17 We're gonna need important that library, which is also registered in this virtue environment, do that's important that we can do that.
2:25 And if you're on Windows, you can ask where Olympic, by the way. So let's just see if we can get Olympic Teoh.
2:32 Talk to the database, we say Olympic upgrade head. That means just latest and basically says nothing. That's a good sign.
2:43 We could come over here and we can put this back in, make sure we save it. And we can say a limbic revision.
2:50 Dash dash auto generate with the message and is shared two pages seem s pages. Some like that.
3:00 Alright, let's try this super so what it's done is it's gone and created. This file year, which has no downgrade, is fine.
3:09 But if we upgrade, it's gonna go to this version. What is good and you can see right here.
3:12 It's adding, the column is shared and said it to be knowable by default. All right, let's go and look at the data base.
3:22 But our pages no is shared, right? Right. So the final thing to do that generated the migration, but it didn't apply a migration.
3:30 So this Olympic upgrade head says, Take all the migrations you haven't here and applying to the database. Okay, let's go over here and see what we got.
3:39 Refresh. Oh, yeah, There's a Boolean column and we can go back with our page now having this and run it and see what we get. Our page.
3:47 It was crashing Works Great now. And of course, all the pages do as well.
3:50 So what we need to do next is we need to go and update this to use that is shared property here and let's set it over


Talk Python's Mastodon Michael Kennedy's Mastodon