WSGI by HTTP GET

N

Niklasro

Hello
Getting a web same page with 2 or more possible "states" eg business
part, private part or all parts, can you recommend a way to represent
the states via HTTP GET? Feasible way could be ?business=business, ?
type=business, ?business=true or others. Should I minimize casting the
variable? Which type should I reason, boolen or string? I now use
seemingly arbitrary ?t=w to represent a state which technically works
leaving a more readable and maintainable solution to wish.
Thanks
Niklas
 
H

Hidura

Be more specific but i recommend you, use a way in what you be very
explicit eg:part='bussiness' a bool for 3 options it's very diffcult
to handle.
 
M

MRAB

> Be more specific but i recommend you, use a way in what you be very
> explicit eg:part='bussiness' a bool for 3 options it's very diffcult
> to handle.
>
I agree. If there are several "states" then use something like
?part=business, ?part=private, etc. Use a Boolean only where there are
(and will only ever be) 2 possible states.
 
N

Niklas R

 > Be more specific but i recommend you, use a way in what you be very
 > explicit eg:part='bussiness' a bool for 3 options it's very diffcult
 > to handle.
 >
I agree. If there are several "states" then use something like
?part=business, ?part=private, etc. Use a Boolean only where there are
(and will only ever be) 2 possible states.

Good point especially since a boolean may expand to get used in three
ways for example a business web may have only 2 states, wanted and for
sale and then later upgrade also to more categories like for rent or
likewise where 3 states are need. Thank you for the replies making me
lean towards keeping what seems to be boolean states more like
ternaries and more flexible.
Niklas
 
J

John Nagle

Hello
Getting a web same page with 2 or more possible "states" eg business
part, private part or all parts, can you recommend a way to represent
the states via HTTP GET? Feasible way could be ?business=business, ?
type=business, ?business=true or others. Should I minimize casting the
variable? Which type should I reason, boolen or string? I now use
seemingly arbitrary ?t=w to represent a state which technically works
leaving a more readable and maintainable solution to wish.
Thanks
Niklas

First, bear in mind that every data value you get from a web
interface is a raw string of bytes. You have no assurance that it is
a "Boolean". You're not even sure it will convert to "str" or
"unicode". It may legitimately contain "%" type URL escapes.
(Even if you think you control the URL format, a proxy, URL
shorterner, or other intermediary may do some format conversion.)

If you want to pass a "boolean" variable, I'd suggest sending
"http://www.example.com&val=t". If you want to send False, omit
"val". On the read side, look for "val", and if the result
starts with "t" or "T", accept it as True. Otherwise, False.

John Nagle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top