#100DaysOfWeb in Python Transcripts
Chapter: Day 52: Anvil - Full Stack Web Apps
Lecture: Adding filtering (continued)

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now what we want to do is go to our all_documents_form. Which is hiding. Let's make some room here. And when you type in this thing,
0:10 which is called TextBox Filter, we want this to change. So, we need to hook the change event down here. Check this out. Change event.
0:18 And what we want to do is we want to basically set the south.repeating_items equal to filtered_docs. We don't have this written yet.
0:30 We're going to write that. And what we're going to do is I'm going to have a function that'll take a document and turn it into text.
0:38 So, if I have this function, and I give it one of these documents and it just says convert into a string. I can do a string search on that.
0:46 So, let's write this filtered documents leveraging this little bit of code here. Here we go.
0:54 So, what we're going to do is going to go to our TextBox Filter. Grab the text. And if they're not searching for anything,
1:01 we're going to return all the docs. We're going to return all the documents. Otherwise, we're going to create a list of documents
1:11 that if we converted to text and then lower case it, and we do a find on the txt here, then, then we're going to get it.
1:20 I guess we want to also say txt = txt.lower(). Like that. In case you type something upper case that wouldn't work well right there. Would it?
1:28 So, we' re just going to go through and say literally as a string, does that piece of text you typed in the filter, does it appear in the document?
1:34 And then we're going to give that back right there. Whew. Okay, and let's see if our filtering works. So, here's our home. It's got all the documents.
1:45 Some of these, like the space photos and Higgs, these are in the science category. They have things like exotic materials.
1:53 This one is logging. So, this is logbook. Let's just look where we talked about logbook. Oh, filtered docs. What did I do wrong here? Ah, self.
2:03 Self, self, self.filtered_docs. So, let's try this again. How about logbook. Oh my goodness. Is that cool or what?
2:12 What about the ones that have to do with science? Oh, I think the ones that have to do with science might not be coming in there quite right.
2:19 This part right here, we have to get the name out. Okay. One more time. 'Cause the category is actually a row. Right? So, now let's try our science.
2:31 Those are the ones with that tag. And about the ones with documentation. Those. What about the ones have to do with datetime.
2:38 Which is what we talked about in Day 1. datetime. How about the word the? That appears a lot. How about RSS? Feedparser?
2:46 See how incredibly easy that is? Watch how quick it is to go back and forth between all of these. Because we've downloaded this,
2:52 we're not hitting the server again. It's just all running off of that cash thing. Right there. Super cool.
2:58 So, we can come over and just search for RSS. Bam, find it. Go pull out the details. I guess the last thing for us to do
3:03 is put the details page in here.


Talk Python's Mastodon Michael Kennedy's Mastodon