simplest solution to embed django server into an existing application.

2014-06-09 Thread Gelonida N

Hi,

I know, that ./manage.py runserver is not considered being secure.
In my context this doesn't matter.
What matters in my context is following:
- start a python process
- start at any time later on demand a web server
- this server shall serve django contents and shall have full read
  / write  access to main processes variables

I'd like to start one python process (an existing program I wrote quite 
some time ago and which I can't refactor easily. At the moment it just 
uses some Django ORMs, but serves no http requests).


For debugging reasons I'd like it to be able to start an embedded, 
unsecure web server on demand (can be single threaded. performance is 
not an issue), which has read / write access to the variables of my 
program (so it must not be started in a subprocess)


My first naive approach was starting the "runserver" command of the 
Django management commands.

This doesn't really work though.

Runserver seems to try to reexecute the entire python executable in 
another process. This causes problems as my code tries to access 
mutually exclusive resources (files, listening on sockets, . . . )


Does anyone have a suggestion of how to serve django contents from 
within one executable?


Would twisted be a solution? (serve django wsgi contents for http 
clients in a thread parallel to the main thread)? If yes does anyone 
have an example (only threads serving contents)


Do you have any other ideas / suggestions?

The solution should work for Linux and Windows and not require too many 
excotic packages / binaries to be installed.
(However if somebody knows a solution working only for one of the 
platforms I'd still be interested)


Thanks in advance for your ideas.



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ln4okr%24nh7%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.


Re: Running Shell script to run Django shell and then scp files to server...

2012-10-02 Thread Gelonida N

On 10/02/2012 04:47 PM, Tom Evans wrote:

On Tue, Oct 2, 2012 at 3:09 PM, Chris McComas  wrote:

I have a script in Django that I run manually 'python manage.py shell' and
then 'from sports import scores' and it goes out and pulls scores from a
couple URLs, modifies the data, and saves it to a SQLite database. Once that
process runs I manually scp my files to a server...

What I'd like to do is write a shell script that I can run on a cron to run
the process at set periods, both actions.

How would I do this so it properly runs the Django shell script?



You can write your own custom command - so run "python manage.py mycommand":

https://docs.djangoproject.com/en/1.4/howto/custom-management-commands/

Or you can setup your environment correctly, eg PYTHONPATH,
DJANGO_SETTINGS_MODULE et al, and run a regular python script. No docs
for this one, and I've always done the former rather than the latter.


If you don't want to write a management command:

This is what you roughly have to do:

import os, import sys
# setup sys.path such, that it finds all required modules

# New setup the environment so, that django settings can be found
os.environ['DJANGO_SETTINGS_MODULE'] = 'your_project.settings'

# next lines recommended to be sure your own code can use logging
from django.conf import settings

# DO NOT REMOVE NEXT COMMAND (It forces django.setting's
#  lazy evaluation to evaluate)
LOGGING = settings.LOGGING

import logging
# Now you can use logging with django setting's log setup

# Now You're free to use django

from your_project.your_app.models import MyModel















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.



adding a database (anda table with its model) on the fly

2012-09-16 Thread Gelonida N


I wondered whether there would be any way to add a new model and a new 
database without having to stop my processes.


I can imagine multiple use cases, where this could be intersting.

One  use case would be for example a graphical application:
- The user would select a sqlite file or perhaps any other DB
- the application would inspect the db and create models for each table
- the db and the models would be imported and added to django
- the user could create save and load query sets and visualize
the results


This can be done without the django orm, but I'd like to use the ORM if 
possible, as I like the construction of query sets.


Thanks for any opinions / answers suggestions.

--
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: how to let user change the language

2012-08-13 Thread Gelonida N

On 08/13/2012 12:09 PM, Marcin Tustin wrote:

This list is not here to find pages in the documentation for you. The
documentation has a contents page, and search.


Thank you very much for your help.


--
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: how to let user change the language

2012-08-13 Thread Gelonida N

I found now the right link to the right doc.

https://docs.djangoproject.com/en/1.3/topics/i18n/internationalization/

Must have been blind. I was not seeing this link for multile times and 
just found the article with the Django docs search funtion.



It mentions set_language(request)

I'll tyr that one out.


On 08/13/2012 12:54 AM, Marcin Tustin wrote:

So, what part, exactly is a problem? What have you tried?

On Sun, Aug 12, 2012 at 6:52 PM, Gelonida N <gelon...@gmail.com
<mailto:gelon...@gmail.com>> wrote:

On 08/12/2012 08:46 PM, Marcin Tustin wrote:

This is linked from the Django front page:
https://docs.djangoproject.__com/en/1.4/topics/i18n/
<https://docs.djangoproject.com/en/1.4/topics/i18n/>

Come back with specific questions when you get stuck.



Thanks for your answer.

I created already all the l18n messages and I can switch the
language site wise  by changing the language in settings.py

However Now I'd like to change them via user preferences. (not cookies)
(So if one user changes the language on one m,achine it should be
changed on any other machine if he logs in.

I'd prefer not to set the language as suggested by the browser, but
let the user the choice even if his useragent suggests another
prefered language.


There seems to be a url based approach and a cookies based approach
I wonder what would be best for my scenario.
(I am in full control of the web server and can add redirects /
rewrite rules, etc. if this helps)


This might be explained somewhere in more details in the Django
docss however I did not find the related page.

The doc mentions:
"It uses these hooks to localize Web apps for particular users
according to their preferences."

but I did not find the how



On Sun, Aug 12, 2012 at 1:10 PM, Gelonida N <gelon...@gmail.com
<mailto:gelon...@gmail.com>
<mailto:gelon...@gmail.com <mailto:gelon...@gmail.com>>> wrote:


 I'd like to have a web site, where the can switch the language
 The first time the user connects the language would be the
prefered
 language as sugegsted by the news agent,
 then the user could select the prefered lanngauge in some user
 preference settings.



 What would be the standard way to do this in Django?

 Thanks in advance for comments,  examples, snippets, links,

 --
 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 <mailto:django-users@googlegroups.com>
 <mailto:django-users@__googlegroups.com
<mailto:django-users@googlegroups.com>>.

 To unsubscribe from this group, send email to
 django-users+unsubscribe@__goo__glegroups.com
<http://googlegroups.com>
 <mailto:django-users%__2bunsubscr...@googlegroups.com
<mailto:django-users%252bunsubscr...@googlegroups.com>__>.

 For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
<http://groups.google.com/__group/django-users?hl=en>
 <http://groups.google.com/__group/django-users?hl=en
<http://groups.google.com/group/django-users?hl=en>>.





--
Marcin Tustin
Tel: 07773 787 105 <tel:07773%20787%20105>

--
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
<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to
django-users+unsubscribe@__googlegroups.com
<mailto:django-users%2bunsubscr...@googlegroups.com>.
For more options, visit this group at
http://groups.google.com/__group/django-users?hl=en
<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
<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to
django-users+unsubscribe@__googlegroups.com
<mailto:django-users%2bunsubscr...@googlegroups.com>.
For more options, visit this group at
http://groups.google.com/__group/django-users?hl=en
<http://groups.google.com/group/django-users?hl=en>.




--
Marcin Tustin
Tel: 07773 787 105

--
You received this message because you are subscribed to the Google
Groups "Django user

Re: how to let user change the language

2012-08-13 Thread Gelonida N


On 08/13/2012 12:54 AM, Marcin Tustin wrote:

So, what part, exactly is a problem? What have you tried?


Changing settings.LANGUAGE_CODE to another language, but this is 
obiously nto what I am looking for, as this does not allow to change the 
language on a user by use base.


If anybody showed my how to select the language on a requests basis, 
then the problem should basically be solved and I should be able to solv 
ethe rest by myself.



It may be, that there is an obvious mentioning in the documentation.
However I fail to see it. Thus my question.


What I'd like to achieve is to be able to have the language settings on 
a user by user basis.


I assume, that this can be achieved via some middleware and some state 
variable, that I had to link to a user.
I did not find the related documention and wanted to know if anybody can 
point me to the right doc (or section of the doc)


The link you refer to is exactly one page and somehow I miss to see any 
outgoing links to more specialized topics.
I know, that I rad already more docs about I18n for django, but don't 
remember the chapter / link name.


In fact the link doesn't even mention, that changing 
settings.LANGUAGE_CODE allows to change the language site wise.

So there must be some other doc explaining more.




On Sun, Aug 12, 2012 at 6:52 PM, Gelonida N <gelon...@gmail.com
<mailto:gelon...@gmail.com>> wrote:

On 08/12/2012 08:46 PM, Marcin Tustin wrote:

This is linked from the Django front page:
https://docs.djangoproject.__com/en/1.4/topics/i18n/
<https://docs.djangoproject.com/en/1.4/topics/i18n/>

Come back with specific questions when you get stuck.



Thanks for your answer.

I created already all the l18n messages and I can switch the
language site wise  by changing the language in settings.py

However Now I'd like to change them via user preferences. (not cookies)
(So if one user changes the language on one m,achine it should be
changed on any other machine if he logs in.

I'd prefer not to set the language as suggested by the browser, but
let the user the choice even if his useragent suggests another
prefered language.


There seems to be a url based approach and a cookies based approach
I wonder what would be best for my scenario.
(I am in full control of the web server and can add redirects /
rewrite rules, etc. if this helps)


This might be explained somewhere in more details in the Django
docss however I did not find the related page.

The doc mentions:
"It uses these hooks to localize Web apps for particular users
according to their preferences."

but I did not find the how



On Sun, Aug 12, 2012 at 1:10 PM, Gelonida N <gelon...@gmail.com
<mailto:gelon...@gmail.com>
<mailto:gelon...@gmail.com <mailto:gelon...@gmail.com>>> wrote:


 I'd like to have a web site, where the can switch the language
 The first time the user connects the language would be the
prefered
 language as sugegsted by the news agent,
 then the user could select the prefered lanngauge in some user
 preference settings.



 What would be the standard way to do this in Django?

 Thanks in advance for comments,  examples, snippets, links,

 --
 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 <mailto:django-users@googlegroups.com>
 <mailto:django-users@__googlegroups.com
<mailto:django-users@googlegroups.com>>.

 To unsubscribe from this group, send email to
 django-users+unsubscribe@__goo__glegroups.com
<http://googlegroups.com>
 <mailto:django-users%__2bunsubscr...@googlegroups.com
<mailto:django-users%252bunsubscr...@googlegroups.com>__>.

 For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
<http://groups.google.com/__group/django-users?hl=en>
 <http://groups.google.com/__group/django-users?hl=en
<http://groups.google.com/group/django-users?hl=en>>.





--
Marcin Tustin
Tel: 07773 787 105 <tel:07773%20787%20105>

--
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
<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to
django-users+unsubscribe@__googlegroups.com
<mailto:django-users%2bunsubscr...@googlegroups.com>.
 

Re: how to let user change the language

2012-08-12 Thread Gelonida N

On 08/12/2012 08:46 PM, Marcin Tustin wrote:

This is linked from the Django front page:
https://docs.djangoproject.com/en/1.4/topics/i18n/

Come back with specific questions when you get stuck.



Thanks for your answer.

I created already all the l18n messages and I can switch the language 
site wise  by changing the language in settings.py


However Now I'd like to change them via user preferences. (not cookies)
(So if one user changes the language on one m,achine it should be 
changed on any other machine if he logs in.


I'd prefer not to set the language as suggested by the browser, but let 
the user the choice even if his useragent suggests another prefered 
language.



There seems to be a url based approach and a cookies based approach I 
wonder what would be best for my scenario.
(I am in full control of the web server and can add redirects / rewrite 
rules, etc. if this helps)



This might be explained somewhere in more details in the Django docss 
however I did not find the related page.


The doc mentions:
"It uses these hooks to localize Web apps for particular users according 
to their preferences."


but I did not find the how




On Sun, Aug 12, 2012 at 1:10 PM, Gelonida N <gelon...@gmail.com
<mailto:gelon...@gmail.com>> wrote:


I'd like to have a web site, where the can switch the language
The first time the user connects the language would be the prefered
language as sugegsted by the news agent,
then the user could select the prefered lanngauge in some user
preference settings.



What would be the standard way to do this in Django?

Thanks in advance for comments,  examples, snippets, links,

--
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
<mailto:django-users@googlegroups.com>.
To unsubscribe from this group, send email to
django-users+unsubscribe@__googlegroups.com
<mailto:django-users%2bunsubscr...@googlegroups.com>.
For more options, visit this group at
http://groups.google.com/__group/django-users?hl=en
<http://groups.google.com/group/django-users?hl=en>.




--
Marcin Tustin
Tel: 07773 787 105

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



how to let user change the language

2012-08-12 Thread Gelonida N


I'd like to have a web site, where the can switch the language
The first time the user connects the language would be the prefered 
language as sugegsted by the news agent,
then the user could select the prefered lanngauge in some user 
preference settings.




What would be the standard way to do this in Django?

Thanks in advance for comments,  examples, snippets, links,

--
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: I can not install Django on Windows7

2012-07-22 Thread Gelonida N

On 07/18/2012 02:50 PM, Владислав Иванов wrote:

when I run the installation of Django python setup.py install - comes at
the end of an error that can not be put Django in C: \ Python27 \ Lib \
site-packages

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


Not sure who and how your python was installed.

On my Windows 7 I can just pip install Django.

However you might try to open a shellwindow as administrator and pip 
install from there.



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



Recommended middleware /tools.tips for profiling a django server

2012-07-11 Thread Gelonida N

Hi,
I'm having a nginx / uwsgi / django server and wanted to get some 
profiling data to identify bottle necks learn more about where time is 
consumed
(80% dynamic difficult to cache contents, so don't worry too much about 
serving static contents)



In this question I'm mostly interested in django / python specific 
profiling.

I posted another question in the uwsgi group for uwsgi specific profiling.


What would be recommended strategies to create decent reports, that can 
help to pinpoint potentially critical code.



I could add specific profiling features to the server even if they would 
slow down the system. I'd just enable them for a few days, gather the 
data and would disable them afterwards.



What statistics do you normally use to identify such issues and how 
could you get them?


Some measures I can think of:


report of django requests and their execution time
-
Is there already any simple middleware measuring request times.
It might be useful for profiling on test servers.
On the real servers I'd probably use directly the uwsgi logs, which 
report if I recall correctly already the request time.



individually profile each Django request
--

In django snippets I found a profiling middleware
http://djangosnippets.org/snippets/727/ which seems to print the stats 
just plainly into the log file. Not sure how one is supposed to create a 
decent report afterwards.


Alternatively I found a suggestion of using hotshot and save the reports.
https://code.djangoproject.com/wiki/ProfilingDjango
http://packages.python.org/django-extensions/runprofileserver.html

or another profiling middleware reporting for each request at the end of 
the response. 
http://www.no-ack.org/2010/12/yet-another-profiling-middleware-for.html


ANy experience with any of above.


number of SQL queries
---
I know how to visualize the number of sql queries for a page request 
with django debug toolbar.


I wondered about a good middleware to report this on a view by view 
basis or on a client by client basis




analyzing these reports.
--

Any good tools to analyze profiling reports for a django uwsig setup.

At the moment I itnend to view whatever reports manually or with self 
written scripts, but would be interested inwhat others use.



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



decorating an include in urls.py

2012-07-06 Thread Gelonida N

I'd like to decorate all views in an include.

Let's take for example:

urlpatterns = patterns('',
url(r'^decorated_admin/', include(admin.site.urls)),
)


Is there any way to decorate all views in admin.site.urls

I was looking for a syntax similiar to:

urlpatterns = patterns('',
url(r'^webfw/admin/', include_and_decorate(admin.site.urls,
  mydecorator)),
)




One use case would be for example to add authentification or specific 
logging  to an entire list of views.



Thanks in advance for any suggestions.

--
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: setting up new django project

2012-06-21 Thread Gelonida N

On 05/28/2012 04:53 AM, xaegis wrote:

Hello, this is my first time posting to a list!
  I am running python 2.7 with django 1.4 installed on Ubuntu 12.04
I am having trouble creating new projects with django. Whenever I use
the command:
Code:

sudo /usr/local/lib/python2.7/dist-packages/django/bin/django-admin.py
startproject cms

I get errors or permission denied messages but if I use:
Code:



Just one other comment.

Are you really sure, that you want to create a Django project with root 
privileges?


This is rather unusual.

Why do you want to do this?

--
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: DRY violation using get_or_create with defaults

2012-06-12 Thread Gelonida N

On 06/12/2012 05:44 AM, Jerome Baum wrote:

Drop the "defaults" kwarg to get_or_create as apparently you're not
using it. Also drop the conditional on those set/save statements.




Wouldn't this create more db accesses than the original code?


On Monday, June 11, 2012 3:44:47 PM UTC+2, ojno wrote:

Hi all,

In my app, which involves doing background tasks and possibly
rerunning them a number of times, I find myself using this pattern a
lot:

instance, created = Model.objects.get_or_create(key1=key1,
key2=key2,
defaults={"field1":field1, "field2":field2})
if not created:
instance.field1 = field1
instance.field2 = field2
instance.save()


This is unsatisfyingly WET. Does anyone know a better way to do this
that still preserves all the integrity and lack of race conditions
get_or_create gives you?

Thanks,
ojno




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



Is there anything like 'static' templates

2012-06-09 Thread Gelonida N

Hi,


This is mostly out of curiousity.

Let's imagine a site containing mostly static HTML files.
However due to laziness / ease of changing the overall sites layout
and the option of using django compressor for the included .css .js files
I wondered how I could use templates and still serve the resulting files
directly by the web server (have them located in 'static' / 'media')


So is there any tool helping with such a work flow?

- Edit modify Change the 'static' templates
- running a build script (or a modified 'collect-static' script)
   creating the resulting html files from their 'static' templates
   and placing them in the static folder.
   and then potentially create the related 'django-compressed' files in
   /static (or /media)








--
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: Tutorial database problem

2012-05-28 Thread Gelonida N

On 05/27/2012 05:38 AM, phantom21 wrote:

I've tried to set up the database as sqlite3.  I keep getting an error
on the ENGINE line, but can't figure out why as it looks correct.

Here is the database section:


DATABASES = {
 'default': {
 'ENGINE': 'django.db.backends.sqlite3',
 'NAME': '/usr/bin/sqlite3/mark.db',  # Or path to database
file if using sqlite3
 'USER': '',  # 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.
 }
}


And here is the error I receive:

Traceback (most recent call last):
   File "manage.py", line 10, in
 execute_from_command_line(sys.argv)
   File "/usr/local/lib/python2.7/dist-packages/django/core/management/
__init__.py", line 443, in execute_from_command_line
 utility.execute()
   File "/usr/local/lib/python2.7/dist-packages/django/core/management/
__init__.py", line 382, in execute
 self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/usr/local/lib/python2.7/dist-packages/django/core/management/
base.py", line 196, in run_from_argv
 self.execute(*args, **options.__dict__)
   File "/usr/local/lib/python2.7/dist-packages/django/core/management/
base.py", line 232, in execute
 output = self.handle(*args, **options)
   File "/usr/local/lib/python2.7/dist-packages/django/core/management/
base.py", line 371, in handle
 return self.handle_noargs(**options)
   File "/usr/local/lib/python2.7/dist-packages/django/core/management/
commands/syncdb.py", line 57, in handle_noargs
 cursor = connection.cursor()
   File "/usr/local/lib/python2.7/dist-packages/django/db/backends/
dummy/base.py", line 15, in complain
 raise ImproperlyConfigured("settings.DATABASES is improperly
configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is
improperly configured. Please supply the ENGINE value. Check settings
documentation for more details.





Well your DATABASES settings look fine (except of the path of the NAME 
entry as others have already pointed out.

To be very sure there are no permission problems


Do you get the error already when running the command

python manage.py syncdb





For testing you could add following line as LAST line in settings.py

print 'DATABASES = %r' % DATABASES

and paste the results to your next answer.
Printing with %r has also the advantage of revealing any hidden characters.


Are you sure, that django uses the setting.py file, that you modified???

If you're not sure, than add following line as the FIRST line in settings.py
a = 1 / 0

If Django fails now with a division by zero you're sure it's using the 
file you think it's using and you can remove this line again.





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



anybody used Jython 2.5+ and Django

2012-05-27 Thread Gelonida N

Did anybody play with this?

What versions of django are supported?

What DB engines are supported?

Any performance comparison between Cpython and Jython?

Thanks in advance for pointers / comments


Any hints on how to create  such a setup on  Ubuntu 12.04?


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



can the Django test server serve cgi scripts?

2012-05-13 Thread Gelonida N

I know, that performance would be entire crap.
However sometimes this could be useful for a minimalist setup.

So let me explain:

For testing I'd like start no web server at all, just the django test 
server. (./manage.py ./runserver )


It will handle all static files and all django views.

Now I'd like to call one CGI script. ( /cgi-in/test.cgi )

What I though is to add a rule to urls.py,

Is there any module, which could setup the environment, call an external 
executable and return its output via django.


Thanks in advance for any suggestion.


--
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: Can't access database with normal Ubuntu Terminal user

2012-04-18 Thread Gelonida N
Not sure if this helps you.


I had to create the file ~/.pgpass in the home directory of my
developers account.


I repeated there the data base name, the user name and the password for
my database.

Example:

localhost:*:db_name:username:password


Afterwards I was able to access the db with
./manage.py dbshell



On 04/17/2012 08:50 AM, Guillaume Chorn wrote:
> Something more specific in case it helps: as an example, when I try to
> access my admin view while logged in as my regular user ("guillaume")
> instead of "postgres", I get the following error:
> 
> 
>   OperationalError at /admin/
> 
> FATAL:  Peer authentication failed for user "postgres"
> 
> Request Method:   GET
> Request URL:  http://127.0.0.1:8000/admin/
> Django Version:   1.3.1
> Exception Type:   OperationalError
> Exception Value:  
> 
> FATAL:  Peer authentication failed for user "postgres"
> 
> Exception Location:
> /usr/local/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py
> in _cursor, line 140
> Python Executable:/usr/bin/python
> Python Version:   2.7.2
> Python Path:  
> 
> ['/home/guillaume/moisiedarling',
>  '/usr/lib/python2.7',
>  '/usr/lib/python2.7/plat-linux2',
>  '/usr/lib/python2.7/lib-tk',
>  '/usr/lib/python2.7/lib-old',
>  '/usr/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages',
>  '/usr/lib/python2.7/dist-packages/PIL',
>  '/usr/lib/python2.7/dist-packages/gst-0.10',
>  '/usr/lib/python2.7/dist-packages/gtk-2.0',
>  '/usr/lib/pymodules/python2.7',
>  '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-client',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-couch',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-installer',
>  '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
>  '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
> 
> Server time:  Tue, 17 Apr 2012 01:46:23 -0500
> 
> 
> 
> On Tue, Apr 17, 2012 at 2:07 PM, Gchorn  > wrote:
> 
> I'm not totally sure if this qualifies as a Django question, but
> it's impeding my ability to make a website with Django so I thought
> I'd ask here.  I'm working with Django in Ubuntu 11.10, where I've
> set up PostgreSQL to make and manage databases for my Django-powered
> website.  Unfortunately, when working with Django in the Terminal, I
> need to first switch over to the user "postgres" (the user I created
> when installing PostgreSQL) in order to do anything with PostgreSQL
> or its databases.  This becomes a problem when I need to
> simultaneously access my database and the local file system, since
> my local filesystem is only accessible to my normal Ubuntu Terminal
> user, "guillaume."
> 
> I already have the correct user and passwords entered in my
> settings.py file for my database, but this doesn't seem to help--I
> still need to switch over to "posgres" in the Terminal to access my
> databases.  I'm guessing I need to either a) give "guillaume" access
> to my databases (which I've tried reading up on in the PostgreSQL
> docs, but am still not sure how to do...part of it is I'm not sure
> how to tell apart Ubuntu users, Unix users, and Postgres users), or
> I need to b) give "postgres" access to my local file system.  Can
> anyone tell me which is the better route to follow, and how to
> achieve it?
> 
> -- 
> 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/-/1NWyssjq5sYJ.
> 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.



Re: Logging works from 'manage.py shell', not from app

2012-04-18 Thread Gelonida N
On 04/13/2012 07:41 PM, Jeff Blaine wrote:
> Hi all. I'm stumped on something. Using logging via 'manage.py shell' is
> working as expected. Using it in the webapp generates zero data and
> zero errors.

I'm not sure whether this is your problem, but please note, that logging
to a log file is not a good idea for django, which might spawn multiple
processes.

logging to log files works only from multiple threads (all spanweed by
the same process)

For very first tests you could use a stdout / stderr log handler or
lateron a socket logger.


> 
> NOTE: /var/log/hostdb.log is WORLD WRITABLE (in order to dodge any
> permissions errors right now while debugging this)
> 
> My logging settings are as follows:
> 
> LOGGING = {
> 'version': 1,
> 'disable_existing_loggers': True,
> 'formatters': {
> 'verbose': {
> 'format': '%(levelname)s %(asctime)s %(module)s %(process)d
> %(thread)d %(message)s'
> },
> 'simple': {
> 'format': '%(levelname)s %(message)s'
> }
> },
> 'handlers': {
> 'console': {
> 'level':'DEBUG',
> 'class':'logging.StreamHandler',
> 'formatter': 'verbose'
> },
> 'logfile': {
> 'level': 'DEBUG',
> 'class': 'logging.handlers.WatchedFileHandler',
> 'formatter': 'verbose',
> 'filename': '/var/log/hostdb.log',
> 'mode': 'a'
> }
> },
> 'loggers': {
> 'django.request': {
> 'handlers': ['logfile', 'console'],
> 'level': 'DEBUG'
> }
> }
> }
> 
> For example, the following works fine (shows up in /var/log/hostdb.log):
> 
> python manage.py shell
>>> import logging
>>> l = logging.getLogger('django.request')
>>> l.info('this is info!')
> 
> Yet I get absolutely nothing logged when a click through pages of the
> app itself.
> 
> Any ideas?
> 
> -- 
> 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/-/TKIfqpwWZcUJ.
> 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: Simplest way to get all models for which admin interface exists

2012-03-15 Thread Gelonida N
Thanks a lot Matt,

On 03/15/2012 03:20 AM, Matt Schinckel wrote:
> All installed ModelAdmin models:
> 
 from django.contrib.admin import site
 site._registry.keys()
> 
> If you only got at this from `manage.py shell`, then you may need to
> import your urls.py file first.
> 
> Getting those that are not registered is a bit longer:
> 
 from django.db.models import get_models
 from django.conf import settings
 set(get_models()).difference(site._registry.keys())
> 
Exactly what I was looking for.


-- 
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: How to disable re-POST via F-5

2012-03-14 Thread Gelonida N
On 03/15/2012 12:35 AM, Russell Keith-Magee wrote:
> 
> On 15/03/2012, at 5:32 AM, Gelonida N wrote:
> 
>> Hi,
>>
>> I'm having a django view, that works for GET and POST requests.
>>
>> Basically une can view some data with GET
>> and add / moify data with a tiny form and POST
>>
>> As the data can change I added a refresh button and this works fine.
>>
>> The problem is just, that some users don't use it but insist on using
>> the F5 (reload) key of their browser.
>>
>>
>> F5 works also well if the previous request was a GET request.
>>
>> However if the previous request was a POST request the browser rebosts
>> and fould thus add some data a second time.
>>
>>
>> Now my question:
>>
>> How to fix this best I have some (untested) ideas, but am not sure
>> what's best.
>>
>> 1.) redirect to same url after post.
> 
> Redirect after post is the right approach. So much so, that it is stated as 
> the right approach (and described as "just good Web development practice") in 
> Django's tutorial 4.
> 
> Yours,
> Russ Magee %-)
> 
Thanks a lot.

Probably I'll do this at least for a start.


I'd still bec curious though, whether there were other approaches
avoiding the redirect, as some of the users will connect over very slow
networks.

So there might be the small risk of a noticable increased latency.

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



Simplest way to get all models for which admin interface exists

2012-03-14 Thread Gelonida N
Hi,

Title says it all.

What is the simplest way to get a list of models for which an admin
interface exists?


I'd also be interested in getting a list of all models for which no
admin interface exists.

-- 
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 disable re-POST via F-5

2012-03-14 Thread Gelonida N
Hi,

I'm having a django view, that works for GET and POST requests.

Basically une can view some data with GET
and add / moify data with a tiny form and POST

As the data can change I added a refresh button and this works fine.

The problem is just, that some users don't use it but insist on using
the F5 (reload) key of their browser.


F5 works also well if the previous request was a GET request.

However if the previous request was a POST request the browser rebosts
and fould thus add some data a second time.


Now my question:

How to fix this best I have some (untested) ideas, but am not sure
what's best.

1.) redirect to same url after post.
===
I assume if I would redirect after the post, thet I would then have the
same page with a get request and subsequent reloads would thus work.

What I don't like is, that this would cause one request more to the
server and thus slightly increase he load of the server and reduce the
latency especially on slow networks (mobile phones)

2.) add some values into the form, which allow detecting a second post
==

I could add a hidden unique value to the post, which would allow me to
detect, that this post has been made already.
If I detect such a double POST, I could ignore it.



3.) Try to solve the issue on the browser side
==

I'm not that experienced, but perhaps some javascript code in the
templates could ensure, that F5 is either blocked or converted to a GET
request???

Or perhaps js could change the url (adding a get parameter) such, that I
can detect a repost by F5



Please note:
What I try to do here is not protecting the site against malicious users.
I try to protect it against accidental reposts. The views in question
do allow multiple posts of the same data and this is useful if done
intentionally by a user. It should just not happen if somebody just
wants to refresh the screen with F5.








-- 
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 admin templates: filter hides table contents

2012-02-13 Thread Gelonida N
Hi,

I wanted to know whether anybody modified the django admin templates such,
that the filter div could be hidden.

At the moment the  containing the filters may hide the
contents of the table.


As I can imagine, that I'm not the only one who might  have large tables
and doesn't like, that part of the table data is hidden behind these
filters I wanted to know whether anybody changed the templates / style
sheets / javascript such, that it is possible to
show / hide the filter window (similiar to how it is done for the
django debug tool bar.

Usage of jquery for showing / hiding is no wroblem as I juse jquery
already for other pages.

Thanks in advance for your answers.



-- 
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: Website Statistics - What should I use to have Google Analytics in Django?

2011-12-01 Thread Gelonida N
On 11/30/2011 09:25 PM, Andre Lopes wrote:
> Hi,
> 
> I need to track visitors with Google Analytics. What should I use to
> get Google Analytics working on Django?
> 
> What is my best choice?
> 
> Best Regards,
> 

Out of curiousity:

Is there anything similiar  which does work well in an intranet
environment or an environment, where one does not want to send data to a
third party server?


-- 
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: Fixture migrations using South?

2011-12-01 Thread Gelonida N
On 11/30/2011 06:26 PM, Jeremy Dunck wrote:
> I have some test fixtures with scenarios under test.  Later, I need to
> migrate (with South) the DB schema around, which of cours necessitates
> changing domain and test code.
> 
> A common problem I run into, though, is that I also need to migrate
> the data in my fixtures.  It is possible to create a new DB, sync it
> to a given migration point, load the fixture, run the remaining
> migrations, and dump a new fixture, then drop the extra db.  But it
> seems like a very awkward dance given how often I have the problem.
> 
> Is there already a solution to this?   It seems to me that South could
> manage some book keeping to maintain what fixtures are at which
> migration level, and a new south command could manage the migration of
> fixtures.
> 
Agreed.

The fact that I have to manually migrate fixtures.
(initialize db with old version, apply fixtures, migrate, extract
fixtures) is one of the reasons why I use fixtures less often then code
generating input data.

A small tool migrating fixtures (at least for amy trivial migrations)
with south might be an incentive to use them a little more often.


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



unit tests and 'system' tests with history

2011-11-30 Thread Gelonida N
I started implementing tests for my django application.


I anticipate two kind of tests:


1.) Unit tests
---

The unit tests should be as the uni tests are implemented in django.

They should be 'atomic' independent, could be executed in any order and
should always yield the same results


2.) Stress / System tests
--

I'd also like to do some other tests, where I work on a system and where
I am able to suffer from my history.

Example (the example is perhaps too simple to see what I'm aiming it)
- I create an entry
- I rename an entry
- I remove an entry

If I had three independent tests I would never find out if I had a weird
bug, which would make the system fail if I tried to remove an entry
which has been renamed before.


What would be a recommended way to run such system tests?

'just create a unit test, which is just calling sunb tests explicitely
in the required order?)

As part of these system tests I would like to add some of my unit tests,
but such, that the data base is NOT reset after each test run.


As you can see from my previous questions I'm used to 'non-atomic'
testing (This was for systems which needed a very huge startup time
and where taking snapshots was virtually impossible)

Thus I often combined unit tests / system tests.

These stress tests shall be able to run for several hours / days,
whereas unit tests would run in a few minutes.


Thanks for any suggestions


-- 
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 tests. where to create users

2011-11-30 Thread Gelonida N
On 11/29/2011 12:34 PM, Piotr Zalewa wrote:
> I use all solutions, depending on the needs.
> 
> When I'm testing a usage of many objects I use fixtures (also with users
> as I'm "pretending" that users created them)
> 
> When there is a test involving a user I create this object, either in
> test or the setUp.
> 
> On 11/28/11 01:58, Gelonida N wrote:
>> Hi,
>>
>> I'd like to run some django tests, which use the test client and which
>> should check, that certain users can only access certain contents.
>>
>> Where would you create this users / passwords.
>> - With a fixture
>> - as part of a test class in the SetUp section and tear
>>   it down afterwards?
> 
> There is no need to remove them
> Just create a user in setUp if you need it for all tests, if for a part
> of the tests only - create 2 test classes and create a user in one of
> them only

Thanks. Yes I noticed meanhwile as well that the the database is reset
implicitely.

> 
>> - create a custom test runner with a setup phase ?
> 
> I've got it as well - I don't create users there, but I've got a few
> other methods which are useful for more than one app.
> 
I mightl look at something like this.
If you midofied the database there, then would this become the initial
state for each test?
Reading the doc I assume yes.

>> Is there any other recommended code section, which could do the setup
>> prior to running tests.
>>
>> Ideally I'd like to avoid fixtures.
> 
> Is there a reason?
> 
Two reasons:

Migrations:

Fixtures are rather sensitive to migrations
(so as part of the migration steps I had to regenerate them)

Lack pseudo randomness:
--
It's a question of taste, but I like a certain amount of controlled
randomness in my tests and data sets. (The idea is to log the random
seed in order to be able to reproduce failures)
So a test covers all the anticipated boundary cases (if the amount is
small enough) , but explores some  others as well.
 As soon a s a new killer data set is found it can be
added as a separate test (or fixture).












-- 
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 tests. where to create users

2011-11-30 Thread Gelonida N
On 11/29/2011 11:45 AM, Tom Christie wrote:
> What's wrong with just creating them in the .setUp()?
> 
> Don't sweat the small amount of time it'll take to re-create the users
> on each test run, it's almost certainly not worth worrying about.
> 

Well this is what I'm doing at the moment.
And I think you're right for this case:
Creating users will not be where a considerable amnount of time is
spent.

I'm just learning to use Django-testing / unit tests and as I could
imagine other setup activities which would consume more time
for setup I wanted to see whether there are ways to do some
programatical setup of 'fixtures' before the first test is run.

Basically I'd like to be sure I know my tools.

-- 
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: Simple task dispatching (How heavy is celery + RabbitMQ)

2011-11-28 Thread Gelonida N
On 11/28/2011 12:14 PM, Gelonida N wrote:
> Hi,
> 
> I'd like to use a light weight dispatching system for a web server.
> 
> Basically some django post requests might require processing, which
> should be done in the back ground due to its run times.
> 
> The results would be added to the django data base.
> 
> The browser could verify via AJAX requests whether the task is finished.
> 
> 
> The server would be running on a rather weak virtual machine with rather
> low memory (nginx / uwsgi / django )
> 
> ( For testing  I run the server on windows with one of the following
> setups (depending on what I'd like to test)
> - django runserver
> - twisted - django
> - cygwin/nginx - fastcgi - django
> 
> Most people seem to recommend celery with RabbitMQ.
> If I understood well, rabbit MQ requires Erlang to be installed and I
> found some posts indicating that RabbitMQ requires quite some memory
> 
> So I wondered whether celery / RabbitMq wouldn't be a little on the
> heavy side and eat away a little too much from my meory.
> 
> 
> Is there any good light weight dispatching alternative to celery or
> would this be one of these  'roll your own dispatcher' tasks?
> 
> 
Thanks a lot for all your answers.


To summarize quickly
RabbitMQ doe snot seem to be as greedy as I expected (probably around
19MB for my expected load)

Django-ztask is a small brokerless solution

Celery supports multiple brokers with difference performance. the dd
broker would not require an additional process (apart from celery)


uwsgi has a spooler which might be what I'm looking for I just would
like to execute some tasks, which are too slow to be treated directly
within an HTTP request  sequentially one after the other.

However if I used uwsgi I had to look for an alternative implementation
and a small wrapper such, that the system would still be working on a
windows host without uwsgi. (performance on windows is not crucial, but
it should work)

Now I just need some time to test some of these options on  windows PC
and on my tiny virtual linux host.


-- 
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 tests. where to create users

2011-11-28 Thread Gelonida N
On 11/28/2011 01:58 AM, Gelonida N wrote:
> Hi,
> 
> I'd like to run some django tests, which use the test client and which
> should check, that certain users can only access certain contents.
> 
> Where would you create this users / passwords.
> - With a fixture
> - as part of a test class in the SetUp section and tear
>  it down afterwards?
> 
> - create a custom test runner with a setup phase ?
> 
> Is there any other recommended code section, which could do the setup
> prior to running tests.
> 
> Ideally I'd like to avoid fixtures.
> Of course I could create a script to generate certain fixtures and run
> only then the tests, but I'd prefer, the user data is created ad part of
> the test procedure.
> 
> 

I played a little more with django unit tests.

Django will reset the data base after each single test.

So it seems, I am stuck with fixtures at least at the moment I do not
know how to create users without fixtures such, that they would be
persistent between unit tests.

I really don't want to use fixtures, but some warm up code run only once
prior to running tests.

Any ideas?


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



Simple task dispatching (How heavy is celery + RabbitMQ)

2011-11-28 Thread Gelonida N
Hi,

I'd like to use a light weight dispatching system for a web server.

Basically some django post requests might require processing, which
should be done in the back ground due to its run times.

The results would be added to the django data base.

The browser could verify via AJAX requests whether the task is finished.


The server would be running on a rather weak virtual machine with rather
low memory (nginx / uwsgi / django )

( For testing  I run the server on windows with one of the following
setups (depending on what I'd like to test)
- django runserver
- twisted - django
- cygwin/nginx - fastcgi - django

Most people seem to recommend celery with RabbitMQ.
If I understood well, rabbit MQ requires Erlang to be installed and I
found some posts indicating that RabbitMQ requires quite some memory

So I wondered whether celery / RabbitMq wouldn't be a little on the
heavy side and eat away a little too much from my meory.


Is there any good light weight dispatching alternative to celery or
would this be one of these  'roll your own dispatcher' tasks?


-- 
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 testing. random test order with some 'dependency constraints'

2011-11-28 Thread Gelonida N
Hi Russel,

Thanks for your answer.

On 11/28/2011 04:12 AM, Russell Keith-Magee wrote:
> On Mon, Nov 28, 2011 at 9:39 AM, Gelonida N <gelon...@gmail.com> wrote:
> . . . 
> Unit tests are supposed to be isolated. They shouldn't depend on
> execution order, or have any pre-requisite other than those specified
> as part of the setUp()/teardown() methods. As a result, you won't find
> a whole lot of documentation on how to do what you're describing.
> 
> The right way to approach this is to identify the required
> preconditions for each test, and either construct those preconditions
> in the setUp() method, 
Yes. However setUp() is being called prior to every test,

So either I had to add caching into the setUp() section
or I had to use setUpClass() / tearDownClass()

I think that with a mix of SetUpClass() / setUp() and some 'caching'
logic I should be able to benefit from results of previous tests if I
wanted to.
Benefiting from previous tests is mainly for run time reductions, which
will allow to run more tests in a reasonable amount of time.



or use Django's test fixtures to install test
> data.
> 

> This is all covered in the documentation for Django's testing system;
> most notably in the section on fixtures.
> 
> [1] https://docs.djangoproject.com/en/1.3/topics/testing/#fixture-loading
> 
I try to avoid fixtures, as they don't allow to create smart data
(except I run a fixture generation tool prior to running the tests)

But perhaps I could create the fixture in the setUpClass() section if
not already existing. and just load them if they already existed.

I just had to find some logic, which would expire outdated fixtures (due
to migrations / etc)

> More broadly, you might want to dig into the documentation for
> Python's unittest module, which is what Django's unit test framework
> is built on.

Now I just have to look at how to best do the shuffling of tests in
order to have a random execution order.
Probably only shuffling only within TestCase classes and shuffling the
order of the TestCases would be what gives least penalty for run time,
but some unpredictable order.

So far I found only sortTestMethodsUsing(), which is not exactly
shuffling but might be one way to change the order.

I'll look also at
load_tests(), discover() / etc.

Though I'm still not sure about the *best* place to introduce shuffling
(without dependency checks)


The documentation mentions, that care has to be taken about test
fixtures *if* one does randomize the order. However no suggestion is
made *how* to best randomize the order if one desires to.


I will do some more searching / expereimenting.
The reasons why I asked this  question is to avoid, that I implement a
working, but rather inelegent / inefficient solution to a problem, which
has already been tackled by others in a more elegant way.




-- 
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 testing. random test order with some 'dependency constraints'

2011-11-27 Thread Gelonida N
I'd like to create some unit tests whch should be executed in random order.


However some tests could benefit from results of some predecessor tests.

Therefore they should be executed only after certain tests.

Did anybody try to implement such a test setup with Django's default
unit tests?

Are there any 'recomended' ways / hooks of changing the order of tests?
Do many test cases depend on a certain order of test??
If yes, then I had to know how to exclude these tests from shuffling.

Are there any recommendations of how to describe dependencies?

Are there any recommended ways of how to carry data between different
tests? (e.g. make them member of the same TestCase class)


Thanks a lot for some feedback / suggestions.




-- 
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 tests. where to create users

2011-11-27 Thread Gelonida N
Hi,

I'd like to run some django tests, which use the test client and which
should check, that certain users can only access certain contents.

Where would you create this users / passwords.
- With a fixture
- as part of a test class in the SetUp section and tear
 it down afterwards?

- create a custom test runner with a setup phase ?

Is there any other recommended code section, which could do the setup
prior to running tests.

Ideally I'd like to avoid fixtures.
Of course I could create a script to generate certain fixtures and run
only then the tests, but I'd prefer, the user data is created ad part of
the test procedure.


-- 
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 testing with postgres without permissions to create databases

2011-11-26 Thread Gelonida N
On 11/26/2011 01:23 AM, Gelonida N wrote:
> It seems I'm not the first one who wans to run django tests with
> postgressql and who doesn't have permissions to create databases.
> 
> I found two suggestions on the web:
> 
> One is to use sqlite for testing instead of postgres.
> However I'm not really happy with this solution, as sqlite is less
> sensitive to sloppyness in the code. I encountered already some issues
> only with postgres, but not with sqlite.
> 
> The other suggestion, that I found is implementing a custom test runner,
> that adapts setup_databases()
> 
> I'll probably try that approach, but was curious about other potential
> tricks.
> 

For the time being I just followed a third path, which is requesting
create privileges.

I could still imagine, that it would be a good idea for some users, if
the default test runner were able handle situations where one has no
create database privileges.


-- 
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: disabling south for running tests

2011-11-26 Thread Gelonida N
Hi Chris,

Thanks a lot.

On 11/26/2011 09:51 AM, Chris Northwood wrote:
> On 25 November 2011 23:59, Gelonida N <gelon...@gmail.com> wrote:

>> As for testing the database is created from scratch and as migrations
>> are not really needed in this case I decided to disable south for
>> running tests.
>>
>> I just wondered whether there were alternative /  more elegant ways.
> 
> There's a setting built into South which does this:
> SOUTH_TESTS_MIGRATE
> [http://south.aeracode.org/docs/settings.html#south-tests-migrate]
> 

I will use SOUTH_TESTS_MIGRATE=True.
This is nicer than my 'workaround'

-- 
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 testing with postgres without permissions to create databases

2011-11-25 Thread Gelonida N
It seems I'm not the first one who wans to run django tests with
postgressql and who doesn't have permissions to create databases.



I found two suggestions on the web:

One is to use sqlite for testing instead of postgres.
However I'm not really happy with this solution, as sqlite is less
sensitive to sloppyness in the code. I encountered already some issues
only with postgres, but not with sqlite.

The other suggestion, that I found is implementing a custom test runner,
that adapts setup_databases()

I'll probably try that approach, but was curious about other potential
tricks.



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



disabling south for running tests

2011-11-25 Thread Gelonida N
Hi,


I just started my first experimets wit running django tests and
encountered several issues.

One of the issues is related to south.

If I want to run  single short tests. then I spend more time creating
the database than I need to run the tests.

The database creation time is especially high if the project contains
already many south database migrations.

As for testing the database is created from scratch and as migrations
are not really needed in this case I decided to disable south for
running tests.

The oway, that I came up with is following.

in settings.py

I do:

# try to determine, whether in testing mode or
# whether in 'normal' mode

# Thanks to Mike Dewherst for pointing me to this 'trick'
# of how one could detect whether one started tests
# Depending on the exact needs, the condition could be
# tuned / adapted
if not 'test' in sys.argv[1:]:
TESTING = True
else:
TESTING = False

if not TESTING:
INSTALLED_APPS +=  ( 'south', )

This is doing the job:

I just wondered whether there were alternative /  more elegant ways.









-- 
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 1.3 and django-test-utils Persistent Database Test Runner

2011-11-25 Thread Gelonida N
I just discovered django-test-utils on the web and noticed, that it has
some functionality, that looks interesting to me.

http://readthedocs.org/docs/django-test-utils/en/latest/keep_database_runner.html#
this shall introduce a management command 'quicktest', which is supposed
to keep the test database intact between two test runs.

However the documentation dates from 2009 and contains the comment:
> Currently support for 1.2 is in a 1.2 compatible branch. This will be merged 
> into trunk soon.

which might indicate, that the project is no more maintained and not
usable for django_1.3

A first test indicates also, that the code is not compatible with django
1.3 (import errors)

Now my question:

Is there an alternative module or is there even a new default
django 1.3 feature allowing to keep a database between two test runs?
avoiding the creation of a db (with all south migrations being applied)


Thanks in advance for suggestions.



-- 
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 testing: adapt some vars in settings.py if testing

2011-11-23 Thread Gelonida N
Hi Mike,

Yes this idea is simple enough.

I just wondered whether there isn't a tiny risk of finding 'test'
as a paramter of one of the option in some esotheric cases.

For what I am doing the solution should be absolutely fine.

With my habit of using ./manage.py I could even change it to
if sys.argv[1] == 'test'



On 11/24/2011 12:23 AM, Mike Dewhirst wrote:
> There was a great solution to this posted just yesterday ...
> 
> import sys
> if 'runserver' in sys.argv:
> DEBUG = True
> else:
> DEBUG = False
> 
> 
> ... which suggests
> 
> if 'test' in sys.argv:
> do this
> 
> 

-- 
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 testing: adapt some vars in settings.py if testing

2011-11-23 Thread Gelonida N
Hi,

I just started reading about django testing.

Now I have a small question.

Whe running tests I would like to change a few variables in settings.py,
but keep all the rest identical.

Example:
- I might like ot change the media directory
- I might like to use another db engine


How can I achieve this best.

The idea, that I have, but that feels a little clumsy is:
create a test_settings.py file.

test_settings.py will just impoert everything from settings.py
and then override the values it wants to.


Somehow I would prefer if settings.py could contain a few if statements
of the kind.

if testing:
   dothis
else:
   dothat

and if I could just type
./manage.py test

Is this possible?
How do you handle such setups?

-- 
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: copy entire data base to another host

2011-11-20 Thread Gelonida N
Hi Ivo,

On 11/20/2011 09:29 PM, Ivo Brodien wrote:
> hi,
> 
> on MYSQL I just do this to copy a MySQL DB to my local machine which runs in 
> MAMP on Mac OS X.
> 
> Something similar should be possible with PostgreSQL as well.
> 
> ssh USERNAME@SERVER "mysqldump -u USERNAME_REMOTE -p'DB_PASSWORD_REMOTE' 
> --single-transaction DB_NAME | gzip -c" | gunzip -c | 
> /Applications/MAMP/Library/bin/mysql -u USERNAME_LOCAL -p'DB_PASSWORD_LOCAL’ 
> DB_NAME
> 
> Since the password is provided on the command line it should only be run on a 
> system with a single user.
> 

Thanks a lot. Yes this is definitely an option if source and target host
the same database engine.


The reason why would I like to avoid this approach and why I tried to
stick with django commands is, that above approach  will not work if I
want to dump a postgres database to a test machine which has only sqlite
or mysql.

Therfore my motivation was to use dumpdata and loaddata of manage.py


Concerning above approach for mysql:

 I think it is not necessary to provide the password in the command
line. If I remember well one can create a temp file with permissions 600
and store the user/password in it
and specify it on the command line with
--defaults-file=tmp_my.cnf

However as I don't use postgres that much I don't know whether postgres
can do the same (specify a non default config file)


> 
> On Nov 20, 2011, at 19:09 , Gelonida N wrote:
> 
>> On 11/20/2011 06:37 PM, Gelonida N wrote:
>>> Hi,
>>>
>>> I for debugging purposes I'd like to clone the data base of one machine
>>> to another one. (both are not necessarily using the same data base engine)
>>>
>>> What would be the suggested procedure?
>>>
>>> What I tried, but what failed is following:
>>>
>>> 1.) On the remote machine
>>> ./manage.py dumpdata > dumpall.json
>>>
>>> 2.) copy dumpall.json to remote machine
>>>
>>> 3.) On the machine to be cloned to:
>>> ./manage.py flush
>>> ./manage.py loaddata dumpall.json
>>>
>>> The error, that I get is:
>>>
>>> IntegrityError: duplicate key value violates unique constraint
>>> "django_content_type_app_label_key"
>>>
>>>
>>> The only ideas, that I have are:
>>> - delete all conflicting tables from the source host before applying my
>>> fixture (I would do the with ./manage.py shell or with a tiny script)
>>>
>>> - dump all apps except the ones causing problems.
>>>
>>> Thanks a lot in advance for any suggestion.
>>>
>>>
>>>
>> What I did now is following (this time the source and destination
>> database were both postgres)
>>
>>
>>
>> 1.) On the remote machine
>> ./manage.py dumpdata > dumpall.json
>>
>> 2.) copy dumpall.json to remote machine
>>
>> 3.) On the machine to be cloned to:
>> ./manage.py sqlflush
>> copy the truncate statement from the output to the clipboard
>> ./manage.py dbshell
>> enter the password and paste the truncate statement and quite the db shell
>>
>> ./manage.py loaddata dumpall.json
>>
>>
>> This is working, but not that nice to automate,
>> as the SQL snippet, that I have to extract from sqlflush
>> depends on the db engine and as I have to be sure, that I have to create
>> a .pgpass entry for postgres in order to avoid the password prompt.
>>
>>
>>
>>
>>
>> -- 
>> 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: copy entire data base to another host

2011-11-20 Thread Gelonida N
On 11/20/2011 06:37 PM, Gelonida N wrote:
> Hi,
> 
> I for debugging purposes I'd like to clone the data base of one machine
> to another one. (both are not necessarily using the same data base engine)
> 
> What would be the suggested procedure?
> 
> What I tried, but what failed is following:
> 
> 1.) On the remote machine
> ./manage.py dumpdata > dumpall.json
> 
> 2.) copy dumpall.json to remote machine
> 
> 3.) On the machine to be cloned to:
> ./manage.py flush
> ./manage.py loaddata dumpall.json
> 
> The error, that I get is:
> 
> IntegrityError: duplicate key value violates unique constraint
> "django_content_type_app_label_key"
> 
> 
> The only ideas, that I have are:
> - delete all conflicting tables from the source host before applying my
> fixture (I would do the with ./manage.py shell or with a tiny script)
> 
> - dump all apps except the ones causing problems.
> 
> Thanks a lot in advance for any suggestion.
> 
> 
> 
What I did now is following (this time the source and destination
database were both postgres)



1.) On the remote machine
./manage.py dumpdata > dumpall.json

2.) copy dumpall.json to remote machine

3.) On the machine to be cloned to:
./manage.py sqlflush
copy the truncate statement from the output to the clipboard
./manage.py dbshell
enter the password and paste the truncate statement and quite the db shell

./manage.py loaddata dumpall.json


This is working, but not that nice to automate,
as the SQL snippet, that I have to extract from sqlflush
depends on the db engine and as I have to be sure, that I have to create
a .pgpass entry for postgres in order to avoid the password prompt.





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



copy entire data base to another host

2011-11-20 Thread Gelonida N
Hi,

I for debugging purposes I'd like to clone the data base of one machine
to another one. (both are not necessarily using the same data base engine)

What would be the suggested procedure?

What I tried, but what failed is following:

1.) On the remote machine
./manage.py dumpdata > dumpall.json

2.) copy dumpall.json to remote machine

3.) On the machine to be cloned to:
./manage.py flush
./manage.py loaddata dumpall.json

The error, that I get is:

IntegrityError: duplicate key value violates unique constraint
"django_content_type_app_label_key"


The only ideas, that I have are:
- delete all conflicting tables from the source host before applying my
fixture (I would do the with ./manage.py shell or with a tiny script)

- dump all apps except the ones causing problems.

Thanks a lot in advance for any suggestion.



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



will an empty middleware class consume any time (except during initial import?)

2011-11-19 Thread Gelonida N
Just out of curiousity,

Let's assume I add a middleware in settings.MIDDLEWARE_CLASSES and the
middleware class is empty. (just a pass statement)

Will it consume any CPU time while handling a request?


To rephrase my question.
 Is it at startup, that Django checks which methods a middleware
implements . (this would be faster for most cases)

or will Django check for every request whether a midlleware has a given
method? (this would allow to add / remove methods in a middleware
dynamically)





-- 
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: logging django errors also on the server

2011-11-19 Thread Gelonida N
On 11/19/2011 10:26 PM, Gelonida N wrote:
> On 09/05/2011 12:58 AM, Gelonida N wrote:
>>
>> Im am debugging a django application.
>>
>> If I set  DEBUG=True
>> then I can see error messages on the browser.
>>
>> Is there any way to see the same error messages in the server log file?


> I am using Django 1.3
> I configured logging and set up a root logger with  log level 'DEBUG'
> 
> I added one log command and one explicit error in the urls.py file.
> I can see the error report in the browser but not in my log files.
> 

The only way, that was working for me was connecting myself to the
got_request_exception signal of the django framework.

so what I do now is:

import sys
import traceback
from django.dispatch import receiver
from django.core.signals import got_request_exception

import logging
logger = logging.getLogger('exceptionlogger')

@receiver(got_request_exception)
def got_request_exception_hndlr(signal, **kwargs):
request = kwargs.get('request')
meta = request.META
logger.error("ReqException %s %s" %
(meta['REMOTE_ADDR'], request.path ))
ex_type, ex_value, _e_b = sys.exc_info()
logger.error(traceback.format_exc())

This code has of course to be imported as soon as possible in order to
catch as many exceptions as possible.

What would be the correct place for it?

- First line of urls.py?
- import it as dummy middleware?

> 
> 
> How to reproduce my problem:
> 
> # create a new django project
> #
> django-admin.py startproject logproblem
> 
> # enter your project directory
> # -
> cd logproblem
> 
> # create a urls.py which prints a log message
> # and which causes an error afterwards
> # file contents as in the next four lines
> #--
> 
> # faulty urls.py file
> import logging
> logging.debug("hello")
> 1/0 # this will raise a ZeroDivisionError
> 
> 
> # Now edit settings.py and change the LOGGING section to:
> -
> LOGGING = {
> 'version': 1,
> 'disable_existing_loggers': False,
> 'handlers': {
> 'console': {
> 'level': 'DEBUG',
> 'class': 'logging.StreamHandler'
> }
> },
> 'loggers': {
> '': {
> 'handlers': ['console'],
> 'level': 'DEBUG',
> 'propagate': True,
> },
> }
> }
> 
> # Now run the server
> # --
> ./manage.py runserver
> 
> 
> The result on the console will only be:
>> Quit the server with CONTROL-C.
>> hello
>> [19/Nov/2011 15:18:32] "GET / HTTP/1.1" 500 79664
> 
> On the browser however I see the division by 0 error and the back trace.
> 
> For debugging of errors which are caused by a remote host I would really
> like to see  such kind of errors in the server logs or an any other log.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 


-- 
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: logging django errors also on the server

2011-11-19 Thread Gelonida N
Hi Uros,

On 09/05/2011 03:37 PM, Uros Trebec wrote:
> Take a look at Sentry: http://readthedocs.org/docs/sentry/
> 
> It works pretty well, uses polling to update the log view, can track
> multiple sites with separate Sentry Server, etc.

This looks like an option, but it is doing much more than I really want
to use.

I'm just looking for a trick to capture the django exceptions and send
the related backtraces to stdout (or a log file)  (which will be stored
in a log file)



> On Sep 5, 12:58 am, Gelonida N <gelon...@gmail.com> wrote:
>> Hi,
>>
>> Im am debugging a django application.
>>
>> If I set  DEBUG=True
>> then I can see error messages on the browser.
>>
>> Is there any way to see the same error messages in the server log file?
>> Occasionally (especially for rpc client or Ajax requests I would prefer
>> looking at the log file instead of looking at the browser error messages)
>>
>> Thanks for any suggestions.
> 


-- 
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: logging django errors also on the server

2011-11-19 Thread Gelonida N
On 09/05/2011 12:58 AM, Gelonida N wrote:
> Hi,
> 
> Im am debugging a django application.
> 
> If I set  DEBUG=True
> then I can see error messages on the browser.
> 
> Is there any way to see the same error messages in the server log file?
> Occasionally (especially for rpc client or Ajax requests I would prefer
> looking at the log file instead of looking at the browser error messages)
> 
> Thanks for any suggestions.
> 
> 

I am using Django 1.3
I configured logging and set up a root logger with  log level 'DEBUG'

I added one log command and one explicit error in the urls.py file.
I can see the error report in the browser but not in my log files.

For me it would be very helpful if I can log ALL errors on the server
side if I wish to.

Is there any trick?



How to reproduce my problem:

# create a new django project
#
django-admin.py startproject logproblem

# enter your project directory
# -
cd logproblem

# create a urls.py which prints a log message
# and which causes an error afterwards
# file contents as in the next four lines
#--

# faulty urls.py file
import logging
logging.debug("hello")
1/0 # this will raise a ZeroDivisionError


# Now edit settings.py and change the LOGGING section to:
-
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler'
}
},
'loggers': {
'': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
}
}

# Now run the server
# --
./manage.py runserver


The result on the console will only be:
> Quit the server with CONTROL-C.
> hello
> [19/Nov/2011 15:18:32] "GET / HTTP/1.1" 500 79664

On the browser however I see the division by 0 error and the back trace.

For debugging of errors which are caused by a remote host I would really
like to see  such kind of errors in the server logs or an any other log.











-- 
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 class that defines __slots__ without defining __getstate__ cannot be pickled

2011-11-13 Thread Gelonida N
Hi,

I have now an error message showing up when accessing the django admin
interface for some of my models. Fails already at the front page

The main problem, that I have is, that the stack trace does not relate
to any line of my code, so I'm alittle at a loss how to fix it.


The stack trace is:

Traceback (most recent call last):
  File "/usr/lib/python2.6/logging/handlers.py", line 541, in emit
s = self.makePickle(record)
  File "/usr/lib/python2.6/logging/handlers.py", line 511, in makePickle
s = cPickle.dumps(record.__dict__, 1)
  File "/opt/mh_python/lib/python2.6/copy_reg.py", line 77, in _reduce_ex
raise TypeError("a class that defines __slots__ without "
TypeError: a class that defines __slots__ without defining __getstate__
cannot be pickled


I think the issue might be related to the fact, that I am using a socket
logger and that socket logging tries to pickle the log record.
Perhaps the admin interface adds args to a log record, that cannot be
pickled?


Ther admin interface seems to work, but I don't really like having back
traces, that I don't understand in my logs.



How to best continue locating the root cause?




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



include() combined with login_required()

2011-11-13 Thread Gelonida N
Hi,


I wondered whether (and if yes how) I can combine
login_required and include() in my urls.py file


Basically I'd like to require login for every url belonging to a certain
application.


currently urls.py looks like:


from django.conf.urls.defaults import patterns, include, url
from django.contrib.auth.decorators import login_required


urlpatterns = patterns('',
url(r'^secured_app/', include('secured_app.urls')),
. .  .
)


I tried to change it to
urlpatterns = patterns('',
url(r'^secured_app/', login_required(
include('secured_app.urls'))),
. .  .
)


I now get the login pronpt, but afterwards django errors of the kind.


'tuple' object is not callable


So obviously I must do it differntly.

What is the correct way of requestiong authentification for an entire
app without having to decorate each entry in the apps url.py file.

Thanks a lot for suggestions.






-- 
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: maultiple .js files for debug and one minimized .js for production

2011-11-10 Thread Gelonida N
On 11/08/2011 07:37 PM, Fabian Ezequiel Gallina wrote:
> 2011/11/8 Andres Reyes >
> 
> I've been using django-compressor and totally recommend it
> 
> 
> https://github.com/mintchaos/django_compressor
> 
> 
> 
> I second that, works like charm and I really like the way it solved the
> thing with a templatetag instead of having to define file groups on
> settings.
> 
Thanks for your feed back.

I'll have a look at it.

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



maultiple .js files for debug and one minimized .js for production

2011-11-08 Thread Gelonida N
Hi,


I'm having an rather weak (CPU) server accesible over a rather slow network.

Therfore my  plan is to use
multiple readable debuggable css files for debugging and
a single, minizmized  .js for for production.

This will affect some of my templates.

How do you handle this setup in your projects.

If statements in the templates?
multiple template files and copying over one or the other?
???

In order to build the minimized files?
Is there any 'intelligent' plugin, which can locates and minimizes all
the .js files or do you go for a make file like approach or just a
simple script (finding / minimizing)

Thanks in advance for any suggestions.

-- 
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: Disable debugging for all, but allow debug toolbar for one host

2011-11-07 Thread Gelonida N
On 11/07/2011 12:49 PM, Tom Evans wrote:
> On Sun, Nov 6, 2011 at 12:30 AM, Gelonida N <gelon...@gmail.com> wrote:
>> Hi,
>>
>> If I understood well, then the Django debug toolbar is only working if
>> debugging is enabled.
>>
>> What I wanted to do is is to disable the explicit django error messages
>> for all but one specific IP address and to disable the django debug
>> toolbar for this one address.
>>
> 
> You've not understood well. Whether the toolbar is displayed depends
> upon a number of things, as explained in the docs:
> 
> https://github.com/django-debug-toolbar/django-debug-toolbar
> 
> See in particular INTERNAL_IPS and SHOW_TOOLBAR_CALLBACK.
> 
> Cheers
> 
> Tom
> 
Thanks Tom, Thanks for putting me straight.

In fact it seems I misread the documentation quite a bit.

I knew about INTERNAL_IPS, but misunderstood it. I thought, that the IP
must be in INTERNAL_IPs AND that DEBUG must be true.

So probably I just have some other hickup in settings.py,

I wasn't aware of SHOW_TOOLBAR_CALLBACK

I should be able to setup the debug toolbasr is I intended to
SHOW_TOOLBAR_CALLBACK should give me even finer granularity and control.

-- 
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: synchronize django admin interface password with other application passwords

2011-11-06 Thread Gelonida N
Hi Mike,

On 11/07/2011 12:15 AM, Mike Dewhirst wrote:
> On 7/11/2011 7:43am, Gelonida N wrote:
>>
>> What would be the easiest way to hook into the password modification
>> form, such, that I can calculate two password hashes with different
>> salts / alorithms?
>>
> You need your own auth backend which inherits the existing django model
> backend. Then borrow the offered password and create the other app's hash.
> 
> https://docs.djangoproject.com/en/dev/ref/authbackends/
> 

I'll look into it.

At the moment I started creating my own 'create_user_form',
which gets all info, and creates then the default user with

django.contrib.auth.models.User.objects.create_user()

and the other user with the other API

But this is of course not that flexible as it does not allow
to create users (or modify passwords) with the default admin interface.


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



synchronize django admin interface password with other application passwords

2011-11-06 Thread Gelonida N
Hi,
I would like to use the django admin interface for authentification of a
web site.

However I also have to store a password hash (different algorith /
different salt) for another application, such, that both applications
can use the same password.

What would be the easiest way to hook into the password modification
form, such, that I can calculate two password hashes with different
salts / alorithms?


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



Disable debugging for all, but allow debug toolbar for one host

2011-11-05 Thread Gelonida N
Hi,

If I understood well, then the Django debug toolbar is only working if
debugging is enabled.

What I wanted to do is is to disable the explicit django error messages
for all but one specific IP address and to disable the django debug
toolbar for this one address.


-- 
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: can't get STATICFILES to work (Django dev version)

2011-10-03 Thread Gelonida N
On 09/26/2011 10:21 PM, nara wrote:
> I am having trouble getting STATICFILES to work. I have read the docs,
> and followed the instructions, but I never get my css files to load.
> My current workaround is to put all the css inline in my template
> file, but that should not be a permanent solution.
> 

Do you ran
./manage.py runserver

or do you run under a real web server.

I you run under anything else than ./manage.py runserver, then

don't forget to run
./magage.py collectstatic

-- 
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: Python Weekly

2011-09-26 Thread Gelonida N
On 09/26/2011 07:43 PM, Rahul wrote:
> Hi Everyone,
> 
> I have started a free weekly newsletter called Python Weekly which
> includes curated news, articles, new releases, software & tools,
> events, jobs etc about Python and related technologies. It's a great
> way to keep abreast of what's happening in Python land. You can
> subscribe to it here, http://www.pythonweekly.com/
> 
> Regards
> Rahul Chaudhary
> 
Can one see the newsletter also online (without subscribing??)

-- 
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: Https with runserver

2011-09-14 Thread Gelonida N
On 09/15/2011 01:44 AM, Russell Keith-Magee wrote:
> 2011/9/14 Simon Bächler :
>> Any news considering HTTPS and runserver?
> 
> What "News" are you expecting?
> 
> The Django project has made no secret of the fact that we don't
> consider runserver to be a "real" webserver. It isn't intended for
> production use. We haven't spent any time or effort auditing it for
> production use. It is missing many key features that a "real"
> webserver needs to have.
> 
> runserver is intended to be the bare minimum necessary to support
> local development. If you have nontrivial needs, you should be looking
> at alternative options for local development.
> 
> Yours,
> Russ Magee %-)
> 
You can also create a minimalist https server with python twisted
(and the openssl module)

You just need  additional url rules, such, that django is also serving
/static amd /media directories:


just set PYTHONPATH
and
DJANGO_SETTINGS_MODULE
as needed,

create a file named django_wrapper.py with following contents:
#  File starts here ##
from django.core.handlers.wsgi import WSGIHandler

application=WSGIHandler()
#  end of file #

and call then

twistd -n web --https $HTTPS_PORT -p $HTTP_PORT \
--certificate yourcert.crt --privkey your_cert.key \
--wsgi django_wrapper.application





-- 
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: logging django errors also on the server

2011-09-05 Thread Gelonida N
On 09/05/2011 03:05 AM, Reinout van Rees wrote:
> On 05-09-11 02:25, Gelonida N wrote:
>> I see my own log traces.
>> In many situations I do see error messages in the log output.
> 
> An important thing that's not mentioned too clearly in Django 1.3's
> logging docs: *add a root logger*. So a logger with an empty string as a
> name. That one catches all messages, including the ones to the
> django.something.error logger.
> 
True, That's not added in the doc and could be added for clarity.
I had already a root logger added though.
So my problem must be somewhere else.

Will keep you informed when I manage to replicate the issue or when I
understand what went wrong.

-- 
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: logging django errors also on the server

2011-09-04 Thread Gelonida N
On 09/05/2011 02:03 AM, Reinout van Rees wrote:
> On 05-09-11 00:58, Gelonida N wrote:
>> Im am debugging a django application.
>>
>> If I set  DEBUG=True
>> then I can see error messages on the browser.
>>
>> Is there any way to see the same error messages in the server log file?
>> Occasionally (especially for rpc client or Ajax requests I would prefer
>> looking at the log file instead of looking at the browser error messages)
> 
> With django 1.3, those 500 errors are logged to python's default
> logging. So if you've got django 1.3 and a properly set up logging,
> you'd get those logs.
> 
This is what I expected, but I didn't see all the messages showing up.

I see my own log traces.
In many situations I do see error messages in the log output.

At a certain moment I managed to have a broken system, where nothing
showed up in the log files.
However when I accessed  the server with a browser I got django's error
report pointing out a syntax error (typo) in my code.

Unfortunately I did not take a snapshot of my code and can't reproduce
this issue now.


I will repost as soon as I encounter this kind of issue again,

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



logging django errors also on the server

2011-09-04 Thread Gelonida N
Hi,

Im am debugging a django application.

If I set  DEBUG=True
then I can see error messages on the browser.

Is there any way to see the same error messages in the server log file?
Occasionally (especially for rpc client or Ajax requests I would prefer
looking at the log file instead of looking at the browser error messages)

Thanks for any suggestions.


-- 
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 1.3 logging not working as I'd expect

2011-08-27 Thread Gelonida N
On 08/28/2011 03:43 AM, Scott Danzig wrote:
> 
> Okay.. update.. it does seem to work right, even without forcing the
> initialization as you suggested.. which is a relief.. Was losing my mind
> (maybe Django 1.3 doesn't require the settings.LOGGING?)  While testing with
> prints, I realized the view function I thought should be called wasn't
> called until AFTER login..  Oops :)
> 
> Thanks all.

Just for your info.

Forcing the import of 'settings.py' with the two lines, that I suggested
might be required in case, that your module might be
THE module using as very first module settings.py.

This is probaly NEVER the case when running in a 'normal' environment.

However for debugging I import  some of my modules from a command line
script, which just sets
sys.path and
os.environ['DJANGO_SETTINGS_MODULE']

In this case you had to force the evaluation of settings.py before
creating a logger.



> 
> 
> Gelonida N wrote:
>>
>> On 08/28/2011 12:00 AM, Scott Danzig wrote:
>>>
>>>
>>> Gelonida N wrote:
>>>> So before your three lines:
>>>>> import logging
>>>>> logger = logging.getLogger('otherlogger')
>>>>> logger.warn('hello')
>>>> you had to be sure, that the django settings and thus the logging
>>>> configuration has really been completed.
>>>>
>>>> You could for example add following two lines before:
>>>>> from django.conf import settings
>>>>> LOGGING = settings.LOGGING # force import
>>>>
>>>> The second line is needed, as the first line is a 'lazy import' and will
>>>> only read the settings and configure logging  when you access the first
>>>> time a element of settings.
>>>> I just used settings.LOGGING, as it should always exist, when you try to
>>>> log.
>>>>
>>>
>>> Thanks Gelonida.. tried your suggestion and added those two lines before
>>> my
>>> import logging ... unfortunately no change.  Perhaps it's not
>>> straightforward.  Sounds like it wasn't obvious to you either.
>>
>> That's weird.
>> This works fine for me.
>>
>>
>> Just some more things to test:
>>
>>
>> Is ee, that you didn't add a root logger in your
>> log config.
>>
>> you could add following two handlers.
>>
>>
>> 'loggers': {
>> # root loggers
>> '': {
>> 'handlers': ['console'],
>> 'level': 'WARNING', # or 'DEBUG'
>> 'propagate': True,
>> },
>> # not sure if this is really useful
>> 'root': {
>> 'handlers': ['console'],
>> 'level': 'WARNING', # or 'DEBUG'
>> 'propagate': True,
>> },
>>
>>
>>
>> If this doesn't help you could add some print statements to be sure,
>> that your settings file is really read.
>>
>>
>>
>> You could add a print statement after  the assignment of
>> LOGGING in settings.py
>>
>> LOGGING={ .. ..}
>> print "LOGGING VARIABLE IS SET NOW"
>>
>>
>>
>> and in your file.
>>
>> print "CHECKPOINT 1"
>> from django.conf import settings
>> print "CHECKPOINT 2"
>> LOGGING = settings.LOGGING # force import
>> print "CHECKPOINT 3"
>> import logging
>> logger = logging.getLogger('otherlogger')
>> print "CHECKPOINT 4"
>> logger.warn('hello')
>> print "CHECKPOINT 5"
>>
>> What do you get as output?
>>
>>
>>
>>
>> -- 
>> 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: ipython 0.11 with django 1.3 /in virtualenv

2011-08-27 Thread Gelonida N
Hi Shawn,

On 08/28/2011 02:49 AM, Shawn Milochik wrote:
> If iPython is installed it should be used automatically in Django's
> manage.py shell.
> 
Apologies. I think I didn't express myself well enough.
ipython is being used bydjango.

What I just don't understand is why ipython does not import my
customisations if called via './manage.py shell'?

What I wanted to do is configuring ipython such, that it imports already
some of my application libraries when starting the shell.

This would accelerate my debugging activities.


With older versions of ipython Imanaged to do this via some code in
ipythonrc.

However since ipython 0.11 the way, that once customizes iptyhon has
changed.

Now I have to some python files like
~/.config/ipython/profile_default/ipython_config.py,
which seem to be loaded when running ipython,
but which don't seem to be loaded when running ./manage.py shell



> If it's not working and works when you run iPython directly, the most
> likely case is that you're running two different Python environments and
> one has iPython installed and the other doesn't.

I have two different ipython versions on my system:
an older one installed by my distro
and 0.11 in the same virtualenv in which I installed django.

I am rather sure though, that ./manage.py shell picks up the correct one.

If I type
dir()
in ipython, then I see the symbol 'get_ipython' which does not exist in
my old ipython version.


> 
> You mention virtualenv in the subject line but not in the question. Try
> running 'pip install ipython' in your virtualenv.
> 
> 
Yes I mentioned it in the title just in case.
I am rather sure though, that I pick up the correct ipython version



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



why is settings.py executed twice?

2011-08-27 Thread Gelonida N
Hi,

This is also one of the things (I just started using django, so I have
still quite many questions) , that I don't really understand.

It doesn't break anything and I am not stuck.
I'd just like to understand.



$ django-admin startproject settings_twice
$ echo 'print "SOMETEXT"' >> settings.py
$ ./manage.py shell

The output, that I get is
SOMETEXT
SOMETEXT

In [1]:


So it seems settings.py is executed twice.

I would have expected, that settings.py is imported multiple times.
What I thought though is, that a module is normally only executed once
during the first import
and that subsequent imports do not execute settings.py anymore.

It seems even, that all modules imported by settings.py are executed twice.

Is ./manage.py shell starting two processes??

If yes, why wasn't settings.py imported before 'forking' ?

Thanks a lot in advance





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



ipython 0.11 with django 1.3 /in virtualenv

2011-08-27 Thread Gelonida N
Hi,


I am having issues with ipythin when I run

./manage.py shell
then ipython_config.py doesn't seem to be executed.

On the other hand if I run ipython directly the file is imported.

Am I missing something?


My setup:

$ find ~/.config/ipython/
/home/gelonida/.config/ipython/
/home/gelonida/.config/ipython/profile_default
/home/gelonida/.config/ipython/profile_default/log
/home/gelonida/.config/ipython/profile_default/ipython_config.py
/home/gelonida/.config/ipython/profile_default/history.sqlite
/home/gelonida/.config/ipython/profile_default/security
/home/gelonida/.config/ipython/profile_default/pid
/home/gelonida/.config/ipython/profile_default/db
/home/gelonida/.config/ipython/profile_default/db/dhist
/home/gelonida/.config/ipython/README

The contents of
/home/gelonida/.config/ipython/profile_default/ipython_config.py

The first few lines are:
import time
print (("HELLO "*17)+"\n") * 20
time.sleep(2)

I added the sleep statement in case, that the print statement woudl have
been overwritten.

If I start ipython,
then I see the HELLO text and a delay of 2 seconds happens


with

./manage.py shell

I don't see the output.

I n order to be sure, that there's nothing weird in my django project I
tested this also with an unmodified django project, which I just created
with.

In order to reproduce just run once
create a
~/.config/ipython/profile_default/ipython_config.py
with a print statement

and start
ipython
# here you should see print statements of ./manage.py shell


then do:


django-admin startproject tstipython
cd tstipython
./manage.py shell
# here you do not see print statements of ./manage.py shell

Thanks in advance for any explanations.
I would really like to understand what exactly happens.






-- 
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 1.3 logging not working as I'd expect

2011-08-27 Thread Gelonida N
On 08/28/2011 12:00 AM, Scott Danzig wrote:
> 
> 
> Gelonida N wrote:
>> So before your three lines:
>>> import logging
>>> logger = logging.getLogger('otherlogger')
>>> logger.warn('hello')
>> you had to be sure, that the django settings and thus the logging
>> configuration has really been completed.
>>
>> You could for example add following two lines before:
>>> from django.conf import settings
>>> LOGGING = settings.LOGGING # force import
>>
>> The second line is needed, as the first line is a 'lazy import' and will
>> only read the settings and configure logging  when you access the first
>> time a element of settings.
>> I just used settings.LOGGING, as it should always exist, when you try to
>> log.
>>
> 
> Thanks Gelonida.. tried your suggestion and added those two lines before my
> import logging ... unfortunately no change.  Perhaps it's not
> straightforward.  Sounds like it wasn't obvious to you either.

That's weird.
This works fine for me.


Just some more things to test:


Is ee, that you didn't add a root logger in your
log config.

you could add following two handlers.


'loggers': {
# root loggers
'': {
'handlers': ['console'],
'level': 'WARNING', # or 'DEBUG'
'propagate': True,
},
# not sure if this is really useful
'root': {
'handlers': ['console'],
'level': 'WARNING', # or 'DEBUG'
'propagate': True,
},



If this doesn't help you could add some print statements to be sure,
that your settings file is really read.



You could add a print statement after  the assignment of
LOGGING in settings.py

LOGGING={ .. ..}
print "LOGGING VARIABLE IS SET NOW"



and in your file.

print "CHECKPOINT 1"
from django.conf import settings
print "CHECKPOINT 2"
LOGGING = settings.LOGGING # force import
print "CHECKPOINT 3"
import logging
logger = logging.getLogger('otherlogger')
print "CHECKPOINT 4"
logger.warn('hello')
print "CHECKPOINT 5"

What do you get as output?




-- 
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: Combining queries? A "join" in Python?

2011-08-27 Thread Gelonida N
On 08/27/2011 11:39 AM, graeme wrote:
> I have a some models related link this:
> 
> A has a foreign key on B which has a foreign key on C
> 
> I also have D with a foreign key on B, and E with a foreign key of C
> 
> If I do A.filter(**args).select_related() I will get all the As, Bs,
> and Cs I want.
> 
> How do I get the Ds with a foreign key on a B in my queryset
> (preferably filtered) and all Es with a foreign key on C (also
> preferably filtered)
> 
> The best I have been able to come up with is to query for all the  the
> Ds and Es I want, and combine them with the Bs and Cs in the view.
> 
> I have a similar problem with another site, except that there not
> every B I want has an A with a foreignkey pointing to it, so I cannot
> just do select_related on A.
> 
> I am not worried about doing an extra query or two per page. What I
> want to avoid is doing an extra query for each object in a lengthy
> list.
> 
You can 'or' two query sets with the '|' operator


so do
queryset1 = Mymodel.objects.all().filter(...)
qyeryset2 = Mymodel.objects.all().filter(...)

combined = queryset1 | queryset2

-- 
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: can django be used in destop application?

2011-08-24 Thread Gelonida N
> Curious concept, using Django for a desktop application.
>
> Can't think of any reason why you couldn't at least try it :)
>
> Cal
>
>
Original poster was rather clear I think,

> > it seems its orm can be used in destop application, isn't it?


It could make sense to use Django orms, because one knows already django
orms, but one doesn't know SqlAlchemy or any other orms.

This use case is possible, but not that nicely supported.
you.


You can also search for the thread
"import django models without runing the server",

which would also be applicable for desktop applications using
django orms


On 08/23/2011 07:36 PM, Cal Leeming [Simplicity Media Ltd] wrote:

-- 
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: How to make an app independent on a specific site?

2011-08-24 Thread Gelonida N
On 08/24/2011 08:15 AM, Praveen Krishna R wrote:
> *Even if you write
> 
> from models import Publisher, Book, Author
> 
> its gonna work, inside the books application;
> *
> On Wed, Aug 24, 2011 at 7:09 AM, Jim  > wrote:
> 
It will be working, but I personally don't like relative imports too much.

If you really wanted to do relative imports, then I would use (for newer
python versions  (>= 2.5)



# must be at the beginning of your python file
# the define will avoid any accidental relative imports
from __future__ import absolute_import

afterwards you can 'explicitely perform a relative import with'
from .models import Publisher, Book, Author # note the '.' before models

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



syntax highlighting for template files and file suffix

2011-08-23 Thread Gelonida N
Hi,

I'm rather new to Django and just start working with a little more with
templates.

I wondered how to make a distinction between html files and html templates.

Shall I used different suffixes or is the directory location enough.

If I don't have different file suffixes, how do you teach your editor,
when editing an html file and when editing a template file.


I am using vim

Are there any 'best practices'?

-- 
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 1.3 logging not working as I'd expect

2011-08-22 Thread Gelonida N
On 08/20/2011 06:51 AM, Scott Danzig wrote:
> I have Django 1.3 working with Python 2.7 and MySQL 5.5 on Mac OSX Lion...
> 
> I'm betting I'm missing something straight forward, but:
> 
> I have a simple Django app in development that uses a dictConfig setting
> simpler than the default in settings.py:
> 
> LOGGING = {
> 'version': 1,
> 'disable_existing_loggers': False,
> 'formatters': {
> 'verbose': {
> 'format': '%(levelname)s %(asctime)s %(module)s %(process)d
> %(thread)d %(message)s'
> },
> },
> 'handlers': {
> 'console':{
> 'level':'DEBUG',
> 'class':'logging.StreamHandler',
> 'formatter': 'verbose'
> },
> 'file':{
> 'level':'DEBUG',
> 'class':'logging.FileHandler',
> 'formatter': 'verbose',
> 'filename': 'testdjango.log',
> },
> },
> 'loggers': {
> 'testlogger': {
> 'handlers': ['console','file'],
> 'level': 'DEBUG',
> 'propagate': True,
>},
> },
> }
> 
> 
> Then later in code that I know is run... (I tried in my app's views.py
> and also the backend).. I put something like this:
> 
> import logging
> logger = logging.getLogger('testlogger')
> logger.warn('hello')
> logger.info('please appear')
> 
> 
> And I just don't see it, neither in the console, nor the file.
> 
> I have also tried something like this:
> import logging
> logger = logging.getLogger('otherlogger')
> hdlr = logging.FileHandler('newlogger.log')
> formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
> hdlr.setFormatter(formatter)
> logger.addHandler(hdlr) 
> logger.setLevel(logging.DEBUG)
> logger.warn('In settings.py!')
> 
You  have to be sure, that logging is configured before actually logging
anything.

So before your three lines:
> import logging
> logger = logging.getLogger('otherlogger')
> logger.warn('hello')
you had to be sure, that the django settings and thus the logging
configuration has really been completed.


You could for example add following two lines before:
> from django.conf import settings
> LOGGING = settings.LOGGING # force import

The second line is needed, as the first line is a 'lazy import' and will
only read the settings and configure logging  when you access the first
time a element of settings.
I just used settings.LOGGING, as it should always exist, when you try to
log.


I am not sure whether there is a more elegant solution.
When I asked this question recently on this list, I didn't receive any
other suggestions.




> And that doesn't work either, unless I put it right in settings.py.. in
> which case it appears 4 times, because, from what I understand,
> settings.py gets loaded that many times.  But then this doesn't work in
> the views.py/backend .. perhaps because the dictConfig gets loaded after
> settings.py is run?  I don't know.
> 
> I'm hoping for someone to give me a heads up about what I'm missing
> here.  Django's been pretty easy to deal with until I started to look
> into logging.
> 
> Thanks.
> 
> -- 
> 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/-/JvmqgFNPMu4J.
> 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 beginner question

2011-08-21 Thread Gelonida N
On 08/21/2011 03:25 AM, Christian Ramsey wrote:
> Hi and thank you so much,  this provided a ton of clarity, especially
> the modelling of the order table with a foreign key to a user, I was
> locked on thinking the user table needed to somehow have the orders
> within it. But I see I needed to step back.
> 
> I've already started to implement all of this and I am trying to
> understand the  additional table, if the Order table already contains
> the user it belongs to, then what will the additional table be set
> for, from my perspective would this be to keep the original order?
> 
>>
>> I never implemented a shopping application and  what I suggest is very
>> probably neither the most elegant nor the most efficient solution.
>> But what is clear is, that you should use at least one table more.
>>
>> Example Suggestion:
>>
>> User: contains info about the user
>>
>> Product: info about a product and it's price (though price might be in a
>> separate table)
>>
>> Order: Info about the order, which could be ForeignKey to a user, the
>> order date, and perhaps payment status.
>>
>> And one table more, which would store one entry of a order:
>> it would store a oeign Key to a Product, the selected amount and a
>> ForeignKey to the order it belongs to.
>>

My suggestion was, that the Order just contains the customer, the order
date, and all other data, that is unique for one order,
but not the items, that have been ordered. tey would be stored in the
4th table.

So the 4th table could be called OrderItem.

each order item would contain
- to which order it belongs to (Freign key)
- what product has been ordered ( foreign key)
- how many items of the product has been ordered.

So basically a customer command cosists of all OrderItems belonging to
one Order.

As I said before there's many solutions, this is just one.



-- 
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 beginner question

2011-08-20 Thread Gelonida N
On 08/21/2011 12:56 AM, Christian Ramsey wrote:
> Hi I am a Django beginner and I am just getting into creating apps
> with it, my goal was to create a simple
> order application for practice. The app will be somewhat like this:
> 
> 1.A user will login or create an account.
> 2.A user will order from a list of items and depending on the item it
> may have size and/or type, some will have preset sizes and no type at
> all.
> 3. Upon purchase which for this demo will not have a monetary system
> integrated, so as a replacement it will email the admin email with the
> details and also display the order to them for printing once they are
> finished.
> 4. The user will be able to check his/her orders in which the admin
> will be able to set to pending or shipped to each order
> 5. The admin will also be able to view all orders from every user and
> delete, edit, mark the details of the order.
> 
> Pretty straightforward I thought but I can't seem to wrap my head
> around the models mostly and especially the product table.
> 
> For the products would I be creating an array of different orders and
> a separate array of sizes in the controller and assigning that to the
> form?
> 
> My 3 classes in my model are currently Users, Products, Orders
> I am not sure how a order from the products is assigned to a user in
> the database,
> does the Users class need to have both products and orders inside of
> it as a one to many for both?
> 
> So when I create the form that submits this information how does it
> assign that order to that product to that user?
> 

I guess you could already start with the products and the users.
This is what yuou need in any case and which allows you already to learn
qutie some django.
- Create the User and product Models and create either your own views or
admin views such, that you can populate the Users and Product database.

Then you could work on the view allowing a logged in user to select
products to be put in the shopping cart.

Only then you had to care about how to implement the shopping cart.

I never implemented a shopping application and  what I suggest is very
probably neither the most elegant nor the most efficient solution.
But what is clear is, that you should use at least one table more.


Example Suggestion:

User: contains info about the user

Product: info about a product and it's price (though price might be in a
separate table)

Order: Info about the order, which could be ForeignKey to a user, the
order date, and perhaps payment status.

And one table more, which would store one entry of a order:
it would store a oeign Key to a Product, the selected amount and a
ForeignKey to the order it belongs to.

Hope this gave you some ideas of how to get started.







-- 
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: How do I select which user/password to use for DB connection after Django app was started?

2011-08-18 Thread Gelonida N
How many different users are connected at the same time?

Would it be feasable to start one django prcoess for each connected user?


On 08/18/2011 11:55 AM, michael kapelko wrote:
> I think I have to emulate Delphi app with a server process, and make
> Django interact with the process. The process can login to DB
> directly. That's not so easy, but I guess that's the only option here
> - move Delphi app from client machine to server one.
> 


-- 
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: RPC for python functions in a Django project

2011-08-17 Thread Gelonida N
Hi Muhammad,


On 08/17/2011 08:18 PM, Muhammad Choudry wrote:
>  I've
> found that JSON-RPC is a good way to go for this, as there is
> typically built in support for this in javascript in addition to the
> numerous additional benefits.
> 
> I've seen several ways to do this:
> 1) Create a unique URI for each function that you would like to
> access:
> https://code.djangoproject.com/wiki/JSONRPCServerMiddleware
> 2) Create one point of access, and pass the method name in the JSON
> package.  In this particular example an SMD is automatically
> generated.
> https://code.djangoproject.com/wiki/Jsonrpc
> 
> The issue with (1) is that if there are many functions to be accessed,
> then there will be many URI's that will be used.  This does not seem
> like an elegant solution.  The issue with (2) is that I need to
> compare functions against a list of all functions.  Again this is not
> an elegant solution either.
> 
> Is there no way that we can take the advantages of (1) and (2) to
> create an interface such that:
>  - Only one URI is used as a point of access
>  - Functions are called directly (without having to be compared
> against a list of functions)
> 
> ?
> 
Did you look at rpc4django.

The way it works roughly:
- you add rpc4django to the installed apps
- in urls.py you create one uri for the rpc calls
- you simply decorate all functions, that should be available via RPC.

By default the function will be available as xmlrpc and jsonrpc function.

For more details: http://packages.python.org/rpc4django/setup.html




-- 
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, Json and Android

2011-08-12 Thread Gelonida N
On 08/12/2011 03:13 AM, Kevin Anthony wrote:
> i'm trying to interface a django json page with an android application.
> it seems most json applications written for android use
> www.somepage.com/json.php?this=that=anotherthing
> 
> But that doesn't work with django,
> 
> Has anyone interfaced Django and Android? and if they did, is there
> any reading material on it?
> 

It might help if you were a little more specific. and gave some kind of
example.

What exactly do you mean with 'json' page?

an asynchronous get request to fetch json data or do you mean JSONRPC?

Django can well obtain the values of 'this' and of 'something'  in a get
request.

with request.GET.get('this', '-')
and
reuest.GET.get('something', '-')

( but probably this is not what you meant)




-- 
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: "Great circle" using the django ORM?

2011-08-11 Thread Gelonida N
Databases with ordinary indexes are rather bad with finding something
nearby.

Thus some DB engines implemented rtree indexes
(Look for example at http://www.sqlite.org/rtree.html )
or similiar kind of indexes allowing to locate objects
within a certain latitude / longitude range.witt much less effort as if
you had one normal laitude index and one normal longitude index.


If you have a huge set of lcoations.
You can reduce the search effort considerable by  first limiting the
search space by identifying all objects within a certain lattude /
longitude range oand only afterwards calculating the exact distance for
the object in this 'rectanguler '  sub region.

As I'm a django newbie and as I don't know the db engines that well
I'm not sure whether your database engine supports r-indexes (or alike)
and whether there are any recommendations of how to write a django
query, such, taht it benefits from such special spactial indexes.



On 08/11/2011 05:09 PM, Thomas Weholt wrote:
> I got a model with longitude and latitude and want to be able to find
> other objects nearby a selected object. Can this be done using the
> django orm? What is the best approach to do this in a django project?
> 
> I found a answer on Stackoverflow, but doesn't work with sqlite. Doing
> it in SQL is ok and probably the best solution performance wise, but
> if it has to be done in python I'll do that too.
> 
> Ref question on stackoverflow:
> http://stackoverflow.com/questions/4610717/django-determining-if-geographic-coordinates-are-inside-of-an-circle
> 


-- 
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: "Great circle" using the django ORM?

2011-08-11 Thread Gelonida N
On 08/11/2011 06:43 PM, Thomas Orozco wrote:
> The distance is: Sqrt( Sqr(lat1-lat2) + Sqr(long1-long2) )

Try the formula close to the poles and you notice that there is
something missing.

Your formula is correct on a flat surface but (there you talk about x
and y and not about lattitude and longitude)  and should be rather
correct  close to the equator


-- 
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: dull look after install on ubuntu

2011-08-11 Thread Gelonida N
Hi Peter,

On 08/11/2011 06:40 AM, Peter Kovgan wrote:
> Why , for example, collectstatic copied not static content?
> 
> 
> example, /home/peter/work/django/projects/src/mysite/polls/ - it's all
> new project file, there were no statics yet
> 
> 
> See there:
> 
> 
> Copying
> '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/media/img/gis/move_vertex_off.png'
> Copying
> '/usr/local/lib/python2.7/dist-packages/django/contrib/admin/media/img/gis/move_vertex_on.png'
n/media/js/prepopulate.min.js'
> Copying '/home/peter/work/django/projects/src/mysite/urls.py.bak'
> Copying '/home/peter/work/django/projects/src/mysite/settings.py'
> Copying '/home/peter/work/django/projects/src/mysite/urls.py'
> Copying '/home/peter/work/django/projects/src/mysite/__init__.pyc'
> Copying '/home/peter/work/django/projects/src/mysite/settings.py.bak'


I agree the files from /home/peter/work/django/projects/src/mysite
should not be copied.(except if you specifically added this directory to
STATICFILES_DIRS)

This looks like a config issue or your django install is really broken.

Normally

STATICFILES_DIRS should contain for example
'/home/peter/work/django/projects/src/mysit/my_static'
(In this directory you can add static contents specific to your site)

and STATIC_ROOT should for example be set to
/home/peter/work/django/projects/src/mysit/my_collected_static

This is where collectstatic should copy all standard and your custom
files, such, that if you use django behind a web server uou can easily
configure your server to fetch any static file from this directory.
initially this directory will be empty it will only be populated by
'collectstatic' and everything in this directory might be deleted.


Perhaps you could post once more your config file?
I never had issues between django on windows and djongo on linux
In my case both behave perfectly well and identically.

-- 
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: dull look after install on ubuntu

2011-08-10 Thread Gelonida N
On 08/10/2011 09:01 PM, Peter Kovgan wrote:
> Ok, Ok, I've got it, read docs.
> 
> But why It must be so complex?
> Why default admin statics become unavailable, if you use another server
> and not that of development: "runner"?
> 
> Should it mean, that I must find elsewhere my admin statics, copy-paste
> them to some place and poin to this place from settings.py?
> 
> OK
> I do not like this burden.
> 
The burden is not really a big burden.

Set STATIC_ROOT in config.py  to a directory, which is empty and where
you have write permissions to.


run afterwards ./manage.py  collectstatic


This should collect all static files (also the ones from standard django
modules) into the STATIC_ROOT directory.

If your STATIC_ROOT directory does NOT contain the files that aren't
served, then this is strange.



Just one more question:

Did you also use Django 1.3 on your windows host or was it a different
version???



-- 
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: dull look after install on ubuntu

2011-08-10 Thread Gelonida N
On 08/10/2011 04:53 AM, Peter Kovgan wrote:
> Thank you guys.
> 
> I use development server of django(manage.py runserver).
> 
> I created an app. from the official site of the django, this one of the
> first tutorial.
> 
> I did it on windows installation.
> 
> Then I came home, installed the same app on ubuntu.
> 
> Now my conf is:
>> django 1.3
>> on python 2.7.1
>> ubuntu 11.04
>> looking through firefox 4
> 
> and it stopped show "stattic content"
> 
> HERE IS COLLECTSTATIC::
> 
> . . . 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py",
> line 41, in __init__
> self.storage = get_storage_class(settings.STATICFILES_STORAGE)()
>   File
> "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/storage.py",
> line 23, in __init__
> raise ImproperlyConfigured("You're using the staticfiles app "
> django.core.exceptions.ImproperlyConfigured: You're using the
> staticfiles app without having set the STATIC_ROOT setting.
> 
> I tried to resolve it myself, but nothing has worked.
> 
> I used answers to another threads, but probably my installation is
> somehow different.
> 
> What exactly I specify in MEDIA_ROOT = ''" ?
> 


Very probably an error in settings.py

STATIC_ROOT has to be an absolut path name using '/' and not '\'
characters pointing to a directory, that is empty (collectstatic will
store files there)


STATICFILES_DIRS should point to the directory, where you put your
static files.

As Praveen pointed out.: A dump of settings.py might help



-- 
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: dull look after install on ubuntu

2011-08-09 Thread Gelonida N
On 08/09/2011 09:58 PM, Peter Kovgan wrote:
> django 1.3
> on python 2.7.1
> ubuntu 11.04
> looking through firefox 4
> 
> Dull look, like all javascript has been removed
> On windows looks nice, but here all works, but no colors, no styles,
> nothing...
> 
> What could it be?


Well you don't really give a lot of info, so my guess might be
completely wrong.


Do you use the django development server (  manage.py runserver) or do
you run with apache / some existing server?

Did you run the command "manage.py collectstatic"?



-- 
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: Tutorial: New class based generic views

2011-08-09 Thread Gelonida N
On 08/09/2011 03:33 PM, Juan Pablo Romero Méndez wrote:
> Hey guys,
> 
> This is the first part of a series of blog posts I'm writing about
> class based generic views:
> 
> http://pseudocorta.blogspot.com/2011/08/django-generic-views.html
> 
> Cheers!
> 
>   Juan Pablo
> 
Hi Juan,

This blog looks interesting. I am curious about the next ones :-) .

For people with little experience it might help a lot if you also add
the import statements.

I personally don't know for example by heart, where generic.CreateView
is coming from.

With many tutorials, blogs, code snippets I spent more time searching
for the correct import than understanding the rest of the code.
Experienced programmes wil know of course the which import to use, but
the few addtional lines shouldn't really hurt them.





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



force reading of django.settings (and thus logging)

2011-08-06 Thread Gelonida N
Hi,

I have a small question:


I use settings.py:LOGGING in order to configure my logging

Now I'd like to add some log traces during the import phase
of a module using django


Example:

import logging
logger = logging.getLogger('mymodule')
logger.INFO('created logger')

import django.db
logger.INFO('another message')



What I see is following:
The message 'created logger' is not displayed

The message 'another message' is displayed

The reason is, that importing django.db was reading the setup file and
thus configuring the logging.

Now I wondered about the 'minimal' import required to convince django
reading its config.


I tried

from django.conf import settings
but this does not seem to read the settings as settings is a



Is there any 'standard' way of forcing the reading of the settings.

Accessing any member of django.conf.settings will force the reading and
enable logging, so what I can do is


from django.conf import settings
DEBUG = settings.DEBUG # force reading of django config


It just doesn't look really pythonic as this line makes only sense to a
user, who knows, that django.conf.settings is a lazy object.



Any suggestion for nicer code is welcome


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



Nested: transaction.commit_on_success and django 1.3

2011-07-28 Thread Gelonida N
Hi,

I have a specific function with an transaction.commit_on_success


@transaction.commit_on_success
def f1():
   with transaction.commit_on_success:
  do_stuff()
  change_model_data_1 . . ,\.



and I have now another function

def f2():
   change_other_model_data()
   f1()


Now I would like to decorate f2() with

@transaction.commit_on_success

My  expected behaviour for my application would be, that the inner
transaction would be ignored in that case and be extended to the outer
transaction.


Are nested decorators supported with  Django 1.3  or should I write a
small wrapper as recommended in

http://djangosnippets.org/snippets/1343/

The suggested snippet is:

def nested_commit_on_success(func):
"""Like commit_on_success, but doesn't commit existing transactions.

This decorator is used to run a function within the scope of a
database transaction, committing the transaction on success and
rolling it back if an exception occurs.

Unlike the standard transaction.commit_on_success decorator, this
version first checks whether a transaction is already active.  If so
then it doesn't perform any commits or rollbacks, leaving that up to
whoever is managing the active transaction.
"""
commit_on_success = transaction.commit_on_success(func)
def _nested_commit_on_success(*args, **kwds):
if transaction.is_managed():
return func(*args,**kwds)
else:
return commit_on_success(*args,**kwds)
return transaction.wraps(func)(_nested_commit_on_success)


I'm asking as this snippet is already 3 years old.

-- 
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: any recipes for 'live' updating a site with model changes

2011-07-27 Thread Gelonida N
On 07/27/2011 11:26 AM, bruno desthuilliers wrote:
> 
> 
> On Jul 27, 10:04 am, Uros Trebec  wrote:
>> Hi,
>>
>> for your DB migration problem you should take a look at South[0].
> 
> +1
> 
> I've just started using it and wonder why I spent so much time doing
> things the painfull and error-prone manual way...
> 
>> As for your 'under maintenance' step you will have to do that manually
> 
> Here are two examples of doing it using apache rewrite rules -
> possibly the most common solution, which I also used on most projects
> (whether PHP, Django, Zope or whatever) so far:
> 
> http://garthhumphreys.com/2011/06/11/painless-django-maintenance-mode-with-fabric/
> http://zebert.blogspot.com/2007/12/maintenance-mode-for-apache.html
> 
> For a latest Django project I use a in-house fork of django-
> maintenance-mode. It still have a few quirks I hope to fix soon so we
> can publish it.
> 

Thanks.
Will look into the rewrite rules.

-- 
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: any recipes for 'live' updating a site with model changes

2011-07-27 Thread Gelonida N
Thanks a lot everybody.

Will look into south..


On 07/27/2011 10:04 AM, Uros Trebec wrote:
> Hi,
> 
> for your DB migration problem you should take a look at South[0].
> As for your 'under maintenance' step you will have to do that manually
> or use some kind of a tool to automate it, as well as other steps for
> the upgrade. There are many such tools, Fabric[1] and Chef[2] being
> two of the most popular.
> 
> [0] http://south.aeracode.org/docs/
> [1] http://docs.fabfile.org/en/1.2.0/index.html
> [2] http://www.opscode.com/chef/
> 

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



any recipes for 'live' updating a site with model changes

2011-07-26 Thread Gelonida N
Hi,

Let's imagine I have a web server running with a Django application.

Now I want to install an update (with a modified model)

Is there any recommended way to upgrade such a server?
Are there any tools helping with such upgrades or with creating upgrade
scripts?

If I had to do it 'manually' this is roughly what I'd do:
- reconfigure the web server to redirect to an 'under maintenance' site
- Before unistalling any new code:
dump all tables
- install the new version
- start an upgrade function, which deletes all tables and repopulates
them from the dumps with some potential conversions.


Thanks in advance for suggestions or examples of projects which handle
updates more or less on the fly.

-- 
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: too many queries: populate template from model foreign key lookup

2011-07-24 Thread Gelonida N
Hi Mark,

On 07/24/2011 10:15 AM, Marc Aymerich wrote:
> 
> 
> On Sun, Jul 24, 2011 at 3:10 AM, Gelonida N <gelon...@gmail.com
> <mailto:gelon...@gmail.com>> wrote:
> 
> Hi,
> 
> I try to populate a template from a Model with a ForeignKey element)
> members of the foreign key element should be displayed.
> 
> If I understand correctly my first attempt resulted in one query for
> fetching the entries from my first model and in one Query for each row
> in order to look up the contents related to the foreign key.
> 
> 
> Hi, you can use select_related in order to prefetch related data.
> https://docs.djangoproject.com/en/dev/ref/models/querysets/#select-related
> 
 This solved my issue and transformed my multiple  queries into one
query with a join statement.

It is interesting to know however, that with my real code.
(slightly more complex models)
Song.objects.all()select_related()
did not have the desired effect.

I had to specify which foreign key to follow to make it work
so I had to use
Song.objects.all()select_related('composer')

Thanks again for the fast help

-- 
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 & py2exe

2011-07-23 Thread Gelonida N
On 07/22/2011 04:15 PM, Alexey Luchko wrote:
> On 22.07.2011 02:59, Gelonida N wrote:
>> Another issue, that I had is trying to use django under windows with
>> py2exe.
>>
>> Management commands are no more found, as django would require the
>> python source code in order to find existing management commands.
>>
>> Perhaps there is an easy  work around, but I am not aware of one.
> 
> Same here.
> 
> I far as I can see it requires some changes to
> django/core/management/__init__.py
> 
> You could try a hack filling django.core.management._commands manually
> in your project's manage.py.
> 
> 
> But for a project's prototype I've just created a script that imports
> settings and then calls a manage command manually like that:
> from django.core.management.commands import syncdb
> syncdb.Command().execute()
> 
> 
I did the same for one  management command.
What's even worse is, that even standard management commands like
'syncdb' are  lost during the creation of py2exe of one doesn't
reregister them manually

The clean fix might be a rewrite of django/core/management/__init__.py


> -- 
> Best regards,
> Alexey.
> 


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



too many queries: populate template from model foreign key lookup

2011-07-23 Thread Gelonida N
Hi,

I try to populate a template from a Model with a ForeignKey element)
members of the foreign key element should be displayed.

If I understand correctly my first attempt resulted in one query for
fetching the entries from my first model and in one Query for each row
in order to look up the contents related to the foreign key.



I try to explain with a simple example.

### The Models 
class Composer(models.Model):
last_name  = models.CharField(max_length=20)
first_name = models.CharField(max_length=20)

class Song(models.Model):
title = models.CharField(max_length=20)
composer = models.ForeignKey(Composer)

# My Task ##
Now I want to populate a template with a list of songs and their composers


Intuitive lazy Solution with many queries
===

The view
---
songs = Song.objects.all()
return render_to_response('mytemplate.html', {'song_list' : songs })


The template
---
{% for song in song_list %}
{{ song.title }} by {{ song.composer.last_name }},
{{song.composer.first_name }} 
{% endfor %}


The problem
---
The problem here is, that django will perform one query to get the list
of songs and will then get perform one query per row in order to look up
the composer by his primary key.


I would prefer to  have one query with a join


The verbose solution
===

I  use values() in order to force the join upfront before rendiering in
the template


The view
-
songs = Song.objects.all().values('title', 'composer__last_name',
'composer__first_name')
return render_to_response('mytemplate.html', {'song_list' : songs })


The template
--
{% for song in song_list %}
{{ song.title }} by {{ song.composer__last_name }},
{{song.composer__first_name }} 
{% endfor %}




The problem
-

This seems to do what I like, however there is one tiny problem.

I have to list all members of both models in the values section.
This seems to be rather verbose and repetetive.


My Questions
==

1.) What is the recommended way to fill a template with values from a
model requiring one (or in my real example even two) joins.



2.) Is it possibe to perform a query and ask it to get ALL values from
the first model and to 'join' ALL values from a second model?
This would avoid having to manually retype all Model members in the
view-code


3.) Is there a way to perform a query with a join, but to receive
an object for each row (instead of receiving a dict with the 'flattened'
values containing double underscores as separators)

This would allow me to still use 'song.composer.last_name' in the
template but to avoid one query per template row



Thanks a lot for your suggestions or for clarifying my potential
misunderstandings of how Django works is supposed to be used.






-- 
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 setup environment

2011-07-21 Thread Gelonida N
http://superjared.com/entry/django-and-crontab-best-friends/

-- 
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: import django models without runing the server

2011-07-21 Thread Gelonida N
On 07/18/2011 04:33 PM, bruno desthuilliers wrote:
> On Jul 18, 3:33 pm, Alexander Crössmann
>  wrote:
>> Hi Malcom,
>>
>> I am not sure the management commands are what I want
> 
> Strange enough, it seems that everyone starts by saying this and ends
> up writing custom management commands ;)
> 


I wrote quite some scripts meanwhile, which just set
DJANGO_SETTINGS_MODULE and use then the models.

I think if a django model is only a tiny part of a bigger script, then
management commands are not really advantageous over management commands.

Another issue, that I had is trying to use django under windows with py2exe.

Management commands are no more found, as django would require the
python source code in order to find existing management commands.

Perhaps there is an easy  work around, but I am not aware of one.




-- 
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: https / nginx / uwsgi / django problems with authentification

2011-07-21 Thread Gelonida N
Hi Robert,


Thanks a lot. This is working :-)

I just added
uwsgi_param UWSGI_SCHEME https;


as you suggested.


On 07/21/2011 06:38 AM, Roberto De Ioris wrote:
> 
>> Hi,
>>
>> I'm not sure whether I have to change my django configuration or my
>> nginx cofiguration.
>> (Thus posted to gmane.comp.python.django.user and to
>> gmane.comp.web.nginx.english)
>>
>> I have following setup:
>>
>> - nginx listening on https
>> - most static contents like .css .js images served by nginx
>> - everything else forwarded to django
>>
>> all .html files are in fact templated and should thus be treated by
>> django. Additionally I wanted to grant access to the contents onlyy to
>> authorized users.
>>
>>
>> djangu urls.py setup
>> ---
>>
>> from django.contrib.auth.decorators import login_required
>> from django.views.generic.simple import direct_to_template
>>
>>
>>  url(r'^(?P.*\.html)$',
>>  login_required(direct_to_template),
>>  ),
>>
>>
>> nginx is configured with
>> -
>>
>> location ~ \.*.html$ {
>> uwsgi_pass django;
>> uwsgi_param  QUERY_STRING   $query_string;
>> uwsgi_param  REQUEST_METHOD $request_method;
>> uwsgi_param  CONTENT_TYPE   $content_type;
>> uwsgi_param  CONTENT_LENGTH $content_length;
>>
>> uwsgi_param  REQUEST_URI$request_uri;
>> uwsgi_param  PATH_INFO  $document_uri;
>> uwsgi_param  DOCUMENT_ROOT  $document_root;
>> uwsgi_param  SERVER_PROTOCOL$server_protocol;
>>
>> uwsgi_param  REMOTE_ADDR$remote_addr;
>> uwsgi_param  REMOTE_PORT$remote_port;
>> uwsgi_param  SERVER_PORT$server_port;
>> uwsgi_param  SERVER_NAME$server_name;
>> }
>>
>> uwsgi is called with
>> --
>> uwsgi -s host:port  -H virtual_env_python --pidfile uwsgi.pid \
>> --pp ..-w wsgi_module
>>
>> The problem is, that the first request to
>>
>> https://mysite:myport/index.html
>>
>> is detected as non authenticated access. (that's what I want)
>> and thus django tries to redirect to  redirected to the authentification
>> page (that's also what I want)
>> which should be
>>
>> Django should redirect to
>> https://mysite:myport/accounts/login/?next=/index.html
>>
>> Unfortunately it redirects to
>> http://mysite:myport/accounts/login/?next=/index.html
>>
>>
>> Therefore I get the error message
>> "400 Bad Request The plain HTTP request was sent to HTTPS port"
>>
>> Is there any variable that I can use to tell django, that the protocol
>> is https and not http for the login pages
>>
>> Ideally I would like to have something like an nginx parameter being
>> passed, such that django knows whether the request is coming from an
>> nginx https server ( all redirects should be https:host:port )
>> or from an nginx http server.
>>
>>
>> Does anyone have a similiar setup or has some ideas?
>>
> 
> 
> 
> You can force the protocol using the HTTPS variable (standard, but not
> enabled in nginx) or you can force the protocol to htts using the
> UWSGI_SCHEME variable
> 
> http://projects.unbit.it/uwsgi/wiki/uWSGIVars
> 
> 
> 


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



https / nginx / uwsgi / django problems with authentification

2011-07-20 Thread Gelonida N
Hi,

I'm not sure whether I have to change my django configuration or my
nginx cofiguration.
(Thus posted to gmane.comp.python.django.user and to
gmane.comp.web.nginx.english)

I have following setup:

- nginx listening on https
- most static contents like .css .js images served by nginx
- everything else forwarded to django

all .html files are in fact templated and should thus be treated by
django. Additionally I wanted to grant access to the contents onlyy to
authorized users.


djangu urls.py setup
---

from django.contrib.auth.decorators import login_required
from django.views.generic.simple import direct_to_template


 url(r'^(?P.*\.html)$',
login_required(direct_to_template),
 ),


nginx is configured with
-

location ~ \.*.html$ {
uwsgi_pass django;
uwsgi_param  QUERY_STRING   $query_string;
uwsgi_param  REQUEST_METHOD $request_method;
uwsgi_param  CONTENT_TYPE   $content_type;
uwsgi_param  CONTENT_LENGTH $content_length;

uwsgi_param  REQUEST_URI$request_uri;
uwsgi_param  PATH_INFO  $document_uri;
uwsgi_param  DOCUMENT_ROOT  $document_root;
uwsgi_param  SERVER_PROTOCOL$server_protocol;

uwsgi_param  REMOTE_ADDR$remote_addr;
uwsgi_param  REMOTE_PORT$remote_port;
uwsgi_param  SERVER_PORT$server_port;
uwsgi_param  SERVER_NAME$server_name;
}

uwsgi is called with
--
uwsgi -s host:port  -H virtual_env_python --pidfile uwsgi.pid \
--pp ..-w wsgi_module

The problem is, that the first request to

https://mysite:myport/index.html

is detected as non authenticated access. (that's what I want)
and thus django tries to redirect to  redirected to the authentification
page (that's also what I want)
which should be

Django should redirect to
https://mysite:myport/accounts/login/?next=/index.html

Unfortunately it redirects to
http://mysite:myport/accounts/login/?next=/index.html


Therefore I get the error message
"400 Bad Request The plain HTTP request was sent to HTTPS port"

Is there any variable that I can use to tell django, that the protocol
is https and not http for the login pages

Ideally I would like to have something like an nginx parameter being
passed, such that django knows whether the request is coming from an
nginx https server ( all redirects should be https:host:port )
or from an nginx http server.


Does anyone have a similiar setup or has some ideas?


-- 
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 example for searching in address book with over 1000 entries

2011-07-12 Thread Gelonida N
Hi,


I'd like to implement a simple django address book Application with over
1000 entries.

I'm still struggling whether (and if yes how) to use Ajax or not
for searching a contact.

Ideally I would start filtering the entries while typing a name in the
search field)


I'd like to use the application from a smart phone the network might be
slow and searching a person shouldn't be too sluggish.

Does anyone have recommendations / suggestions a pointer to a sample app
/ tuytorial doing something similiar?

Thanks in advance






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