Skip to content
This repository has been archived by the owner on Jul 20, 2018. It is now read-only.

Some architecture questions #15

Open
uhbif19 opened this issue Apr 5, 2011 · 2 comments
Open

Some architecture questions #15

uhbif19 opened this issue Apr 5, 2011 · 2 comments

Comments

@uhbif19
Copy link

uhbif19 commented Apr 5, 2011

I was looking at redisco models code, to adapt my patch to Models. I become many questions about its architecture.

What is doing Manager class ? It is just a alias to ModelSet ?

What is doing key.py, validation.py, utils.py ?

For what is need ModelBase ? Why ModelBase init was splited to many functions ? Why not methods ?

Uhm. Thanks :)

@iamteem
Copy link
Owner

iamteem commented Apr 6, 2011

Hi!

When queries are made through a class, a Manager is the one that handles that query. It allows for chaining several methods to a single ModelSet - this will give you some kindDSL. This was the plan, but I don't think it's finished.

The key class is for generating the keys to be used when storing stuff in Redis.
Example:

k = Key('Person')
k['1']['name'] # => 'Person:1:name'

Validation is supposed to handle validations - but I think I baked it in somewhere in the attributes.py - I opted to follow how appengine does it, passing validator functions when defining attributes to a model.

utils.py should contain just a bunch of helper functions. _encode_key encodes strings to base64. Strings that are stored in keys are base64 encoded.

ModelBase is the metaclass of the Model. I can't remember why I used functions :|

@uhbif19
Copy link
Author

uhbif19 commented Apr 6, 2011

When queries are made through a class, a Manager is the one that handles that query. > It allows for chaining several methods to a single ModelSet - this will give you some
kindDSL. This was the plan, but I don't think it's finished.

If object is field (not method) it means that object is constant at every call. In a reality every object geting prodce new ModelSet instance.

IMHO SQLAlchemy-style will be more clear and simple.

Ex:

m = Model()

m.query() # is ModelSet

example patch: https://github.com/uhbif19/redisco/commit/612682efe09e7c7b2566100c612404d3fb5808dc

That are you thinking about it ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants