New User() function

7 views
Skip to first unread message

Nicolas Pinault

unread,
Feb 11, 2012, 4:41:23 PM2/11/12
to karr...@googlegroups.com
Bonsoir Pierre,

I have added a new function User() to Karrigell 4.3.6. With this
function one can get the name of the user who is currently logged in. I
use this to know who makes modification in the data of the web site.

Here are my modifications :
1) Add the folowing to SQLiteUsersDb class in admin_db.py

def get_user(self,**kw):
"""Return the role of user with session key skey"""
conn = sqlite3.connect(self.path)
cursor = conn.cursor()
args = []
for key in kw.keys():
value = kw[key]
if key=='password':
_hash = hashlib.md5()
_hash.update(value.encode('utf-8'))
value = _hash.digest()
args.append(value)
clause = ' AND '.join(key+'=?' for key in kw.keys())
cursor.execute('SELECT login FROM users WHERE '+clause,args)
result = cursor.fetchall()
if not result:
return None
else:
return result[0][0]

2) Add the following to RequestHandle class in Karrigell.py :

def user(self):
if self.users_db is None:
return None
if not self.skey_cookie in self.cookies:
return False
skey = self.cookies[self.skey_cookie].value
return self.users_db.get_user(skey=skey)

3) Add the following to self.namespace dict in run() method in
RequestHandler class (Karrigell.py) :

'User':self.user,

That's it.

Please add this to Karrigell 4.3.7 (after a check of course).

Cordialement,
Nicolas

Pierre Quentel

unread,
Feb 13, 2012, 9:37:57 AM2/13/12
to karrigell
Bonjour Nicolas,

Les grands esprits se rencontrent ;-) The last patch I wrote on
version 4.3.6 was exactly on this topic, and with almost the same
implementation as yours ! I had not commited it yet, I'm going to do
it in a minute

By the way, no activity on the mailing list or SVN doesn't mean I'm
not busy on Karrigell : I'm working on a FTP-like program and a forum.
More on this later

Cordialement,
Pierre

Nicolas Pinault

unread,
Feb 13, 2012, 4:55:47 PM2/13/12
to karr...@googlegroups.com
Bonsoir Pierre,

> Bonjour Nicolas,
>
> Les grands esprits se rencontrent ;-) The last patch I wrote on
> version 4.3.6 was exactly on this topic, and with almost the same
> implementation as yours ! I had not commited it yet, I'm going to do
> it in a minute
Great ! It works.

>
> By the way, no activity on the mailing list or SVN doesn't mean I'm
> not busy on Karrigell : I'm working on a FTP-like program and a forum.
Cool.
> More on this later
Pas trop tard quand m�me ;)


I have recently discovered Nagare (www.nagare.org), another french web
framework. The programming model is very interesting but the management
of the whole thing is complicated. Just for curiosity, I suggest you
take a look at it. And, who knows, maybe it will give you good ideas for
Karrigell...

Cordialement,
Nicolas
>
> Cordialement,
> Pierre

Pierre Quentel

unread,
Feb 14, 2012, 2:32:53 AM2/14/12
to karrigell
Nicolas,

I know Nagare a little because the author, Alain Poirier, lives in
Rennes like me, we've met a couple of times. The concept of
"continuation" is interesting but as you say it's not easy to
understand at first. He has the same approach as Karrigell for HTML :
building a DOM with built-in classes (he uses << where HTMLTags uses
<= ), without a templating system

The author of Nagare works for a local company, Net-ng, so the
framework is used in production for many sites

A+
Pierre

On 13 fév, 22:55, Nicolas Pinault <nico...@famillepinault.fr> wrote:
> Bonsoir Pierre,> Bonjour Nicolas,

Nicolas Pinault

unread,
Feb 20, 2012, 3:32:42 PM2/20/12
to karr...@googlegroups.com
Pierre,

> Nicolas,
>
> I know Nagare a little because the author, Alain Poirier, lives in
> Rennes like me, we've met a couple of times. The concept of
> "continuation" is interesting but as you say it's not easy to
> understand at first. He has the same approach as Karrigell for HTML :
> building a DOM with built-in classes (he uses<< where HTMLTags uses
> <= ), without a templating system

Cool !
So it will be easier for you to merge both frameworks to get best of both ;)


>
> The author of Nagare works for a local company, Net-ng, so the
> framework is used in production for many sites

I've tried it. This is why I know, it is complex to set up.
I like some of the concepts of Nagare. I don't like it's complexity.

Nicolas
>
> A+
> Pierre

Reply all
Reply to author
Forward
0 new messages