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
Is there a terser way to get a reference to my DB than self.request.root.db?
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
  4 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
 
Zak  
View profile  
 More options Aug 11 2012, 2:03 am
From: Zak <zakdan...@gmail.com>
Date: Fri, 10 Aug 2012 23:03:24 -0700 (PDT)
Local: Sat, Aug 11 2012 2:03 am
Subject: Is there a terser way to get a reference to my DB than self.request.root.db?

self.request.root.db is quite a bit of dot notation and I'm wondering if
there is a shortcut or better way to get db.


 
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.
Malthe Borch  
View profile  
 More options Aug 11 2012, 3:08 am
From: Malthe Borch <mbo...@gmail.com>
Date: Sat, 11 Aug 2012 09:08:18 +0200
Local: Sat, Aug 11 2012 3:08 am
Subject: Re: Is there a terser way to get a reference to my DB than self.request.root.db?
You could write a base class that defined it as a `property`.

On 11 August 2012 08:03, Zak <zakdan...@gmail.com> wrote:


 
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.
Jonathan Vanasco  
View profile  
 More options Aug 11 2012, 5:07 pm
From: Jonathan Vanasco <jonat...@findmeon.com>
Date: Sat, 11 Aug 2012 14:07:34 -0700 (PDT)
Local: Sat, Aug 11 2012 5:07 pm
Subject: Re: Is there a terser way to get a reference to my DB than self.request.root.db?
storing the db connection somewhere under the active request is the
optimal thing to do -- it makes the db generally accessible throughout
the app.

there are some ways to make it easier to get to:
- if you use a class based approach to writing views, you could have a
base class that does much of the work
- you could write a helper function

class base_class(object):
    def dbSession(self):
        return self.request.root.db

def getDbSession(request=None):
    if not request:
       request= get_current_request():
    return request.root.db


 
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.
kusut  
View profile  
 More options Aug 12 2012, 12:10 am
From: kusut <tinoku...@gmail.com>
Date: Sun, 12 Aug 2012 11:10:59 +0700
Local: Sun, Aug 12 2012 12:10 am
Subject: Re: Is there a terser way to get a reference to my DB than self.request.root.db?
On 12 August 2012 04:07, Jonathan Vanasco <jonat...@findmeon.com> wrote:

> there are some ways to make it easier to get to:
> - if you use a class based approach to writing views, you could have a
> base class that does much of the work
> - you could write a helper function

- pyramid.config.Configurator.set_request_property [0]
- pyramid.request.Request.set_property [1]

[0] http://pyramid.readthedocs.org/en/latest/api/config.html#pyramid.conf...
[1] http://pyramid.readthedocs.org/en/latest/api/request.html#pyramid.req...

--
http://kusut.web.id


 
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 »