Adding a CMS to Your Pyramid Web App Transcripts
Chapter: Saving content to a database
Lecture: Creating the Redirect SQLAlchemy class
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
while we're at it, let's go ahead and add the redirect class as well. And again, copy paste is the way to go. And this turns out to be even easier.
0:12
So we look over here and say, Read I Rex redirect singular green ir lower case and all this stuff actually is exactly the same.
0:21
So or not, it could even change that We have Ah, you Earl. And we also have a short URL in our redirect Onda. We don't have a title. We have a name.
0:33
The name is required, but we're not going to search by it. The URL is required, but we're also not going to search by. This is the destination.
0:41
Nobody's going to say I want to find all the redirects that might go there.
0:45
Maybe maybe you will probably not eso You can add that index later, but for this one, this is super important.
0:51
This is when you come and hit like slash bites or slash company slash history.
0:57
We want to quickly get back and see if there's a redirect just to know if there is get that record back, though this is the one we need.
1:04
The index on this. Nothing. Nothing changes about this one up here, so I think we're good on the class.
1:10
And again we gotto bring it into all models here like So Now let's look at our database real quick. Oh, here we can look at it on.
1:22
Do a little refresh notice. There's no re Durex and there's no pages. But when we run this, your A D V session is going to import all models.
1:34
And then in this global in it, it's going to call sequel Commie base metadata create all because these derived from sequel Commie Base and they're not in the database.
1:46
When we'd run it, it should create this. So let's just to restart. Graph didn't crash. That's a good sign over here into a refresh. Check that out.
1:56
We got are two tables over here in the database, and they're exactly like you would expect. Here's a short your l.
2:02
And that little blue thing means that hasn't index. Here's our index for that. And what?
2:07
Not the same for pages, so it looks like this was created correctly in the database.
2:11
One quick note about the required fields, like the notable, were using sequel light For the moment, I don't believe sequel light supports the concept of no ability or not.
2:24
No ability. So it you won't see that actually show up in the database.
2:28
But on MAWR official riel database servers like Post Grass or my sequel or Microsoft Sequel server something like that, you should see the nal ability showing up there.
2:39
All right, well, were ready. Our database is now ready to store these pages here and the reader X there.