Lazy Registration

3 views
Skip to first unread message

Matt Woolnough

unread,
Jan 24, 2010, 9:45:58 PM1/24/10
to pylons-discuss

Just wanting to get some ideas on how best to implement 'lazy
registration' using pylons. An example of this functionality is in
Amazon where a user can add items to their shopping cart without being
signed in.

Any ideas appreciated. - thanks.

Matthew

Jamie

unread,
Jan 25, 2010, 2:27:28 AM1/25/10
to pylons-discuss
That's a pretty broad application design question and with an answer
that isn't likely to be Pylons-specific. The easiest way would be to
just keep track of the cart items using a Beaker session.

Matt Woolnough

unread,
Jan 25, 2010, 3:57:01 AM1/25/10
to pylons-discuss
The answer doesn't need to be pylons specific. I just happen to be
using this framework, so this group seemed like a good place to start.

I'm looking to store info thats a bit more complex than just a item
number, so I'm considering storing temporary items created in guest
sessions in a table along with items saved in users sessions.

The temporary items would need to be flagged in someway in the DB &
cleaned out somehow....

Any thoughts?

Matthew

Wichert Akkerman

unread,
Jan 25, 2010, 4:36:22 AM1/25/10
to pylons-...@googlegroups.com
On 1/25/10 09:57 , Matt Woolnough wrote:
> The answer doesn't need to be pylons specific. I just happen to be
> using this framework, so this group seemed like a good place to start.
>
> I'm looking to store info thats a bit more complex than just a item
> number, so I'm considering storing temporary items created in guest
> sessions in a table along with items saved in users sessions.
>
> The temporary items would need to be flagged in someway in the DB&
> cleaned out somehow....
>
> Any thoughts?

Beaker sessions.

Wichert.

Jonathan Vanasco

unread,
Jan 25, 2010, 11:53:26 AM1/25/10
to pylons-discuss

On Jan 25, 4:36 am, Wichert Akkerman <wich...@wiggy.net> wrote:
> Beaker sessions.

either beaker sessions, or just use a beaker session id as the
shopping cart / user id

you could do a dbtable that has this:

table: cart
id bigserial primary key not null,
session_id char(32) unique ,
useraccount_id bigint references useraccount(id),

allow null in session_id and useraccount_id , so that session carts
can be merged into useraccount carts after registration, and vice-
versa.


DD

unread,
Jan 25, 2010, 11:59:40 AM1/25/10
to pylons-...@googlegroups.com
I use beaker sessions for something similar. Basically, i have sqlite
based session (so its there if my server restarts), and I serialize the
entire shopping cart object into the session.

Once a user logs in, the session object is converted to a 'real'
shopping cart which, in my case, is bound to the user_id.

Of course, the annoying part of this is that this session -> cart
conversion has to happen, but its not really that bad (i have a pretty
simple use case).
DD.

Matt Woolnough

unread,
Jan 26, 2010, 12:54:02 AM1/26/10
to pylons-discuss
Thanks guys for your input.

I found a couple of threads on stackoverflow on similar questions:

http://stackoverflow.com/questions/1969711/best-way-to-place-temporary-data-for-an-webapp
http://stackoverflow.com/questions/964476/store-in-session-data-vs-store-in-sql-database-for-temporary-data

Although it seems there will be a performance penalty for this type of
arrangement, I think I'll attempt to implement something like what
Jonathan suggests. Hopefully the decision doesn't turn out to be a
bad one... Oh well it's all just a learning experience eh?

cheers again

jgar...@jonathangardner.net

unread,
Jan 26, 2010, 3:35:53 AM1/26/10
to pylons-discuss
A better idea might be to map carts to sessions, and then sessions to
customers.

Each session has a cart. Each cart may belong to more than one
session.

A customer can identify with more than one session, although each
session can only identify with up to one customer.

This way, the customer can put stuff in their cart at home, go to
work, add some more stuff, and then come home, and have everything in
their cart. The customer has two active sessions because the browser
at work and the browser at home don't share cookies. Plus, your logs
will have a more realistic picture of what's really going on, since
each session maps to exactly one browser.

On Jan 25, 9:54 pm, Matt Woolnough <m...@woolnough.com.au> wrote:
> Thanks guys for your input.
>
> I found a couple of threads on stackoverflow on similar questions:
>

> http://stackoverflow.com/questions/1969711/best-way-to-place-temporar...http://stackoverflow.com/questions/964476/store-in-session-data-vs-st...

Matt Woolnough

unread,
Jan 27, 2010, 6:14:41 PM1/27/10
to pylons-discuss
Hi Jonathan,

Thanks for the suggestion, I just can't work out how I'd match up the
individual sessions to the same cart if the user is not signed in.

Am I missing something here?

Matthew

On Jan 26, 6:35 pm, "jgard...@jonathangardner.net"


<jgard...@jonathangardner.net> wrote:
> A better idea might be to map carts to sessions, and then sessions to
> customers.
>
> Each session has a cart. Each cart may belong to more than one
> session.
>
> A customer can identify with more than one session, although each
> session can only identify with up to one customer.
>
> This way, the customer can put stuff in their cart at home, go to
> work, add some more stuff, and then come home, and have everything in
> their cart. The customer has two active sessions because the browser
> at work and the browser at home don't share cookies. Plus, your logs
> will have a more realistic picture of what's really going on, since
> each session maps to exactly one browser.
>
> On Jan 25, 9:54 pm, Matt Woolnough <m...@woolnough.com.au> wrote:
>
>
>
> > Thanks guys for your input.
>
> > I found a couple of threads on stackoverflow on similar questions:
>

> >http://stackoverflow.com/questions/1969711/best-way-to-place-temporar......


>
> > Although it seems there will be a performance penalty for this type of
> > arrangement, I think I'll attempt to implement something like what
> > Jonathan suggests.  Hopefully the decision doesn't turn out to be a
> > bad one...  Oh well it's all just a learning experience eh?
>

> > cheers again- Hide quoted text -
>
> - Show quoted text -

alec....@clearlybusiness.com

unread,
Jan 27, 2010, 8:13:34 PM1/27/10
to pylons-...@googlegroups.com, pylons-discuss
When a user first visits the website, a cokie is set on that machine only  - anything you add to the beaker session  will stay in there, then when the user registers you can use the the data that was saved to the session before they registered.

I can't think of any way for a user to go to different sites and access the same cart unless they've signed in or have some sort of token that they provide from both sites (for a contrived example though, if a user went to the site at home and added items to a cart, then copied their cookie from teh home machine to another machine they would see the same card data)
--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.

Reply all
Reply to author
Forward
0 new messages