Re: Closures, Django Request Object, Django architecture

2009-08-25 Thread Dennis Fogg
and > it needs access to the session from the request object. > > You are correct in that what I really want is per thread architectural > hooks so I can store the request there. > Django does not provide these hooks (probably on purpose) so I'm > discouraged in using it. > > But, sessio

Re: Closures, Django Request Object, Django architecture

2009-08-25 Thread Dennis Fogg
I looked at my code based on your feedback. In this particular case, the code that needs the request is doing status notifications http://blog.ianbicking.org/web-application-patterns-status-notification.html and it needs access to the session from the request object. You are correct in that what

Re: Closures, Django Request Object, Django architecture

2009-08-25 Thread Matthias Kestenholz
inking that the django middleware will access the request object > and create a closure. > I think I can use a classmethod for the closure so I can access it > from anywhere. > This will create a new object for every request -- I'm assuming that > it will not impact > performance but I

Closures, Django Request Object, Django architecture

2009-08-25 Thread Dennis
I seem to need the Django HttpRequest object in functions that are called by view functions. I could pass the request, but I'm thinking of trying to create a closure in middleware so that I can access the request object (and maybe other objects) from anywhere. This seems like it's stretching

Re: Get current user outside a view / without an request object

2009-08-20 Thread Julienoune
Hello, I'have a little problem with this code?? when I'l trying to put : " def __init__(self, inputUser, *args, **kwargs):" I have the following error : __init__() takes at least 2 non-keyword arguments (1 given) So, I suppose I need to set the inputUser in a specific place, but I can' figure

Re: Get current user outside a view / without an request object

2009-08-06 Thread Julián C . Pérez
Bingo!!! :D I follow this: http://oebfare.com/blog/2008/feb/23/changing-modelchoicefield-queryset/ and now I'm happy with mi desired current user based queryset Thank you all! BTW, my form class finally looks like... --- class SendMessageForm(forms.Form): recipientUser =

Re: Get current user outside a view / without an request object

2009-08-06 Thread Paulo Almeida
But why don't you put: recipientUser = ShowValidContactList(currentUser=self.user) inside the __init__? - Paulo 2009/8/6 Julián C. Pérez > > Thanks for reply, Paulo > But if I... > --- > class SendMessageForm(forms.Form): > >recipientUser =

Re: Get current user outside a view / without an request object

2009-08-06 Thread Julián C . Pérez
Thanks for reply, Paulo But if I... --- class SendMessageForm(forms.Form): recipientUser = ShowValidContactList(currentUser=self.user, label=u'Send to') messageSubject= forms.CharField(label=u'Subject') messageContent = forms.CharField(label=u'Content',

Re: Get current user outside a view / without an request object

2009-08-06 Thread Paulo Almeida
It doesn't have to be a callable, you can just do something like: recipientUser = ShowValidContactList(currentUser=self.currentUser) I never used that kwargs.pop function (I didn't know you could do that), but I have code like this: class ExperimentForm(ModelForm): """ Generate form to

Re: Get current user outside a view / without an request object

2009-08-06 Thread Julián C . Pérez
My real problem it that the field should looks like: --- recipientUser = ShowValidContactList(currentUser=_something_, label=u'Send to') --- and if I have a form's init method like... --- def __init__(self, *args, **kwargs): self.currentUser = kwargs.pop('currentUser', None)

Re: Get current user outside a view / without an request object

2009-08-06 Thread Daniel Roseman
On Aug 6, 3:34 pm, Julián C. Pérez wrote: > Hi > I tried doing that... > But it does not work > For example, if I do something like... > --- > class SendMessageForm(forms.Form): >         recipientUser = ShowValidContactList(label=u'Send to') >         messageSubject=

Re: Get current user outside a view / without an request object

2009-08-06 Thread Julián C . Pérez
Hi I tried doing that... But it does not work For example, if I do something like... --- class SendMessageForm(forms.Form): recipientUser = ShowValidContactList(label=u'Send to') messageSubject= forms.CharField(label=u'Subject') messageContent = forms.CharField

Re: Get current user outside a view / without an request object

2009-08-06 Thread krylatij
> ..go back and read the original poster's > message. Having the user in threadlocals doesn't solve any problem, > since he's trying to create a form class based on information in the > request and that only happens at import time, not every time something > in the file is looked at. Yes, my

Re: Get current user outside a view / without an request object

2009-08-06 Thread Malcolm Tredinnick
On Thu, 2009-08-06 at 03:33 -0700, krylatij wrote: > Why do you think so? It's bad encapsulation practice, for a start. It breaks Python's namespacing habits. In this particular case, however, go back and read the original poster's message. Having the user in threadlocals doesn't solve any

Re: Get current user outside a view / without an request object

2009-08-06 Thread krylatij
Why do you think so? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to

Re: Get current user outside a view / without an request object

2009-08-06 Thread Daniel Roseman
On Aug 6, 9:14 am, krylatij <kryla...@gmail.com> wrote: > You can also use threadlocals middleware (ask google about it =)) > to get current user without request object No, really, don't. Just don't. -- DR. --~--~-~--~~~---~--~~ You received this mes

Re: Get current user outside a view / without an request object

2009-08-06 Thread krylatij
You can also use threadlocals middleware (ask google about it =)) to get current user without request object --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Get current user outside a view / without an request object

2009-08-06 Thread Daniel Roseman
On Aug 6, 2:24 am, Julián C. Pérez wrote: > Hi everyone > I'm in trouble because of a form class > I have a form class with attributes defined, but with one thing: > One of the attributes requires the current user, or al least its > username > > The form definition in as shown

Get current user outside a view / without an request object

2009-08-05 Thread Julián C . Pérez
Hi everyone I'm in trouble because of a form class I have a form class with attributes defined, but with one thing: One of the attributes requires the current user, or al least its username The form definition in as shown below: --- class SendMessageForm(forms.Form): recipientUser =

Re: HOW DO YOU ACCESS SESSION AND COOKIES DATA W/O USING THE REQUEST OBJECT ?

2009-06-02 Thread Rami
o from a py > > function that does not have 'request' object. > > You could write up something similar to get_language() in > utils.translation or use threadlocals. I don't know if this is > actually a good idea. --~--~-~--~~~---~--~~ You receiv

Re: HOW DO YOU ACCESS SESSION AND COOKIES DATA W/O USING THE REQUEST OBJECT ?

2009-06-02 Thread akaariai
On 1 kesä, 22:38, Rami <rrr...@gmail.com> wrote: > I'm trying to access Session's (logged in) user id info from a py > function that does not have 'request' object. You could write up something similar to get_language() in utils.translation or use threadlocals. I don't know if this

Re: HOW DO YOU ACCESS SESSION AND COOKIES DATA W/O USING THE REQUEST OBJECT ?

2009-06-01 Thread Alex Gaynor
On Mon, Jun 1, 2009 at 2:38 PM, Rami <rrr...@gmail.com> wrote: > > I'm trying to access Session's (logged in) user id info from a py > function that does not have 'request' object. I can't find an obvious > way to access the session or the cookie data NOT through an >

HOW DO YOU ACCESS SESSION AND COOKIES DATA W/O USING THE REQUEST OBJECT ?

2009-06-01 Thread Rami
I'm trying to access Session's (logged in) user id info from a py function that does not have 'request' object. I can't find an obvious way to access the session or the cookie data NOT through an instantiated request (HttpRequest) obj [the same way for example you can access any Session

Re: request object in custom template filter code?

2009-03-25 Thread Malcolm Tredinnick
On Wed, 2009-03-25 at 05:23 -0700, foxbunny wrote: > I am trying to write a custom template filter which takes a variable > which is a model object and grabs fields from a related object based > on request.session['lang'] parameter. Or it would if I knew how to get > the `lang` parameter from

Re: request object in custom template filter code?

2009-03-25 Thread foxbunny
I forgot to mention I'm on django-trunk rev. 10163. Branko --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe

request object in custom template filter code?

2009-03-25 Thread foxbunny
/18914/ line 35, `fieldlang = request.sessions.get` obviously doesn't work because request object doesn't exist in the scope. How can I access it? TIA Branko --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "D

Re: request object needed in form methods

2009-03-19 Thread Thomas Guettler
>> Why not store the request >> object (in a thread safe way) on module level? ... > The biggest con is encourages bad design practices, the way Python works is > you have a global and local scope, if you want something in your local scope > you pass it to it. > >

Re: request object needed in form methods

2009-03-19 Thread Daniel Roseman
On Mar 19, 1:22 pm, Thomas Guettler <h...@tbz-pariv.de> wrote: > Hi, > > I know that you can pass the request object to form like this: > > class MyForm(forms.Form): >     def __init__(self, request, *args, **kwargs): >         self.request=request >         f

Re: request object needed in form methods

2009-03-19 Thread Alex Gaynor
On Thu, Mar 19, 2009 at 9:22 AM, Thomas Guettler <h...@tbz-pariv.de> wrote: > > Hi, > > I know that you can pass the request object to form like this: > > class MyForm(forms.Form): >def __init__(self, request, *args, **kwargs): >self.request=request >

request object needed in form methods

2009-03-19 Thread Thomas Guettler
Hi, I know that you can pass the request object to form like this: class MyForm(forms.Form): def __init__(self, request, *args, **kwargs): self.request=request forms.Form.__init__(self, *args, **kwargs) Somehow I am tired of rewriting this. Why not store the request object

Re: Can I get the request object into the django.contrib.auth.views.password_change view template?

2009-01-20 Thread Hans Fangohr
Hi Malcolm, On 20 Jan 2009, at 02:33, Malcolm Tredinnick wrote: > > On Tue, 2009-01-20 at 02:07 +, Hans Fangohr wrote: > [...] >> However, in the template files, I extend my base.html which makes use >> of the request object (basically checking whether the request ha

Re: Can I get the request object into the django.contrib.auth.views.password_change view template?

2009-01-19 Thread Malcolm Tredinnick
On Tue, 2009-01-20 at 02:07 +, Hans Fangohr wrote: [...] > However, in the template files, I extend my base.html which makes use > of the request object (basically checking whether the request has as > authenticated used and changing the html depending on this). >

Can I get the request object into the django.contrib.auth.views.password_change view template?

2009-01-19 Thread Hans Fangohr
of the request object (basically checking whether the request has as authenticated used and changing the html depending on this). It appears that the request object is not available in registration/ password_change_form.html when called from the view django.contrib.auth.views.password_change. Here

Re: Request object from models

2008-11-21 Thread barbara shaurette
Yeah, you want to assign that user_id value in the view, when you're saving the instance: mydocument.author_id = request.user.id mydocument.save() Are you trying to solve for a case where you want the current *admin* user to be the author_id for the record? You can also add a save

Re: Request object from models

2008-11-21 Thread Steve Holden
> > Hi there, > > I'm trying to set up a default value the author field in the model > above as the current user as the default value. > Is there any way to access the request object from here? > The fact that you say "current user" implies that instances of the mo

Re: Request object from models

2008-11-21 Thread Alex Koshelev
No. Request object does not exist when model classes are created. On Fri, Nov 21, 2008 at 13:47, FT <[EMAIL PROTECTED]> wrote: > > class Document(models.Model): > >created = models.DateTimeField( >help_text='Timestamp when the document is created', > blan

Request object from models

2008-11-21 Thread FT
the author field in the model above as the current user as the default value. Is there any way to access the request object from here? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" grou

Re: How to access the request object in a decorator

2008-11-17 Thread TH
nd this is obviously what you want: > > def anonymous_only(view): >   # 'view' is the view function to decorate >   # since we decorate views, we know the first parameter >   # is always going to be the current request >   # >   # '_wrapper' is th

Re: How to access the request object in a decorator

2008-11-17 Thread bruno desthuilliers
that will be used instead # of 'view'. def _wrapper(request, *args, **kw): # here we can access the request object and # either redirect or call 'view' if request.user.is_authenticated(): return HttpResponseRedirect('/page_for_logged_in_user') return view(request, *args, **kw)

Re: How to access the request object in a decorator

2008-11-17 Thread Jarek Zgoda
Wiadomość napisana w dniu 2008-11-17, o godz. 10:02, przez TH: > I wanted to redirect a logged in user if he access certain page. For > example i do not want the user to access registration page if he is > logged in. > > A simple way to do this is: > > def register(request): >if

How to access the request object in a decorator

2008-11-17 Thread TH
Hello, I wanted to redirect a logged in user if he access certain page. For example i do not want the user to access registration page if he is logged in. A simple way to do this is: def register(request): if request.user.is_authenticated(): return HttpResponseRedirect('/

Re: Request object in template HTML

2008-07-15 Thread Eric Abrahamsen
On Jul 15, 2008, at 9:55 PM, Nazmi ZORLU wrote: > Hi, > > I wonder if I can access request object in html template or absolute > page url that currently rendering. If you're not using generic views, you can pass "context_instance=RequestContext(request)&quo

Request object in template HTML

2008-07-15 Thread Nazmi ZORLU
Hi, I wonder if I can access request object in html template or absolute page url that currently rendering. Thanks, Nazmi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" grou

Creating a request object + middleware benefits

2008-05-29 Thread Peter
I'm looking for a quick and simple way to create a request object - as it would be received by a specific view - for some very basic testing. Additionally, I want this object to have all the added attributes from the middleware modules e.g. request.user. I tried this: (1) I looked

Re: "request"object within models.py

2008-05-19 Thread Richard Dahl
James, Thanks, this is great. I never made this connection before. I have been using threadlocals for a while (to implement a custom manager with role-based access). Since the start I have been passing a users role as a kw argument in to the Manager via the shell for testing, and until

Re: "request"object within models.py

2008-05-19 Thread James Bennett
On Mon, May 19, 2008 at 4:10 PM, Tim Chase <[EMAIL PROTECTED]> wrote: > It's the last bit that can throw folks...many folks seem to use > very nice/helpful bits of the framework that abstract the save() > call so it's never thought-about. Wouldn't adding a parameter to > save() stymie the admin

Re: "request"object within models.py

2008-05-19 Thread Tim Chase
>> how do you pass the request object to models? > > Same way you pass any argument to any function or method in > Python: write your function/method to accept the argument, and > pass it from the code that calls the function/method. It's the last bit that can throw folks

Re: "request"object within models.py

2008-05-19 Thread enri57ar
On May 19, 5:35 pm, "Richard Dahl" <[EMAIL PROTECTED]> wrote: > http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser > -richard > Thanks!, it works --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django

Re: "request"object within models.py

2008-05-19 Thread James Bennett
On Mon, May 19, 2008 at 3:45 PM, Richard Dahl <[EMAIL PROTECTED]> wrote: > how do you pass the request object to models? Same way you pass any argument to any function or method in Python: write your function/method to accept the argument, and pass it from the code that calls the functi

Re: "request"object within models.py

2008-05-19 Thread Richard Dahl
how do you pass the request object to models? -richard On 5/19/08, James Bennett <[EMAIL PROTECTED]> wrote: > > > On Mon, May 19, 2008 at 3:24 PM, enri57ar <[EMAIL PROTECTED]> wrote: > > How access to request object within models ? > > Pass it as an argument the

Re: "request"object within models.py

2008-05-19 Thread James Bennett
On Mon, May 19, 2008 at 3:24 PM, enri57ar <[EMAIL PROTECTED]> wrote: > How access to request object within models ? Pass it as an argument the same as any other value. Magical hacks to try to make it available otherwise are likely to land you in trouble later on. -- "Bureaucr

Re: "request"object within models.py

2008-05-19 Thread Richard Dahl
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser -richard On 5/19/08, enri57ar <[EMAIL PROTECTED]> wrote: > > > How access to request object within models ? > > > from django.contrib.auth.models import User > > Class Message(models.Model): &

"request"object within models.py

2008-05-19 Thread enri57ar
How access to request object within models ? from django.contrib.auth.models import User Class Message(models.Model): message = ... user_id = models.ForeignKey(User) def save(self): user_id = request.user.id # doesn't work super(Mensaje, self).save

Re: Handle on request object from custom tag

2008-05-10 Thread T.garzon
roups.com Para: Django users <django-users@googlegroups.com> Asunto: Re: Handle on request object from custom tag Fecha: 10/05/08 06:27 > > > That did it -- thanks. > > On May 9, 10:41 pm, James Bennett [EMAIL PROTECTED] wrote: > On Fri, May 9, 2008 at 10:11 PM, Greg Fuller [EM

Re: Handle on request object from custom tag

2008-05-09 Thread Greg Fuller
That did it -- thanks. On May 9, 10:41 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Fri, May 9, 2008 at 10:11 PM, Greg Fuller <[EMAIL PROTECTED]> wrote: > > How do I get a handle on the request object from within a custom > > template tag

Re: Handle on request object from custom tag

2008-05-09 Thread James Bennett
On Fri, May 9, 2008 at 10:11 PM, Greg Fuller <[EMAIL PROTECTED]> wrote: > How do I get a handle on the request object from within a custom > template tag? By making the request available to the template as a context variable, then accessing it the same as any other cont

Handle on request object from custom tag

2008-05-09 Thread Greg Fuller
I searched for solutions/examples with no luck, but this can't be that hard. How do I get a handle on the request object from within a custom template tag? Thanks --- Greg F --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: Accessing request object in templates

2008-01-04 Thread annacoder
On Jan 4, 7:34 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-01-03 at 23:10 +0530, venkata subramanian wrote: > > Hi, > > I had a problem recently. > > To access the request object in all of my templates. > > The solution I got surprised m

Re: Accessing request object in templates

2008-01-04 Thread annacoder
> But, my question was not related to the how part. > > Here's a quick rundown of the "why". > > Templates aren't triggered by HTTP requests like views are. Instead, > they're rendered inside views, which *are* triggered by HTTP requests. > Since the request triggers

Re: Accessing request object in templates

2008-01-03 Thread Malcolm Tredinnick
On Thu, 2008-01-03 at 23:10 +0530, venkata subramanian wrote: > Hi, > I had a problem recently. > To access the request object in all of my templates. > The solution I got surprised me. It involved explicitly passing on > the request object from the views. >

Re: Accessing request object in templates

2008-01-03 Thread Marty Alchin
rendered inside views, which *are* triggered by HTTP requests. Since the request triggers the view, it makes sense for the view to receive the request object. Since templates are rendered by views, it makes sense for templates to receive whatever the view sends them, and nothing more. This is a design

Re: Accessing request object in templates

2008-01-03 Thread annacoder
I understand *how* it is done. But, my question was not related to the how part. On Jan 4, 12:17 am, Ariel Calzada <[EMAIL PROTECTED]> wrote: > venkata subramanian wrote: > > Hi, > > I had a problem recently. > > To access the request object in all of my templat

Re: Accessing request object in templates

2008-01-03 Thread annacoder
gt; > <[EMAIL PROTECTED]> wrote: > > Hi, > > I had a problem recently. > > To access the request object in all of my templates. > > The solution I got surprised me. It involved explicitly passing on > > the request object from the views. > > (Example, to pa

Re: Accessing request object in templates

2008-01-03 Thread Ariel Calzada
venkata subramanian wrote: > Hi, > I had a problem recently. > To access the request object in all of my templates. > The solution I got surprised me. It involved explicitly passing on > the request object from the views. > (Example, to pass a RequestContext object as

Re: Accessing request object in templates

2008-01-03 Thread Alex Koshelev
PROTECTED]> wrote: > Hi, > I had a problem recently. > To access the request object in all of my templates. > The solution I got surprised me. It involved explicitly passing on > the request object from the views. > (Example, to pass a RequestContext object as a context_insta

Re: Accessing request object in templates

2008-01-03 Thread Sam Lai
Security maybe? Not sure, but if you add django.core.context_processors.request to your TEMPLATE_CONTEXT_PROCESSORS list in settings.py, you won't have to explicitly add the request object in every view. You still have to pass a RequestContext object to the render_to_response method, but you

Accessing request object in templates

2008-01-03 Thread venkata subramanian
Hi, I had a problem recently. To access the request object in all of my templates. The solution I got surprised me. It involved explicitly passing on the request object from the views. (Example, to pass a RequestContext object as a context_instance parameter in render_to_response method

Re: Changing site theme based on request object

2007-10-08 Thread tim_perrett
Hey Guys Thanks for your great responses up to now - most interesting. Ive been reading the documentation and thats been pretty useful (surprise surprise!), but i have another question... As the kind of per site skinning falls in line with some of the ideas of the Django site object, it makes

Re: Changing site theme based on request object

2007-10-06 Thread Malcolm Tredinnick
On Sat, 2007-10-06 at 19:08 +, tim_perrett wrote: > Thanks for the speedy reply Malcom... > > Ive taken a look at loaders.py in the latest trunk... I see what you > mean; pretty interesting. I could just write my own loader, import any > classes I needed to use (like the

Re: Changing site theme based on request object

2007-10-06 Thread tim_perrett
Thanks for the speedy reply Malcom... Ive taken a look at loaders.py in the latest trunk... I see what you mean; pretty interesting. I could just write my own loader, import any classes I needed to use (like the django.http.HttpRequest so I can use get_host()) and even use the ORM in the

Re: Changing site theme based on request object

2007-10-06 Thread Malcolm Tredinnick
t() -- which is also available as the get_host() method on the request object in recent Django code (that was added in [6166]). > > I would then somehow need to change the template path, and this is > where my understanding drops off I found this post > http://www.nabble.com/How-to-p

Changing site theme based on request object

2007-10-06 Thread tim_perrett
-a-template-based-on-the-request-object--tf4153180.html#a11822505 but am not sure how i would or could go about building a custom template loader? Also, would there be any scope for checking in the database what theme a particular host name would recive? I am not new to web dev, but am new to python

Re: Access the request object in a filter?

2007-08-09 Thread Collin Grady
{% if item|in_cart:request %} --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to

Access the request object in a filter?

2007-08-09 Thread [EMAIL PROTECTED]
art from this bit. I know that I can make a template tag that has access to the request object (added by the Context Processors), but am a bit stuck as to how to do this in a filter. Ideally I would like to do something like: {% if item|in_cart %}foo{% else %}bar{% endif %} So, all I really need to

Re: How to pick a template based on the request object?

2007-07-26 Thread [EMAIL PROTECTED]
ke to > pick a template based on the request object. That's easy as long as I > implement the views using something similar to the utility function > render_and_response() which knows to add a template folder to the > template name based on the request object. > > However, I'd like to a

Re: How to pick a template based on the request object?

2007-07-26 Thread Doug B
Using threadlocals and a custom template loader would probably work, just put your loader first in settings.py. http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: request object out of a view (I need to access session['data'])

2007-04-04 Thread Adrian Ribao
n > links he pointed to? They detail how you get the request object accessible > in your templates, and thus your custom template tag.) > > In order to get access to the request object in your custom template tag, > you must make some code changes elsewhe

Re: request object out of a view (I need to access session['data'])

2007-04-03 Thread Karen Tracey
I'll try to elaborate what James said. (Did you consult the documentation links he pointed to? They detail how you get the request object accessible in your templates, and thus your custom template tag.) In order to get access to the request object in your custom template tag, you must make

Re: request object out of a view (I need to access session['data'])

2007-04-03 Thread Grupo Django
I don't know if I didn't understand you or if I you didn't don't understand me :-) Not sure abou what you are saying, I think I can't use it to make the template tag work. The template tag doesn't use a view to render the content, so it doesn't get the request object as a parameter

Re: request object out of a view (I need to access session['data'])

2007-04-03 Thread James Bennett
On 4/3/07, Grupo Django <[EMAIL PROTECTED]> wrote: > Inside the custom template tag, I don't get the request object since > it's not a view. Look into using RequestContext[1] in your views (generic views all use it automatically), and enabling the "request" context proces

request object out of a view (I need to access session['data'])

2007-04-03 Thread Grupo Django
get the request object since it's not a view. I have no idea about how to retrieve the data. And a secondary question related to this. If I wanted to retrieve a value by GET within the template tag. Is it possible to access it? Thank you very much

Re: Retrieve `request` object in `urls.py`?

2007-03-25 Thread Alex Dong
quick reply. > > > What I'm wondering about is that I've seen the pattern repeat itself > > quite a few times where I have to write a little wrapper doing nothing > > more than retrieving something from the `request` object. > > Like > > * reques

Re: Retrieve `request` object in `urls.py`?

2007-03-25 Thread Malcolm Tredinnick
was doing at all. I'm not really sure what answer you are expecting here. You have to extract the user information at view processing time -- it can't be done any earlier because that is the only time you have the accurate request object. So you need to have views. Small functions that d

Re: Retrieve `request` object in `urls.py`?

2007-03-25 Thread Alex Dong
Hi Malcolm, Thanks for the quick reply. What I'm wondering about is that I've seen the pattern repeat itself quite a few times where I have to write a little wrapper doing nothing more than retrieving something from the `request` object. Like * request.user.get_home_url

Re: Retrieve `request` object in `urls.py`?

2007-03-25 Thread Malcolm Tredinnick
t; > I'm wondering how can I eliminate the need for the > `redirect_to_personalized_watch_list` and use django's `redirect_to` > generic view? It'll be much easier if I could get `request` object in > the `urls.py`. You can't do this directly because of the different scopes the lines of code are executed in. Any

Retrieve `request` object in `urls.py`?

2007-03-25 Thread Alex Dong
`request` object in the `urls.py`. Thanks, Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from

Re: ManyToManyField, limit_choices_to and properties of the request object

2007-03-19 Thread quentinsf
Brilliant - thanks, Sam. Is this in the docs anywhere, I wonder? I've seen a few queries along these lines. Might be an FAQ Q --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to

Re: ManyToManyField, limit_choices_to and properties of the request object

2007-03-19 Thread Sam Morris
On Mon, 19 Mar 2007 09:29:08 -0700, quentinsf wrote: > I need to do something similar. In a form I want to limit the options > in a ForeignKey's pull-down select field to objects owned by an > organisation of which the user is a member. > > I've been trying to work out where this would fit.

Re: ManyToManyField, limit_choices_to and properties of the request object

2007-03-19 Thread quentinsf
I need to do something similar. In a form I want to limit the options in a ForeignKey's pull-down select field to objects owned by an organisation of which the user is a member. I've been trying to work out where this would fit. Any help much appreciated.

ManyToManyField, limit_choices_to and properties of the request object

2007-03-19 Thread Sam Morris
Is it possible to use a ManyToManyField's limit_choices_to attribute to limit a user to picking only from related objects that have author = request.user? Given that request has no place in the model definition, would it be necessary to write a custom manipulator? -- Sam Morris

Re: Accessing the current request object in a template loader

2006-12-17 Thread Graham Dumpleton
kahless wrote: > hi, > i want to make a simple template loader which loads from directories > depending on the sub-site the user requests a page from. (or probably > also from the user session - which theme he has set, etc.) > > so i would need to get the current request object

Accessing the current request object in a template loader

2006-12-17 Thread kahless
hi, i want to make a simple template loader which loads from directories depending on the sub-site the user requests a page from. (or probably also from the user session - which theme he has set, etc.) so i would need to get the current request object but haven't found a solution

Re: Re: Can I pass a Request object within "extra_context" of a Generic View.

2006-11-02 Thread James Bennett
On 11/2/06, Merric Mercer <[EMAIL PROTECTED]> wrote: > That looks like a very good way. Many thanks. For the sake of > completeness - does that mean my earlier example wouldn't work? Or is > just not preferred? It could work provided the code in the 'test' view returns the appropriate value,

Re: Can I pass a Request object within "extra_context" of a Generic View.

2006-11-02 Thread Merric Mercer
as Django seems to have many different ways to achieve a particular task. Cheers MerMer James Bennett wrote: > On 11/2/06, Merric Mercer <[EMAIL PROTECTED]> wrote: > >> Assuming I have a generic view. Can I used the "extra_context" >> parameter to pass a requ

Re: Can I pass a Request object within "extra_context" of a Generic View.

2006-11-02 Thread James Bennett
On 11/2/06, Merric Mercer <[EMAIL PROTECTED]> wrote: > Assuming I have a generic view. Can I used the "extra_context" > parameter to pass a request object to a function elsewhere or resolve > request.path directly? Why not use RequestContext instead of Context, and ena

Can I pass a Request object within "extra_context" of a Generic View.

2006-11-02 Thread Merric Mercer
Assuming I have a generic view. Can I used the "extra_context" parameter to pass a request object to a function elsewhere or resolve request.path directly? Example of what I am trying to do is below:- from django.http import HttpResponse, HttpRequest from jmyapp.blog.views i

Request object

2006-08-23 Thread victor
Hello, I'm a Java programmer and new to the world of Python and Django. Because of this, I could be missing something obvious trying to access the request object from file urls.py in my project. Is it possible? Where does the request object defined in the views as a parameter come from? Thank

Re: Access request object in model's hooks and display methods

2005-11-17 Thread Ian Holsman
couldn't we do something similar to get_active_site() call on the sites table? that way people who need the 'request' object could just call it and it wouldn't impact the api of anything else? On 11/18/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote: > > On 11/17/05, plisk <[

Re: Access request object in model's hooks and display methods

2005-11-17 Thread Adrian Holovaty
On 11/17/05, plisk <[EMAIL PROTECTED]> wrote: > Seems like its not possible to access request object in hooks like > pre_save and display methods(those are listed in list_display) ? Is it > supposed to be like this by design ? If so then hardly its very > convinient to use in

Re: Access request object in model's hooks and display methods

2005-11-17 Thread plisk
limodou wrote: > 2005/11/17, plisk <[EMAIL PROTECTED]>: > > > > Hi there. > > > > Seems like its not possible to access request object in hooks like > > pre_save and display methods(those are listed in list_display) ? Is it > > supposed to be lik

<    1   2   3   >