Re: Pythonic SQL-Based Accounts System

2016-11-14 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Re: Pythonic SQL-Based Accounts System

No worries mate. Any problems please let me know.

URL: http://forum.audiogames.net/viewtopic.php?pid=285828#p285828





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Pythonic SQL-Based Accounts System

2016-11-13 Thread AudioGames . net Forum — Developers room : danny via Audiogames-reflector


  


Re: Pythonic SQL-Based Accounts System

I must say, this looks extremely prommissing and may end up replacing the account system in my current code, assuming I can get it to work, though it looks really simple to set up. I'll let you know if I get it working. Nice job on it.

URL: http://forum.audiogames.net/viewtopic.php?pid=285805#p285805





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Pythonic SQL-Based Accounts System

2016-11-13 Thread AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector


  


Pythonic SQL-Based Accounts System

Hi all,I've been reading these forums and I see a few bits about multiplayer games, so I thought I'd share something which I stripped out of an effort of my own.Basically I was writing a game server, when I realised many of the components were reusable, so while I considered how to precede I stripped the code down, and put the accounts system and the protocol into separate libraries, so others can hopefully benefit from them.What you end up with is a system-agnostic accounts system.sqlalchemy is used as a backend. You can use your existing engine if you're using sqlalchemy already - and in fact this is recommended - by passing it to the setup function:from sqlalchemy_accounts import setup

accounts = setup(engineengine)accounts pretends to be a module, and you can access it's methods:account = accounts.create_account(username='john', password='rubbish_password')
assert accounts.authenticate('john', 'rubbish_password') is account
account.lock('You are not welcome.')
assert accounts.authenticate(account.username, account.password) is NoneObviously this would be fairly useless if you couldn't add extra information, so (still using SQL), you can add dictionary-style attributes:account['email'] = 'j...@example.com'
assert account['email'] == 'j...@example.com'If anyone finds this useful and wants me to add in more functionality, please let me know.You can download it from:https://github.com/chrisnorman7/sqlalchemy_accountsI have just updated the code style so flakes8 doesn't throw a fit when it runs through it, so problems may be related to that. Either complain on here or submit an issue / pull request.Cheers, and I hope this helps someone.

URL: http://forum.audiogames.net/viewtopic.php?pid=285729#p285729





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector