2

I'm developing a CLI for a web todolist service. I'm done with the backend and have just started to write the CLI functions. Before I start, I tought what the best way was to store user data. I'm using ConfigParser for storing user specified preferencies. These are stored in ~/.confrc.

The user data is in the form of Json. I'm using Python for my project. I'm getting these in the form of:

{"user_id": 1, "name": "Project_name", "color": "#ff8581", "collapsed": 0, "item_order": 1, "cache_count": 13, "indent": 1, "id": 455831}

Should I store this data to a configuration file, that will be proccessed via ConfigParser ? This may be good idea at first, but a project might have a name that is used by another project. Thus I can't store them via the RawConfigParser.set(). I could store them via the id, as they are unique, but than the conf file itself would be very clutter.

What would the best way to store a simple todolist user data ?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Fatih Arslan
  • 16,499
  • 9
  • 54
  • 55
  • 3
    `.confrc` is just about the worst name ever for a configuration file. Do you want one config file per user? Per project? Does the user need to be in a dir to use these files? – Fred Foo Dec 03 '10 at 14:52
  • 1
    Confrc is just an example, it's not the real filename. There will be one user and one single file. There are several projects that belongs to one user. I'm intending to have two files. One is used for app preferencies and one file to save data. The user can be anywhere, but the files are stored in the home dir. – Fatih Arslan Dec 03 '10 at 17:22

1 Answers1

5

If there is only one file to store, using ~/.${PROJECT}rc is a good idea, otherwise, use a separate directory ~/.${PROJECT}.

You could also refer to the XDG Base Directory Specification.

Ryan Li
  • 9,020
  • 7
  • 33
  • 62
  • This is a good simple suggestion. One extra safety tip: Remember to put appropriate version number information in the config files. This will allow you to have some flexibility to change config representations as the project evolves. – mjhm Dec 03 '10 at 15:39
  • Thanks for the link, I'll will examine it. – Fatih Arslan Dec 03 '10 at 17:25