Friday, June 28, 2013

Re: standalone script to call a view

On Fri, Jun 28, 2013 at 7:12 AM, Sergiy Khohlov <skhohlov@gmail.com> wrote:
> View is used for serving web requests not for serving bash script . Ok
> you have called a view and receive a http page. Ia it expected result?
> I think more easy way is create a function which is be called by view and
> your script.

I don't really understand what you mean by "create a function which is
be called by view and your script." (Also, it's a python script not a
bash script.)

I understand how the views are normally used. In this case the view,
is normally called from a web page. It extracts data from the db and
downloads a CSV file. I want to do that same thing, except from a
script, not from the web page. Perhaps I have to go further down the
chain, and instead of calling the view, invoke what eventually gets
called. It's just that the view returns exactly what I need and if I
go any further down I'll have to duplicate some existing code, which
I'd rather not have to do.

> On Fri, Jun 28, 2013 at 3:41 PM, Larry Martell <larry.martell@gmail.com>
> wrote:
>>
>> I am trying to write a standalone script that calls one of my views. I
>> can call the view, but I'm having a problem with proving what it
>> wants. One of the things the view needs is request.user, and that
>> looks like this:
>>
>> (Pdb) type(request.user)
>> <class 'django.utils.functional.SimpleLazyObject'>
>> (Pdb) type(request)
>> <class 'django.core.handlers.wsgi.WSGIRequest'>
>>
>> I'm trying to create the objects it needs by instantiating WSGIRequest
>> and SimpleLazyObject, but I'm having issues proving what they need,
>> and I'm just going deeper and deeper down the rabbit hole. Maybe I'm
>> going about this the wrong way.
>>
>> Anyone ever done something like this and can give me some advise on
>> what the best way to achieve this is?
>>
>> Thanks!
>> -larry
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscribe@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment