Re: Operate with Postgresql from Django views.

2009-12-21 Thread Nicu Marcu
Yes, this was the problem, thanks for your help.

2009/12/21 Christophe Pettus 

>
> On Dec 21, 2009, at 1:34 AM, NMarcu wrote:
> > Everything is OK, if the view is finished, but if after this line I
> > add an infinite loop, and in this time I check that table from console
> > for the new record, that is not there.
>
> This sounds like a transaction issue.  In the standard Django
> transaction handling model, the transaction is not committed until the
> view function returns; this means that if you check immediately after
> the data modification statement, but before the view function has
> completed, you won't see the new data from a different database
> connection.
>
> It's probably not a great idea to idle in a view function, waiting for
> a daemon to complete some background process, since the process isn't
> really "background" then; the user at the browser is going to be
> waiting until the daemon process completes.  If you *must* handle it
> this way, you can switch to doing manual transaction control instead
> of using Django's transaction management.
> --
> -- Christophe Pettus
>x...@thebuild.com
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>
>


-- 
All the best,

Nicolae MARCU

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Custom Django-Admin commands

2009-12-21 Thread Justin Steward
On Tue, Dec 22, 2009 at 3:51 PM, Alex_Gaynor  wrote:
>
> Do you have __init__.py files in each of those directories?

Of course - Else it woud not work from the project's root directory either.

~Justin

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Custom Django-Admin commands

2009-12-21 Thread Alex_Gaynor


On Dec 21, 8:38 pm, Justin Steward  wrote:
> On Tue, Dec 22, 2009 at 12:16 PM, Doug Blank  wrote:
>
> > You probably just need to set your PYTHONPATH:
>
> > cd /home/user
> > PYTHONPATH=proj python proj/manage.py custom
>
> That was my initial thought too, however setting the PYTHONPATH does
> not affect the behaviour in this instance.
>
> ~Justin

Do you have __init__.py files in each of those directories?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: One thing to add to 0.96 to 1.0 porting guide

2009-12-21 Thread Karen Tracey
On Mon, Dec 21, 2009 at 10:19 PM, Russell  wrote:

> http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/
>
> The guide didn't mention the change in
> django.datastructure.MultiValueDict which affects QueryDict directly
> and request.POST and request.GET eventually. The change is minor, but
> critical: MultiValueDict.iteritems() returns (key, last_value) instead
> of (key, [values]).
>
> I've paid painful price to find out the cause of my borken data and
> hope this could be written in the guide explicitly and save people
> some time.
>
>
The guide covers the common (and less common, in two different sections)
changes needed to port code from 0.96 to 1.0. It's meant as an aid to those
who have code which needs only the more common changes, and does not attempt
to be an exhaustive list of things that might need to be changed.  Rather it
points to the release notes, which in turn point to the complete list of
backwards-incompatible changes from 0.96 to 1.0.  There the change you note
is documented:

http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges#CorrectedMultiValueDict.iteritemstoreturnitemsratherthanlists

The problem with the full list is it is overwhelming for people who only
need to make the more common changes, so the guide was developed.  But then
the problem with the guide is that it doesn't cover everything.  But if it
covered everything, it would become the full list and again be rather
overwhelming for people who really only need to know about the common
things.

Karen

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




One thing to add to 0.96 to 1.0 porting guide

2009-12-21 Thread Russell
http://docs.djangoproject.com/en/dev/releases/1.0-porting-guide/

The guide didn't mention the change in
django.datastructure.MultiValueDict which affects QueryDict directly
and request.POST and request.GET eventually. The change is minor, but
critical: MultiValueDict.iteritems() returns (key, last_value) instead
of (key, [values]).

I've paid painful price to find out the cause of my borken data and
hope this could be written in the guide explicitly and save people
some time.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Custom Django-Admin commands

2009-12-21 Thread Justin Steward
On Tue, Dec 22, 2009 at 12:16 PM, Doug Blank  wrote:
>
> You probably just need to set your PYTHONPATH:
>
> cd /home/user
> PYTHONPATH=proj python proj/manage.py custom
>

That was my initial thought too, however setting the PYTHONPATH does
not affect the behaviour in this instance.


~Justin

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Custom Django-Admin commands

2009-12-21 Thread Doug Blank
On Mon, Dec 21, 2009 at 8:10 PM, Justin Steward  wrote:
> Hi all,
>
> I've written a custom command to use with manage.py, and from the root
> of the project directory, it works great.
>
> But the problem is, this command is almost never going to be called
> from within the project directory.
>
> (hoping the spacing doesn't get too mangled when I send this)
> /home/
>  user/ <- ""/home/user/proj/manage.py custom" command doesn't exist.
>     proj/  <- "/home/user/proj/manage.py custom" works
>       manage.py
>       app/
>         management/
>           commands/
>             custom.py
>
> Is there something I'm missing?

You probably just need to set your PYTHONPATH:

cd /home/user
PYTHONPATH=proj python proj/manage.py custom

-Doug

>
> ~Justin
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.




Custom Django-Admin commands

2009-12-21 Thread Justin Steward
Hi all,

I've written a custom command to use with manage.py, and from the root
of the project directory, it works great.

But the problem is, this command is almost never going to be called
from within the project directory.

(hoping the spacing doesn't get too mangled when I send this)
/home/
  user/ <- ""/home/user/proj/manage.py custom" command doesn't exist.
 proj/  <- "/home/user/proj/manage.py custom" works
   manage.py
   app/
 management/
   commands/
 custom.py

Is there something I'm missing?


~Justin

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Does Django support sockets of type SOCK_STREAM for full-duplex communication with a client?

2009-12-21 Thread Chris
Hello,

I have a client that needs to constantly send data to Django-based
backend. The client code follows the pattern:

...
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
s.connect( ( '10.20.30.40',  8080 ) )
while True :
data = s.recv( 2048 )
print data

s.send( r'something' )
...

Could you advice on possible approaches to come up with a Django
implementation of a backend that can work with such client, please?

Thank you,
Chris

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Binary Post Data to ImageField

2009-12-21 Thread 邓超
As I know Django can not save binary data with it's default orm, you can try
to select another orm like sqlalchemy, or you can try to
modify the orm to make it can save binary data.

2009/12/21 Markus T. 

> Hi,
>
> I'm trying to save binary POST data to an ImageFile field - so far
> with no satisfying success.
>
> I can't seem to convince the client (Flex based image editor) to send
> binary data as correct "multipart/form-data"; I only have the option
> to send as raw binary data or with POST variables.
>
> My view function happily receives the binary data, and it looks ok. As
> far as I understand things, if the uploaded data was sent correctly as
> multipart-form-data, Django would create an InMemoryUploadFile object
> and pass it in request.FILES. I could use this code to save the image
> then:
>
> model_instance.image.save("%s.jpg" % img_id, request.FILES
> ['user_img'], True)
>
> What sensible approach could I use to update/save the image with
> binary POST data? I do not want to create a temporary file, though.
>
> I just don't seem to have enough in-depth Django knowledge to find a
> satisfying solution...
>
> Thanks!
>
> Markus
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>
>


-- 
Deng Chao

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Best way to handle class attribute as a space separated string?

2009-12-21 Thread Margie Roginski
Ok, well just thought maybe I was missing some  python builtin or
django method that others were using.  Looks like it's just something
that needs be coded up and encapsulated.

Thanks for your comments!

Margie

On Dec 21, 2:03 pm, Kieran Brownlees  wrote:
> Not very practical but fun to make and good for wtf moments when
> reading old code :)
>
> self.attrs['class'] = ' '.join([x for x in self.attr.get('class') and
> self.attr['class'].split(' ') or []] + [self.pastClass])
>
> Could make it a little shorter with two lines:
> e, a, p = self.attrs.get('class'), self.attrs, self.pastClass
> a['class'] = ' '.join([x for x in e and e.split(' ') or []] + [p])
>
> Could fit the final version in with three tabs and it's only 79 chars!
>
> Kieran
>
> On Dec 22, 10:32 am, Margie Roginski  wrote:
>
> > I have a variety of places in my code where I add a class to a
> > widget.  For example, I have a render() function for a DateWidget that
> > contains this code, which adds a special class if the date is in the
> > past.
>
> >                 if date < datetime.datetime.now():
> >                     if self.attrs.get("class"):
> >                         self.attrs["class"] += " " + self.pastClass
> >                     else:
> >                         self.attrs["class"] = self.pastClass
>
> > This checks if there's already a class attribute and if there is,
> > appends a space and then the string in self.pastClass, and if tehre is
> > not, just creates the class attribute containing self.pastClass.
>
> > This seems like a lot of code to do something really simple and I feel
> > like I'm repeating it in various places.  I'm wondering if there is
> > some better way that folks deal with this little nit?
>
> > Margie

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Hashed, salted mysql password in settings.py, reccomendation to protect information

2009-12-21 Thread fruity

Sorry again, even better:

http://code.djangoproject.com/wiki/SplitSettings

fruity wrote:
> Thank you very much.
> 
> After a while of searching on django-snippets there was the answer :)
> 
> http://www.djangosnippets.org/snippets/94/
> 
> Brice Leroy wrote:
>> Easy,
>>   put your password in a settings_secret.py file, do not import this
>> file on your repository. Add:
>> from settings_secret import mysql_password
>> ...
>> you're set :)
>>
>> Brice
>>
>> 2009/12/21 fruity :
>>> Hello,
>>>
>>> I'd like to protect the mysql password that is in settings.py
>>>
>>> I read in the django docs that is possible to use SHA1 hashes as
>>> password for mysql and I've tried using mysql to salt and hash the
>>> password but still if I would have my project on a public svn|git
>>> repository anyone could just read sha1$salt$hash and reverse it.
>>>
>>> Is there any common practice to protect this password? For example to
>>> have it into an external file sources by the settings.py and use a svn
>>> or git ignore on it?
>>>
>>> Also, how do you generate the hash?  via mysql? slappasswd? cracklibs?
>>> And how do you escape weird chars in the salt?
>>>
>>> I've tried to add sha1$mysaltnoweirdchars$hash and it gives me error on
>>> django release 1.1
>>>
>>> Thank you very much for your time.
>>>
>>> fruity
>>>
>>> --
>>>
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To post to this group, send email to django-us...@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-us...@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-us...@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-us...@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: Hashed, salted mysql password in settings.py, reccomendation to protect information

2009-12-21 Thread fruity
Thank you very much.

After a while of searching on django-snippets there was the answer :)

http://www.djangosnippets.org/snippets/94/

Brice Leroy wrote:
> Easy,
>   put your password in a settings_secret.py file, do not import this
> file on your repository. Add:
> from settings_secret import mysql_password
> ...
> you're set :)
> 
> Brice
> 
> 2009/12/21 fruity :
>> Hello,
>>
>> I'd like to protect the mysql password that is in settings.py
>>
>> I read in the django docs that is possible to use SHA1 hashes as
>> password for mysql and I've tried using mysql to salt and hash the
>> password but still if I would have my project on a public svn|git
>> repository anyone could just read sha1$salt$hash and reverse it.
>>
>> Is there any common practice to protect this password? For example to
>> have it into an external file sources by the settings.py and use a svn
>> or git ignore on it?
>>
>> Also, how do you generate the hash?  via mysql? slappasswd? cracklibs?
>> And how do you escape weird chars in the salt?
>>
>> I've tried to add sha1$mysaltnoweirdchars$hash and it gives me error on
>> django release 1.1
>>
>> Thank you very much for your time.
>>
>> fruity
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django-us...@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-us...@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-us...@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: Hashed, salted mysql password in settings.py, reccomendation to protect information

2009-12-21 Thread Brice Leroy
Easy,
  put your password in a settings_secret.py file, do not import this
file on your repository. Add:
from settings_secret import mysql_password
...
you're set :)

Brice

2009/12/21 fruity :
> Hello,
>
> I'd like to protect the mysql password that is in settings.py
>
> I read in the django docs that is possible to use SHA1 hashes as
> password for mysql and I've tried using mysql to salt and hash the
> password but still if I would have my project on a public svn|git
> repository anyone could just read sha1$salt$hash and reverse it.
>
> Is there any common practice to protect this password? For example to
> have it into an external file sources by the settings.py and use a svn
> or git ignore on it?
>
> Also, how do you generate the hash?  via mysql? slappasswd? cracklibs?
> And how do you escape weird chars in the salt?
>
> I've tried to add sha1$mysaltnoweirdchars$hash and it gives me error on
> django release 1.1
>
> Thank you very much for your time.
>
> fruity
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: super() argument 1 must be type, not None

2009-12-21 Thread TiNo
On Tue, Dec 22, 2009 at 00:19, Kieran Brownlees wrote:

> Have you restarted your server lately? I find that bug turns up from
> time to time when the auto reloader doesn't reload properly.
>

Yep. Also tried in the dev server as mentioned...

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Enable users to input formatted text

2009-12-21 Thread Continuation
django-tinymce looks like is what I need.

Thanks for pointing me to that.

On Dec 21, 5:50 pm, "pjrhar...@gmail.com"  wrote:
> You've got to decide what you want to allow. If the users are trusted
> you could allow them to input HTML, then you have to make sure its
> marked as safe so the HTML is not escaped.[1]
>
> Alternatively you could use a markup language that can be converted to
> HTML.[2]
>
> If you just want the newlines, you can convert them to HTML.[3]
>
> Finally, theres a variety of different options for rich text editors,
> for example django-tinymce[4]
>
> 1.http://docs.djangoproject.com/en/dev/ref/templates/builtins/#safe
> 2.http://docs.djangoproject.com/en/dev/ref/contrib/#ref-contrib-markup
> 3.http://docs.djangoproject.com/en/dev/ref/templates/builtins/#linebreaks
> 4.http://code.google.com/p/django-tinymce/

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: super() argument 1 must be type, not None

2009-12-21 Thread Kieran Brownlees
Have you restarted your server lately? I find that bug turns up from
time to time when the auto reloader doesn't reload properly.

Kieran

On Dec 22, 12:17 pm, TiNo  wrote:
> Hi,
>
> I am overriding a save function of a model with the following code:
>
>     def save(self, *args, **kwargs):
>         if (not self.id) and self.email != '':
>             self.create_user()
>         if hasattr(self, 'user'):
>             self.user.email = self.email
>             self.user.first_name = self.voornaam
>             self.user.last_name = " ".join((self.tussenvoegsel,
> self.achternaam))
>             self.user.save()
>         super(Lid, self).save(*args, **kwargs)
>
> where Lid is the name of the Model. However, for some reason it throws the
> following error since a while (don't know since when, don't know what
> changed, can't find anything suspicious in hg log...) "super() argument 1
> must be type, not None". When I run with pdb.set_trace as the first line of
> the save method in the dev server, I can see that Lid is indeed None. What
> is surprising is that ALL my imports are None (User, datetime, models,
> etc.). I vaguely remember encountering this error before, but I don't
> remember what I did to fix it. What could have overridden all those things
> with None?
>
> Does anybody have any clues? I can post my whole models.py if necessary, but
> it's rather large.
>
> Thanks,
>
> Tino

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




super() argument 1 must be type, not None

2009-12-21 Thread TiNo
Hi,

I am overriding a save function of a model with the following code:

def save(self, *args, **kwargs):
if (not self.id) and self.email != '':
self.create_user()
if hasattr(self, 'user'):
self.user.email = self.email
self.user.first_name = self.voornaam
self.user.last_name = " ".join((self.tussenvoegsel,
self.achternaam))
self.user.save()
super(Lid, self).save(*args, **kwargs)

where Lid is the name of the Model. However, for some reason it throws the
following error since a while (don't know since when, don't know what
changed, can't find anything suspicious in hg log...) "super() argument 1
must be type, not None". When I run with pdb.set_trace as the first line of
the save method in the dev server, I can see that Lid is indeed None. What
is surprising is that ALL my imports are None (User, datetime, models,
etc.). I vaguely remember encountering this error before, but I don't
remember what I did to fix it. What could have overridden all those things
with None?

Does anybody have any clues? I can post my whole models.py if necessary, but
it's rather large.

Thanks,

Tino

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Enable users to input formatted text

2009-12-21 Thread pjrhar...@gmail.com
You've got to decide what you want to allow. If the users are trusted
you could allow them to input HTML, then you have to make sure its
marked as safe so the HTML is not escaped.[1]

Alternatively you could use a markup language that can be converted to
HTML.[2]

If you just want the newlines, you can convert them to HTML.[3]

Finally, theres a variety of different options for rich text editors,
for example django-tinymce[4]

1. http://docs.djangoproject.com/en/dev/ref/templates/builtins/#safe
2. http://docs.djangoproject.com/en/dev/ref/contrib/#ref-contrib-markup
3. http://docs.djangoproject.com/en/dev/ref/templates/builtins/#linebreaks
4. http://code.google.com/p/django-tinymce/

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Best way to handle class attribute as a space separated string?

2009-12-21 Thread Shawn Milochik
I'd use a dictionary or list. If it has to persist, use simplejson to  
serialize it and create a couple of functions to wrap the JSON stuff.

Then you can use property() to simplify it further.

Shawn

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 way to handle class attribute as a space separated string?

2009-12-21 Thread Margie Roginski
I have a variety of places in my code where I add a class to a
widget.  For example, I have a render() function for a DateWidget that
contains this code, which adds a special class if the date is in the
past.

if date < datetime.datetime.now():
if self.attrs.get("class"):
self.attrs["class"] += " " + self.pastClass
else:
self.attrs["class"] = self.pastClass

This checks if there's already a class attribute and if there is,
appends a space and then the string in self.pastClass, and if tehre is
not, just creates the class attribute containing self.pastClass.

This seems like a lot of code to do something really simple and I feel
like I'm repeating it in various places.  I'm wondering if there is
some better way that folks deal with this little nit?

Margie

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: authentication security

2009-12-21 Thread macdd


On Dec 21, 10:35 am, Eric Chamberlain  wrote:
> On Dec 18, 2009, at 7:58 PM, macdd wrote:
>
> > I am reading the django book. I just finished the chapter on
> > authentication. I get the jist of it. What I don't understand is the
> > overall security of authentication. If everything you do is passed as
> > plain text then it isn't very secure. Okay so https comes in. What I
> > don't understand is when to use it and when not to. It seems like if
> > you authenticate over https just for user credentials and then go back
> > to http (like yahoo) than someone could just ease drop your cookie and
> > be you, making logging in and out in any form pointless?
>
> We use https for all our authenticated pages.
>
> Our primary concern was packet capture on public WiFi connections.
>
> --
> Eric Chamberlain, Founder
> RF.com -http://RF.com/

thanks for your guys' response. I guess I know just enough to
understand but not enough to actually be practical about.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Overhead of using django.contrib.markup vs. pre-rendered HTML field

2009-12-21 Thread Jesaja Everling
Hi Brian,

thanks for your reply!
It's true that this is probably mostly a matter of personal preference/
application needs, but I agree with you that it's a good deal nowadays
to trade a little bit of disk-space for some processing power.

Best Regards,

Jesaja Everling


On 21 Gru, 18:33, Brian Neal  wrote:
> On Dec 21, 7:12 am, Jesaja Everling  wrote:
>
> > Hi All!
>
> > I'm wondering how expensive it is in terms of processing power to use
> > the django.contrib.markup filters for displaying blog posts instead of
> > storing pre-rendered HTML in a db field.
> > The Pinax blog application makes use of these markup-filters to render
> > HTML on the fly, for example. I assume that especially with caching
> > enabled this won't pose a problem, but it still might be advisable to
> > store pre-rendered HTML once a new blog-post is saved.
> > Does the reStructuredText filter introduce noticeable overhead or is
> > it negligible?
>
> This question always generates a lot of heat when it crops up on sites
> like reddit and digg, so you are bound to get a lot of varied and
> strongly held opinions.
>
> The only way you are really going to know is to take some benchmarks
> and see what the difference is, then you have to decide if the
> overhead is too great for your specific application and site. The
> overhead is probably acceptable for a great majority of sites, but
> only you should decide that for yourself.
>
> I almost always pre-render it and save it in the database. On my site,
> my content is going to be read many, many orders of magnitude more
> than it is written, so I just get the conversion from markup to HTML
> over with once. It's a trade-off between database space and CPU, and
> one that I am very willing to make given my circumstances of my site
> and my applications. Your mileage may vary, of course.
>
> Best,
> BN

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Hashed, salted mysql password in settings.py, reccomendation to protect information

2009-12-21 Thread fruity
Hello,

I'd like to protect the mysql password that is in settings.py

I read in the django docs that is possible to use SHA1 hashes as
password for mysql and I've tried using mysql to salt and hash the
password but still if I would have my project on a public svn|git
repository anyone could just read sha1$salt$hash and reverse it.

Is there any common practice to protect this password? For example to
have it into an external file sources by the settings.py and use a svn
or git ignore on it?

Also, how do you generate the hash?  via mysql? slappasswd? cracklibs?
And how do you escape weird chars in the salt?

I've tried to add sha1$mysaltnoweirdchars$hash and it gives me error on
django release 1.1

Thank you very much for your time.

fruity

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Operate with Postgresql from Django views.

2009-12-21 Thread Christophe Pettus

On Dec 21, 2009, at 1:34 AM, NMarcu wrote:
> Everything is OK, if the view is finished, but if after this line I
> add an infinite loop, and in this time I check that table from console
> for the new record, that is not there.

This sounds like a transaction issue.  In the standard Django  
transaction handling model, the transaction is not committed until the  
view function returns; this means that if you check immediately after  
the data modification statement, but before the view function has  
completed, you won't see the new data from a different database  
connection.

It's probably not a great idea to idle in a view function, waiting for  
a daemon to complete some background process, since the process isn't  
really "background" then; the user at the browser is going to be  
waiting until the daemon process completes.  If you *must* handle it  
this way, you can switch to doing manual transaction control instead  
of using Django's transaction management.
--
-- Christophe Pettus
x...@thebuild.com

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: authentication security

2009-12-21 Thread Eric Chamberlain

On Dec 18, 2009, at 7:58 PM, macdd wrote:

> I am reading the django book. I just finished the chapter on
> authentication. I get the jist of it. What I don't understand is the
> overall security of authentication. If everything you do is passed as
> plain text then it isn't very secure. Okay so https comes in. What I
> don't understand is when to use it and when not to. It seems like if
> you authenticate over https just for user credentials and then go back
> to http (like yahoo) than someone could just ease drop your cookie and
> be you, making logging in and out in any form pointless?
> 

We use https for all our authenticated pages.

Our primary concern was packet capture on public WiFi connections.

--
Eric Chamberlain, Founder
RF.com - http://RF.com/







--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Overhead of using django.contrib.markup vs. pre-rendered HTML field

2009-12-21 Thread Brian Neal
On Dec 21, 7:12 am, Jesaja Everling  wrote:
> Hi All!
>
> I'm wondering how expensive it is in terms of processing power to use
> the django.contrib.markup filters for displaying blog posts instead of
> storing pre-rendered HTML in a db field.
> The Pinax blog application makes use of these markup-filters to render
> HTML on the fly, for example. I assume that especially with caching
> enabled this won't pose a problem, but it still might be advisable to
> store pre-rendered HTML once a new blog-post is saved.
> Does the reStructuredText filter introduce noticeable overhead or is
> it negligible?

This question always generates a lot of heat when it crops up on sites
like reddit and digg, so you are bound to get a lot of varied and
strongly held opinions.

The only way you are really going to know is to take some benchmarks
and see what the difference is, then you have to decide if the
overhead is too great for your specific application and site. The
overhead is probably acceptable for a great majority of sites, but
only you should decide that for yourself.

I almost always pre-render it and save it in the database. On my site,
my content is going to be read many, many orders of magnitude more
than it is written, so I just get the conversion from markup to HTML
over with once. It's a trade-off between database space and CPU, and
one that I am very willing to make given my circumstances of my site
and my applications. Your mileage may vary, of course.

Best,
BN

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Need Google Appengine - Django - Facebook (pyFacebook) Advice

2009-12-21 Thread Kaan Soral
Hello;

I currently develop Facebook applications with Php, the need for a
scalable platform and the charm to use a decent framework led me to
learn Appengine, after experimenting a little bit with webapp
framework and not being able to use pyFacebook lib with webapp, I
decided I should learn Django to use with Appengine and pyFacebook
(the pyFacebook is obviously designed for Django).

Is there anyone out there that develop Facebook applications with
Django on Appengine and pyFacebook that can summarize me what kind of
problems I may face.

It may sound a pointless question, but Facebook is a problematic
platform, even using its official php api is problematic
sometimes.Handling possible appengine/pyFacebook/django conflicts
would be a nightmare.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Is this right: Modifying the admin changelist?

2009-12-21 Thread Daniel Roseman
On Dec 21, 4:40 pm, yummy_droid  wrote:
> Anyone have advice on this?

Not really. Your solution is probably the best that can be done - it
does involve instantiating the ChangeList twice, but that's pretty
much unavoidable. One of the main criticisms a lot of people have of
the (otherwise wonderful) admin application is that a lot of the
methods are pretty monolithic - there aren't many hooks that you can
use to override small bits without having to repeat the whole method.

That said, here's an option that just occurred to me. The template has
access to the changelist object, which you use to get the query set to
calculate the aggregate. So you can use that `cl` via the template by
writing a template tag that takes that as a parameter, gets the
queryset and adds the aggregate value.
--
DR.

--

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




Problem importing datetime from xml

2009-12-21 Thread bax...@gretschpages.com
I'm importing data from xml using xmltramp. Among the data are a bunch
of times formatted like so:

  2010-05-15 00:00:00

When I import that, I'm getting

Enter a valid date/time in -MM-DD HH:MM[:ss[.uu]] format.

I've tried altering the formatting, but I'm just not getting these
pulled in. 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-us...@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-based journal publishing system

2009-12-21 Thread Fabio Natali
Hi everybody.

---
In short:

Do you know of any Django-based alternatives to "Open Journal Systems"
[0]?
---

---
In details:

I want to publish a magazine on the internet, say 3 or 4 issues per
year. The publishing process will be collaborative, there will be
several users involved, each user will be granted with specific
rights.

The public part of the site will simply be an archive of issues
(downloadable as pdf). The latest issue will be in evidence.

Not much different from what OJS offers, but Django seems very good at
this task and I guess it could provide me some more flexibility in the
future.

So, do you know of any Django project to do this?
---

Thanks and regards,
Fabio.

[0] http://pkp.sfu.ca/?q=ojs

-- 
Fabio Natali

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Is this right: Modifying the admin changelist?

2009-12-21 Thread yummy_droid
Anyone have advice on this?

On Dec 20, 2:54 am, yummy_droid  wrote:
> Hi,
>
> I wanted a "sum" of a particular column being listed in theadminlist
> page. I looked it up and did it the following way. Is this the correct
> way of doing it?
>
> I modified theadmin.py to do the calculation:
>
>  class CollectionAdmin(admin.ModelAdmin):
>     list_display = ('supplier', 'collected_date', 'tonnage',)
>     list_filter = ('collected_date',)
>
>     defchangelist_view(self, request, extra_context=None):
>         from django.contrib.admin.views.main import ChangeList
>         from django.db.models import Sum
>         if extra_context is None:
>             extra_context = {}
>         mycl = ChangeList(request, self.model, list(self.list_display),
> self.list_display_links, self.list_filter, self.date_hierarchy,
> self.search_fields, self.list_select_related, self.list_per_page,
> self.list_editable, self)
>         fieldsum = mycl.get_query_set().aggregate(Sum('tonnage'))
>         extra_context['tonnage__sum'] = fieldsum['tonnage__sum']
>         return super(CollectionAdmin, self).changelist_view(request,
> extra_context=extra_context)
>
> then i added the following line to change_list.html:
>
>       {% if tonnage__sum %}Total tonnage: {{ tonnage__sum }}{% endif
> %}
>
> Am I doing something bad in thechangelist_viewfunction above? Or is
> it the right way to do this?
>
> the reason I want to use theadminlist is because I like the
> filtering option, and I can then see directly the sum of the column
> based on whatever is currently filtered.
>
> Thanks.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Logout and session

2009-12-21 Thread David De La Harpe Golden
On Mon, Dec 21, 2009 at 12:52:24PM -0200, Victor Loureiro Lima wrote:

> Well, template caching invalidates view cache right? Plus, my understanding
> of the template cache is that
> it will hit my view, do all the DB stuff, but skip the template processing
> which takes a while to finish, is my understanding right?
>

re "all the DB stuff": Depends what your view code is doing, but bear in mind 
QuerySets are lazy,  so it may allow skipping the heavy bit where a QuerySet 
is actually forced to produce any results and thus be more of a win than you
might think.

> In your opinion, what would be the correct approach? Cache the views objects
> instead of the view it self, and cache
> some of the templating? That would avoid the vary_on_cookie and would had a
> more granular effect on the system.
> 

I'm not sure, remember I haven't really used such fine-grained caching, but
I think the _template_ level caching should still operate for logged-in
users when CACHE_MIDDLEWARE_ANONYMOUS_ONLY is true, since the
CACHE_MIDDLEWARE_ANONYMOUS_ONLY settings is controlling, well, the
middleware (request-response wrapping) caching.

So you could use fine-grained template fragment caching for logged-in users, 
and 
CACHE_MIDDLEWARE_ANONYMOUS_ONLY would still coarse-grain cache the 
non-logged-in ones
(regardless of existing session cookie as it's using 
request.user.is_authenticated() )

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Cron vs event triggered action

2009-12-21 Thread David De La Harpe Golden
On Sat, Dec 19, 2009 at 06:28:23AM -0800, Tim Daniel wrote:
> David, Celery sounds really good, thanks for the tip, I'll have a
> deeper look into it as soon as I've got some time, if I can't get it

> one question: Is it capable of running on every web server
> that supports Python?

Well, it's kind of independent of the web server bits: In principle, one could
use celery plus django orm for some project that doesn't involve any web serving
at all (celery still depends on django-as-an-orm-layer-and-stuff, but not
django-as-a-web-application-server). See:
http://ask.github.com/celery/faq.html#can-i-use-celery-without-django

So it's really "where can celery run". Unix/Linux/MacOSX and probably Windows
servers where you have shell and the ability to kick off a celeryd daemon, sure.
I'd be less clear on strange setups where django itself or parts of
django can be coaxed into working for some value of working ("cloud" stuff,
jython...).

> or are there any other requirements or things to
> think about?

Well, the message queue and carrot (the binding to the message queue celery 
sits on top). 
The message queue is a service you will have to run. It's easier than it may 
sound 
if on on linux, since rabbitmq is probably in your distro repository. and celery
can be easy_installed, pulling in carrot.

("rabbit" probably explaining the rabbit-food naming theme...)

(Once you have the message queue and carrot available, you may also find them
useful in themselves for tieing stuff together
http://ask.github.com/carrot/introduction.html#examples )

Oh yeah, other thing:
If you're using python <2.6, you'll need to use the python multiprocessing
backport, and you currently have to watch out for an annoying bug - if you 
naively 
install what is still the current release, you'll 
get one with the bug, either use an earlier or patched version.
http://github.com/ask/celery/issues/closed/#issue/24
http://code.google.com/p/python-multiprocessing/issues/detail?id=18
(I wish they'd do another release...)
http://code.google.com/p/python-multiprocessing/issues/detail?id=21

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Logout and session

2009-12-21 Thread Victor Loureiro Lima
2009/12/21 David De La Harpe Golden 

> On Thu, Dec 17, 2009 at 03:54:02PM -0200, Victor Loureiro Lima wrote:
> > Okay, let me further explain my problem...
> >
> >  My website depends heavilly on the caching system, I'm using cache_page
> to
> > cache my view ( using memcached backend ),
> > however I have the "Hello, "  on top of every page when
> the
> > user is logged, thus I cant just cache everything.
>
> Well, there is (now) a mechanism in place for caching template fragments.
> So I suppose you could cache everything but the hello... I haven't tried to
> use
> caching in such fine-grained fashion though:
>
>
> http://docs.djangoproject.com/en/dev/topics/cache/#template-fragment-caching
>

Well, template caching invalidates view cache right? Plus, my understanding
of the template cache is that
it will hit my view, do all the DB stuff, but skip the template processing
which takes a while to finish, is my understanding right?


>
> > as a side note, I had to apply a patch to
> > django, in order for it to ignore certain cookie name regexp's
>
> Dirty, but if you're already mangling the django cache code to vary
> on a subset of cookies rather than the standardised behaviour of varying
> on all cookies (since it's really varying on the "Cookie" HTTP header), you
> could
> probably further mangle it to vary only on a custom cookie other than
> the django session cookie. I don't think this is a good approach, just
> saying.
>

Well, we use google analytics on all pages, and the analytics cookie changes
very often, for the same user,
thus it would generate another cache just because analytics cookie changed,
and thats not what I want, I want
one cache per session ID cookie, only... that why we followed that
approach... And I know that patching django
sucks a lot, but we couldnt live with the 5 requests/second that the
non-cached django app was doing under heavy load.



>
> >  That solved my problem, using @vary_on_cookie on my views, now I solved
> my
> > caching issues, however I noticed that whenever a user logs out, I
> recieve a
> > new sessionid, thus if the user log's in I will create a cache for him,
> > based on its session id. But when it logs off, instead of joining the
> other
> > clients that dont have the sessionid, it will become another "cached
> > instance", and I have to avoid that situation.
>
> How about clients that have a sessionid before login?

Clients that dont have the session ID will all hit the same cache.


> you may be assuming clients don't have a session cookie before they login?


Clients that never logged in will not have the session ID cookie. Clients
that have
logged in, will have the session ID cookie set for the web-browser session (
cookie is
set to exist while the browser is opened ).


> That may wind up true in your case I guess, but n.b. don't think
> that login creates sessions in general - it may "bless" an existing
> anonymous session with data in it into ownership by the logger-in (except
> when the existing
> session is already owned by someone logged in, then it is replaced for
> security).
>
>
> http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/__init__.py#L65
>
> This is a feature - consider user starting filling out a form anonymously,
> data
> being stashed in the session, then user logs in to authorise doing
> something (posting comment, say).
>

yes, in that case that would really be a problem... Maybe we could
circunvent using our navigation scheme
to avoid that scenario, but that would really be a bust in our designs...

In your opinion, what would be the correct approach? Cache the views objects
instead of the view it self, and cache
some of the templating? That would avoid the vary_on_cookie and would had a
more granular effect on the system.

Atenciosamente,
Victor Lima


> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: FeedMagnet: New Django-powered website just launched

2009-12-21 Thread pabloi
Great thanks for the response. I was wondering mostly cause we are
using Amazon infrastructure, which is by the way amazing, but is
always good to consider alternatives.

- Pablo

On Dec 17, 6:00 pm, Jason Ford  wrote:
> Thanks! My comparison of Django and Ruby on Rails was definitely more
> subjective than objective. Although I read several good articles that
> had more objective metrics to compare Ruby and Python speed, I did not
> run those kinds of tests myself. My approach was more about gathering
> the information that was already out there - both online and from
> professional contacts - parsing it, and formulating some high-level
> thoughts on the differences between the two so I could make a decision
> for our site. I can say that our Django implementation is
> significantly faster than the CakePHP prototype I had initially built.
> We attribute most of that to being able to easily run simultaneous
> threads in Python for pulling in content.
>
> Our infrastructure requirements are actually not that high right now.
> By using Python's built-in threading to gather content and CouchDB to
> quickly store and retrieve it, we're keeping resource requirements at
> a minimum. We do plan to upgrade to the cloud at some point, but for
> now we are on SliceHost, monitoring performance to determine when to
> upgrade.
>
> - Jason
>
> On Dec 17, 8:43 am, pabloi  wrote:
>
> > Hi Jason, the site looks very nice.
>
> > I also found your blog posting regarding Django vs Ruby very
> > interesting, if I may ask, did you make some metrics to determine how
> > faster Python can be over Ruby?
> > Also, this might be a lot to ask but ... what kind of infrastructure
> > do you use to support your site, I guess the site might required a lot
> > of resources to work.
>
> > Congrats on the launching!
>
> > - Pablo
>
> > On Dec 17, 12:10 pm, Jason Ford  wrote:
>
> > > Let's see. We started on the Django version in mid-October...so right
> > > at 2 months from first code until now. Luke had used Django on a few
> > > projects before this one, but the past two months have been my
> > > introduction to Django. I really like it - especially compared with
> > > some of the PHP frameworks I had dabbled in previously. Not only was
> > > it quicker to build in Django, but I feel like our code is much more
> > > maintainable too.
>
> > > - Jason
>
> > > On Dec 17, 2:21 am, OkaMthembo  wrote:
>
> > > > Look great, Jason. If i may ask, how long did it take from nought to 
> > > > finish?
>
> > > > Lloyd
>
> > > > On Thu, Dec 17, 2009 at 12:18 AM, Jason Ford  
> > > > wrote:
> > > > > We just launched the public beta of FeedMagnet a few minutes ago. It
> > > > > is a Django-powered web app that helps business harness social media.
> > > > > It is essentially an aggregator that pulls in content from multiple
> > > > > social networks and lets you do things with it - like putting the
> > > > > incoming content back up on your own website.
>
> > > > >http://www.feedmagnet.com
>
> > > > > Our experience using Django to build the site has been fantastic.
> > > > > We're also using CouchDB to store all of the updates and images as
> > > > > they come in from Twitter, Flickr, Delicious, RSS feeds, and other
> > > > > sources. We're planning to release our custom CouchDB/Python
> > > > > integration code as an open source module soon.
>
> > > > > Thanks to the Django community for the excellent framework,
> > > > > documentation, and user groups. We're glad to be a part of the
> > > > > community!
>
> > > > > - Jason
>
> > > > > --
>
> > > > > You received this message because you are subscribed to the Google 
> > > > > Groups
> > > > > "Django users" group.
> > > > > To post to this group, send email to django-us...@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > > > > django-users+unsubscr...@googlegroups.com > > > >  groups.com>
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/django-users?hl=en.
>
> > > > --
> > > > Regards,
> > > > Sithembewena Lloyd Dubehttp://www.lloyddube.com

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Logout and session

2009-12-21 Thread David De La Harpe Golden
On Thu, Dec 17, 2009 at 03:54:02PM -0200, Victor Loureiro Lima wrote:
> Okay, let me further explain my problem...
> 
>  My website depends heavilly on the caching system, I'm using cache_page to
> cache my view ( using memcached backend ),
> however I have the "Hello, "  on top of every page when the
> user is logged, thus I cant just cache everything.

Well, there is (now) a mechanism in place for caching template fragments. 
So I suppose you could cache everything but the hello... I haven't tried to use 
caching in such fine-grained fashion though:

http://docs.djangoproject.com/en/dev/topics/cache/#template-fragment-caching

> as a side note, I had to apply a patch to
> django, in order for it to ignore certain cookie name regexp's

Dirty, but if you're already mangling the django cache code to vary
on a subset of cookies rather than the standardised behaviour of varying
on all cookies (since it's really varying on the "Cookie" HTTP header), you 
could
probably further mangle it to vary only on a custom cookie other than
the django session cookie. I don't think this is a good approach, just saying.

>  That solved my problem, using @vary_on_cookie on my views, now I solved my
> caching issues, however I noticed that whenever a user logs out, I recieve a
> new sessionid, thus if the user log's in I will create a cache for him,
> based on its session id. But when it logs off, instead of joining the other
> clients that dont have the sessionid, it will become another "cached
> instance", and I have to avoid that situation.

How about clients that have a sessionid before login? you may be
assuming clients don't have a session cookie before they login? That
may wind up true in your case I guess, but n.b. don't think
that login creates sessions in general - it may "bless" an existing
anonymous session with data in it into ownership by the logger-in (except when 
the existing
session is already owned by someone logged in, then it is replaced for 
security).

http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/__init__.py#L65

This is a feature - consider user starting filling out a form anonymously, data
being stashed in the session, then user logs in to authorise doing
something (posting comment, say).

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: format date output in mail form

2009-12-21 Thread rvandam
@Guilherme Cavalcanti

I haven't thought of using a template for the mail. That will be my
next approach for this problem. Thank you for this.

For now I have this in my model:
  Aankomst = form.cleaned_data['Aankomst']
aankomst = str(Aankomst)
 message = aankomst + '\n' etc...
from django.core.mail import send_mail
send_mail(subject, message, sender,
recipients)
return render_to_response('thanks_nl.html', {
'message': message,
}, context_instance = RequestContext(request))

Which results in a mail with this date: 2010-07-30

The output in the template thanks_nl.html is 2010-07-30 too.

On 21 dec, 14:24, Guilherme Cavalcanti 
wrote:
> Take a look:
>
>                 template = get_template("email/notification.html")
>                 ctx = Context({'title': self.title, 'update_account_link': 
> "#",
> 'update_km_link': "#", 'date': datetime.now(), 'user':
> self.user_profile.user.username, 'text': self.text, 'aviseme_link':
> "#", 'media_url': settings.MEDIA_URL })
>
>                 rendered = template.render(ctx)
>
> On Dec 21, 10:22 am, Guilherme Cavalcanti 
> wrote:
>
> > Hello,
>
> > can you show how date is being printed? Maybe if you try to create an
> > "template" using {{ date|date:"j N \d\e Y" }} (or what else format you
> > want) and just call render passing an context with the datetime
> > object.
>
> > On Dec 21, 9:26 am, rvandam  wrote:
>
> > > I found some date formatting in forms/fields.py, forms/widgets.py and
> > > in contrib/localflavor/generic/forms.py. I tried if small
> > > modifications resulted in a different output, but nothing worked. I
> > > also tried to change the local setting in settings.py. Is there a way
> > > to modify the date ouptut format?
>
> > > On 18 dec, 11:21, rvandam  wrote:
>
> > > > I saw a solution on the list to format a datefield in a template.
> > > > Unfortunately i didnt find any solution for formatting a datefield in
> > > > a mailform. I have this in my model:
>
> > > >   Aankomst = forms.DateField(('%d/%m/%Y',), widget=forms.DateTimeInput
> > > > (format='%d/%m/%Y', attrs={
> > > >                         'class':'formVeld',
> > > >                         'readonly':'readonly',
> > > >                         'size':'8'
> > > >                         }), required=False)
>
> > > > This is a part of my view:
>
> > > >                         Aankomst = form.cleaned_data['Aankomst']
> > > >                         aankomst = str(Aankomst)
> > > >                         message = aankomst
>
> > > > The date output in my mail is:
>
> > > > 2010-07-30
>
> > > > I would like it to have it as: 03/07/2010 Is there a solution for 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-us...@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 you get recordcount?

2009-12-21 Thread Shawn Milochik
Add this line to that code:

print dir(tms)

I think you'll find a method of the recordset that will give you the count. I 
don't remember off of the top of my head. Why are you doing a direct SQL query 
instead of using a queryset from your model?

Shawn


--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 you get recordcount?

2009-12-21 Thread Jason Beaudoin
On Mon, Dec 21, 2009 at 9:02 AM, Bobby Roberts  wrote:
>    Looking at this code:
>
>    newsqlcmd="select title,author from booklist"
>    cursor=connection.cursor()
>    cursor.execute (newsqlcmd)
>    tms=cursor.fetchall()  #this is the actual recordset being pushed
> back to the template
>
>
>    how can I get the record count?  I could loop through and
> increment a counter but i know that is inefficient.

will the count() method work?
http://www.djangoproject.com/documentation/models/lookup/

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 do you get recordcount?

2009-12-21 Thread Bobby Roberts
Looking at this code:

newsqlcmd="select title,author from booklist"
cursor=connection.cursor()
cursor.execute (newsqlcmd)
tms=cursor.fetchall()  #this is the actual recordset being pushed
back to the template


how can I get the record count?  I could loop through and
increment a counter but i know that is inefficient.



--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: format date output in mail form

2009-12-21 Thread Guilherme Cavalcanti
Take a look:

template = get_template("email/notification.html")
ctx = Context({'title': self.title, 'update_account_link': "#",
'update_km_link': "#", 'date': datetime.now(), 'user':
self.user_profile.user.username, 'text': self.text, 'aviseme_link':
"#", 'media_url': settings.MEDIA_URL })

rendered = template.render(ctx)

On Dec 21, 10:22 am, Guilherme Cavalcanti 
wrote:
> Hello,
>
> can you show how date is being printed? Maybe if you try to create an
> "template" using {{ date|date:"j N \d\e Y" }} (or what else format you
> want) and just call render passing an context with the datetime
> object.
>
> On Dec 21, 9:26 am, rvandam  wrote:
>
>
>
> > I found some date formatting in forms/fields.py, forms/widgets.py and
> > in contrib/localflavor/generic/forms.py. I tried if small
> > modifications resulted in a different output, but nothing worked. I
> > also tried to change the local setting in settings.py. Is there a way
> > to modify the date ouptut format?
>
> > On 18 dec, 11:21, rvandam  wrote:
>
> > > I saw a solution on the list to format a datefield in a template.
> > > Unfortunately i didnt find any solution for formatting a datefield in
> > > a mailform. I have this in my model:
>
> > >   Aankomst = forms.DateField(('%d/%m/%Y',), widget=forms.DateTimeInput
> > > (format='%d/%m/%Y', attrs={
> > >                         'class':'formVeld',
> > >                         'readonly':'readonly',
> > >                         'size':'8'
> > >                         }), required=False)
>
> > > This is a part of my view:
>
> > >                         Aankomst = form.cleaned_data['Aankomst']
> > >                         aankomst = str(Aankomst)
> > >                         message = aankomst
>
> > > The date output in my mail is:
>
> > > 2010-07-30
>
> > > I would like it to have it as: 03/07/2010 Is there a solution for 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-us...@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: format date output in mail form

2009-12-21 Thread Guilherme Cavalcanti
Hello,

can you show how date is being printed? Maybe if you try to create an
"template" using {{ date|date:"j N \d\e Y" }} (or what else format you
want) and just call render passing an context with the datetime
object.

On Dec 21, 9:26 am, rvandam  wrote:
> I found some date formatting in forms/fields.py, forms/widgets.py and
> in contrib/localflavor/generic/forms.py. I tried if small
> modifications resulted in a different output, but nothing worked. I
> also tried to change the local setting in settings.py. Is there a way
> to modify the date ouptut format?
>
> On 18 dec, 11:21, rvandam  wrote:
>
>
>
> > I saw a solution on the list to format a datefield in a template.
> > Unfortunately i didnt find any solution for formatting a datefield in
> > a mailform. I have this in my model:
>
> >   Aankomst = forms.DateField(('%d/%m/%Y',), widget=forms.DateTimeInput
> > (format='%d/%m/%Y', attrs={
> >                         'class':'formVeld',
> >                         'readonly':'readonly',
> >                         'size':'8'
> >                         }), required=False)
>
> > This is a part of my view:
>
> >                         Aankomst = form.cleaned_data['Aankomst']
> >                         aankomst = str(Aankomst)
> >                         message = aankomst
>
> > The date output in my mail is:
>
> > 2010-07-30
>
> > I would like it to have it as: 03/07/2010 Is there a solution for 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-us...@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.




Overhead of using django.contrib.markup vs. pre-rendered HTML field

2009-12-21 Thread Jesaja Everling
Hi All!

I'm wondering how expensive it is in terms of processing power to use
the django.contrib.markup filters for displaying blog posts instead of
storing pre-rendered HTML in a db field.
The Pinax blog application makes use of these markup-filters to render
HTML on the fly, for example. I assume that especially with caching
enabled this won't pose a problem, but it still might be advisable to
store pre-rendered HTML once a new blog-post is saved.
Does the reStructuredText filter introduce noticeable overhead or is
it negligible?

Best Regards,

Jesaja Everling

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: format date output in mail form

2009-12-21 Thread rvandam
I found some date formatting in forms/fields.py, forms/widgets.py and
in contrib/localflavor/generic/forms.py. I tried if small
modifications resulted in a different output, but nothing worked. I
also tried to change the local setting in settings.py. Is there a way
to modify the date ouptut format?

On 18 dec, 11:21, rvandam  wrote:
> I saw a solution on the list to format a datefield in a template.
> Unfortunately i didnt find any solution for formatting a datefield in
> a mailform. I have this in my model:
>
>   Aankomst = forms.DateField(('%d/%m/%Y',), widget=forms.DateTimeInput
> (format='%d/%m/%Y', attrs={
>                         'class':'formVeld',
>                         'readonly':'readonly',
>                         'size':'8'
>                         }), required=False)
>
> This is a part of my view:
>
>                         Aankomst = form.cleaned_data['Aankomst']
>                         aankomst = str(Aankomst)
>                         message = aankomst
>
> The date output in my mail is:
>
> 2010-07-30
>
> I would like it to have it as: 03/07/2010 Is there a solution for 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-us...@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.




ckfinder with django

2009-12-21 Thread Alessandro Ronchi
Has someone managed to use ckfinder with django ? I want only staff
users of my apps to be able to upload files, is it possible?

-- 
Alessandro Ronchi

http://www.soasi.com
SOASI - Sviluppo Software e Sistemi Open Source

http://hobbygiochi.com
Hobby & Giochi, l'e-commerce del divertimento

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: pass to a template many querysets

2009-12-21 Thread rebus_
2009/12/21 Francesco Benincasa :
> Hi all,
> I need to pass to a template more than one list of diffent models objects.
>
> Now I'm using a date_based.archive_index but I can pass it only a queryset as
> argument, isn't it?
>
> What's the correct approach? To try to pass in a same queryset all objects I
> need (and in this case, how?) or I can also pass two or three different
> querysets?
>
> Thank you very much.
>


extra_context: A dictionary of values to add to the template context.
By default, this is an empty dictionary. If a value in the dictionary
is callable, the generic view will call it just before rendering the
template.


http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-date-based-archive-index

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Enable users to input formatted text

2009-12-21 Thread BobAalsma
Umm, I think you would then also invite/enable hackers to upload
unwanted thingies, such as viruses and scripts...

On Dec 21, 8:12 am, Continuation  wrote:
> I have a TextField() field that stores user entered text. However the
> formatting is a bit weird, eg. new lines are lost when displaying that
> field.
>
> What is the best way to retain that formatting and also enable users
> to format their inputs with either HTML tags or some rich text editors?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




pass to a template many querysets

2009-12-21 Thread Francesco Benincasa
Hi all,
I need to pass to a template more than one list of diffent models objects.

Now I'm using a date_based.archive_index but I can pass it only a queryset as
argument, isn't it?

What's the correct approach? To try to pass in a same queryset all objects I
need (and in this case, how?) or I can also pass two or three different
querysets?

Thank you very much.

-- 
| Francesco Benincasa - http://ciccio2000.altervista.org/
| EcoSCIENZE Societa' Cooperativa - http://www.ecoscienze.org/
| Ingegneria Senza Frontiere Bologna - http://isf.ing.unibo.it/
| Bologna Free Software Forum - http://www.bfsf.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-us...@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.




Binary Post Data to ImageField

2009-12-21 Thread Markus T.
Hi,

I'm trying to save binary POST data to an ImageFile field - so far
with no satisfying success.

I can't seem to convince the client (Flex based image editor) to send
binary data as correct "multipart/form-data"; I only have the option
to send as raw binary data or with POST variables.

My view function happily receives the binary data, and it looks ok. As
far as I understand things, if the uploaded data was sent correctly as
multipart-form-data, Django would create an InMemoryUploadFile object
and pass it in request.FILES. I could use this code to save the image
then:

model_instance.image.save("%s.jpg" % img_id, request.FILES
['user_img'], True)

What sensible approach could I use to update/save the image with
binary POST data? I do not want to create a temporary file, though.

I just don't seem to have enough in-depth Django knowledge to find a
satisfying solution...

Thanks!

Markus

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




passing additional parameters to custom form fields

2009-12-21 Thread druzhinin
hi folks,

I am trying to create a custom form field, that is based on
MultipleChoicefield.  it populates itself from database and displays a
nice multi-checkbox table for multiple photos selection for adding
them to  article... I've run into problems when trying to process
'initial' inside __init__:

class PhotoChoiceField(MultipleChoiceField):
"""
Photo selection field, that populates itself
with photos from selected gallery on init
"""
widget = PhotoSelectWidget

def __init__(self,  photosize, required=True, widget=None,
label=None,
 initial=None, help_text=None, *args, **kwargs):
 self.photosize = photosize

super(PhotoChoiceField, self).__init__(choices=(),
required=required,
widget=widget, label=label, initial=initial,
help_text=help_text,
*args, **kwargs)
...
  self.gallery=Gallery.objects.get(pk=initial)
...


Form class has 'initial' attribute set:
class AttachForm(forms.Form):
sel_photos = PhotoChoiceField(label = _('Select photos from the
gallery'),
  photosize = _('admin_thumbnail')

form = AttachForm(initial={sel_photos':request.GET.get('album')})

But it seems that i cannot get 'initial' set at Form level processed
at Field level. It is always None.

I need to pass some aadditional arguments to fields when creating form
instance, can somebody give me a hint on how to do that?

Fedor

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Operate with Postgresql from Django views.

2009-12-21 Thread NMarcu
Hello,

   I have a problem, or I don't know how is working.

I want to do an operation to a table, on Postgresql database. By
example: I want to add new data in a table. I do it like this:
ob_device = Device(id=device_address)
ob_device.save()

Everything is OK, if the view is finished, but if after this line I
add an infinite loop, and in this time I check that table from console
for the new record, that is not there. I do this exercise, because I
have a daemon that works with my table. When I add from views some
data in a table, the daemon update another table, depend of my data.
But the problem is that I need to access that update in the same
views. I set a flag to wait the daemon to do his job, but that is not
set...means daemon, wait the view to be completed, or something like
this. What is the problem? Hope I was clear with explanation.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.