Detailed Notes
Part 2 of our look at using session variables for passing data.
You can view source for today and all prior days by reviewing the tag Day 37 at this GitHub: https://github.com/robbroadhead/develpreneur-pythontutorial
Transcript Text
[Music] well hello and welcome back we are going to continue sort of like a part two as we're looking at pulling some of our values into sessions and we're gonna track our current time frame at this point so as we go into edit one if we do return our annual goals there we go i don't know why that's popping up when we do an edit here we're going to come in and we want to make sure that we're going to set our current one but also be able to pick up a parent if there is one so we have a couple things we need to do and first thing we want to do is we've got our p that we is our variable we just kept it very simple uh somewhere in here let's do it this way i think we did it like that oh maybe it's nice and it was probably single quotes around it there we go so we were just going to set that so when we come in and do edit task then uh we're going to set the parent but the first thing we need to do now in this case this is so we've got an id so we're editing once we already have potentially a parent and so what we need to do actually here is say either actually i guess what we do is we just set our parents which we're going to do here and let's check our parent so we're going to come through all of this let's see and we're going to actually do here see did i use that already just in case yes i did so when i create a time frame i'm gonna go see if the parents out there let's see data's time frame blah blah blah blah okay so this isn't creating so i can get set my parent in this case now the edit is a little different because in here what i want to do is i'm going to uh let's see so i set my roadmap but i also need to set my parents if i have a parent if i don't have a parent then it's going to be me and actually when i come out of this it needs to be me anyway so what i need to do here uh well this is the check what i do need to do right before i jump to my screen is i need to do the request whoops request dot session p is actually going to be equal to my id and we're doing this as an id so it's going to be uh let's see so here it's edit so i'm just going to make it equal to this id so i need to make sure that i'm going to check it i need to check it beforehand and i do that let's see so as i come in i'm going to edit and well in this case i'm actually in pretty good shape because what i'm going to do is i'm going to say that i'm i'm gonna grab the data for that guy and i'm actually in pretty good shape because i've already grabbed the data uh parent where did i set parent parent parent parent parent parent equals data dot parent so then edit i'm okay in a create let's make sure i got that creating a time frame then i'm going to try to grab the parent if i can and i don't need to actually set it at this point um because it would have been from an edit and then the parent is going to be there so i should be okay so let's check that oh and then actually while we're at it uh when we do an edit time frame i'm sorry edit task where's our tasks there's active edit a road map create a road map list a road map oh and actually we need to we need to free this up so when we select a new roadmap we just need to make sure uh let's just put it and we'll put it up here uh here what we need to do is request.session p equals none because we'll make sure we jump to a new time frame i'm sorry a new roadmap that we clean out the time frame parents because now roadmap is our our top level our route of our path that we need to follow down sort of our cookie trail let's see creating a road map we can actually probably create road map let's just do it just to be safe we're going to do the same and actually when we do create roadmap right now we're going to come in and that's one of the first things we're going to do is we're going to clean those two out which again i probably should call this like uh let's do it that way let's do uh clean session and uh that has to have the request and we're just gonna do it like that so we're gonna do clean session request whoops let me do that so we'll probably use that in a couple places uh so now let's jump back to our parent we're gonna steal that code and when we do an edit task giving a little vamping a little bit in our edit task okay so an edit task we come in uh let's see so editing a task we should be in pretty good shape prints null but if actually that should be parent equals none let's do that and actually here because we're doing this so parent actually equals as we come in it's going to be the object because we're getting a task object so it's going to be data dot i would call that time frame oh this is actually a parent for a task let's look at that did we do it that way uh we did not we don't have stack tasks they're tasks they are all attached to a singular frame so okay so we're good there so our parent is actually in this case is our time frame and then if we come through here this is where we handle if uh let's see so if it's a post then we do some stuff but if not and so this is where we can just say here is if there's a parent in the session then we're gonna get that uh let's see if he's there then we're gonna grab that parent and we're gonna set him there and so now we don't need to do this because this is where we're checking our um query string variables we don't need those two let's make sure we got that right let's press it okay so we should be good there so that's in editing a task we may need it let's see if we go to create task um i'm gonna get rid of that test i don't think i use that anymore did i clean that up somewhere i did not let's get rid of that just to get that out of there clean that thing up and let's see deleting a task create a task here we go so here we were not in creating a task we don't send anything in but now what we can do is let's see we get it this is a new one so if it's in request session then uh data dot time frame equals parent then actually just call it that let's say it's going to be tf tf and so now when we create one if there's one in the session we're going to create it based off of that oh we're going to save that there we go because it was barking about it and i think we are in good shape in that so now we should be set that we could start all the way up in our road map and uh let's see so this is annual goals 2021 and now we've got personal goals and professional goals and um this is going to be just like we'll do delete goals we're going to create one here but it's looking for time frame matching the query so i think when i do this creating a time frame so it should be tf which is interesting why it is not so let's take a look at that real quick so if we do the time frame without anything so that calls create time frame time frame there we go uh that's id we should be good there we should be good there let's see let's go look at that oh where did that go let's go look at that error a little more specifically so he's in 296. is right here so if he's in the session oh what we need to do is if uh not equal to none then we do that probably have to change that a couple places and so let's check that real quick let's go back here let's uh reload that page and now if we do create time frame so now we've got that uh it's got a road map it has no parent but let's go back and let's go to our personal goals and so let's look at this one real quick is we have no parent because it doesn't have a parent time frame we can uh create a let's create a goal for the period oh we gotta clean that up a little bit but let's create a task so let's do so this is an annual goal for personal and let's just create a task and we should see but we're not seeing it because we didn't get our our time frame didn't get set as we came through for creating a new uh task so let's take a look at that when we create a task that is the task so we're walking our way through these guys so let's create tasks if we go here create task there we go so if p is in the session then it should say uh data.timeframe equals that let's make sure that we change that somewhere oh i don't think we did because i think if we do task edit uh let's see go page parent id uh let's go back we may have switched that up a little bit so here oh we don't have one on the create task so if we go to edit task we probably see that same thing where we have a parent and let's see so we pulled it from the time frame so in create task what we need to do is we've got a parent whoops and he's going to be parent but we need to come here and either say let's do it this way so parent is either no so let's just do parent well let's do this yeah we'll do it this way so parent equals a time frame and then here uh let's see we can just do parent equals tf so if we do that and then we come back here and we do our create task now we should see it's still not coming through okay so i'm on a time frame so i should see my time frame so and then when i do create tasks let's take a look at whoops let's take a look at that real quick so create task let's look at this real quick print request dot session take a look that real quick as we do a create now when we look uh he does that let's do my parent um print whoops print parent and let's just see what he looks like because he says here i'm gonna set my parent otherwise i'll go through here all right let's try this guy real quick back through this because this we're gonna make this a three-parter now whoops go back here because i want to look over here and uh so parent is annual personal goals which is my time frame and so he should be picking that up but he is not so i may not have that in my edit task let's see if i go task edit and i think that's the only one i've got if i set here she should all be good oh i may not be setting my let's make sure i'm setting my form properly so oh i bet i'm not let's see so here's my form uh oh so what i want to do is actually let's break him down here let's bring him further down where i actually load that up probably not load my values right and so now there we go so now i can create a task i've got this and this is just going to be delete me well actually i don't even have to do that and so if i create a goal for a period if i go to second like a first quarter i'm gonna have um oh if i create a time frame then my parents okay if i go into a time frame like my first quarter goals if i create a task then it's for the time frame of first quarter if i create a time frame my parent is first quarter and so there we go we've got those now we do have um i think we're actually in pretty good shape because we can do we want to change our task list but now we've got a very basic version of this we did have a listing of tasks in general that we're going to want to deal with i'm sorry that's not there that's in our url so we have this tasks which we actually no longer have access to we may want to clean that up because now it shows all of our tasks and actually i'm sorry time frames is the other one that shows all time frames and we may want to change that up but for right now i think that gives us a our basic flowing through our application we're going to continue we're going to do some cleanup and we're actually getting pretty darn close to something we can use here and we'll take care of that next time around so go out there have yourself a great day and we will talk to you next time you
Transcript Segments
[Music]
well hello and welcome back
we are going to continue sort of like a
part two as we're looking at pulling
some of our values into sessions
and we're gonna track our current time
frame at this point
so as we go into edit one if we do
return our annual goals
there we go i don't know why that's
popping up
when we do an edit here we're going to
come in
and we want to make sure that we're
going to set our current one but also
be able to pick up a parent if there is
one so we have a couple things we need
to do
and first thing we want to do is we've
got our p
that we is our variable we just kept it
very simple
uh somewhere in here let's do it this
way
i think we did it like that oh maybe
it's nice and it was probably single
quotes around it
there we go so we were just going to set
that so when we come in and do edit task
then uh we're going to set the parent
but the first thing we need to do now in
this case
this is so we've got an id so we're
editing once we already have
potentially a parent
and so what we need to do actually here
is say either actually i guess what we
do is we just set our parents
which we're going to do here and let's
check our parent
so we're going to come through all of
this let's see and we're going to
actually do
here see did i use that already
just in case yes i did
so when i create a time frame
i'm gonna go see if the parents out
there let's see data's time frame blah
blah blah blah okay so this isn't
creating so i can get
set my parent in this case now the edit
is a little different because in here
what i want to do is i'm going to
uh let's see so i set my roadmap but i
also need to set my parents
if i have a parent if i don't have a
parent
then it's going to be me
and actually when i come out of this
it needs to be me anyway so what i need
to do here
uh well this is the check what i do need
to do right before i
jump to my screen
is i need to do the request whoops
request dot session
p is actually going to be equal to
my id and we're doing this as an id so
it's going to be
uh let's see so here it's edit so i'm
just going to make it equal to this id
so i need to make sure that i'm going to
check it i need to check it beforehand
and i do that
let's see so as i come in i'm going to
edit and well in this case i'm actually
in pretty good shape because what i'm
going to do is i'm going to say that
i'm i'm gonna grab the data for that guy
and
i'm actually in pretty good shape
because i've already grabbed the data uh
parent where did i set parent parent
parent parent parent
parent equals data dot parent so then
edit i'm okay in a create let's make
sure i got that
creating a time frame
then i'm going to try to grab the parent
if i can
and i don't need to actually
set it at this point um
because it would have been from an edit
and then the parent is
going to be there so i should be okay so
let's check that oh and then
actually while we're at it uh when we do
an edit time
frame i'm sorry edit task
where's our tasks there's active edit a
road map
create a road map list a road map oh and
actually we need to
we need to free this up so when we
select a new roadmap
we just need to make sure uh
let's just put it and we'll put it up
here
uh here what we need to do is
request.session
p equals none because we'll make sure we
jump to a new time
frame i'm sorry a new roadmap that we
clean out the time frame parents because
now
roadmap is our our top level our route
of
our path that we need to follow down
sort of our cookie trail
let's see creating a road map we can
actually probably create road map let's
just do it just to be safe we're going
to do the same
and actually when we do create roadmap
right now we're going to come in and
that's one of the first things we're
going to do is we're going to clean
those two
out
which again i probably should call this
like uh
let's do it that way let's do uh
clean session
and uh that has to have the request
and we're just gonna do it like that
so we're gonna do clean session
request whoops let me do that
so we'll probably use that in a couple
places uh so now let's jump back to our
parent we're gonna steal that code
and when we do an edit task
giving a little vamping a little bit in
our edit task okay so an edit task
we come in uh let's see so editing a
task we should be in pretty good shape
prints null but if
actually that should be parent equals
none let's do that
and actually here because we're doing
this so parent actually equals
as we come in it's going to be the
object because we're getting a task
object so it's going to be data dot
i would call that time frame oh this is
actually a parent for a task let's look
at that did we do it that way
uh we did not we don't have stack tasks
they're tasks they are
all attached to a singular
frame so okay so we're good there so our
parent is actually
in this case is our time frame
and then if we come through here this is
where
we handle if uh let's see so if it's a
post
then we do some stuff but if not and so
this is where we can just
say here is if there's a parent in the
session
then we're gonna get that uh
let's see if he's there then we're gonna
grab that parent and we're gonna set him
there
and so now we don't need to do this
because this is where we're checking our
um query string variables we don't need
those two
let's make sure we got that right let's
press it okay so we should be good there
so that's in editing a task we may need
it let's see if we go to create
task
um i'm gonna get rid of that test i
don't think i use that anymore did i
clean that up somewhere
i did not let's get rid of that just to
get that out of there
clean that thing up and let's see
deleting a task
create a task here we go so here we were
not
in creating a task we don't send
anything in but now what we can do
is let's see we get it this is a new one
so if it's in request session then
uh data dot time frame
equals parent then actually just call it
that let's say it's going to be tf
tf and so now when we create one if
there's one in the session we're going
to create it based off of that
oh we're going to save that there we go
because it was barking about it
and i think we are in good shape
in that so now we should be set that we
could start all the way up in our road
map
and uh let's see so this is annual goals
2021
and now we've got personal goals and
professional goals
and um this is going to be just like
we'll do delete
goals we're going to create one here but
it's looking for
time frame matching the query so i think
when i do this creating a time frame
so it should be tf
which is interesting why it is not
so let's take a look at that real quick
so if we do the time frame
without anything so that calls create
time frame
time frame there we go
uh that's id we should be good there we
should be good there
let's see let's go look at that oh where
did that go let's go look at that error
a little more specifically
so he's in 296.
is right here
so if he's in the session oh
what we need to do is if
uh not equal to none
then we do that probably have to change
that a couple places
and so let's check that real quick let's
go back here
let's uh reload that page and now if we
do create time frame so now we've got
that
uh it's got a road map it has no parent
but let's go back and
let's go to our personal goals
and so let's look at this one real quick
is we have no parent because it doesn't
have a
parent time frame
we can uh create a let's create a goal
for the period oh we gotta
clean that up a little bit but let's
create a task
so let's do so this is an annual goal
for personal
and let's just create a task
and we should see but we're not seeing
it because we didn't get our
our time frame didn't get set
as we came through for creating a new
uh task so let's take a look at that
when we create a task that is the task
so we're walking our way through these
guys so let's create tasks
if we go here
create task there we go so if p
is in the session then it should say
uh data.timeframe equals that
let's make sure that we change that
somewhere oh i don't think we did
because i think if we do task
edit uh let's see go
page parent id
uh let's go back we may have switched
that up a little bit so
here
oh we don't have one on the
create task so if we go to edit task we
probably see that same thing where we
have a parent
and let's see so we pulled it from the
time frame
so in create task what we need to do is
we've got a parent
whoops
and he's going to be parent but we need
to come here
and either say
let's do it this way so parent is either
no
so let's just do parent well let's do
this
yeah we'll do it this way so parent
equals a time frame
and then here uh let's see
we can just do parent
equals tf
so if we do that and then we come back
here
and we do our create task now we should
see
it's still not coming through
okay so i'm on a time frame so i should
see
my time frame so and then when i do
create tasks let's take a look at whoops
let's take a look at that real quick
so create task let's look at this real
quick
request dot session
take a look that real quick as we do a
create
now when we look
uh he does that
let's do my parent um
print whoops
print parent and let's just see what he
looks like because he says here i'm
gonna set my parent otherwise i'll go
through here
all right let's try this guy real quick
back through this because this we're
gonna make this a three-parter
now whoops go back here because i want
to look over here
and uh so parent is annual personal
goals
which is my time frame and so he should
be picking that up but he is not so i
may not have that in my
edit task let's see
if i go task edit and i think that's the
only one i've got
if i set here she should all be
good oh i may not be setting my let's
make sure i'm setting my
form properly so oh i bet i'm not
let's see so here's my form
uh oh so what i want to do is actually
let's break him down
here let's bring him further down where
i actually load that up
probably not load my values right
and so now there we go so now i can
create a task i've got this
and this is just going to be delete me
well actually i don't even have to do
that
and so if i create a goal for a period
if i go to second
like a first quarter i'm gonna have um
oh if i create a time frame then my
parents okay
if i go into a time frame like my first
quarter goals
if i create a task then it's for the
time frame of first quarter
if i create a time frame my parent is
first quarter
and so there we go we've got those now
we do
have um i think we're actually in pretty
good shape because we can do
we want to change our task list but now
we've got a very basic
version of this we did have
a listing of tasks in general
that we're going to want to deal with
i'm sorry that's not there that's in our
url
so we have this tasks which we actually
no longer have
access to
we may want to clean that up because now
it shows
all of our tasks and actually i'm sorry
time frames
is the other one that shows all time
frames and we may want to change that up
but for right now i think that gives us
a our basic
flowing through our application we're
going to continue we're going to do some
cleanup
and we're actually getting pretty darn
close to something we can use here
and we'll take care of that next time
around so go out there
have yourself a great day and we will
talk to you
next time
you