jeudi 30 juin 2016

Subordinate reference books in web dev

A web application needs subordinate reference books.

Example: 1) a customer 2) his/her bank accounts.

This is my first project. Pardon me if this is all clumsy.

In pseudocode:

Models

class Customer:
    id
    name

class BankAccount:
    customer = ForeignKey(Customer)
    account

For example, this is a completely new customer. S/he doesn't have an id yet.

Well, I don't know how to cope with this problem in web applications.

I'm going to use such url:

http://counterparts/4/accounts/create

Where 4 is counterpart's id. It is important for the user not to interfere with this id. I thought about several variants with signing the id:

  1. http://counterparts/4:dWvne64Iu-6mIdc7T6LRHE173AY/accounts/create Looks ugly.

  2. input type=hidden. But this will ruin the cache.

  3. http://counterparts/4/accounts/create + 4:dWvne64Iu-6mIdc7T6LRHE173AY in cookies. In this case 4 in the url is a bit redundant. I'm in favour of this variant and am going to return the user back to where he was if he interferes with this url.

The problem with all these methods is that I myself invented them. Well, I think this is a typical situation. Why should I reinvent the wheel if I'm that clumsy here.

Could you give me some piece of advice: what is the best practice of coping with such problems.




Aucun commentaire:

Enregistrer un commentaire