Re: Problem with django sitemap

2012-12-17 Thread Sandeep kaur
On Tue, Dec 18, 2012 at 1:17 PM, Frankline  wrote:
> But the sites framework has already been installed, as you can see from my
> settings file.
>
According to me, If that is true then it should not have thrown Import
error.

To install the sitemap app, follow these steps:

   1. Add 'django.contrib.sitemaps' to your
INSTALLED_APPSsetting.
   2. Make sure 'django.template.loaders.app_directories.Loader' is in your
   
TEMPLATE_LOADERSsetting.
It’s in there by default, so you’ll only need to change this if
   you’ve changed that setting.
   3. Make sure you’ve installed the sites
framework
   .


-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.com

-- 
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: Problem with django sitemap

2012-12-17 Thread Frankline
But the sites framework has already been installed, as you can see from my
settings file.

On Tue, Dec 18, 2012 at 10:44 AM, Sandeep kaur wrote:

> On Sun, Dec 16, 2012 at 10:55 PM, Frankline  wrote:
> >
> > I'm having a problem implementing the sitemaps in my application. I'm
> 
> >
> > ImportError at /sitemap.xml
> >
> > No module named django.contrib.sitemaps
> >
> > Request Method: GET
> > Request URL: http://localhost:8000/sitemap.xml
> > Django Version: 1.4.2
> > Exception Type: ImportError
> > Exception Value:
> >
> > No module named django.contrib.sitemaps
> >
> > Exception Location:
> > /home/frank/Projects/python/django/
> techjobsea.com/baseline27/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/utils/importlib.py
> > in import_module, line 35
> > Python Executable:
> > /home/frank/Projects/python/django/techjobsea.com/baseline27/bin/python
> > Python Version: 2.7.3
> >
>
> Are you sure, you followed all the installation steps, especially step 3
> in :
>
> https://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/
>
>
> --
> Sandeep Kaur
> E-Mail: mkaurkha...@gmail.com
> Blog: sandymadaan.wordpress.com
>
> --
> 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.
>
>

-- 
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: Problem with django sitemap

2012-12-17 Thread Sandeep kaur
On Sun, Dec 16, 2012 at 10:55 PM, Frankline  wrote:
>
> I'm having a problem implementing the sitemaps in my application. I'm

>
> ImportError at /sitemap.xml
>
> No module named django.contrib.sitemaps
>
> Request Method: GET
> Request URL: http://localhost:8000/sitemap.xml
> Django Version: 1.4.2
> Exception Type: ImportError
> Exception Value:
>
> No module named django.contrib.sitemaps
>
> Exception Location:
> /home/frank/Projects/python/django/techjobsea.com/baseline27/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/utils/importlib.py
> in import_module, line 35
> Python Executable:
> /home/frank/Projects/python/django/techjobsea.com/baseline27/bin/python
> Python Version: 2.7.3
>

Are you sure, you followed all the installation steps, especially step 3 in :

https://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/


--
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.com

-- 
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.



AW: problem with timeout

2012-12-17 Thread Szabo, Patrick (LNG-VIE)
Nevermind…select_related() did the trick.
226 queries cut to 4…amazing this little statement ☺




. . . . . . . . . . . . . . . . . . . . . . . . . .

Ing. Patrick Szabo

Developer

LexisNexis

A-1030 Wien, Marxergasse 25



patrick.sz...@lexisnexis.at

Tel.: +43 1 53452 1573

Fax.: +43 1 534 52 146

. . . . . . . . . . . . . . . . . . . . . . . . . .


Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von Szabo, Patrick (LNG-VIE)
Gesendet: Dienstag, 18. Dezember 2012 08:08
An: django-users@googlegroups.com
Betreff: AW: problem with timeout

Thanks, that does sound like a better idea and now that i think about it i saw 
this behaviour on many other webinterfaces already…don’t know why i didn’t 
think about that ☺

However I’ve noticed that it’s not the query that is taking so long, it’s the 
processing of the result that takes ~180 seconds…yes 10 minutes might have been 
a little exaggerated ;-)

It’s this code:

for buchung in buchungen:
if str(buchung.Produkt.Bestell_Nr):
   buch_pool[str(buchung.Produkt) + " #" + 
str(buchung.Produkt.Bestell_Nr)].append([str(buchung.Aktivitaet), 
str(buchung.Minuten)])
else:

buch_pool[str(buchung.Produkt)].append([str(buchung.Aktivitaet), 
str(buchung.Minuten)])

You mightbe wondering why I’m even building such a weird construct. Truth is, 
this thing has grown over time with different devs working on it and I don’t 
have time to change it.

My guess is that this code is triggering a load of queries…any idea how to make 
this more efficient ?


Von: django-users@googlegroups.com 
[mailto:django-users@googlegroups.com] Im Auftrag von Russell Keith-Magee
Gesendet: Dienstag, 18. Dezember 2012 00:55
An: django-users@googlegroups.com
Betreff: Re: problem with timeout


On Mon, Dec 17, 2012 at 7:34 PM, Szabo, Patrick (LNG-VIE) 
mailto:patrick.sz...@lexisnexis.at>> wrote:
Hi,

I have an operation that takes about 10 minutes to befinished. It takes that 
long because our DB is pretty big.
This produces a timeout.

I have tried so set the timeout in apache higher but it seems that apache is 
not taking this directivejust keeps timing out after 300 seconds.

Is there anything I can to to overcome this within my app ?
Yes. Stop doing long lived operations in a web request.

Seriously, stop. :-)

HTTP is designed to be a large number of short lived operations, not long lived 
operations. At the moment, you're hitting a resource limit at the HTTP server, 
but I'd be deeply surprised if that's the only problem you hit. HTTP just isn't 
designed to work in the way you've described.

If you need to perform a long lived operation, you need to structure your 
workflow differently. Instead of a single request that takes 10 minutes to 
create a response, you:

 1) Issue a request that creates a record in the database with all the details 
necessary to start the "job"
 2) Return to the user a success message that indicates work has started.
 3) In the background, in a *completely separate process*, process the job.
 4) When the job is finished, insert the results into the database, and mark 
the job as finished
 5) If the user hits the page representing the job, they can view the results.

The important detail here is that you get the heavy lifting *out* of the 
request-response cycle. How you achieve that is up to you. On the very simple 
end, you just have a job status page that the user manually reloads, and a cron 
task in the background to do the heavy lifting. On the complex end, you could 
use long polling or web sockets to provide the status update, and something 
like Celery to handle the task management.

Yours,
Russ Magee %-)

--
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.



. . . . . . . . . . . . . . . . . . . . . . . . . .

Ing. Patrick Szabo

Developer

LexisNexis

A-1030 Wien, Marxergasse 25



patrick.sz...@lexisnexis.at

Tel.: +43 1 53452 1573

Fax.: +43 1 534 52 146

. . . . . . . . . . . . . . . . . . . . . . . . . .


--
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: Problem with django sitemap

2012-12-17 Thread Frankline
Anyone???

On Sun, Dec 16, 2012 at 8:25 PM, Frankline  wrote:

> I'm having a problem implementing the sitemaps in my application. I'm
> using Virtualenv, django 1.4 and Python 2.7. I would appreciate if you
> can help me resolve this.
>
> This is what I have done:
>
> 1. In my *urls.py*
>
> from sitemap import JobPostSitemap
> sitemaps = {
> 'jobs': JobPostSitemap,
> }
> ... # Removed other urls
> url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
> {'sitemaps': sitemaps}),
>
> 2. Then in my *sitemap.py* file
>
> from django.contrib.sitemaps import Sitemap
> from jobs.models import JobPost
>
> class JobPostSitemap(Sitemap):
> changefreq = "never"
> priority = 0.5
>
> def items(self):
> return JobPost.objects.filter(approved=True)
>
> def lastmod(self, obj):
> return obj.pub_date
>
>
> 3. My *settings.py* file is as follows:
>
> ...
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> 'django.contrib.sitemaps',
> 'jobs',
> )
> ...
>
> Now when I open my browser and navigate to *http://localhost**
> :8000/sitemap.xml* , I get the following error:
>
>
> ImportError at /sitemap.xml
>
> No module named django.contrib.sitemaps
>
>  Request Method: GET  Request URL: http://localhost:8000/sitemap.xml  Django
> Version: 1.4.2  Exception Type: ImportError  Exception Value:
>
> No module named django.contrib.sitemaps
>
>  Exception Location: /home/frank/Projects/python/django/
> techjobsea.com/baseline27/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/utils/importlib.pyin
>  import_module, line 35  Python
> Executable: /home/frank/Projects/python/django/
> techjobsea.com/baseline27/bin/python  Python Version: 2.7.3

-- 
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: Theming Django with Diazo/XSLT

2012-12-17 Thread Derek
You do not say which part of Django you need to theme.  Assuming its the 
admin, I suggest you look at Grappelli[1] as they have done extensive work 
in  theming. You could either provide your own CSS and override any 
templates as needed; or start from scratch but with their approach/code as 
an example.

Derek

[1] https://django-grappelli.readthedocs.org/en/latest/index.html

On Friday, 14 December 2012 23:55:31 UTC+2, 4 The good Life we work wrote:
>
>  Hallo,
>
> I'm used to theme Plone with Diazo/ XSLT. 
> 
> Is there any tutorial for Django?
>
> Thanks,
> Michael
>  

-- 
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/-/G1Qz8bvR7e0J.
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.



AW: problem with timeout

2012-12-17 Thread Szabo, Patrick (LNG-VIE)
Thanks, that does sound like a better idea and now that i think about it i saw 
this behaviour on many other webinterfaces already…don’t know why i didn’t 
think about that ☺

However I’ve noticed that it’s not the query that is taking so long, it’s the 
processing of the result that takes ~180 seconds…yes 10 minutes might have been 
a little exaggerated ;-)

It’s this code:

for buchung in buchungen:
if str(buchung.Produkt.Bestell_Nr):
   buch_pool[str(buchung.Produkt) + " #" + 
str(buchung.Produkt.Bestell_Nr)].append([str(buchung.Aktivitaet), 
str(buchung.Minuten)])
else:

buch_pool[str(buchung.Produkt)].append([str(buchung.Aktivitaet), 
str(buchung.Minuten)])

You mightbe wondering why I’m even building such a weird construct. Truth is, 
this thing has grown over time with different devs working on it and I don’t 
have time to change it.

My guess is that this code is triggering a load of queries…any idea how to make 
this more efficient ?


Von: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Im 
Auftrag von Russell Keith-Magee
Gesendet: Dienstag, 18. Dezember 2012 00:55
An: django-users@googlegroups.com
Betreff: Re: problem with timeout


On Mon, Dec 17, 2012 at 7:34 PM, Szabo, Patrick (LNG-VIE) 
mailto:patrick.sz...@lexisnexis.at>> wrote:
Hi,

I have an operation that takes about 10 minutes to befinished. It takes that 
long because our DB is pretty big.
This produces a timeout.

I have tried so set the timeout in apache higher but it seems that apache is 
not taking this directivejust keeps timing out after 300 seconds.

Is there anything I can to to overcome this within my app ?
Yes. Stop doing long lived operations in a web request.

Seriously, stop. :-)

HTTP is designed to be a large number of short lived operations, not long lived 
operations. At the moment, you're hitting a resource limit at the HTTP server, 
but I'd be deeply surprised if that's the only problem you hit. HTTP just isn't 
designed to work in the way you've described.

If you need to perform a long lived operation, you need to structure your 
workflow differently. Instead of a single request that takes 10 minutes to 
create a response, you:

 1) Issue a request that creates a record in the database with all the details 
necessary to start the "job"
 2) Return to the user a success message that indicates work has started.
 3) In the background, in a *completely separate process*, process the job.
 4) When the job is finished, insert the results into the database, and mark 
the job as finished
 5) If the user hits the page representing the job, they can view the results.

The important detail here is that you get the heavy lifting *out* of the 
request-response cycle. How you achieve that is up to you. On the very simple 
end, you just have a job status page that the user manually reloads, and a cron 
task in the background to do the heavy lifting. On the complex end, you could 
use long polling or web sockets to provide the status update, and something 
like Celery to handle the task management.

Yours,
Russ Magee %-)

--
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.



. . . . . . . . . . . . . . . . . . . . . . . . . .

Ing. Patrick Szabo

Developer

LexisNexis

A-1030 Wien, Marxergasse 25



patrick.sz...@lexisnexis.at

Tel.: +43 1 53452 1573

Fax.: +43 1 534 52 146

. . . . . . . . . . . . . . . . . . . . . . . . . .


-- 
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: IntegrityError

2012-12-17 Thread Chris Cogdon
I'd need to see the source for Job and that other model, plus a proper 
exception traceback, so I can tell at what point the IntegrityError is 
being thrown.

also, you should not be using form.save() there... if you do a commit=False 
to get a copy of the model, you only need to save that model... re-saving 
the form again is probably an error.

On Monday, December 17, 2012 10:55:00 PM UTC-8, sandy wrote:
>
> On Tue, Dec 18, 2012 at 2:48 AM, Satinderpal Singh 
> > wrote: 
> > I created a search box for searching the information about the client 
> > so that this information uses to create the report. 
>
> add these lines : 
>
> > def search(request): 
>  
> >   {% endfor %} 
> > 
> > i want to get job id to be saved through header view: 
> > def header(request): 
>job =Job.objects.get(id=request.GET['q']) 
> > if request.method=='POST': 
> > form = headForm(request.POST) 
> > if form.is_valid(): 
> > cd = form.cleaned_data 
>profile = form.save(commit=False) 
>profile.job = job 
>profile.save() 
>form.save() 
> > HttpResponseRedirect(reverse('Automation.report.views.result')) 
> > 
> > But get the following error: 
> > IntegrityError at /report/header/ 
> > (1048, "Column 'job_id' cannot be null") 
> > 
> > Please anybody tell me where i am wrong? 
> > 
> Hope this helps you. 
>
> -- 
> Sandeep Kaur 
> E-Mail: mkaur...@gmail.com  
> Blog: sandymadaan.wordpress.com 
>

-- 
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/-/OhGhVvo7EP4J.
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: IntegrityError

2012-12-17 Thread Sandeep kaur
On Tue, Dec 18, 2012 at 2:48 AM, Satinderpal Singh
 wrote:
> I created a search box for searching the information about the client
> so that this information uses to create the report.

add these lines :

> def search(request):

>   {% endfor %}
>
> i want to get job id to be saved through header view:
> def header(request):
   job =Job.objects.get(id=request.GET['q'])
> if request.method=='POST':
> form = headForm(request.POST)
> if form.is_valid():
> cd = form.cleaned_data
   profile = form.save(commit=False)
   profile.job = job
   profile.save()
   form.save()
> HttpResponseRedirect(reverse('Automation.report.views.result'))
>
> But get the following error:
> IntegrityError at /report/header/
> (1048, "Column 'job_id' cannot be null")
>
> Please anybody tell me where i am wrong?
>
Hope this helps you.

-- 
Sandeep Kaur
E-Mail: mkaurkha...@gmail.com
Blog: sandymadaan.wordpress.com

-- 
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: IntegrityError

2012-12-17 Thread Chris Cogdon
Can you post the code for the model, and the complete exception trace? I 
ask you use something that will properly maintain the intending, such as 
pastebin or dpaste.

On Monday, December 17, 2012 1:18:54 PM UTC-8, Satinderpal Singh wrote:
>
> I created a search box for searching the information about the client 
> so that this information uses to create the report. 
> def search(request): 
> query = request.GET.get('q', '') 
> if query: 
> results = Job.objects.filter(id = 
> query).values('client__client__name','client__client__address_1','clientjob__material__name','suspencejob__field__name','id','job_no','date','site','report_type',)
>  
>
> else: 
> results = [] 
> return render_to_response("report/search.html", {"results": 
> results,"query": query}) 
>
> I want to save the value of job in the report table to create a report 
> like: 
>   {% for job in results %} 
> Job Id : {{ job.id }} 
> Name:{{job.client__client__name}} 
> Job No. : {{job.job_no}} 
> Site : {{job.site}} 
> Reference Letter No : {{job.Reference_Letter_no}} 
> Letter Date : {{job.Letter_date}} 
> Address : {{job.client__client__address_1}} 
> Material : {{job.clientjob__material__name}} 
> Report 
>   {% endfor %} 
>
> i want to get job id to be saved through header view: 
> def header(request): 
> if request.method=='POST': 
> form = headForm(request.POST) 
> if form.is_valid(): 
> cd = form.cleaned_data 
> form.save() 
> return 
> HttpResponseRedirect(reverse('Automation.report.views.result')) 
>
> But get the following error: 
> IntegrityError at /report/header/ 
> (1048, "Column 'job_id' cannot be null") 
>
> Please anybody tell me where i am wrong? 
>
>
>
>
> -- 
> Satinderpal Singh 
> http://satindergoraya.blogspot.in/ 
> http://satindergoraya91.blogspot.in/ 
>

-- 
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/-/8St7erk3yrAJ.
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: Unexpected behavior with regexp model filtering (Sqlite)

2012-12-17 Thread Chris Cogdon
And for completeness, here's how django implements the regex function when 
using sqlite3:

def _sqlite_regexp(re_pattern, re_string):
try:
return bool(re.search(re_pattern, re_string))
except:
return False



-- 
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/-/Hyh93MgKq8gJ.
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: Unexpected behavior with regexp model filtering (Sqlite)

2012-12-17 Thread Chris Cogdon
Django uses "search" rather than "match" for the _regex option. If you want 
match, make sure the regex starts with a ^

On Monday, December 17, 2012 6:55:09 PM UTC-8, Beni wrote:
>
> Hi,
>
> I'm getting stuck on figuring out why regex searches are matching any part 
> of a field when I use my model's regexp filter (instead of matching 
> linearly); they're behaving like calls to re.search instead of re.match.
>
> Since I'm using Sqlite, I registered my own function based on Python's 
> re.match. I tried testing the function in a shell by directly connecting to 
> the database to search the field and comparing those results to using the 
> model's regexp filter. The filter returns significantly more items and when 
> I test to see if they are strict matches for the regexp the 'extra' ones 
> fail. 
> I'm attaching a transcript of the shell tests.
>
> Any insight or advice would be greatly appreciated.
>
> Beni
>

-- 
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/-/80Lco8qgLrsJ.
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: Django back button issue after log-out

2012-12-17 Thread Chris Cogdon
But that means you're going to need to wrap _all_ your views in that 
structure, and that also means that none of those views will be cacheable.

That could be desirable, depending on your application.

You might also want to consider using @vary_on_cookie, which means that the 
cache will be specific to that user only for the current cookie values. a 
"logout" will clear the session cookies, and thus the cache is invalid.

On Monday, December 17, 2012 6:07:49 AM UTC-8, Ashish Sable wrote:
>
> yup... Got the solution just the bower cache needs to be cleared.
>
> from django.views.decorators.cache import cache_control
>
> @cache_control(no_cache=True, must_revalidate=True, no_store=True)
> def view():
>
> After logout it will render to login page.
>
> On Monday, 17 December 2012 18:39:25 UTC+5:30, ke1g wrote:
>>
>>
>>
>> On Mon, Dec 17, 2012 at 5:14 AM, Ashish Sable wrote:
>>
>>>
>>> I have written simple registration(login,logout) Django apps.
>>>  when i click on logout and then back button from browser 
>>> it shows me previous page. it should redirect me to login page. please 
>>> help
>>>
>>>
>>  The back button in your browser just shows you cached stuff.  It doesn't 
>> contact the server, so there is nothing Django can do.
>>
>

-- 
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/-/h2MT1GlK_sMJ.
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: How to stop my views from cacheing

2012-12-17 Thread Chris Cogdon
What you're doing is saying "any _new_ results returned from this view are 
uncacheable", but that doesn't impact the results that are in the cache 
already.

Read up on this section to see how to "invalidate" the existing cache:

https://docs.djangoproject.com/en/1.4/topics/cache/#cache-versioning


On Monday, December 17, 2012 7:26:45 PM UTC-8, Dwayne Ghant wrote:
>
> Thanks Chris,
>
> That's exactly what I thought I was doing. Can you please tell me what 
> missed? How, exactly do unclear the cache; if that's not what I'm currently 
> doing?
>
> On Monday, December 17, 2012, Chris Cogdon wrote:
>
>> You'll need to clear the cache. Remember, once the view is cached, django 
>> wont go down to the view until the cache thinks the content has expired.
>>
>>
>> On Monday, December 17, 2012 5:14:56 PM UTC-8, Dwayne Ghant wrote:
>>>
>>> Hello All: 
>>>
>>> I have a python view that I'm building but the for some strange reason 
>>> the view keeps caching.  Just to give an example: 
>>>
>>> @api_view(['POST'])
>>> @parser_classes((XMLParser,))
>>> @cache_page(0)
>>> @cache_control(private=True)
>>> def test_view(request, format=None):
>>> return Response({'received data TESTING2': 'testing'})
>>>
>>> Doesn't return "received data TESTING2': testing ." Instead, it keep 
>>> returning the old cached information. Can some please tell me how to 
>>> explicitly turn off caching while I'm still developing?  It a pain!! I I 
>>> have listed the references below that I used to trouble shoot: 
>>>
>>> https://docs.djangoproject.**com/en/dev/topics/cache/?from=**
>>> olddocs#the-per-view-cache
>>> https://docs.djangoproject.**com/en/dev/ref/settings/#std:**
>>> setting-CACHES
>>> https://docs.djangoproject.**com/en/dev/topics/cache/
>>>
>>>
>>> Any help would be deeply appreciated. 
>>>
>>> Thanx
>>>
>>>  -- 
>> 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/-/ImrvggfbaEkJ.
>> 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.
>>
>

-- 
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/-/S1uc6ADIzBAJ.
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: How to stop my views from cacheing

2012-12-17 Thread Dwayne Ghant
Thanks Chris,

That's exactly what I thought I was doing. Can you please tell me what
missed? How, exactly do unclear the cache; if that's not what I'm currently
doing?

On Monday, December 17, 2012, Chris Cogdon wrote:

> You'll need to clear the cache. Remember, once the view is cached, django
> wont go down to the view until the cache thinks the content has expired.
>
>
> On Monday, December 17, 2012 5:14:56 PM UTC-8, Dwayne Ghant wrote:
>>
>> Hello All:
>>
>> I have a python view that I'm building but the for some strange reason
>> the view keeps caching.  Just to give an example:
>>
>> @api_view(['POST'])
>> @parser_classes((XMLParser,))
>> @cache_page(0)
>> @cache_control(private=True)
>> def test_view(request, format=None):
>> return Response({'received data TESTING2': 'testing'})
>>
>> Doesn't return "received data TESTING2': testing ." Instead, it keep
>> returning the old cached information. Can some please tell me how to
>> explicitly turn off caching while I'm still developing?  It a pain!! I I
>> have listed the references below that I used to trouble shoot:
>>
>> https://docs.djangoproject.**com/en/dev/topics/cache/?from=**
>> olddocs#the-per-view-cache
>> https://docs.djangoproject.**com/en/dev/ref/settings/#std:**
>> setting-CACHES
>> https://docs.djangoproject.**com/en/dev/topics/cache/
>>
>>
>> Any help would be deeply appreciated.
>>
>> Thanx
>>
>>  --
> 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/-/ImrvggfbaEkJ.
> To post to this group, send email to 
> django-users@googlegroups.com 'django-users@googlegroups.com');>
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com  'django-users%2bunsubscr...@googlegroups.com');>.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
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: Use GraphDB with Django

2012-12-17 Thread Amirouche
Héllo,

What is you progress on the subject ? I answer your questions based on my 
experience of both doing Django, and graph database work with a framework 
like Django.

With the Python package Bulbs/Bulbflow, I can interface graph 
> databases and 
> model my domain objects. http://bulbflow.com/quickstart/#domain-models 
> What I would like to do is to define my domain models in this way and 
> use 
> them to query/update the graph db through my views in Django, instead 
> of 
> going through Django's ORM to the relational database.
>
 

> Has anyone tried to do this? Or do you know what implementation effort 
> would 
> be required on the Django-side to make this bridge? 
>

What you need to do is create a reusable application that will link 
Bulbflow with Django
settings so that you can import the graph object representing the graph. 
It's easy,
it has been done (disclaimer they are all my project and unmaintened so 
far):

- https://github.com/amirouche/Flask-Bulbs
- https://bitbucket.org/amirouche/flask-graphiti

And for django:

- https://bitbucket.org/amirouche/django-graphiti
 
I'm not up-to-date regarding bulbflow but this must be pretty similar work
 

> In particular, I would be interested in how to keep the graph object 
> persistent, 
> in order to use it from within my views. 
>

I don't understand the question fully but basically you issue queries that 
saves you models' nodes and edges.
 
Cheers,
 
 Amirouche

-- 
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/-/eN02xNDguCMJ.
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.



Unexpected behavior with regexp model filtering (Sqlite)

2012-12-17 Thread Beni
Hi,

I'm getting stuck on figuring out why regex searches are matching any part 
of a field when I use my model's regexp filter (instead of matching 
linearly); they're behaving like calls to re.search instead of re.match.

Since I'm using Sqlite, I registered my own function based on Python's 
re.match. I tried testing the function in a shell by directly connecting to 
the database to search the field and comparing those results to using the 
model's regexp filter. The filter returns significantly more items and when 
I test to see if they are strict matches for the regexp the 'extra' ones 
fail. 
I'm attaching a transcript of the shell tests.

Any insight or advice would be greatly appreciated.

Beni

-- 
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/-/YSL83-vSqhAJ.
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.

Bensiins-MacBook-Pro:myproject benicorp$ python manage.py shell
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import sqlite3, re
>>> from settings import DATABASES
>>> def regexp(pattern, item):
... reg = re.compile(pattern)
... return reg.match(item) is not None
... 
>>> loc = DATABASES['default']['NAME']
>>> conn = sqlite3.connect(loc)
>>> conn.create_function("REGEXP", 2, regexp)
>>> c=conn.cursor()
>>> c.execute("select * from myapp_word where arpabet REGEXP '; M.*'")

>>> res=c.fetchall()
>>> len(res)
8639
>>> test=[r for r in res if r[2][2]!="M"]
>>> len(test)
0
>>> conn.close()
>>> from myapp.models import Word
>>> res2 = Word.objects.filter(arpabet__regex='; M.*')
>>> res2=list(res2)
>>> len(res2)
18333
>>> test2 =[r for r in res2 if r.arpabet[2]!="M"]
>>> len(test2)
9694
>>> 18333-8639
9694

Re: How to stop my views from cacheing

2012-12-17 Thread Chris Cogdon
You'll need to clear the cache. Remember, once the view is cached, django 
wont go down to the view until the cache thinks the content has expired.


On Monday, December 17, 2012 5:14:56 PM UTC-8, Dwayne Ghant wrote:
>
> Hello All: 
>
> I have a python view that I'm building but the for some strange reason the 
> view keeps caching.  Just to give an example: 
>
> @api_view(['POST'])
> @parser_classes((XMLParser,))
> @cache_page(0)
> @cache_control(private=True)
> def test_view(request, format=None):
> return Response({'received data TESTING2': 'testing'})
>
> Doesn't return "received data TESTING2': testing ." Instead, it keep 
> returning the old cached information. Can some please tell me how to 
> explicitly turn off caching while I'm still developing?  It a pain!! I I 
> have listed the references below that I used to trouble shoot: 
>
>
> https://docs.djangoproject.com/en/dev/topics/cache/?from=olddocs#the-per-view-cache
> https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-CACHES
> https://docs.djangoproject.com/en/dev/topics/cache/
>
>
> Any help would be deeply appreciated. 
>
> Thanx
>
>

-- 
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/-/ImrvggfbaEkJ.
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.



How to stop my views from cacheing

2012-12-17 Thread Dwayne Ghant
Hello All: 

I have a python view that I'm building but the for some strange reason the 
view keeps caching.  Just to give an example: 

@api_view(['POST'])
@parser_classes((XMLParser,))
@cache_page(0)
@cache_control(private=True)
def test_view(request, format=None):
return Response({'received data TESTING2': 'testing'})

Doesn't return "received data TESTING2': testing ." Instead, it keep 
returning the old cached information. Can some please tell me how to 
explicitly turn off caching while I'm still developing?  It a pain!! I I 
have listed the references below that I used to trouble shoot: 

https://docs.djangoproject.com/en/dev/topics/cache/?from=olddocs#the-per-view-cache
https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-CACHES
https://docs.djangoproject.com/en/dev/topics/cache/


Any help would be deeply appreciated. 

Thanx

-- 
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/-/J3fSCyJi0-8J.
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: problem with timeout

2012-12-17 Thread Russell Keith-Magee
On Mon, Dec 17, 2012 at 7:34 PM, Szabo, Patrick (LNG-VIE) <
patrick.sz...@lexisnexis.at> wrote:

> Hi,
>
> I have an operation that takes about 10 minutes to befinished. It takes
> that long because our DB is pretty big.
> This produces a timeout.
>
> I have tried so set the timeout in apache higher but it seems that apache
> is not taking this directivejust keeps timing out after 300 seconds.
>
> Is there anything I can to to overcome this within my app ?
>
> Yes. Stop doing long lived operations in a web request.

Seriously, stop. :-)

HTTP is designed to be a large number of short lived operations, not long
lived operations. At the moment, you're hitting a resource limit at the
HTTP server, but I'd be deeply surprised if that's the only problem you
hit. HTTP just isn't designed to work in the way you've described.

If you need to perform a long lived operation, you need to structure your
workflow differently. Instead of a single request that takes 10 minutes to
create a response, you:

 1) Issue a request that creates a record in the database with all the
details necessary to start the "job"
 2) Return to the user a success message that indicates work has started.
 3) In the background, in a *completely separate process*, process the job.
 4) When the job is finished, insert the results into the database, and
mark the job as finished
 5) If the user hits the page representing the job, they can view the
results.

The important detail here is that you get the heavy lifting *out* of the
request-response cycle. How you achieve that is up to you. On the very
simple end, you just have a job status page that the user manually reloads,
and a cron task in the background to do the heavy lifting. On the complex
end, you could use long polling or web sockets to provide the status
update, and something like Celery to handle the task management.

Yours,
Russ Magee %-)

-- 
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.



How to distribute a hybrid Django project/app ??

2012-12-17 Thread Chris Cogdon
[Firstly, sorry if this appears to be a repost: I'd written a lengthy 
question previously and posted, but never saw it up in the listing. Did the 
ThreadMonster eat it?]

I'm putting the final touches on a art show management tool, written for 
Django of course, and I am seeing opinions on the best way to arrange its 
structure to be as useful as possible to others.

I want to both have this able to be used as a stand-alone application, with 
minimal interaction with Django, and also as an application that can be 
used in a larger project. The two aren't necessarily compatible, but I've 
seen a few projects now seem to fit both bills well and am considering 
using this pattern.

The project is distributed as one directory tree using the Django-1.4 
struture, with some minor re-arrangements of the settings files

ProjectName
+-- __init__.py (so that ProjectName can be imported as a python Module)
+-- ProjectName
+-- common_settings.py
+-- App1
+-- App2
+-- manage.py
+-- local_settings.py (imports common_settings)

If someone wanted to just use this as a standalone application (in the 
general sense), then they'd make changes to local_settings.py, syncdb and 
migrate, then start up whatever webservice they wanted configured.

If someone wanted to use the apps provided in their own Django project, 
then they'd install the above directory as a python package, then include 
ProjectName.App1 in their INSTALLED_APPS setting. The internal ProjectName 
and any settings files are now ignored.


In either case, the entire tree above would be available as a PyPI package, 
as well as via github.


Does that sound like a good, useful, plan? In the alternate, does anyone 
have other suggestions worth looking at ?

-- 
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/-/CAWO2nzexD8J.
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: django doesn't send me error mails

2012-12-17 Thread Chris Cogdon
I don't have any magic answers for you yet.

My only suggestion would be to find out what's different in the environment 
between running as uwsgi and running under runserver. Perhaps something in 
the environment, or perhaps the username under which django runs in either 
case.

/var/log/maillog is going to provide good information... see if you can get 
hold of it from your provider.



On Monday, December 17, 2012 8:30:36 AM UTC-8, Ali Vakilzade wrote:
>
> ok, after this answer a said I sghoulf test django internal server
> I simply started server with runserver
> (didn't change email backend)
> and the mail sending worked!
>
> so now I think It's a uwsgi related problem
> but I couldn't fine anything about that
>
> (there was a page on stackoverflow saying run uwsgi in threader mode but 
> it didn't help)
>
> http://stackoverflow.com/questions/8549371/mysterious-issue-with-django-uwsgi-send-email
>
>
> در دوشنبه 17 دسامبر 2012، ساعت 7:07:18 (UTC+3:30)، Chris Cogdon نوشته:
>>
>> My best guess is that the mail transport agent on the server is rejecting 
>> the mail because something is different from mail that is send through 
>> other places in your django code. Perhaps the mail "sender" is not correct, 
>> for example?
>>
>> Unfortunately, looking at the mail log is the best way to see what's 
>> happening. If that's not available, you might want to see what is being 
>> sent.
>>
>> Set this:
>>
>> EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
>>
>> and then run your project with "runserver". The mail that it tries to 
>> send will be sent to the console instead. Check out the "from" headers and 
>> make sure they make sense. Compare that to the other kinds of email that 
>> are sent.
>>
>> (Make sure you're still running with DEBUG=False)
>>
>>
>>
>> On Sunday, December 16, 2012 2:18:26 PM UTC-8, Ali Vakilzade wrote:
>>>
>>> I don't have access to that file on server.
>>> and log from uwsgi doesn't have any error massage about mail sending
>>>
>>> can it be a python3 branch related bug?
>>>
>>>
>>> در دوشنبه 17 دسامبر 2012، ساعت 1:36:05 (UTC+3:30)، Chris Cogdon نوشته:

 Oh... there's your problem... you've set the admin email to ... i'm 
 sure that doesn't exist! :)

 Seriously, though... all that looks correct. Can you check your 
 server's /var/log/maillog to see if the mail is being accepted?

 On Sunday, December 16, 2012 1:33:01 PM UTC-8, Ali Vakilzade wrote:
>
> I can send mails using send_mail or mail_admins methods
>
> but django it self doesn't send me any mail on 404 error or 500 error.
>
> I have even added  raise Exception('Test') to my view function
> I see the 500 error for that but no mail was sent
>
> This is my settings.py: http://dpaste.com/846959/
>
> I use :
> django from git master
> python 3.2
>
>

-- 
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/-/2tYPqWiPZhgJ.
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: A question about the Middleware module "djangodblog" and its "DBLogMiddleware" class

2012-12-17 Thread Bill Freeman
On Mon, Dec 17, 2012 at 3:02 PM, dariyoosh  wrote:

> *Yes, I suspect so.  Try the following:
>>
>> python manage.py shell
>> import djangodblog
>> djangodblog.__file__
>>
>> (That's two underscores on each side of the word file).  This will print
>> a string that I expect will end with '.../djangodblog/__init__.pyc'*
>> ***.  Whatever is there instead of "..." will tell you how to find the
>> djangdblog directory.  In it you will find both __init__.py and
>> middleware.py, and only in middleware.py will you find the definition of
>> DBLogMiddleware.
>> *
>>
>>
>>
>
> Many thanks for this interesting information. Here is the output of these
> commands:
>
> *$ python -tt manage.py shell*
> Python 2.7.3 (default, Jul 24 2012, 10:05:38)
> [GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>>
> >>>
> >>> *import djangodblog*
> >>> *djangodblog.__file__*
> '/usr/lib/python2.7/site-packages/djangodblog/__init__.pyc'
> >>>
> *$ cat /usr/lib/python2.7/site-packages/djangodblog/middleware.py*
> import warnings
>
> __all__ = ('DBLogMiddleware',)
>
> class DBLogMiddleware(object):
> """We now use signals"""
> def process_exception(self, request, exception):
> warnings.warn("DBLogMiddleware is no longer used.",
> DeprecationWarning)
> $
> $
> $ *cat /usr/lib/python2.7/site-packages/djangodblog/__init__.py*
> __version__ = (2, 2, 1)
> $
> $
>
>
> So it seems that my installation is different, in the book the author has
> used Django 1.1, whereas the version
> installed in my system is 1.4.2 Maybe the difference of the version
> explains the problem.
>

More likely it is a difference in the version of djangodblog, probably
having been made "more standard" since the book version.

>
> Thanks again for your time and your help.
>
> Regards,
> Dariyoosh
>
>
> On Monday, December 17, 2012 7:39:03 PM UTC+1, ke1g wrote:
>>
>>
>>
>> On Mon, Dec 17, 2012 at 12:41 PM, dariyoosh  wrote:
>>
>>> Hello there,
>>>
>>>
>>> Thank you very much for your time and your attention to my question.
>>> Your solution solved the problem !
>>>
>>> It works pretty well now. :)
>>>
>>> Just one question, initially I had written
>>> *'djangodblog.DBLogMiddleware'*
>>> simply because this was what author has suggested in the book.
>>>
>>> But now thanks to your solution, that is, *'djangodblog.middleware.
>>> DBLogMiddleware'*
>>> it works without any problem.
>>>
>>> So, does this mean that *'djangodblog.DBLogMiddleware'* is wrong? and
>>> therefore
>>> the author made a mistake that I have to report to the Errata web site
>>> of the book? or
>>> simply this is a component missing from my Django installation?
>>>
>>
>> Yes, I suspect so.  Try the following:
>>
>> python manage.py shell
>> import djangodblog
>> djangodblog.__file__
>>
>> (That's two underscores on each side of the word file).  This will print
>> a string that I expect will end with '.../djangodblog/__init__.pyc'**.
>> Whatever is there instead of "..." will tell you how to find the djangdblog
>> directory.  In it you will find both __init__.py and middleware.py, and
>> only in middleware.py will you find the definition of DBLogMiddleware.
>> That's normal by convention.  There's no physical reason that
>> DBLogMiddleware could not have been defined in __init__.py, or imported
>> there from the middlware module, in which case your original
>> djangdblog.DBLogMiddleware would have worked.  But that's not the usual
>> convention.
>>
>>>
>>> Once again, thanks a lot for your help!
>>>
>>> Regards,
>>> Dariyoosh
>>>
>>>
>>>
>>>
>>> On Monday, December 17, 2012 6:04:01 PM UTC+1, ke1g wrote:


 I don't have djangodblog handy, but, at a guess try changing settings
 to use:

 *'djangodblog.middleware.DBLogMiddleware'*

 instead of:

 *'djangodblog.DBLogMiddleware'*

>>>  --
>>> 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/-/o0OD_**xvrNhgJ
>>> .
>>>
>>> To post to this group, send email to django...@googlegroups.com.
>>> To unsubscribe from this group, send email to django-users...@**
>>> googlegroups.com.
>>>
>>> For more options, visit this group at http://groups.google.com/**
>>> group/django-users?hl=en
>>> .
>>>
>>
>>  --
> 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/-/FEJZO3gCU4wJ.
>
> 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/

Re: LDAP search results "disappear"

2012-12-17 Thread peter

On 12/17/2012 03:58 PM, Kevin Cole wrote:

On Mon, Dec 17, 2012 at 1:57 PM, Kevin Cole  wrote:


And here I'll display my ignorance about threading.  I've done nothing
specific to ask for threading. I wouldn't know how to thread even if I
had a sewing machine. ;-) I'm using apache prefork with mod-wsgi.  In
testing, I go to the URL page first, which I had hoped would set the
global variable like everywhere else that I set values for small
handful of globals, and that going to the autoname URL after that
would see the global I had set.

s/I go to the URL page first/I go to the login page first/

The desing of the view's of django, do not allow you to pass global 
variables between the views. If you want to pass, data between views, 
you need to use ajax, to send the data in a get or post requests.


def index(request):
print 'helou'
return render_to_response('index.html', {'lala': 'lala'})

#index.html
# 
# obj = {type:'get', url='/test/view0', data: {tamangandapio:'yeah'}, type='json',
# response: function (){ console.log(response) }
# }
# $.ajax(obj);
# 

def view0(request)
  #here you see the data send by the jquery code below
  print request.GET
  res = {'success':'i got it'}
  return HttpResponse(simplejson.dumps(res), 
mimetype='application/javascript')



please don't use global variables in views

--
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: A question about the Middleware module "djangodblog" and its "DBLogMiddleware" class

2012-12-17 Thread dariyoosh

>
> *Yes, I suspect so.  Try the following:
>
> python manage.py shell
> import djangodblog
> djangodblog.__file__
>
> (That's two underscores on each side of the word file).  This will print a 
> string that I expect will end with '.../djangodblog/__init__.pyc'*
> *.  Whatever is there instead of "..." will tell you how to find the 
> djangdblog directory.  In it you will find both __init__.py and 
> middleware.py, and only in middleware.py will you find the definition of 
> DBLogMiddleware. 
> *
>
>
>

Many thanks for this interesting information. Here is the output of these 
commands:

*$ python -tt manage.py shell*
Python 2.7.3 (default, Jul 24 2012, 10:05:38) 
[GCC 4.7.0 20120507 (Red Hat 4.7.0-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> 
>>> 
>>> *import djangodblog*
>>> *djangodblog.__file__*
'/usr/lib/python2.7/site-packages/djangodblog/__init__.pyc'
>>> 
*$ cat /usr/lib/python2.7/site-packages/djangodblog/middleware.py*
import warnings

__all__ = ('DBLogMiddleware',)

class DBLogMiddleware(object):
"""We now use signals"""
def process_exception(self, request, exception):
warnings.warn("DBLogMiddleware is no longer used.", 
DeprecationWarning)
$ 
$ 
$ *cat /usr/lib/python2.7/site-packages/djangodblog/__init__.py*
__version__ = (2, 2, 1)
$ 
$ 


So it seems that my installation is different, in the book the author has 
used Django 1.1, whereas the version
installed in my system is 1.4.2 Maybe the difference of the version 
explains the problem.

Thanks again for your time and your help.

Regards,
Dariyoosh


On Monday, December 17, 2012 7:39:03 PM UTC+1, ke1g wrote:
>
>
>
> On Mon, Dec 17, 2012 at 12:41 PM, dariyoosh 
> > wrote:
>
>> Hello there,
>>
>>
>> Thank you very much for your time and your attention to my question.
>> Your solution solved the problem !
>>
>> It works pretty well now. :)
>>
>> Just one question, initially I had written
>> *'djangodblog.DBLogMiddleware'*
>> simply because this was what author has suggested in the book. 
>>
>> But now thanks to your solution, that is, *'djangodblog.middleware.
>> DBLogMiddleware'*
>> it works without any problem.
>>
>> So, does this mean that *'djangodblog.DBLogMiddleware'* is wrong? and 
>> therefore
>> the author made a mistake that I have to report to the Errata web site of 
>> the book? or 
>> simply this is a component missing from my Django installation?
>>
>
> Yes, I suspect so.  Try the following:
>
> python manage.py shell
> import djangodblog
> djangodblog.__file__
>
> (That's two underscores on each side of the word file).  This will print a 
> string that I expect will end with '.../djangodblog/__init__.pyc'.  
> Whatever is there instead of "..." will tell you how to find the djangdblog 
> directory.  In it you will find both __init__.py and middleware.py, and 
> only in middleware.py will you find the definition of DBLogMiddleware.  
> That's normal by convention.  There's no physical reason that 
> DBLogMiddleware could not have been defined in __init__.py, or imported 
> there from the middlware module, in which case your original 
> djangdblog.DBLogMiddleware would have worked.  But that's not the usual 
> convention. 
>
>>
>> Once again, thanks a lot for your help!
>>
>> Regards,
>> Dariyoosh
>>
>>
>>
>>
>> On Monday, December 17, 2012 6:04:01 PM UTC+1, ke1g wrote:
>>>
>>>
>>> I don't have djangodblog handy, but, at a guess try changing settings to 
>>> use:
>>>
>>> *'djangodblog.middleware.DBLogMiddleware'*
>>>
>>> instead of:
>>>
>>> *'djangodblog.DBLogMiddleware'*
>>>
>>  -- 
>> 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/-/o0OD_xvrNhgJ.
>>
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

-- 
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/-/FEJZO3gCU4wJ.
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: LDAP search results "disappear"

2012-12-17 Thread Bill Freeman
On Mon, Dec 17, 2012 at 1:58 PM, Kevin Cole  wrote:

> On Mon, Dec 17, 2012 at 1:57 PM, Kevin Cole  wrote:
>
> > And here I'll display my ignorance about threading.  I've done nothing
> > specific to ask for threading. I wouldn't know how to thread even if I
> > had a sewing machine. ;-) I'm using apache prefork with mod-wsgi.  In
> > testing, I go to the URL page first, which I had hoped would set the
> > global variable like everywhere else that I set values for small
> > handful of globals, and that going to the autoname URL after that
> > would see the global I had set.
>
> s/I go to the URL page first/I go to the login page first/
>

Mind you, I'm not certain that it's a threading issue.  If this happens
under runserver, it can't be threading because that's single threaded.
Most of the deployment things I've seen default to some multi (process,
actually) threading, though.

Is it possible that fetch_names is returning something that times out
somehow and then looks empty?  You might try rendering type(direktorie) in
both views.  If it looks like a thing of some kind other than a list, then
you might need to copy its parts in login, rather than saving it as is.

-- 
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: LDAP search results "disappear"

2012-12-17 Thread Kevin Cole
On Mon, Dec 17, 2012 at 1:57 PM, Kevin Cole  wrote:

> And here I'll display my ignorance about threading.  I've done nothing
> specific to ask for threading. I wouldn't know how to thread even if I
> had a sewing machine. ;-) I'm using apache prefork with mod-wsgi.  In
> testing, I go to the URL page first, which I had hoped would set the
> global variable like everywhere else that I set values for small
> handful of globals, and that going to the autoname URL after that
> would see the global I had set.

s/I go to the URL page first/I go to the login page first/

-- 
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: LDAP search results "disappear"

2012-12-17 Thread Kevin Cole
On Mon, Dec 17, 2012 at 1:42 PM, Bill Freeman  wrote:

> Perhaps in the thread in which autoname is run, login has not yet been run.

And here I'll display my ignorance about threading.  I've done nothing
specific to ask for threading. I wouldn't know how to thread even if I
had a sewing machine. ;-) I'm using apache prefork with mod-wsgi.  In
testing, I go to the URL page first, which I had hoped would set the
global variable like everywhere else that I set values for small
handful of globals, and that going to the autoname URL after that
would see the global I had set.

-- 
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: Django Celery FIFO ORDER

2012-12-17 Thread Nikolas Stevenson-Molnar
No problem; best of luck! :)

_Nik

On 12/17/2012 10:47 AM, psychok7 wrote:
> ok i see your point.. Well i am going to use my redis db already used
> by celerey to do the sorting then. hope its fast enough.
>
> Thanks for your time to help me out ;)
>
> On Monday, December 10, 2012 4:20:52 PM UTC, psychok7 wrote:
>
> So I have this 2 applications connected with a REST API (json
> messages). One written in Django and the other in Php. I have an
> exact database replica on both sides (using mysql).
>
> When i press "submit" on one of them, i want that data to be saved
> on the current app database, and start a cron job with
> celery/redis to update the remote database for the other app using
> rest.
>
> /*My question is, how do i attribute the same worker to my tasks
> in order to keep a FIFO order?*/
>
> I need my data to be consistent and FIFO is really important.
>
> -- 
> 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/-/bvwtkC89v2kJ.
> 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.

-- 
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: Django Celery FIFO ORDER

2012-12-17 Thread psychok7
ok i see your point.. Well i am going to use my redis db already used by 
celerey to do the sorting then. hope its fast enough.

Thanks for your time to help me out ;)

On Monday, December 10, 2012 4:20:52 PM UTC, psychok7 wrote:
>
> So I have this 2 applications connected with a REST API (json messages). 
> One written in Django and the other in Php. I have an exact database 
> replica on both sides (using mysql).
>
> When i press "submit" on one of them, i want that data to be saved on the 
> current app database, and start a cron job with celery/redis to update the 
> remote database for the other app using rest.
>
> *My question is, how do i attribute the same worker to my tasks in order 
> to keep a FIFO order?*
>
> I need my data to be consistent and FIFO is really important.
>

-- 
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/-/bvwtkC89v2kJ.
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: LDAP search results "disappear"

2012-12-17 Thread Bill Freeman
On Mon, Dec 17, 2012 at 1:03 PM, Kevin Cole  wrote:

> Also asked on StackOverflow
>
>
> http://stackoverflow.com/questions/13918785/django-ldap-search-results-disappear
>
> Why in the code below, does the global *direktorie* return the correct
> data in the *login()* debug template, yet when I try to access the same
> variable from *autoname()* it says the list has a length of *0*? I don't
> reference *direktorie* in any other places in *views.py* -- or anywhere
> else for that matter. (All of the code below is merely an attempt to
> discover what I'm doing wrong. I don't really care about the length of the
> returned list. I just want to know it's being seen and has roughly the
> right number of entries.)
>
> ##
>
> from django.http   import HttpResponse, HttpResponseRedirect, 
> Http404from django.shortcuts  import render_to_response, 
> get_object_or_404import json  # JSON for jQuery AJAX 
> autocompletefrom   eldappery import *# LDAP for jQuery AJAX 
> autocomplete
>
> direktorie = []
> ##
> def login(request):
>   """LDAP Login routine"""
>   global direktorie
>
>   if request.method == "POST":   # If submitted...
> if request.POST["username"] and request.POST["password"]:
>   username = request.POST["username"]
>   password = request.POST["password"]
>   LDAPfeed = dapperize(username, password)   # ...login
>   if LDAPfeed:
> direktorie = fetch_names(LDAPfeed,"")# ...get everybody
> ls  = locals()   # DEBUG!
> gs  = globals()  # DEBUG!
> return render_to_response("debug.html",
>   {"ls": ls,
>"gs": gs})# DEBUG! Works! (direktorie 
> full)
>   else:
> return HttpResponseRedirect("/login/")
>   return render_to_response("login.html",
> context_instance=RequestContext(request))
> ##
>
> def autoname(request):
>   """Auto-complete names"""
>   global direktorie
>   if request.is_ajax():#   results = [{"id":5,#   "label": 
> 5,#   "value": 5}]# DEBUG! Works! (5 in template)
> results = [{"id":len(direktorie),
> "label": len(direktorie),
> "value": len(direktorie)}]  # DEBUG! Doesn't work! (0 in 
> template)
> data = json.dumps(results)  # Convert to JSON string
>   else: # No results returned!
> data = "fail"   # Error...
>   mimetype = "application/json" # MIME type = JSON
>   return HttpResponse(data, mimetype)   # Send JSON back to web page
> ##
>
>
>  Perhaps in the thread in which autoname is run, login has not yet been
run.

-- 
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: A question about the Middleware module "djangodblog" and its "DBLogMiddleware" class

2012-12-17 Thread Bill Freeman
On Mon, Dec 17, 2012 at 12:41 PM, dariyoosh  wrote:

> Hello there,
>
>
> Thank you very much for your time and your attention to my question.
> Your solution solved the problem !
>
> It works pretty well now. :)
>
> Just one question, initially I had written
> *'djangodblog.DBLogMiddleware'*
> simply because this was what author has suggested in the book.
>
> But now thanks to your solution, that is, *'djangodblog.middleware.
> DBLogMiddleware'*
> it works without any problem.
>
> So, does this mean that *'djangodblog.DBLogMiddleware'* is wrong? and
> therefore
> the author made a mistake that I have to report to the Errata web site of
> the book? or
> simply this is a component missing from my Django installation?
>

Yes, I suspect so.  Try the following:

python manage.py shell
import djangodblog
djangodblog.__file__

(That's two underscores on each side of the word file).  This will print a
string that I expect will end with '.../djangodblog/__init__.pyc'.
Whatever is there instead of "..." will tell you how to find the djangdblog
directory.  In it you will find both __init__.py and middleware.py, and
only in middleware.py will you find the definition of DBLogMiddleware.
That's normal by convention.  There's no physical reason that
DBLogMiddleware could not have been defined in __init__.py, or imported
there from the middlware module, in which case your original
djangdblog.DBLogMiddleware would have worked.  But that's not the usual
convention.

>
> Once again, thanks a lot for your help!
>
> Regards,
> Dariyoosh
>
>
>
>
> On Monday, December 17, 2012 6:04:01 PM UTC+1, ke1g wrote:
>>
>>
>> I don't have djangodblog handy, but, at a guess try changing settings to
>> use:
>>
>> *'djangodblog.middleware.DBLogMiddleware'*
>>
>> instead of:
>>
>> *'djangodblog.DBLogMiddleware'*
>>
>  --
> 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/-/o0OD_xvrNhgJ.
>
> 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.
>

-- 
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: Django Celery FIFO ORDER

2012-12-17 Thread Nikolas Stevenson-Molnar
If you're processing 10k requests serially, then the database won't be
your bottleneck. Since you'd be sorting by primary key, and that gets
automatically indexed, your database won't even flinch at selecting the
top row from 10k records. The real bottleneck is going to be the fact
that you're processing one at a time, and that you have to wait to send
the REST request and for it to return. And there's going to be no way
(that I can see) to scale that until you rethink the architecture.

_Nik

On 12/15/2012 6:27 AM, psychok7 wrote:
> hey Nikolas, it looks like a solution that would work in fact, but
> there are some limitations in terms of performance (i need my app to
> be scalable). If for each request i sort my database it will
> eventually become slow for 10.000 requests, so i was actually looking
> for a more scalable solution.
>
> For know i can work with your idea, but wouldn't want it to be long
> term. If you have any more ideas please share.
>
> On Monday, December 10, 2012 4:20:52 PM UTC, psychok7 wrote:
>
> So I have this 2 applications connected with a REST API (json
> messages). One written in Django and the other in Php. I have an
> exact database replica on both sides (using mysql).
>
> When i press "submit" on one of them, i want that data to be saved
> on the current app database, and start a cron job with
> celery/redis to update the remote database for the other app using
> rest.
>
> /*My question is, how do i attribute the same worker to my tasks
> in order to keep a FIFO order?*/
>
> I need my data to be consistent and FIFO is really important.
>
> -- 
> 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/-/dmZ0utouw48J.
> 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.

-- 
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.



LDAP search results "disappear"

2012-12-17 Thread Kevin Cole
Also asked on StackOverflow

http://stackoverflow.com/questions/13918785/django-ldap-search-results-disappear

Why in the code below, does the global *direktorie* return the correct data 
in the *login()* debug template, yet when I try to access the same variable 
from *autoname()* it says the list has a length of *0*? I don't reference *
direktorie* in any other places in *views.py* -- or anywhere else for that 
matter. (All of the code below is merely an attempt to discover what I'm 
doing wrong. I don't really care about the length of the returned list. I 
just want to know it's being seen and has roughly the right number of 
entries.)

##

from django.http   import HttpResponse, HttpResponseRedirect, 
Http404from django.shortcuts  import render_to_response, 
get_object_or_404import json  # JSON for jQuery AJAX 
autocompletefrom   eldappery import *# LDAP for jQuery AJAX autocomplete

direktorie = []
##
def login(request):
  """LDAP Login routine"""
  global direktorie

  if request.method == "POST":   # If submitted...
if request.POST["username"] and request.POST["password"]:
  username = request.POST["username"]
  password = request.POST["password"]
  LDAPfeed = dapperize(username, password)   # ...login
  if LDAPfeed:
direktorie = fetch_names(LDAPfeed,"")# ...get everybody
ls  = locals()   # DEBUG!
gs  = globals()  # DEBUG!
return render_to_response("debug.html",
  {"ls": ls,
   "gs": gs})# DEBUG! Works! (direktorie 
full)
  else:
return HttpResponseRedirect("/login/")
  return render_to_response("login.html",
context_instance=RequestContext(request))
##

def autoname(request):
  """Auto-complete names"""
  global direktorie
  if request.is_ajax():#   results = [{"id":5,#   "label": 5,#  
 "value": 5}]# DEBUG! Works! (5 in template)
results = [{"id":len(direktorie),
"label": len(direktorie),
"value": len(direktorie)}]  # DEBUG! Doesn't work! (0 in 
template)
data = json.dumps(results)  # Convert to JSON string
  else: # No results returned!
data = "fail"   # Error...
  mimetype = "application/json" # MIME type = JSON
  return HttpResponse(data, mimetype)   # Send JSON back to web page
##


-- 
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/-/aIEZD33ST-MJ.
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: A question about the Middleware module "djangodblog" and its "DBLogMiddleware" class

2012-12-17 Thread dariyoosh
Hello there,


Thank you very much for your time and your attention to my question.
Your solution solved the problem !

It works pretty well now. :)

Just one question, initially I had written
*'djangodblog.DBLogMiddleware'*
simply because this was what author has suggested in the book. 

But now thanks to your solution, that is, *
'djangodblog.middleware.DBLogMiddleware'*
it works without any problem.

So, does this mean that *'djangodblog.DBLogMiddleware'* is wrong? and 
therefore
the author made a mistake that I have to report to the Errata web site of 
the book? or 
simply this is a component missing from my Django installation?

Once again, thanks a lot for your help!

Regards,
Dariyoosh



On Monday, December 17, 2012 6:04:01 PM UTC+1, ke1g wrote:
>
>
> I don't have djangodblog handy, but, at a guess try changing settings to 
> use:
>
> *'djangodblog.middleware.DBLogMiddleware'*
>
> instead of:
>
> *'djangodblog.DBLogMiddleware'*
>

-- 
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/-/o0OD_xvrNhgJ.
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: A question about the Middleware module "djangodblog" and its "DBLogMiddleware" class

2012-12-17 Thread Bill Freeman
I don't have djangodblog handy, but, at a guess try changing settings to
use:

*'djangodblog.middleware.DBLogMiddleware'*

instead of:

*'djangodblog.DBLogMiddleware'*

-- 
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.



A question about the Middleware module "djangodblog" and its "DBLogMiddleware" class

2012-12-17 Thread dariyoosh
Hello everybody


Currently I'm learning python Web development by Django and I'm reading 
James McGaw' book: "Beginning Django E-Commerce" (Apress Edition).

So far, I've followed step by step the instructions given in the book and 
everything worked pretty well:

- installation of Django, MySQL,

- creation of the Django specific database tabes while I run
$ python -tt manage.py syncdb


- starting the server
$ python -tt manage.py runserver

I opened firefox and I saw the message "It worked!" while I entered the 
url "http://127.0.0.1:8000/"; which indicated that the server was running 
ready to receive requests.

Yet, things became more complicated when in the next chapter we started 
creating an application. I changed the content of the following files

- settings.py
- urls.py

and also creating the corresponding HTML files according to the directory 
hierarchy described in the book for the templates. After following step by 
step instructions in the book, I stoped and restarted the server with the 
new URL of the application, I got the following message on the browser

"*A server error occurred.  Please contact the administrator.*"

And on the terminal, where I had run the command to start the server I saw 
the following exception StackTrace

$  *python -tt manage.py runserver*
Validating models...

0 errors found
Django version 1.4.2, using settings 'ecomstore.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
  File "/usr/lib64/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
  File 
"/usr/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", 
line 67, in __call__
return self.application(environ, start_response)
  File "/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py", 
line 219, in __call__
self.load_middleware()
  File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", 
line 51, in load_middleware
raise exceptions.ImproperlyConfigured('Middleware module "%s" does not 
define a "%s" class' % (mw_module, mw_classname))
*ImproperlyConfigured: Middleware module "djangodblog" does not define a 
"DBLogMiddleware" class*
[17/Dec/2012 08:27:27] "GET / HTTP/1.1" 500 59

Any idea about this error? What causes this problem?

Thanks in advance,

Regards,
Dariyoosh



In the case where it might be helpful here is the content of the file 
settings.py of the project:


# Django settings for ecomstore project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', 
   # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 
'oracle'.
'NAME': 'ecomstore',   # Or path to database file if using 
sqlite3.
'USER': 'train2012',   # Not used with sqlite3.
'PASSWORD': '**',  # Not used with sqlite3.
'HOST': '',# Set to empty string for localhost. Not 
used with sqlite3.
'PORT': '',# Set to empty string for default. Not 
used with sqlite3.
}
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded 
files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/";, "http://example.com/media/";
MEDIA_URL = ''

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/";
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative pa

Re: django doesn't send me error mails

2012-12-17 Thread Ali Vakilzade
ok, after this answer a said I sghoulf test django internal server
I simply started server with runserver
(didn't change email backend)
and the mail sending worked!

so now I think It's a uwsgi related problem
but I couldn't fine anything about that

(there was a page on stackoverflow saying run uwsgi in threader mode but it 
didn't help)
http://stackoverflow.com/questions/8549371/mysterious-issue-with-django-uwsgi-send-email


در دوشنبه 17 دسامبر 2012، ساعت 7:07:18 (UTC+3:30)، Chris Cogdon نوشته:
>
> My best guess is that the mail transport agent on the server is rejecting 
> the mail because something is different from mail that is send through 
> other places in your django code. Perhaps the mail "sender" is not correct, 
> for example?
>
> Unfortunately, looking at the mail log is the best way to see what's 
> happening. If that's not available, you might want to see what is being 
> sent.
>
> Set this:
>
> EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
>
> and then run your project with "runserver". The mail that it tries to send 
> will be sent to the console instead. Check out the "from" headers and make 
> sure they make sense. Compare that to the other kinds of email that are 
> sent.
>
> (Make sure you're still running with DEBUG=False)
>
>
>
> On Sunday, December 16, 2012 2:18:26 PM UTC-8, Ali Vakilzade wrote:
>>
>> I don't have access to that file on server.
>> and log from uwsgi doesn't have any error massage about mail sending
>>
>> can it be a python3 branch related bug?
>>
>>
>> در دوشنبه 17 دسامبر 2012، ساعت 1:36:05 (UTC+3:30)، Chris Cogdon نوشته:
>>>
>>> Oh... there's your problem... you've set the admin email to ... i'm 
>>> sure that doesn't exist! :)
>>>
>>> Seriously, though... all that looks correct. Can you check your server's 
>>> /var/log/maillog to see if the mail is being accepted?
>>>
>>> On Sunday, December 16, 2012 1:33:01 PM UTC-8, Ali Vakilzade wrote:

 I can send mails using send_mail or mail_admins methods

 but django it self doesn't send me any mail on 404 error or 500 error.

 I have even added  raise Exception('Test') to my view function
 I see the 500 error for that but no mail was sent

 This is my settings.py: http://dpaste.com/846959/

 I use :
 django from git master
 python 3.2



-- 
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/-/Ku2rT8q_M4gJ.
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: deprecation of DotExpandedDict announced?

2012-12-17 Thread Roman Klesel
2012/12/17 donarb 

>
>
> https://github.com/django/django/commit/c57abd3c29cedcca00821d2a0d5708f10977f3c6
>
>


ahh the commit, thanks!

-- 
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: deprecation of DotExpandedDict announced?

2012-12-17 Thread donarb
On Monday, December 17, 2012 7:37:59 AM UTC-8, roman wrote:
>
> Hello everyone,
>
> just trying 1.5 beta ...
>
> django.utils.datastructures.DotExpandedDict seems to be no longer there. 
> Can't find where this has been announced.
> Did I miss something?
>
> Regards
>  Roman
>


https://github.com/django/django/commit/c57abd3c29cedcca00821d2a0d5708f10977f3c6
 

-- 
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/-/WNNknLvDN_EJ.
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.



deprecation of DotExpandedDict announced?

2012-12-17 Thread roman
Hello everyone,

just trying 1.5 beta ...

django.utils.datastructures.DotExpandedDict seems to be no longer there. 
Can't find where this has been announced.
Did I miss something?

Regards
 Roman

-- 
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/-/84a3UB9Prn8J.
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: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-17 Thread Tom Evans
On Fri, Dec 14, 2012 at 5:46 PM, bobhaugen  wrote:
> RuntimeWarning: DateTimeField received a naive datetime (2012-12-14
> 17:39:38.878379) while time zone support is active.
>
> This is happening in my tests, but not in normal code.
>
> From dropping a trace in, it looks like it is happening before the test
> setup even runs.
>
> I double-checked my models,  not a DateTimeField in the lot. Nor anywhere
> else in my code except for South migrations, where it is found in
> models['auth.user']. (But I'm not creating any Users in my test code,
> either...)
>
> The tests run ok, but the error messages will be disconcerting to people who
> install my open-source project code.
>
> Any clues?
>
> Thanks.
>

Following the thread I see that you have figured out where and why
this is coming from. There is a simple tip you can use to speed this
up in future, simply run python with warnings set to error, and any
Warnings will be converted into RuntimeErrors - so you get a lovely
stack trace showing exactly how and when the warning was issued.

You can configure python to stop only on certain Warnings, but the
simplest way is to turn all Warnings into Errors:

python -W error manage.py 

Full details on what you can specify with -W here:

http://docs.python.org/2/library/warnings.html#the-warnings-filter

Cheers

Tom

-- 
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: Django back button issue after log-out

2012-12-17 Thread Ashish Sable
yup... Got the solution just the bower cache needs to be cleared.

from django.views.decorators.cache import cache_control

@cache_control(no_cache=True, must_revalidate=True, no_store=True)
def view():

After logout it will render to login page.

On Monday, 17 December 2012 18:39:25 UTC+5:30, ke1g wrote:
>
>
>
> On Mon, Dec 17, 2012 at 5:14 AM, Ashish Sable 
> 
> > wrote:
>
>>
>> I have written simple registration(login,logout) Django apps.
>>  when i click on logout and then back button from browser 
>> it shows me previous page. it should redirect me to login page. please 
>> help
>>
>>
>  The back button in your browser just shows you cached stuff.  It doesn't 
> contact the server, so there is nothing Django can do.
>

-- 
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/-/R63HRRmbB34J.
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: Django back button issue after log-out

2012-12-17 Thread Bill Freeman
On Mon, Dec 17, 2012 at 5:14 AM, Ashish Sable wrote:

>
> I have written simple registration(login,logout) Django apps.
>  when i click on logout and then back button from browser
> it shows me previous page. it should redirect me to login page. please help
>
>
 The back button in your browser just shows you cached stuff.  It doesn't
contact the server, so there is nothing Django can do.

-- 
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.



Django back button issue after log-out

2012-12-17 Thread Ashish Sable

I have written simple registration(login,logout) Django apps.
 when i click on logout and then back button from browser 
it shows me previous page. it should redirect me to login page. please help

-- 
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/-/u1A3OwU1_8EJ.
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: problem with timeout

2012-12-17 Thread Avraham Serour
you could optimize the database (creating indexes, putting in memory, using
a ssd etc)
you can run the process in backgorund


On Mon, Dec 17, 2012 at 1:34 PM, Szabo, Patrick (LNG-VIE) <
patrick.sz...@lexisnexis.at> wrote:

> Hi,
>
> I have an operation that takes about 10 minutes to befinished. It takes
> that long because our DB is pretty big.
> This produces a timeout.
>
> I have tried so set the timeout in apache higher but it seems that apache
> is not taking this directivejust keeps timing out after 300 seconds.
>
> Is there anything I can to to overcome this within my app ?
>
> The exception says that a connections was aborted by the software oft he
> hostcomputer (translated from german): core_output_filter: writing data to
> the network
>
> This is how i get the entries:
>
> Datum being a Date and int(str(datestring).split('-')[0]) delivering a
> year like 2012
>
> Buchung.objects.filter(Datum__year = int(str(datestring).split('-')[0]))
>
>
> Help would be much appreciated.
>
>
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> Ing. Patrick Szabo
> Developer
> LexisNexis
> A-1030 Wien, Marxergasse 25
>
> mailto:patrick.sz...@lexisnexis.at
> Tel.: +43 1 53452 1573
> Fax.: +43 1 534 52 146
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
>
> --
> 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.
>
>

-- 
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.



problem with timeout

2012-12-17 Thread Szabo, Patrick (LNG-VIE)
Hi,

I have an operation that takes about 10 minutes to befinished. It takes that 
long because our DB is pretty big.
This produces a timeout.

I have tried so set the timeout in apache higher but it seems that apache is 
not taking this directivejust keeps timing out after 300 seconds.

Is there anything I can to to overcome this within my app ?

The exception says that a connections was aborted by the software oft he 
hostcomputer (translated from german): core_output_filter: writing data to the 
network

This is how i get the entries:

Datum being a Date and int(str(datestring).split('-')[0]) delivering a year 
like 2012

Buchung.objects.filter(Datum__year = int(str(datestring).split('-')[0]))


Help would be much appreciated.



. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
Developer
LexisNexis
A-1030 Wien, Marxergasse 25

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 1 53452 1573
Fax.: +43 1 534 52 146

. . . . . . . . . . . . . . . . . . . . . . . . . .

-- 
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: Implementing a monitoring system with django.

2012-12-17 Thread Sergiy Khohlov
"Pro python system administration"  by Rytis Sileika  published  by
Apress covers this area. Jinja2 is used for generating templates.  You
also can use django for this task.

Many thanks,

Serge


+380 636150445
skype: skhohlov


2012/12/17 Ryan Nowakowski :
> Checkout Graphite[1].  It seems like it would handle your graphing
> requirement.
>
> 1. http://graphite.wikidot.com/start
>
> On Mon, Dec 10, 2012 at 08:41:14PM +0100, Marc Aymerich wrote:
>> Hi,
>> I'm considering to implement a simple monitorization system that
>> basically gathers some data from a set of nodes (<1000 nodes). The
>> gathered data should be stored in order to let users perform some
>> queries and maybe also generate some graphs.
>>
>> I'm looking for advice in what components are best suited for each of
>> the following parts:
>>
>> 1) Storage: maybe something nonsql like MongoDB? or perhaps RRD?
>> 2) Data gathering: celery periodic tasks?
>> 3) Graphs: rrd? or some java script framework for graphing?
>>
>> thanks for your comments!!
>> --
>> Marc
>>
>> --
>> 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.
>>
>
> --
> 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.
>

-- 
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.