Re: Separate file stream from request input stream while upload

2012-08-07 Thread 春燕 李
Thanks !

In my application, I want to upload  image files(such as *.iso) which
are always large, it will take long time before the uploading
completed. During this time, I cannot  send out other request on
current page, because a new request will refresh the current page and
make the uploading failed. My aim is that after I click the Upload
button, the file uploading is processed in backend, I can send out
other request  simutanously. Firstly , I tried to get the stream, and
write  new handler to replace the exsiting processing. But after I
read the source code , I find that the input stream got by django is
activity limited,  it only can be read once, once reading is started,
the current page shouldn't be refresh, or else the stream reading will
be failed.

Is it realizable to  uploading backend and simutanously send other
request on current page, and the uploading won't interrupt because of
leaving this page?

Thanks again!
Yours,  C. Y. Lee

On 8月8日, 上午11时53分, Russell Keith-Magee 
wrote:
> On Wed, Aug 8, 2012 at 10:11 AM, 春燕 李  wrote:
> >   As you know, Django can process file uploading with its own
> > uploadhandler. But all the request data is processed as stream, and
> > mod_wsgi provides a way to read the stream,  what you can do is just
> > read the stream sequentially, which means that you cannot separate
> > file stream from the request input stream. When you  upload file ,  it
> > won't response immediately , you have to wait till file uploading has
> > completed.
>
> > Is there  any way  to separate file stream from request input stream,
> > so I can  process and save the file independently  to avoid long time
> > waiting during file uploading?
>
> Yes, it is possible. What you need to do is separate the file upload
> from the page request.
>
> A good example of how this works is inside Gmail itself. When you
> attach a file to an email in Gmail, the Gmail interface disables the
> send button, and sets up a background request (stimulated by
> Javascript) that uploads the file. When the background file upload
> completes, the Javascript handling the upload request reenables the
> "send" button. You then send your email, submitting the non-file
> content to the server.
>
> There isn't anything particularly special you need to do from a Django
> perspective -- the file upload is handled using a normal
> file-uploading view. The only difference is on the user interface
> side, because the user is effectively interacting with *2* views --
> one that they can see, and one that is hidden and only used by the
> background upload.
>
> A quick search of Google will give you lots of examples of how to
> handle background file uploads in this way.
>
> Yours,
> Russ Magee %-)

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



Re: object.create speed, creating 3 objects takes 1 sec in sqlite

2012-08-07 Thread Cal Leeming [Simplicity Media Ltd]
Hi Anton,

In short, attempting to do any sort of bulk import "out of the box" with
the ORM, will always end with bad performance.

No matter how fast your disks are (SSDs with 4000 iops in RAID 1 for
example), you'll still only get around 0.1s per insert via the ORM on a
single thread, and if you multi thread the import on a MySQL backend then
you'll end up hitting the notorious high throughput race condition (
https://code.djangoproject.com/ticket/18557 )

The method used to speed up your bulk imports depend entirely on the actual
data itself.

Depending on whether or not you absolutely need all the functionality of
the ORM during import (signals, hooks etc) - then you could also look at
using bulk_create() that comes with Django 1.4.

I actually did a webcast about a year ago on how to do bulk updates to
achieve massively increased throughput (from 30 rows/sec to 8000 rows/sec)
- and this method was eventually integrated into the DSE plugin (
http://pypi.python.org/pypi/dse/3.3.0 - look for bulk_update ).

As your table and indexes grow, both read/write performance will slowly
start to get worse once you pass the 1mil rows point - so make sure to put
some thought into the initial model structure (using ints to define choices
where possible, no indexes on varchar/char if possible, make good use of
composite/compound indexes etc).

Failing that, if you want to drag every single microsecond of performance
out of this, then you could performance the bulk imports as raw SQL.

Hope this helps!

Cal

On Mon, Aug 6, 2012 at 4:14 PM, creecode  wrote:

> Hello Anton,
>
> On Friday, August 3, 2012 9:05:47 AM UTC-7, Anton wrote:
>
>
>> My Problem: I will populate it with 5 items.
>>
>> Has Django really such a bad performance for data insertion?
>>
>> I can't believe it, so ... can somebody give me a hint?
>> Is there a doc page dedicated to speed/performance issues??
>>
>> Otherwise I have to look for an other system.
>>
>
> Before you go looking for another system you may want to do some research
> on inserting lots of rows in Django.  Cal Leeming on this list has had
> some experience dealing with lots of rows and there are several threads on
> the topic.  Check the Google interface for this group and use the search
> feature.  Also try Googling for inserting lots of data with Django, several
> folks have written about their experiences inserting lots of rows.
>
> Toodle-loo...
> creecode
>
> --
> 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/-/yLxStReK_1gJ.
>
> 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: Separate file stream from request input stream while upload

2012-08-07 Thread Russell Keith-Magee
On Wed, Aug 8, 2012 at 10:11 AM, 春燕 李  wrote:
>   As you know, Django can process file uploading with its own
> uploadhandler. But all the request data is processed as stream, and
> mod_wsgi provides a way to read the stream,  what you can do is just
> read the stream sequentially, which means that you cannot separate
> file stream from the request input stream. When you  upload file ,  it
> won't response immediately , you have to wait till file uploading has
> completed.
>
> Is there  any way  to separate file stream from request input stream,
> so I can  process and save the file independently  to avoid long time
> waiting during file uploading?

Yes, it is possible. What you need to do is separate the file upload
from the page request.

A good example of how this works is inside Gmail itself. When you
attach a file to an email in Gmail, the Gmail interface disables the
send button, and sets up a background request (stimulated by
Javascript) that uploads the file. When the background file upload
completes, the Javascript handling the upload request reenables the
"send" button. You then send your email, submitting the non-file
content to the server.

There isn't anything particularly special you need to do from a Django
perspective -- the file upload is handled using a normal
file-uploading view. The only difference is on the user interface
side, because the user is effectively interacting with *2* views --
one that they can see, and one that is hidden and only used by the
background upload.

A quick search of Google will give you lots of examples of how to
handle background file uploads in this way.

Yours,
Russ Magee %-)

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



Separate file stream from request input stream while upload

2012-08-07 Thread 春燕 李
  As you know, Django can process file uploading with its own
uploadhandler. But all the request data is processed as stream, and
mod_wsgi provides a way to read the stream,  what you can do is just
read the stream sequentially, which means that you cannot separate
file stream from the request input stream. When you  upload file ,  it
won't response immediately , you have to wait till file uploading has
completed.

Is there  any way  to separate file stream from request input stream,
so I can  process and save the file independently  to avoid long time
waiting during file uploading?

-- 
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: Nullable User email

2012-08-07 Thread Melvyn Sopacua
On 7-8-2012 17:08, Demian Brecht wrote:

> 1. Copy/paste the entire model, changing the attribute of the one field.
> 2. User._meta.fields[4].null = true
3. Override the __new__ method in your subclassed model and remove the
email field definition from the class attributes to the meta class
before you call super(). This does involve a bit of a copying from
db/models/ModelBase.__new__ but it's cleaner as __new__ is meant exactly
for this purpose.


-- 
Melvyn Sopacua

-- 
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: Jquery 1.7.2 Ajax

2012-08-07 Thread Ivo Marcelo Leonardi Zaniolo
I've just solved it.
There is a cross domain protection on jquery versions since 1.5. To make
these kind of requests between domains you have to disable it setting on
Ajax request the crossDomain=false.

And that is it.

Ivo Marcelo Leonardi Zaniolo
+55 71 9302 3400
imarcel...@gmail.com
www.informatizzare.com.br
imarcelolz.blogspot.com.br
Em 07/08/2012 18:18, "Mr. Gerardo Gonzalez Cruz" 
escreveu:

> What problem is it?
>
> On Tue, Aug 7, 2012 at 1:09 PM, Ivo Marcelo Leonardi Zaniolo <
> imarcel...@gmail.com> wrote:
>
>> Hello,
>>
>> Have someone tried to make Ajax requests using jquery 1.7?
>> On the older versions of jquery everything works fine.
>>
>> Does somebody have a tip about it?
>>
>> Tanks
>> Ivo Marcelo Leonardi Zaniolo
>> +55 71 9302 3400
>> imarcel...@gmail.com
>> www.informatizzare.com.br
>> imarcelolz.blogspot.com.br
>>
>> --
>> 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.
>>
>
>
>
> --
>
>
> Best regards / Saludos Cordiales
> Gerardo González Cruz
>
> Cell Phone: 2721188508
> Blog: http://gerardogc2378.blogspot.com/ http://ggcsblog.blogspot.com/
> Web Page: http://ggcspace.heroku.com/
> Skype: gerardo.enlaceit
> oDesk: gerardogc2378
> gerardogc2...@tropo.im
> @gerardogc2378
>
>  --
> 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: Jquery 1.7.2 Ajax

2012-08-07 Thread Mr. Gerardo Gonzalez Cruz
What problem is it?

On Tue, Aug 7, 2012 at 1:09 PM, Ivo Marcelo Leonardi Zaniolo <
imarcel...@gmail.com> wrote:

> Hello,
>
> Have someone tried to make Ajax requests using jquery 1.7?
> On the older versions of jquery everything works fine.
>
> Does somebody have a tip about it?
>
> Tanks
> Ivo Marcelo Leonardi Zaniolo
> +55 71 9302 3400
> imarcel...@gmail.com
> www.informatizzare.com.br
> imarcelolz.blogspot.com.br
>
> --
> 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.
>



-- 


Best regards / Saludos Cordiales
Gerardo González Cruz

Cell Phone: 2721188508
Blog: http://gerardogc2378.blogspot.com/ http://ggcsblog.blogspot.com/
Web Page: http://ggcspace.heroku.com/
Skype: gerardo.enlaceit
oDesk: gerardogc2378
gerardogc2...@tropo.im
@gerardogc2378

-- 
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: Nullable User email

2012-08-07 Thread Demian Brecht
Thanks for the quote, was unaware of the convention.

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



Jquery 1.7.2 Ajax

2012-08-07 Thread Ivo Marcelo Leonardi Zaniolo
Hello,

Have someone tried to make Ajax requests using jquery 1.7?
On the older versions of jquery everything works fine.

Does somebody have a tip about it?

Tanks
Ivo Marcelo Leonardi Zaniolo
+55 71 9302 3400
imarcel...@gmail.com
www.informatizzare.com.br
imarcelolz.blogspot.com.br

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



Pluggable Q&A Django App

2012-08-07 Thread natasha.ba...@utoronto.ca
Hi All,

I'm looking to implement a Stack Overflow style Q&A feed on my site.

I have looked into the following solutions:
1) OSQA
2) Askbot
3) Soclone

The problem with these is that they don't really seem to be standalone 
apps, and more like fully featured sites.

Any thoughts on a standalone pluggable app with the ability to ask/answer 
questions, upvoting and downvoting, tagging, etc.? Would rather not 
re-invent the wheel if it has been done before.

Cheers,
Natasha

-- 
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/-/6vcGvcohXTUJ.
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: Migrating app from Django 1.3.3 to 1.4

2012-08-07 Thread Germán
What other applications/extensions are you using? I remember a similar 
problem using debug-toolbar. I had to upgrade it to a newer revision (can't 
remember if the necessary changes were already contained in a release).

On Tuesday, August 7, 2012 10:24:06 AM UTC-4, dokondr wrote:
>
> Hi all!
> I am trying to run ConceptNet (
> http://csc.media.mit.edu/docs/conceptnet/install.html) originally 
> deployed on Django 1.3.
> When running this app with Django1.4 on Mac OS X 10.6.8. (Snow Leopard) I 
> get:
>
> "ImproperlyConfigured: settings.DATABASES is improperly configured. Please 
> supply the ENGINE value. Check settings documentation for more details."
>
> (Please see detailed log at the end of this message.)
>
> To solve this I tried to create new config for 1.4 and run with SQLite 
> database (ready to use) in my work directory.  I have changed the old 
> contents of 'db_config.py'
>
> DB_ENGINE = "sqlite3"
> DB_NAME = "ConceptNet.db"
> DB_HOST = ""
> DB_PORT = ""
> DB_USER = ""
> DB_PASSWORD = ""
> DB_SCHEMAS = ""
>
> to new format for 1.4 in the same file ('db_config.py") :
>
> DATABASES = {
>'default': {
> 'ENGINE': 'django.db.backends.sqlite3', # Add 
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3'\
>  or 'oracle'.
> 'NAME': 'ConceptNet.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.
> }
> }
>
> This did not help.
> I also renamed 'db_config.py' to 'settings.py' in the same working 
> directory. I am still getting the same error.
> What shall I do to make Django 1.4 find my configuration?
>
> Thanks!
> Dmitri
>
> - Detailed dump ---
>
> -bash: ipyhton: command not found
> >ipython
> Leopard libedit detected.
> Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
> Type "copyright", "credits" or "license" for more information.
>
> IPython 0.10 -- An enhanced Interactive Python.
> ? -> Introduction and overview of IPython's features.
> %quickref -> Quick reference.
> help  -> Python's own help system.
> object?   -> Details about 'object'. ?object also works, ?? prints more.
>
> In [1]: from conceptnet.models import Concept
> /Library/Python/2.6/site-packages/django/conf/__init__.py:75: 
> DeprecationWarning: The ADMIN_MEDIA_PREFIX setting has been removed; use 
> STATIC_URL instead.
>   "use STATIC_URL instead.", DeprecationWarning)
> /Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-universal.egg/pytz/tzinfo.py:5:
>  
> DeprecationWarning: the sets module is deprecated
>   from sets import Set
>
> In [2]: dog = Concept.get('dog', 'en')
> ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (47, 0))
>
> ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (17, 0))
>
> ---
> ImproperlyConfigured  Traceback (most recent call last)
>
> /Users/user/wks/Macys/ConceptNet/ConceptNet-sqlite/ in 
> ()
>
> /Library/Python/2.6/site-packages/conceptnet/models.pyc in get(cls, text, 
> language, auto_create)
> 611 """
> 612 if not isinstance(language, Language):
> --> 613 language = Language.get(language)
> 614 surface = SurfaceForm.get(text, language, auto_create)
> 615 if surface is None:
>
> /Library/Python/2.6/site-packages/conceptnet/corpus/models.pyc in get(id)
> 103 """
> 104 if isinstance(id,Language): return id
> --> 105 return get_lang(id)
> 106 
> 107 @property
>
> /Library/Python/2.6/site-packages/django/utils/functional.pyc in 
> wrapper(*args)
>  25 if mem_args in cache:
>  26 return cache[mem_args]
> ---> 27 result = func(*args)
>  28 cache[mem_args] = result
>  29 return result
>
> /Library/Python/2.6/site-packages/conceptnet/corpus/models.pyc in 
> get_lang(lang_code)
>  65 it doesn't have to be looked up again.
>  66 """
> ---> 67 return Language.objects.get(id=lang_code)
>  68 get_lang = memoize(get_lang, cached_langs, 1)
>  69 
>
> /Library/Python/2.6/site-packages/django/db/models/manager.pyc in 
> get(self, *args, **kwargs)
> 129 
> 130 def get(self, *args, **kwargs):
> --> 131 return self.get_query_set().get(*args, **kwargs)
> 132 
> 133 def get_or_create(self, **kwargs):
>
> /Library/Python/2.6/site-packages/django/db/models/quer

Re: Nullable User email

2012-08-07 Thread Germán
It seems you shouldn't use null but rather an empty string:
https://docs.djangoproject.com/en/dev/ref/models/fields/#null

> Avoid using 
> null
>  on 
> string-based fields such as 
> CharField
>  and 
> TextField
>  unless 
> you have an excellent reason. If a string-based field has null=True, that 
> means it has two possible values for “no data”: NULL, and the empty 
> string. In most cases, it’s redundant to have two possible values for “no 
> data;” Django convention is to use the empty string, not NULL.



On Tuesday, August 7, 2012 11:08:50 AM UTC-4, Demian Brecht wrote:
>
> In an authentication backend I'm currently writing, I've supplied a custom 
> User model that extends the contrib.auth User model. I have the need to 
> allow email addresses to be NULL. 
>
> A little context: I'm writing an OAuth2 wrapper for an OAuth2 client I 
> relatively recently wrote (yes, I know that there are other clients already 
> written out there, but I'm writing this one due to being quite partial to 
> my module ;)). Some OAuth2 providers don't provide user e-mail addresses, 
> regardless of scope params. All providers however, provide some form of a 
> user ID. As you can't simply use field hiding in Django models, I figure 
> that I can achieve this by one of the following two methods:
>
> 1. Copy/paste the entire model, changing the attribute of the one field.
> 2. User._meta.fields[4].null = true
>
> #2, even though seemingly hacky at best seems to be the lesser of the two 
> evils as it at least keeps things DRY (and is potentially far less 
> maintenance down the road).
>
> My question is, is there another method of achieving this that I'm not 
> seeing? Preferably one that *isn't* hacky?
>
> Thanks,
> Demian
>

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



Geodjango on Windows issue

2012-08-07 Thread Danny Im
Hello all, 

I'm hoping to get some assistance on this.

Issue:
A user can upload a shapefile to the django application once upon a fresh 
apache restart.  Any subsequent shapefile upload by any other user results in 
the server not giving any response back to the client.  Other uploads go 
through fine.  Shapefile uploads make use of GDAL (in particular, the code will 
hang on a call to OGRGeometry.transform), other uploads do not.  

What I think is happening:
A python thread will hang whenever a user uploads a shapefile (and thus calling 
a GDAL library function), given that another thread has previously used a GDAL 
function.  

What I've done so far:
>From the geodjango documentation 
>(https://docs.djangoproject.com/en/1.4/ref/contrib/gis/deployment/), no 
>threading should be used for webserver deployment as GDAL is not thread safe.  
>However, since I'm using apache on windows, it appears that the mpm used 
>creates multiple threads for each request
http://httpd.apache.org/docs/2.2/mod/mpm_winnt.html

My question:  Is there any way to use apache on windows for geodjango 
applications?  I'm assuming my problem will be solved if I can have each 
request be handled by a separate process - are there any other webservers that 
I should look into?  I'd prefer solutions that would work on Windows.

Relevant software used: 
Windows Server 2008 R2
Apache HTTP Server version 2.2.22
GDAL/OGR 1.9.1
Django 1.4
MapServer CGI 6.0.3

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/-/3MCkF0uQZM4J.
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: Migrating app from Django 1.3.3 to 1.4

2012-08-07 Thread Aaron C. de Bruyn
On 2012-08-07 at 07:24:06 -0700, dokondr wrote:
> DATABASES = {
>'default': {
> 'ENGINE': 'django.db.backends.sqlite3', # Add 

Do you actually have the sqlite3 library installed?
(Debian/Ubuntu: apt-get install python-pysqlite2)

> ImproperlyConfigured: settings.DATABASES is improperly configured. Please 
> supply the ENGINE value. Check settings documentation for more details.

If it's a new database, you probably need to run 'python manage.py syncdb' too.

-A

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



Nullable User email

2012-08-07 Thread Demian Brecht
In an authentication backend I'm currently writing, I've supplied a custom
User model that extends the contrib.auth User model. I have the need to
allow email addresses to be NULL.

A little context: I'm writing an OAuth2 wrapper for an OAuth2 client I
relatively recently wrote (yes, I know that there are other clients already
written out there, but I'm writing this one due to being quite partial to
my module ;)). Some OAuth2 providers don't provide user e-mail addresses,
regardless of scope params. All providers however, provide some form of a
user ID. As you can't simply use field hiding in Django models, I figure
that I can achieve this by one of the following two methods:

1. Copy/paste the entire model, changing the attribute of the one field.
2. User._meta.fields[4].null = true

#2, even though seemingly hacky at best seems to be the lesser of the two
evils as it at least keeps things DRY (and is potentially far less
maintenance down the road).

My question is, is there another method of achieving this that I'm not
seeing? Preferably one that *isn't* hacky?

Thanks,
Demian

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



Migrating app from Django 1.3.3 to 1.4

2012-08-07 Thread dokondr
Hi all!
I am trying to run ConceptNet 
(http://csc.media.mit.edu/docs/conceptnet/install.html) originally deployed 
on Django 1.3.
When running this app with Django1.4 on Mac OS X 10.6.8. (Snow Leopard) I 
get:

"ImproperlyConfigured: settings.DATABASES is improperly configured. Please 
supply the ENGINE value. Check settings documentation for more details."

(Please see detailed log at the end of this message.)

To solve this I tried to create new config for 1.4 and run with SQLite 
database (ready to use) in my work directory.  I have changed the old 
contents of 'db_config.py'

DB_ENGINE = "sqlite3"
DB_NAME = "ConceptNet.db"
DB_HOST = ""
DB_PORT = ""
DB_USER = ""
DB_PASSWORD = ""
DB_SCHEMAS = ""

to new format for 1.4 in the same file ('db_config.py") :

DATABASES = {
   'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3'\
 or 'oracle'.
'NAME': 'ConceptNet.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.
}
}

This did not help.
I also renamed 'db_config.py' to 'settings.py' in the same working 
directory. I am still getting the same error.
What shall I do to make Django 1.4 find my configuration?

Thanks!
Dmitri

- Detailed dump ---

-bash: ipyhton: command not found
>ipython
Leopard libedit detected.
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help  -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from conceptnet.models import Concept
/Library/Python/2.6/site-packages/django/conf/__init__.py:75: 
DeprecationWarning: The ADMIN_MEDIA_PREFIX setting has been removed; use 
STATIC_URL instead.
  "use STATIC_URL instead.", DeprecationWarning)
/Library/Python/2.6/site-packages/matplotlib-0.91.1-py2.6-macosx-10.6-universal.egg/pytz/tzinfo.py:5:
 
DeprecationWarning: the sets module is deprecated
  from sets import Set

In [2]: dog = Concept.get('dog', 'en')
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (47, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (17, 0))

---
ImproperlyConfigured  Traceback (most recent call last)

/Users/user/wks/Macys/ConceptNet/ConceptNet-sqlite/ in 
()

/Library/Python/2.6/site-packages/conceptnet/models.pyc in get(cls, text, 
language, auto_create)
611 """
612 if not isinstance(language, Language):
--> 613 language = Language.get(language)
614 surface = SurfaceForm.get(text, language, auto_create)
615 if surface is None:

/Library/Python/2.6/site-packages/conceptnet/corpus/models.pyc in get(id)
103 """
104 if isinstance(id,Language): return id
--> 105 return get_lang(id)
106 
107 @property

/Library/Python/2.6/site-packages/django/utils/functional.pyc in 
wrapper(*args)
 25 if mem_args in cache:
 26 return cache[mem_args]
---> 27 result = func(*args)
 28 cache[mem_args] = result
 29 return result

/Library/Python/2.6/site-packages/conceptnet/corpus/models.pyc in 
get_lang(lang_code)
 65 it doesn't have to be looked up again.
 66 """
---> 67 return Language.objects.get(id=lang_code)
 68 get_lang = memoize(get_lang, cached_langs, 1)
 69 

/Library/Python/2.6/site-packages/django/db/models/manager.pyc in get(self, 
*args, **kwargs)
129 
130 def get(self, *args, **kwargs):
--> 131 return self.get_query_set().get(*args, **kwargs)
132 
133 def get_or_create(self, **kwargs):

/Library/Python/2.6/site-packages/django/db/models/query.pyc in get(self, 
*args, **kwargs)
359 if self.query.can_filter():
360 clone = clone.order_by()
--> 361 num = len(clone)
362 if num == 1:
363 return clone._result_cache[0]

/Library/Python/2.6/site-packages/django/db/models/query.pyc in 
__len__(self)
 83 self._result_cache = list(self._iter)
 84 else:
---> 85 self._result_cache = list(self.iterator())
 86 elif self._iter:
 87

Re: edit a submitted form-load it on template

2012-08-07 Thread Alexis Roda

Al 07/08/12 14:04, En/na mapapage ha escrit:



$(document).ready(function () {
$("a").on("click", function(event) {
event.preventDefault();
var id = $(this).attr("id");
$.get("edit_wreqs"+"/"+id+"/", function(data) {
});
});
});



Disclaimer: I don't use jquery myself. My response is based on my 
experience with other js toolkits. The same ideas probably apply but the 
details may be different.


Well, you actually don't do anything with the value returned from the 
server (the function passed to 'get' is empty).


Once the 'get' call completes you'll get a chunk of HTML, corresponding 
to the rendering of the template 'main_Webrequests.html', that you 
should process in some way: the callback should locate the relevant HTML 
"code" within 'data' and insert-into/replace-part-of the current page 
with that "code". A quick googling shows that 'replaceWith' may be useful.


Depending on what you're trying to do it may be simpler (and faster) 
just fetching the object attributes from the server (instead of the 
whole page) and use those values to populate an edit form.




HTH

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



edit a submitted form-load it on template

2012-08-07 Thread mapapage
I have an app where a user submits some forms. Now I want the user to be 
able to edit his previous submitted forms.
 So on the template(e.g old_Webrequests.html) I just load a list with links 
corresponding to every submitted form(view:old_Webreqs(request,user_id)). 
{% for a in all_reqs %}
{{ a }}
{% endfor %}

According to user's choice I perform an ajax request to a 
view(edit_wreqs(request, user_id, wr_id )) passing the selected form's 
id in order to query the object from the db.

$(document).ready(function () {
 $("a").on("click", function(event) {
  event.preventDefault();
  var id = $(this).attr("id");
  $.get("edit_wreqs"+"/"+id+"/", function(data) {
  });
 }); 
});

 
At this point I suppose I will load an instance of that object. But how can 
I return this instance to the template where the user submits the form(eg 
main_Webrequests.html) the time the user hits the link?Or how the template 
will be loaded the time the user hits the link?With my code when the user 
hits the link the requested object is printed in the terminal but nothing 
changes on the screen.

def edit_wreqs(request, user_id, wr_id ):
  
f = Webrequests.objects.get(id=wr_id)
print f
if request.method == 'POST':
form = WebrequestsForm(data=request.POST, own_id=u_id, instance=f) 
if form.is_valid():
form.save()
return render_to_response('success.html', locals(), 
context_instance= RequestContext(request))
else:
form = WebrequestsForm(instance=f) 

return render_to_response('main_Webrequests.html', locals(), 
context_instance= RequestContext(request))

Where am I wrong?




-- 
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/-/HHsPLznjuOwJ.
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 + selenium testing with several browsers

2012-08-07 Thread Rafael Durán Castañeda

On 08/06/2012 12:34 AM, LS wrote:
I have a series of test cases defined using the LiveServerTestCase 
class provided by Django. I derive a number of classes from it, and 
run the tests using manage.py test as per the docs at 
https://docs.djangoproject.com/en/1.4/topics/testing/


This is all working fine, it starts firefox (or chrome if I change the 
code), but since I'm using a lot of html5 stuff in javascript (that 
has already broken in one browser or the other before), I'd like my 
tests to run on a series of browsers (at a minimum firefox and chrome, 
possibly several versions of each).


I'm looking for a solution that allows me to create tests as simply as 
now (i.e: just add methods to a class) and reuse them in each browser.


I thought about overloading DjangoTestSuiteRunner to start each 
browser in turn and run each test there, but there has to be a simpler 
way to do this, since I feel this would be a fairly common use case.


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/-/09kzUgfrqloJ.

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.

Hi,

I think you  just define a base class that implements all tests and 
different test suites that overrides/implements just the browser details.


Bye

--
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: Compile/generate JavaScript from Django Templates?

2012-08-07 Thread Melvyn Sopacua
On 7-8-2012 10:52, Alec Taylor wrote:
> To completely decouple the client-side, would it be possible to
> generate JavaScript from the server-side Django Template?

The template documentation explicitly tells you it can generate *any*
text-based format. [1]
A few threads ago I gave an example and pointed to
contrib/gis/templates/gis/admin/openlayers.js.

[1] https://docs.djangoproject.com/en/1.4/topics/templates/#templates
-- 
Melvyn Sopacua

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



Compile/generate JavaScript from Django Templates?

2012-08-07 Thread Alec Taylor
To completely decouple the client-side, would it be possible to
generate JavaScript from the server-side Django Template?

E.g.: using PyJamas

If not, I will use tastypie or piston to expose a RESTful JSON API
which I will consume with a JavaScript framework on the client-side
(AngularJS).

Would simplify things a lot and prevent double typing thought if it is
possible to compile/generate JavaScript from Django Templates.

Thanks for all information,

Alec Taylor

-- 
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: Choosing a Django-based CMS

2012-08-07 Thread Matthias Kestenholz
Hi Sean

On Tue, Aug 7, 2012 at 5:52 AM, Sean O'Brian  wrote:
> Thanks all.
> As I get, I should try both Mezzazine and FeinCMS.
> May be they're have another advantages and disadvantages.
>

(Disclaimer: I'm one of the main developers of FeinCMS.)

The best place to ask questions about FeinCMS would be the
django-feincms mailing list. It's true that development isn't very
active this month (yet), a lot happened since the last release though.
You can see the breakdown here:

http://feincms-django-cms.readthedocs.org/en/next/releases/1.7.html

Development happens on the `next` branch in the github repository.
`master` normally does not get much activity since `master` tracks the
official maintenance branch (v1.6.x at the moment).


Thanks,
Matthias

-- 
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: fastcgi vs wsgi

2012-08-07 Thread Gour
On Tue, 07 Aug 2012 00:39:36 +0200
Melvyn Sopacua  wrote:

> The system used is not of much influence. The bulk of the memory usage
> of a WSGI and fastcgi app is the modules that are loaded by the python
> interpreter, similar to how php-fpm memory increases with each
> extension that is loaded. Caching settings are also of influence.

Thank you very much...it's very helpful.

> The best way to find out is to load your apps and turn debugging off
> on your staging server (settings.DEBUG is a major memory hog). I do
> however find that uwsgi gives you a lot of control combined with sane
> defaults. Limits to configure include memory usage and forking models.

I've found out about uwsgi's idle & cheap option...very useful.
 
> So you main goal is to turn off in django what you don't need.
> Candidates:
> - i18n/l10n
> - cachemiddleware
> - context processors
> - settings.DEBUG
> - uninstall PIL if you don't use it

Thanks a lot.


Sincerely,
Gour

-- 
Thus the wise living entity's pure consciousness becomes covered by 
his eternal enemy in the form of lust, which is never satisfied and 
which burns like fire.

http://atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810


signature.asc
Description: PGP signature