2 deleted 47 characters in body; edited tags; edited title
source | link

Accessing an object accross different view functions in Flask

I am creating aexperimenting with an web app for searching and buying bus tickets. I have created somecame up with a few objects like RequestedRoute, Passenger, and Ticket:

class RequestedRoute:
   departure_station
   destination_station
   desired_departure_date
   number_of_travelers

And I have some Flask view functions are triggered when different URLs are visitedas well. I am using Python Flask:

The home function is triggeredcalled when the user visits the home page. The home page has a form where the user can enter departurethe departure, destinationdestination, etc and athere's Search button as well.

def home():
    return index.html 

The search function is triggeredcalled when the user presses the Search button. A RequestedRoute object will be created, and a RequestedRoute.get_available_routes() method will be triggered and the available routes will be listed on the webpage and there will be a Select button next to each route.

def search():
    requested_route = RequestedRoute("fetch data from the HTML form")
    return "available_routes.html"

The select function will be triggered when the user selects a route and a payment_details.html page containing a form with name, surname, and card credit details will be rendered.

def select():
    return "payment_details.html" 

My question is this: In the select function I need to know the number of travelers so that I can let the payment_details.html template know how many user forms to create where the user can enter the name, surname for each passenger. Should I instantiate a RequestedRoute object again? That feels reduntant as I did that once in the search function when the user searched for available routes. How can I access the RequestedRoute data again in the select function?

Any other suggestion to the design would be greatly appreciated.

Accessing an object accross different view functions

I am creating a web app for searching and buying bus tickets. I have created some objects like RequestedRoute, Passenger, and Ticket:

class RequestedRoute:
   departure_station
   destination_station
   desired_departure_date
   number_of_travelers

And I have some view functions are triggered when different URLs are visited. I am using Python Flask:

The home function is triggered when the user visits the home page. The home page has a form where user can enter departure, destination, etc and a Search button.

def home():
    return index.html 

The search function is triggered when the user presses the Search button. A RequestedRoute object will be created, and a RequestedRoute.get_available_routes() method will be triggered and the available routes will be listed on the webpage and there will be a Select button next to each route.

def search():
    requested_route = RequestedRoute("fetch data from the HTML form")
    return "available_routes.html"

The select function will be triggered when the user selects a route and a payment_details.html page containing a form with name, surname, and card credit details will be rendered.

def select():
    return "payment_details.html" 

My question is this: In the select function I need to know the number of travelers so that I can let the payment_details.html template know how many user forms to create where the user can enter the name, surname for each passenger. Should I instantiate a RequestedRoute object again? That feels reduntant as I did that once in the search function when the user searched for available routes. How can I access the RequestedRoute data again in the select function?

Any other suggestion to the design would be greatly appreciated.

Accessing an object accross different view functions in Flask

I am experimenting with an web app for searching and buying bus tickets. I came up with a few objects like RequestedRoute, Passenger, and Ticket:

I have some Flask view functions as well. The home function is called when the user visits the home page. The home page has a form where the user can enter the departure, destination, etc and there's Search button as well.

def home():
    return index.html 

The search function is called when the user presses the Search button. A RequestedRoute object will be created, and a RequestedRoute.get_available_routes() method will be triggered and the available routes will be listed on the webpage and there will be a Select button next to each route.

def search():
    requested_route = RequestedRoute("fetch data from the HTML form")
    return "available_routes.html"

The select function will be triggered when the user selects a route and a payment_details.html page containing a form with name, surname, and card credit details will be rendered.

def select():
    return "payment_details.html" 

My question is this: In the select function I need to know the number of travelers so that I can let the payment_details.html template know how many user forms to create where the user can enter the name, surname for each passenger. Should I instantiate a RequestedRoute object again? That feels reduntant as I did that once in the search function when the user searched for available routes. How can I access the RequestedRoute data again in the select function?

    Bumped by Community user
    Bumped by Community user
1
source | link

Accessing an object accross different view functions

I am creating a web app for searching and buying bus tickets. I have created some objects like RequestedRoute, Passenger, and Ticket:

class RequestedRoute:
   departure_station
   destination_station
   desired_departure_date
   number_of_travelers

And I have some view functions are triggered when different URLs are visited. I am using Python Flask:

The home function is triggered when the user visits the home page. The home page has a form where user can enter departure, destination, etc and a Search button.

def home():
    return index.html 

The search function is triggered when the user presses the Search button. A RequestedRoute object will be created, and a RequestedRoute.get_available_routes() method will be triggered and the available routes will be listed on the webpage and there will be a Select button next to each route.

def search():
    requested_route = RequestedRoute("fetch data from the HTML form")
    return "available_routes.html"

The select function will be triggered when the user selects a route and a payment_details.html page containing a form with name, surname, and card credit details will be rendered.

def select():
    return "payment_details.html" 

My question is this: In the select function I need to know the number of travelers so that I can let the payment_details.html template know how many user forms to create where the user can enter the name, surname for each passenger. Should I instantiate a RequestedRoute object again? That feels reduntant as I did that once in the search function when the user searched for available routes. How can I access the RequestedRoute data again in the select function?

Any other suggestion to the design would be greatly appreciated.