Re: Dynamic page refreash

2011-08-02 Thread H . İbrahim Yılmaz
http://www.quackit.com/javascript/javascript_refresh_page.cfm

2011/8/2 lmcadory 

> I'm having this problem, my web design knowledge is limited and I'm
> having a hard time searching for the solution (if there is one)
>
> The problem is this:
>
> I have a view that counts the number of lines in a file. It then
> pushes that result to an html page. What I want it to do is when that
> line count changes when I press the refresh button on the browser it
> displays the new number. Right now I have to reload the server to
> display the results.
>
> I, if I'm asking the question correctly, is there a way I can tell the
> view to run again and republish the results?
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
http://www.arkeoloji.web.tr

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Dynamic page refreash

2011-08-02 Thread bruno desthuilliers
On 2 août, 21:43, lmcadory  wrote:
> I fixed it. I needed to remove --noreload

This doesn't fix anything - try to run it using anything but the test
server and you'll have the same problem (or even worse in a multi-
threading or multi-process environment).

You actually have to  move the first two lines :

  file = 'someFile.txt'
  infile = open(file, 'r')

within your view function.  Else the file is only opened when your
view module is imported, not when the view function is called.

Also, beware that if you don't use an absolute path for the file, it
will be looked for in the "current working directory" whatever it is
at that time (warning: the "current working directory" is NOT your
app's or project directory - it can be absolutely any possible
directory on your filesystem).

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Dynamic page refreash

2011-08-02 Thread dirleyrls
I think you should open, count the lines of and close the file inside
the view. The view code is executed once per request. I think that
somethink like this will solve your problems:

def test_results(request):
infile = open('someFile.txt', 'r')
# ... count the lines of the file
infile.close()
return render_to_response('results.html', {'results':f}



On 2 ago, 14:55, lmcadory  wrote:
> Here is my code, minus all the import statements.
>
> file = 'someFile.txt'
> infile = open(file, 'r')
>
> def test_results(request):
>       expectedResults = 10
>       lines = infile.readlines()
>       lineCount = len(lines)
>       if lineCount == expectedResults:
>             p = 'Passed'
>             return render_to_response('results.html', {'results':p}
>       else:
>             f = 'Fail'
>             return render_to_response('results.html', {'results':f}
>
> #HTML
> 
> 
> The test {{ results }}.
> 
> 

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Dynamic page refreash

2011-08-02 Thread lmcadory
I fixed it. I needed to remove --noreload

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/9bDXiW-7insJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Dynamic page refreash

2011-08-02 Thread lmcadory
There should be closing brackets on the ends of the 2
render_to_response statements.

On Aug 2, 1:55 pm, lmcadory  wrote:
> Here is my code, minus all the import statements.
>
> file = 'someFile.txt'
> infile = open(file, 'r')
>
> def test_results(request):
>       expectedResults = 10
>       lines = infile.readlines()
>       lineCount = len(lines)
>       if lineCount == expectedResults:
>             p = 'Passed'
>             return render_to_response('results.html', {'results':p}
>       else:
>             f = 'Fail'
>             return render_to_response('results.html', {'results':f}
>
> #HTML
> 
> 
> The test {{ results }}.
> 
> 

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Dynamic page refreash

2011-08-02 Thread lmcadory
Display the results.

On Aug 2, 1:37 pm, bruno desthuilliers 
wrote:
> On 2 août, 19:22, lmcadory  wrote:
>
> > I'm having this problem, my web design knowledge is limited and I'm
> > having a hard time searching for the solution (if there is one)
>
> > The problem is this:
>
> > I have a view that counts the number of lines in a file. It then
> > pushes that result to an html page.
>
> Uh ? What does that mean exactly ? (the "pushes that result to an html
> page" part)
>
> > What I want it to do is when that
> > line count changes when I press the refresh button on the browser it
> > displays the new number. Right now I have to reload the server to
> > display the results.
>
> You shouldn't, so chances are you did something wrong (like putting
> the code that computes the lines count at the module top-level or
> something alike), but it's hard to tell exactly without looking at
> your code.
>
>
>
> > I, if I'm asking the question correctly, is there a way I can tell the
> > view to run again and republish the results?
>
> The view function is called each time you reload the corresponding
> url.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Dynamic page refreash

2011-08-02 Thread lmcadory
Here is my code, minus all the import statements.

file = 'someFile.txt'
infile = open(file, 'r')

def test_results(request):
  expectedResults = 10
  lines = infile.readlines()
  lineCount = len(lines)
  if lineCount == expectedResults:
p = 'Passed'
return render_to_response('results.html', {'results':p}
  else:
f = 'Fail'
return render_to_response('results.html', {'results':f}



#HTML


The test {{ results }}.



-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Dynamic page refreash

2011-08-02 Thread bruno desthuilliers
On 2 août, 19:22, lmcadory  wrote:
> I'm having this problem, my web design knowledge is limited and I'm
> having a hard time searching for the solution (if there is one)
>
> The problem is this:
>
> I have a view that counts the number of lines in a file. It then
> pushes that result to an html page.

Uh ? What does that mean exactly ? (the "pushes that result to an html
page" part)

> What I want it to do is when that
> line count changes when I press the refresh button on the browser it
> displays the new number. Right now I have to reload the server to
> display the results.

You shouldn't, so chances are you did something wrong (like putting
the code that computes the lines count at the module top-level or
something alike), but it's hard to tell exactly without looking at
your code.

>
> I, if I'm asking the question correctly, is there a way I can tell the
> view to run again and republish the results?

The view function is called each time you reload the corresponding
url.

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.