Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Pyramid Auth Demo with SQLAlchemy
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Christian Benke  
View profile  
 More options Sep 13 2012, 12:00 pm
From: Christian Benke <benkoka...@gmail.com>
Date: Thu, 13 Sep 2012 18:00:04 +0200
Local: Thurs, Sep 13 2012 12:00 pm
Subject: Pyramid Auth Demo with SQLAlchemy
Hello!

Based on http://michael.merickel.org/projects/pyramid_auth_demo/object_securit...
i've adapted the code of the demo to work with SQLAlchemy:
https://github.com/peletiah/pyramid_auth_demo_sqlalchemy

I'm new to Pyramid and although i've been scripting with Python for a
while, OO-programming is still confusing for me.
The code above works, but i have doubts if the way i implemented it is
reusable and scalable and if i did it in a "pythonic" way.

Here are some questions:

I have to fetch the "user"-object for a "login" so i've added the
function "get_user" after the User-class-definition in models.py(I use
this query in "login_view" in views.py and "groupfinder" in
security.py).
I did the same with the function "get_page" to fetch the "page"-object
for an "uri".

This doesn't seem to be very clean, having arbitrary functions lying
around in the models-Module. Is there a better place to put such a
function - or actually another way to do the login-checking?

Here are the links to the code i've mentioned:
https://github.com/peletiah/pyramid_auth_demo_sqlalchemy/blob/master/...
https://github.com/peletiah/pyramid_auth_demo_sqlalchemy/blob/master/...
https://github.com/peletiah/pyramid_auth_demo_sqlalchemy/blob/master/...

In "views.home_view" i check if the user is already logged in and
display information in "templates/home.mako" accordingly. Since a
query for .one() returns an exception if no match is found, i use
.first() instead, which returns None. Would it be "cleaner" to reuse
the "models.get_user"-Function again and then work with try/except to
return "None" when the user is not logged in?

https://github.com/peletiah/pyramid_auth_demo_sqlalchemy/blob/master/...
https://github.com/peletiah/pyramid_auth_demo_sqlalchemy/blob/master/...

There are some other queries in views(Which only occur once, but might
be reused multiple times in a larger project) - what is the general
rule of thumb - where do i put such queries to get a tidy codebase?

Thanks,
Christian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
William Chambers  
View profile  
 More options Sep 14 2012, 2:38 am
From: William Chambers <bioselem...@gmail.com>
Date: Thu, 13 Sep 2012 23:38:36 -0700 (PDT)
Local: Fri, Sep 14 2012 2:38 am
Subject: Re: Pyramid Auth Demo with SQLAlchemy

Hey Christian,

I suspect it could be cleaned up just a tad, but the amateur code in me
says that's about the same way I'd handle it. I've been toying with little
projects of my own for the past couple years, wanting to put together a set
of lego blocks for applications to use. Any chance you'd be interested in
talking ( gtalk perhaps) and maybe seeing if we could team up on something?

William


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »