Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StorageObj Python 3 implementation #218

Open
adrianespejo opened this issue Mar 18, 2019 · 0 comments
Open

StorageObj Python 3 implementation #218

adrianespejo opened this issue Mar 18, 2019 · 0 comments

Comments

@adrianespejo
Copy link
Collaborator

The current implementation of StorageObj is not efficient. In Python 3, we may change this to only have StorageDict as IStorage object, and a StorageObj would only be an element of the StorageDict.

class MailByUser(StorageDict[str,str]):
       pass

mbu = MailByUser('test.customers')
mbu['cugni'] = '[email protected]'

class Client(StorageObj):
    user_id: KEY(str)
    mail: str
    collection_name = 'test.customers'    # keyspace and table name
    # if collection_name is not set the table will be based on the name of the class

print(Client.repo['cugni'])    # prints Client("cugni","[email protected]")
# or
print(Client.find('cugni'))

pol = Client()
pol.user_id = 'pol'
pol.mail = '[email protected]'
pol.make_persistent()    # if type KEY is not set in Client a key can be specified here as a parameter
# or
Client.repo['pol'] = pol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant