Re: accessing user info in templates

2006-02-20 Thread Max Battcher

char wrote:
> Thanks! I'm still curious though. Why wouldn't user.user work?

It is a "magic" issue.  Basically the user field prior to magic-removal 
is simply the metadata container and the get_FOO stuff is auto-generated 
function to actually get the real data.  Magic-Removal changes things 
up, of course, check out the Descriptor stuff.

-- 
--Max Battcher--
http://www.worldmaker.net/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: accessing user info in templates

2006-02-20 Thread char

Thanks! I'm still curious though. Why wouldn't user.user work?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: accessing user info in templates

2006-02-20 Thread Maniac

char wrote:

>{% for user in object_list %}
>  {{ user.user.first_name
>}}
>{% endfor %}
>  
>
Use "user.get_user" instead of "user.user". This is the same method that 
you use in your __repr__ just without parentheses (they aren't needed in 
the template syntax).

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



accessing user info in templates

2006-02-20 Thread char

Hi.

I have an "expanded" user definition that wraps auth.user, like so:

...

class MetroUser(meta.Model):
user = meta.ForeignKey(User, edit_inline=meta.STACKED,
num_in_admin=1, max_num_in_admin=1)
notes = meta.TextField()

def __repr__(self):
return self.get_user().__repr__()

...


I try to access the nested auth.User information in my template like
so:

...

{% for user in object_list %}
  {{ user.user.first_name
}}
{% endfor %}

...


but it doesn't work. If I replace user.user.first_name with user.notes
it works, so it's just a problem with the nested auth.User information.
I know the nested user is there, I just can't seem to access it from
the template. Anyone able to help me out here?

Thanks

Charlie


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: urllib2.open failing in Django?

2006-02-20 Thread Malcolm Tredinnick

Jakub Labath wrote:
> Hi,
>
> I believe as soon as you call socket.setdefaultimeout it also changes
> certain behavior for ALL sockets in general (blocking non blocking
> etc) plus obviously the timeout.
> That is in my opinion pure evil(TM) because surely database drivers,
> connection handlers, logging tools and god knows what will never have
> the same expectations as to how the sockets should behave.
> I didn't find a way to set a timeout for a specific connection when
> using urllib, urllib2 or even httplib - in python 2.3.
> So I ended up using raw sockets :-( because then it is possible to set
> a custom timeout without changing behaviour of all the other sockets.
>
> BTW If anybody knows a better way to do this I would not mind learning
> a trick or two :-), because reimplementing HTTP 1.0 GET request was a
> breeze, but if I had to re-implement https with authentication I'd be
> one unhappy coder.

Getting a bit away from Django here, but still...

Because urllib2 is highly modular, fixing this problem is not entirely
as painful as it seems. The actual connection stuff is done by
httplib.HTTPConnection and httplib.HTTPSConnection (you can trace it
through from urllib2.HTTP(S)Handler

So you need to override the connect() methods in those classes to call
self.sock.set_timeout() after creating the socket. I have done this in
the past in various pieces of production code that needed fairly
fine-grained control.

There is either a patch in Python (for the future) or still being
reviewed to fix this generically, too. See this thread on python-devel:
http://mail.python.org/pipermail/python-dev/2005-December/058996.html

Cheers,
Malcolm


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: urllib2.open failing in Django?

2006-02-20 Thread Jakub Labath

Hi,

I believe as soon as you call socket.setdefaultimeout it also changes
certain behavior for ALL sockets in general (blocking non blocking
etc) plus obviously the timeout.
That is in my opinion pure evil(TM) because surely database drivers,
connection handlers, logging tools and god knows what will never have
the same expectations as to how the sockets should behave.
I didn't find a way to set a timeout for a specific connection when
using urllib, urllib2 or even httplib - in python 2.3.
So I ended up using raw sockets :-( because then it is possible to set
a custom timeout without changing behaviour of all the other sockets.

BTW If anybody knows a better way to do this I would not mind learning
a trick or two :-), because reimplementing HTTP 1.0 GET request was a
breeze, but if I had to re-implement https with authentication I'd be
one unhappy coder.

Jakub


On 2/20/06, Ned Batchelder <[EMAIL PROTECTED]> wrote:
>
> The value was 20 (the unit is seconds).  With the function call
> removed, the calls completed successfully in much less time than 20
> seconds, on the order of 1 second, so I don't thing the timeout was
> actually kicking in.
>
> --Ned.
>
>
>
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Comments broken in magic-removal?

2006-02-20 Thread Malcolm Tredinnick

Andrew Gwozdziewycz wrote:
> Hello,
>
> I'm trying to use the contrib.comments in the magic-removal branch.
> I'm running into some problems though...
>
>   {% get_free_comment_list for excuses.topic topic.id as
> comment_list %}
>
> Is the part that is failing. This was adapted from the
> djangoproject.com website, as it was the only example
> I could find in using it. However, the tokens after the "for" seem to
> be wrong, as get_object fails.
[...snip...]

If this is the problem you are seeing, then the code has not been
updated for the magic-removal branch. the get_object() call on
instances has been replaced by ModelClass.objects.get(...) in
magic-removal.

See the table in
http://code.djangoproject.com/wiki/RemovingTheMagic#Descriptorfields
for any other mapping problems you might come across and want to fix.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Comments broken in magic-removal?

2006-02-20 Thread Andrew Gwozdziewycz

Hello,

I'm trying to use the contrib.comments in the magic-removal branch.  
I'm running into some problems though...

  {% get_free_comment_list for excuses.topic topic.id as  
comment_list %}

Is the part that is failing. This was adapted from the  
djangoproject.com website, as it was the only example
I could find in using it. However, the tokens after the "for" seem to  
be wrong, as get_object fails. Magic-removal
gets rid of the pluralization for models, hence my attempt at  
excuses.topic rather than excuses.topics. The app
name is excuses, and I'm trying to get comments for a particular  
Topic. Any suggestions?




---
Andrew Gwozdziewycz
[EMAIL PROTECTED]
http://ihadagreatview.org
http://and.rovir.us



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: adding page

2006-02-20 Thread kmh

Mary Adel wrote:
> I have anither questions on the flatepage
> Does the flat page need any configuration for the url.py file or no
> cause i made a faltepage but it didn't appear in the browser so i really
> don't know the steps to make it appear in the browser

If you've added:

django.contrib.flatpages.middleware.FlatpageFallbackMiddleware

to your middleware list as in the documentation then that is all you
need.  There is no URL hook because flatpages work as middleware by
catching 404 responses and seeing if there is a corresponding flatpage
and serving that instead.  It's been a while since I used them but I
think you need to make sure you have a trailing slash on the URL in the
admin.

If you are running Django from SVN then there is a chance that you are
seeing the bug that Tom caught in #1376.  It is now fixed so just do
svn update

Kieran


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: adding page

2006-02-20 Thread Mary Adel

I have anither questions on the flatepage 
Does the flat page need any configuration for the url.py file or no
cause i made a faltepage but it didn't appear in the browser so i really
don't know the steps to make it appear in the browser

Thanks,
Mary


On Mon, 2006-02-20 at 14:03 -0500, Tom Tobin wrote:
> On 2/20/06, Mary Adel <[EMAIL PROTECTED]> 
> wrote:http://www.djangoproject.com/documentation/model_api/flat
> >
> > I have a question and i have deadline tomm :( and really i need help
> > I build a model called pages which has page name and page link and page
> > content and then i build the database and i make the admin interface to
> > fill all the data but the problem is that:
> > I need to add page dynamically without adding by hands in the url.py
> > file any lines and then add a function in the view.py file
> 
> For a start, have you taken a look at the flatpages module?  Your need
> sounds fairly close to what flatpages does, as far as I can tell.
> 
> http://www.djangoproject.com/documentation/flatpages/
> 
> 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: only show something(form) if javascript-enabled

2006-02-20 Thread Lachlan Cannon

gabor wrote:
> hi,
> 
> what is the standard way to only show a form if the user has 
> javascript-enabled?

You could have the form in the page, and have it set to display: none; which is 
undone with js. Of course if someone has css disabled they'll see it...
-- 
Lach
Personal: http://illuminosity.net/
Business: http://taravar.com/




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: django problem at dreamhost

2006-02-20 Thread Lachlan Cannon

I've been having 500 errors at Dreamhost too. The week before last I finished 
my 
site, had it up and running and everything was fine. Then checked it on the 
next 
Monday, and having not changed anything I was getting 
 this mess. Dreamhost say they haven't changed 
anything on the server... I've tried redownloading django fresh from svn and 
that hasn't cleared it up. Has anyone else had a problem like this?

Thanks.
-- 
Lach
Personal: http://illuminosity.net/
Business: http://taravar.com/




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Web Services

2006-02-20 Thread [EMAIL PROTECTED]

I wonder what will come out out http://code.djangoproject.com/ticket/115


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: only show something(form) if javascript-enabled

2006-02-20 Thread Amit Upadhyay
On 2/21/06, gabor <[EMAIL PROTECTED]> wrote:
what is the standard way to only show a form if the user has_javascript_-enabled?Use id="integrity_form" style="display:none" in the form, and then document.getElementById("integrity_form").style.display = "block", ofcourse this won't happen unless _javascript_ is enabled.
-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---



Re: only show something(form) if javascript-enabled

2006-02-20 Thread Jason Huggins

gabor wrote:
> so is there a way to only show some part of the webpage (or the whole
> webpage) if javascript is enabled?

Use javascript to build up the form and its visual elements on
pageload. A user without Javascript enabled would see a blank page. :-)


-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-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: only show something(form) if javascript-enabled

2006-02-20 Thread Graham King

  You could make the form invisible using css:

#theFormId {
   display: none;
}

  then use Javascript to change this to display = block. If they don't 
have Javascript the form won't appear.

  Or you could use Javascript to write the form out, as in:

document.write('
'); but the CSS version is much cleaner. And yes, you should also make sure you check the data on the server side, otherwise something nasty is bound to happen. Best regards, Graham. gabor wrote: > hi, > > what is the standard way to only show a form if the user has > javascript-enabled? > > i have a form which's "integrity" relies on some javascript stuff, > so i really don't want the user to submit it with javascript-disabled. > > so is there a way to only show some part of the webpage (or the whole > webpage) if javascript is enabled? > > i know about but i need the opposite :) > > > p.s: for all who want to send me a reply that i shouldn't rely on client >side validation. i know :) > > gabor > > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---

only show something(form) if javascript-enabled

2006-02-20 Thread gabor

hi,

what is the standard way to only show a form if the user has 
javascript-enabled?

i have a form which's "integrity" relies on some javascript stuff,
so i really don't want the user to submit it with javascript-disabled.

so is there a way to only show some part of the webpage (or the whole 
webpage) if javascript is enabled?

i know about  but i need the opposite :)


p.s: for all who want to send me a reply that i shouldn't rely on client 
   side validation. i know :)

gabor

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: using the devel-webserver for production?

2006-02-20 Thread gabor

Jacob Kaplan-Moss wrote:
> On Feb 20, 2006, at 3:28 PM, gabor wrote:
>> 1. except that it was not meant for that, are there any fundamental
>> problems with the "runserver"-webserver?
> 
> Using runserver in production is like driving your car on a spare  
> tire.  It'll work, but when it blows up in your face someone's going  
> to get hurt.
> 
> Seriously, here's just a few reasons you shouldn't use it in production:
> 
> * the dev server can only handle one request at a time (no concurrency)
> * since it handles everything in Python including the low-level  
> transport, it'll be very slow compared to a real server
> * it's likely got all sorts of security holes since NOBODY uses it  
> for public sites
> * all the cool kids will laugh at you.
> 
> There's no reason you can't use Apache2 on RedHat8; just built it  
> yourself (which is not nearly as hard as it sounds; a standard  
> configure/make/make install dance does it fine).  Or take a look at  
> lighttpd+fcgi.
> 
> Trust me -- you think you'll be happy using the dev server now, but  
> something serious will go wrong and you'll end up installing a real  
> production environment anyway.  Do it now and save yourself the  
> heartache.
> 
:)

ok, thanks for the help.

i'll set up something "serious" then there. i think i'll go with the 
lighttpd+fcgi approach.


gabor

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: using the devel-webserver for production?

2006-02-20 Thread Jacob Kaplan-Moss

On Feb 20, 2006, at 3:28 PM, gabor wrote:
> 1. except that it was not meant for that, are there any fundamental
> problems with the "runserver"-webserver?

Using runserver in production is like driving your car on a spare  
tire.  It'll work, but when it blows up in your face someone's going  
to get hurt.

Seriously, here's just a few reasons you shouldn't use it in production:

* the dev server can only handle one request at a time (no concurrency)
* since it handles everything in Python including the low-level  
transport, it'll be very slow compared to a real server
* it's likely got all sorts of security holes since NOBODY uses it  
for public sites
* all the cool kids will laugh at you.

There's no reason you can't use Apache2 on RedHat8; just built it  
yourself (which is not nearly as hard as it sounds; a standard  
configure/make/make install dance does it fine).  Or take a look at  
lighttpd+fcgi.

Trust me -- you think you'll be happy using the dev server now, but  
something serious will go wrong and you'll end up installing a real  
production environment anyway.  Do it now and save yourself the  
heartache.

Jacob

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



using the devel-webserver for production?

2006-02-20 Thread gabor

hi,

i know, i know. the webserver that's started with the "manage.py runserver",

is not meant for production usage.

but this is my situation:

1. the system will be used by very few people. i assume at most 10 
accounts, and at most 3-4 users working with it at the same time.

2. the program will mostly use only the admin-part. it will be used to 
feed data into the database (the data is displayed by a different program).
3. i have to make this work on a redhat8 system, where i have only 
apache1.3 (so no apache2+mod_python). so my plan is to have apache proxy 
the requests into the internal "runserver"-webserver. (so that the media 
files can be server by the apachec1.3)


questions:

1. except that it was not meant for that, are there any fundamental 
problems with the "runserver"-webserver?

2. any other ideas? maybe try to compile lighttpd, and then try a 
fastcgi setup?


i'd like to keep the config as simple as possible for now.

thanks,
gabor

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: adding page

2006-02-20 Thread Mary Adel

Thanks i ll have a look on it now and i ll see how it will help me 

On Mon, 2006-02-20 at 18:21 +0100, Sime Ramov wrote:
> On Feb 20, 2006, at 8:11 AM, Mary Adel wrote:
> > 
> 
> http://www.djangoproject.com/documentation/flatpages/
> 
> 
> 


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: two object returned for exact pk lookup

2006-02-20 Thread Amit Upadhyay
On 2/15/06, Maniac <[EMAIL PROTECTED]> wrote:
If it's MySQL then it looks very much like threading issues (withPostgres it fails somewhat differently). There is a patch fixing it inhttp://code.djangoproject.com/ticket/463
Hi Maniac,Thanks for the pointer, I applied the patch and my application has been running without those scary mails since last 6-8 hours. Adrian, what is the stutus on that bug, can you please apply it to trunk?
-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---



Re: urllib2.open failing in Django?

2006-02-20 Thread Ned Batchelder

The value was 20 (the unit is seconds).  With the function call
removed, the calls completed successfully in much less time than 20
seconds, on the order of 1 second, so I don't thing the timeout was
actually kicking in.

--Ned.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: adding page

2006-02-20 Thread Tom Tobin
On 2/20/06, Mary Adel <[EMAIL PROTECTED]> wrote:
>
> I have a question and i have deadline tomm :( and really i need help
> I build a model called pages which has page name and page link and page
> content and then i build the database and i make the admin interface to
> fill all the data but the problem is that:
> I need to add page dynamically without adding by hands in the url.py
> file any lines and then add a function in the view.py file

For a start, have you taken a look at the flatpages module?  Your need
sounds fairly close to what flatpages does, as far as I can tell.

http://www.djangoproject.com/documentation/flatpages/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Django Development Position Available

2006-02-20 Thread Allan

AirSage Inc. is seeking energetic Web Application Developers to expand
and enhance the company's unique product offering.  AirSage creates
software that allows road traffic speeds and other information to be
determined from cellular network signalling data.

The qualified candidate will possess all or most of the following
characteristics:

--*-- Experience and significant comfort level working in a UNIX or
Linux environment.

--*-- Basic knowledge of networking and system administration.

--*-- (optional) Telecommunications Industry experience, or experience
working with Federal, State, and Municipal Transportation departments.

--*-- Three years of experience developing non-trivial web applications

--*-- Working knowledge of relational databases

--*-- Apache deployment experience

--*-- Proficiency in JavaScript

--*-- Experience in Django, TurboGears, and/or AJAX

--*-- Experience developing graphics-intensive web applications
(interactive maps, real-time displays, etc.).

--*-- Evidence that completed web applications were successfully
adopted by the customers or marketplace

--*-- Fluency in English

--*-- Excellent written communications skills in English

--*-- A driven, goal-oriented personality, and a willingness to take on
administrative, documentation, testing, or analysis tasks when
necessary

--*-- An ability to work independently, yet sill provide regular and
insightful communication to upper management

Qualified candidates should send their resume as an email attachment to
[EMAIL PROTECTED]  Include your salary history and highlights of
particularly relevant experience in the body of the email.

AirSage has offices in Atlanta, Montreal, and in Vina del Mar, Chile.
Please do not apply if you are not comfortable working in a fast-paced,
entrepreneurial environment.  AirSage is an equal-opportunity employer.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: urllib2.open failing in Django?

2006-02-20 Thread Tom Tobin
On 2/20/06, Ned Batchelder <[EMAIL PROTECTED]> wrote:
>
> I found the problem on my end.  It was a call to
> socket.setdefaulttimeout().  The bug I had found but can't locate now
> was correct: if you call that socket function, urllib2 (and httplib)
> have very difficult times completing reads.

Was the value you passed in through setdefaulttimeout() particularly
small, by any chance?

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Creating a menu structure

2006-02-20 Thread akaihola

I've hit the same challenge. I'd like to maintain a list of nested
categories with the admin interface.

Any news on this?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: adding page

2006-02-20 Thread Sime Ramov

On Feb 20, 2006, at 8:11 AM, Mary Adel wrote:
> 

http://www.djangoproject.com/documentation/flatpages/

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



adding page

2006-02-20 Thread Mary Adel

I have a question and i have deadline tomm :( and really i need help
I build a model called pages which has page name and page link and page
content and then i build the database and i make the admin interface to
fill all the data but the problem is that:
I need to add page dynamically without adding by hands in the url.py
file any lines and then add a function in the view.py file

I mean to make adding page dynamically so as the client can add page
without any need to the developer

I don't know if it is easy or not but please help 


Thanks
Mary
   


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Template Does Not exist Error

2006-02-20 Thread [EMAIL PROTECTED]

Thanks Mate!


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Template Does Not exist Error

2006-02-20 Thread Amit Upadhyay
On 2/20/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hi all,I'm using { % extends "parent" % } and I'm getting a "...template doesnot exist error" for the parent template.I have the two templates in the same directory and they are in a
subfolder of my template directory.Use {% extends "subfolder/parent" %} if they are in a subfolder of templates directory. -- Amit UpadhyayBlog: 
http://www.rootshell.be/~upadhyay+91-9867-359-701
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---



do_html2python and errors.

2006-02-20 Thread Felix Ingram

All,

I'm a bit stumped.  Being a good little developer I'm following the
guidelines for the new admin changes
(http://code.djangoproject.com/wiki/NewAdminChanges) and calling
'do_html2python' regardless of whether there are any errors from the
user.

This clears up one problem I was having where 'render' was getting
passed different lists depending on whether we're adding or changing
the model.

The new problem is when errors are present.  Trying to convert bad
data fails (as is expected) but now I cannot convert the data which
reintroduces the problem of what to pass to render.

I feel that i'm missing the 'neat' way to do this.  I've explained
what I'm trying to achieve on the wiki
(http://code.djangoproject.com/wiki/CustomFormFields) incase anyone
wants more detail.

Any ideas/pointers?

F.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: urllib2.open failing in Django?

2006-02-20 Thread Ned Batchelder

I found the problem on my end.  It was a call to
socket.setdefaulttimeout().  The bug I had found but can't locate now
was correct: if you call that socket function, urllib2 (and httplib)
have very difficult times completing reads.

I took out my call to setdefaulttimeout, and now it works great.
Django is vindicated.

--Ned.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Template Does Not exist Error

2006-02-20 Thread [EMAIL PROTECTED]

Hi all,

I'm using { % extends "parent" % } and I'm getting a "...template does
not exist error" for the parent template.

I have the two templates in the same directory and they are in a
subfolder of my template directory.

Has enyone had or solved this problem?

I saw that someone else on this forum had the same problem but there
was no solution?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: urllib2.open failing in Django?

2006-02-20 Thread Amit Upadhyay
On 2/20/06, Ned Batchelder <[EMAIL PROTECTED]> wrote:
I have some code in a Django view that makes a request on anotherserver.  It uses urllib2 to make an SSL connection to the server andrequest a page.  Here's the code:I dont know about https, but I am doing a lot of fetching page over http, and parsing html in my django application, and its working like a charm.
-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---



urllib2.open failing in Django?

2006-02-20 Thread Ned Batchelder

I have some code in a Django view that makes a request on another
server.  It uses urllib2 to make an SSL connection to the server and
request a page.  Here's the code:

authb64 = ('%s:%s' % (username, password)).encode('base64').strip()
req = urllib2.Request('https://'+url)
req.add_header("Authorization", "Basic " + authb64)
page = urllib2.urlopen(req)
data = page.read()

When I run this in Django, I usually (but not always!) get an
exception: 
from the urlopen call.  Occasionally, it will work and return the data
properly.

This exact same code run in a standalone script succeeds 100% of the
time, even when called repeatedly in a tight loop.

I'm using Python 2.4.1.  My earlier researches into this problem found
a recurring bug in Python having to do with socket.settimeout or
something.  Does this ring any bells?

--Ned.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Manipulator and views problem, where to save object ?

2006-02-20 Thread Amit Upadhyay
On 2/20/06, coulix <[EMAIL PROTECTED]> wrote:
Seems like i was just unlucky in the number 5 - 6 - 8if i use a field which appears in my model with,null = Trueit seems like the validator is not eve called, is it a feature ?That may be the case, I have not tried it with null=True as yet so cant say anything. 
otherwise when its called i get an error :isFoo() takes exactly 3 arguments (2 given)
Exception Location:/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/formfields.pyin get_validation_errors, line 70Remove 'self' from function definition.
-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay+91-9867-359-701
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---



Re: Can't change '[algo]$[salt]$[hexdigest]' passwords!!!

2006-02-20 Thread limodou

On 2/20/06, Ben Vinger <[EMAIL PROTECTED]> wrote:
>
> Hello
>
> When I create users in the admin site, I have the
> following problem:
>
> Newly created user cannot log using the password I've
> just assigned them.
>
> What does "Use '[algo]$[salt]$[hexdigest]'" mean?

algo is arithmetic, may be md5 or sha1. salt is a random number used
in creating digest password. hexdigest is a digest string created by
md5 or sha1.

The easy appoach to create a new password is just like:

 >>> import md5
 >>> md5.new('test').hexdigest()
 '098f6bcd4621d373cade4e832627b4f6'

And "test" is exactly the new password. And the first time, you could
use md5 to create a new password, and don't need according to the
format given above. And if you login successfully the first time,
django will auto change the password to sha1 arthmetic and store the
password just like the format.

Hope this will be helpful.
>
> Running Django-0.91, postgresql-8.1.2, apache_2.0.55,
> Python  2.4.2 on Windows 2000
>
> Thanks
> Ben

--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Can't change '[algo]$[salt]$[hexdigest]' passwords!!!

2006-02-20 Thread Ben Vinger

Hello

When I create users in the admin site, I have the
following problem:

Newly created user cannot log using the password I've
just assigned them.

What does "Use '[algo]$[salt]$[hexdigest]'" mean?

Running Django-0.91, postgresql-8.1.2, apache_2.0.55,
Python  2.4.2 on Windows 2000

Thanks
Ben



___ 
To help you stay safe and secure online, we've developed the all new Yahoo! 
Security Centre. http://uk.security.yahoo.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Manipulator and views problem, where to save object ?

2006-02-20 Thread coulix

Seems like i was just unlucky in the number 5 - 6 - 8
if i use a field which appears in my model with
,null = True
it seems like the validator is not eve called, is it a feature ?

otherwise when its called i get an error :
isFoo() takes exactly 3 arguments (2 given)
Exception Location:

/usr/lib/python2.4/site-packages/Django-0.91-py2.4.egg/django/core/formfields.py
in get_validation_errors, line 70

even closer.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Manipulator and views problem, where to save object ?

2006-02-20 Thread coulix

Oh true,
didnt get the 500 error howerver no way to raise the error
isValideImageWeight.
all the test get added, when i check in the admin view the field
"image" is empty.

Is there a way to see what value does all fields have before being
inserted to the db, looks like image is empty...

my model :
[...]
image = meta.ImageField(upload_to='img', help_text=_('Photot du plat
fini') , blank=True, null = True)
[...]

the template :
[...]
Photo du plat fini:
{{form.image_file}}{{ form.image }}   (100*100
pixels)
[...]

the view.py
[...]
#Validator
def isValideImageWeight(self, field_data, all_data):
print field_data
if len(field_data["content"]) > 100:
raise validators.ValidationError, "file too big !"

#Ajouter
def create_recette(request):
manipulator = recettes.AddManipulator()
#12 being image_fil , recettes.AddManipulator().fields
manipulator.fields[12].validator_list.append(isValideImageWeight)
manipulator.fields[11].validator_list.append(isValideImageWeight)
[...]


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Manipulator and views problem, where to save object ?

2006-02-20 Thread Amit Upadhyay
On 2/20/06, coulix <[EMAIL PROTECTED]> wrote:
Hum i cant spot the type expect the 500 as comments ?On 2/20/06, coulix <
[EMAIL PROTECTED]> wrote:
#Validatordef isValideImageWeight(self, field_data, all_data):print field_dataif len(field_data["content"] > 10

) : # 500,000 bytes (100kB)raise validators.ValidationError, "Le fichier ne dois pas depasser100kb"In your isValideImageWeight, you have used  
if len(field_data["content"] > 10
):You will get a 500 internal error as len on boolean gives TypeError. What you want is:
if len(field_data["content"]) > 10: 
Best wishes,-- Amit UpadhyayBlog: http://www.rootshell.be/~upadhyay
+91-9867-359-701
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---



Re: Manipulator and views problem, where to save object ?

2006-02-20 Thread coulix

Hum i cant spot the type expect the 500 as comments ?


i took off the line "from manipulators import RecetteManipulator" line
since i dont need  it anymore, it still doesnt raise the expected erro
when the file is more than 100kb. hum maybe its somwthing to do with
the form template

print recettes.AddManipulator().fields
[FormField "nom", FormField "categorie", FormField "auteur", FormField
"ingredients", FormField "etapes", FormField "conseils", FormField
"dure", FormField "difficulte", FormField "quantite", FormField "prix",
FormField "pub_date", FormField "image_file", FormField "image"]

I thought it may come from the template :



Details 
{% if form.nom.errors %}*** {{ form.nom.errors|join:", " }}{% 
endif
%}
Nom de la recette: * {{form.nom}} 
Auteur: * {{form.auteur}}
Categorie: * {{form.categorie}}
Dure (min):  {{form.dure}}
Quantite:  
{{form.quantite}}
Difficulte: * {{form.difficulte}}
Prix (cfp):  {{form.prix}}
Photo du plat fini:
{{form.image_file}}{{ form.image }}   (100*100
pixels)




Contenant
Ingredients: *
Nom de l'ingredient suivi de son poid, quantite, ou
volume.{{form.ingredients}}
Etapes: * {{form.etapes}}
Conseils et astuces: 
{{form.conseils}}





so close.


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Manipulator and views problem, where to save object ?

2006-02-20 Thread Amit Upadhyay
On 2/20/06, coulix <[EMAIL PROTECTED]> wrote:
#Validatordef isValideImageWeight(self, field_data, all_data):print field_dataif len(field_data["content"] > 10
) : # 500,000 bytes (100kB)raise validators.ValidationError, "Le fichier ne dois pas depasser100kb"Typo? -- Amit UpadhyayBlog: 
http://www.rootshell.be/~upadhyay+91-9867-359-701
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---



Re: Manipulator and views problem, where to save object ?

2006-02-20 Thread coulix

Thank you  !! i was overdoing it ! 2 lines of code.
however the validator upon image_file doest seem to work.

print recettes.AddManipulator().fields (thks for the trick) give me :

[FormField "nom", FormField "categorie", FormField "auteur", FormField
"ingredients", FormField "etapes", FormField "conseils", FormField
"dure", FormField "difficulte", FormField "quantite", FormField "prix",
FormField "pub_date", FormField "image_file", FormField "image"]

image_file being in position 11 (if start from 0) or 12 i tried both.
but the validation doest happen, tested with a 250 km image.

Otherwise it posted it well.

here is my view.py

# Create your views here.
from django.core.exceptions import Http404
from django.utils.httpwrappers import HttpResponse,
HttpResponseRedirect
from django.models.recettes import recettes, notes
from django.core.extensions import get_object_or_404,
render_to_response
from django.core import formfields

from manipulators import RecetteManipulator

def detail(request, recettes_id):
r = get_object_or_404(recettes, pk=recettes_id)
n = notes.get_list(recette__pk=recettes_id)
return render_to_response('recettes/detail', {'recette': r,
'id':recettes_id, 'note':n},)

def printable(request, recettes_id):
r = get_object_or_404(recettes, pk=recettes_id)
return render_to_response('recettes/printable', {'recette': r},)

#Validator
def isValideImageWeight(self, field_data, all_data):
print field_data
if len(field_data["content"] > 10) : # 500,000 bytes (100kB)
raise validators.ValidationError, "Le fichier ne dois pas 
depasser
100kb"

#Ajouter
def create_recette(request):
manipulator = recettes.AddManipulator()
#12 being image_fil , recettes.AddManipulator().fields
manipulator.fields[11].validator_list.append(isValideImageWeight)
if request.POST:
# If data was POSTed, we're trying to create a new Place.
new_data = request.POST.copy()

# Check for errors.
errors = manipulator.get_validation_errors(new_data)

if not errors:
# No errors. This means we can save the data!
manipulator.do_html2python(new_data)
new_recette = manipulator.save(new_data)
# Redirect to the object's "edit" page. Always use a 
redirect
# after POST data, so that reloads don't accidently 
create
# duplicate entires, and so users don't see the 
confusing
# "Repost POST data?" alert box in their browsers.
return HttpResponseRedirect("/cefinban/recette/%i/" %
new_recette.id)
else:
# No POST, so we want a brand new form without any data or 
errors.
errors = new_data = {}

# Create the FormWrapper, template, context, response.
form = formfields.FormWrapper(manipulator, new_data, errors)
return render_to_response('recettes/recettes_form', {'form': form})


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Custom Form Fields, Validators and Manipulators

2006-02-20 Thread Felix Ingram

All,

I'm trying to implement a custom form field similar to the Tagging example.

Here's a simplified example of the model I'm using:

class Port(meta.model):
number = meta.IntegerField()
protocol = meta.CharField(maxlength=4)

class Application(meta.model):
name = meta.CharField(maxlength=50)
version = meta.IntegerField()
ports = meta.ManyToManyField(Port)

I'd like users to enter '80:tcp, 443:tcp' and have this validated and
saved appropriately.  With the AddManipulator everything is fine: My
validation routine works, so does the render method and so does
convert_post_data.  A new application is therefore saved in the
database (see below for the code I'm using).

The problems start when ChangeManipulators are used.  When the entry
is read from the database the render method is now passed a list of
ids rather than '80:tcp, 443:tcp' or similar which causes the lookups
I do to fail.  This makes me think that I'm missing something
fundamental and am going about it in the wrong way.

So, my questions are:

1. Am I going about this in the wrong way?
2. Should I be making a custom manipulator for the model rather than
farming out the work to the field?
3. If not, then how do I make sure that 'render' gets passed consistent data.

Thanks in advance for any pointers,

F.

P.S.  For your viewing pleasure here's what I've been using so far:

class FormPortField(formfields.TextField):

requires_data_list = True

def __init__(self, **kw):
formfields.TextField.__init__(self, **kw)
self.validator_list.append(self.isValidList)

def isValidList(self, field_data, all_data):
for datum in field_data:
for port in datum.split(','):
if port.lower().strip() != 'icmp':
try:
no, proto = port.split(':')
except ValueError:
raise validators.ValidationError, _("Ports
should be specified in the form 'number:protocol'.  E.g. '80:tcp'")
if int(no) < 1 or int(no) > 65355:
raise validators.ValidationError, _("Port
number must be between 1 and 65355")
if proto.lower().strip() not in ['tcp', 'udp']:
raise validators.ValidationError, _("Protocol
must be either 'TCP' or 'UDP'")

def render(self, data):
if data is None:
data = ''
if isinstance(data, unicode):
data = data.encode(DEFAULT_CHARSET)
data = ', '.join(data)
return '' % \
(self.get_id(), self.__class__.__name__, self.is_required
and ' required' or '',
self.field_name, 40, escape(data))

def convert_post_data(self, new_data):
name = self.get_member_name()
if new_data.has_key(self.field_name):
d = new_data.getlist(self.field_name)
portlist=[]
for datum in d:
for n in datum.split(','):
n = n.strip()
if n:
if n.lower() == 'icmp':
   
portlist.append(ports.get_object(protocol__exact="icmp").id)
else:
port, proto = n.split(':')
port_ref =
ports.get_object(number__exact=int(port),
protocol__exact=proto.lower())
portlist.append(port_ref.id)
new_data.setlist( name, portlist)

class PortsField(meta.ManyToManyField):
" Special case implementation of a Many to Many relationship to a
'Ports' table "

def __init__(self, *args, **kw):
meta.ManyToManyField.__init__(self, *args, **kw)
self.help_text = kw.get('help_text', '')

def get_manipulator_field_objs(self):
if self.rel.raw_id_admin:
return [formfields.CommaSeparatedIntegerField]
else:
return [curry(FormPortField)]

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Manipulator and views problem, where to save object ?

2006-02-20 Thread Amit Upadhyay
On 2/20/06, coulix <[EMAIL PROTECTED]> wrote:
Hello,i have a simple goal, displaying a form, populate it, save it to thedatabase.At the execption of a new validator to check the weight of the imagesent.First point  i need to write my own manipulator which is pretty much a
copy of the model, i only want to add a validator to one field (image)the other default one suite me well how do i achieve this wihtoutrepeating myself. You can replace your manipulator with the following:
manipulator = recettes.AddManipulator()manipulator.fields[8].validator_list.append(isValideImageWeight)# 8 here refers to position of image field in your model, correct it if # it is not so. u can use print 
recettes.AddManipulator().fields to see the # fields in order.After writting this manipulator, i realise i need a save() function
what is it intended to do ?Normally every manipulator should implement a save() and it should do whatever you want your form precessing logic is.-- Amit UpadhyayBlog: 
http://www.rootshell.be/~upadhyay+91-9867-359-701
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]  For more options, visit this group at http://groups.google.com/group/django-users  -~--~~~~--~~--~--~---



Manipulator and views problem, where to save object ?

2006-02-20 Thread coulix

Hello,
i have a simple goal, displaying a form, populate it, save it to the
database.
At the execption of a new validator to check the weight of the image
sent.

First point  i need to write my own manipulator which is pretty much a
copy of the model, i only want to add a validator to one field (image)
the other default one suite me well how do i achieve this wihtout
repeating myself.

After writting this manipulator, i realise i need a save() function
what is it intended to do ?, i could't find a full exemple. Does it
override the view method described in the documentation
http://www.djangoproject.com/documentation/forms/ ?
I read i also need to specify the id of the object how ?.

Here are the code of my model recette.py, views.py and Manipulator.py
i put some question allong the key points i dont get.

http://django.pastebin.com/564111
and the website to have a look
http://ozserver.no-ip.com:345/cefinban/recette/ajouter

Method to look at  are create_recette in views.py and Manipulator.py
some key methods :
--
views.py
def create_recette(request):
manipulator = RecetteManipulator()
if request.POST:
# If data was POSTed, we're trying to create a new Place.
new_data = request.POST.copy()

# Check for errors.
errors = manipulator.get_validation_errors(new_data)

if not errors:
# No errors. This means we can save the data!
manipulator.do_html2python(new_data)
new_recette = manipulator.save(new_data)
# Redirect to the object's "edit" page. Always use a 
redirect
# after POST data, so that reloads don't accidently 
create
# duplicate entires, and so users don't see the 
confusing
# "Repost POST data?" alert box in their browsers.
return HttpResponseRedirect("/cefinban/recette/%i/" %
new_recette.id)
else:
# No POST, so we want a brand new form without any data or 
errors.
errors = new_data = {}

# Create the FormWrapper, template, context, response.
form = formfields.FormWrapper(manipulator, new_data, errors)
return render_to_response('recettes/recettes_form', {'form': form})

--
manipulator.py

from django.core import formfields, validators
from django.models.recettes import recettes

DIFFICULTY_CHOICES = (
(1, 'Simple'),
(2, 'Intermedaire'),
(3, 'Difficile'),
)

CATEGORY_CHOICES = (
(1, 'Entree'),
(2, 'Plat principal - Poissons'),
(3, 'Plat principal - Viandes'),
(4, 'Plat principal - Legumes et feculents'),
(5, 'Dessert'),
(6, 'Boisson'),
(7, 'Amuse Gueule'),
(8, 'Autre'),
)

class RecetteManipulator(formfields.Manipulator):
def __init__(self):
#Why do i need to overide all the fields to only add one validator ?
self.fields = [
formfields.TextField(field_name="nom", length=30, 
maxlength=80,
is_required=True),
formfields.TextField(field_name="auteur", length=30, 
maxlength=30,
is_required=True ),
formfields.LargeTextField(field_name="ingredients",
is_required=True),
formfields.LargeTextField(field_name="etapes", 
is_required=True),
formfields.LargeTextField(field_name="conseils"),
formfields.PositiveIntegerField(field_name="dure"),

formfields.PositiveSmallIntegerField(field_name="quantite"),
formfields.PositiveIntegerField(field_name="prix"),

formfields.ImageUploadField(field_name="image_file",validator_list=[self.isValideImageWeight]),
formfields.SelectField(field_name="difficulte",
choices=DIFFICULTY_CHOICES, is_required=True),
formfields.SelectField(field_name="categorie",
choices=CATEGORY_CHOICES, is_required=True),
]
def isValideImageWeight(self, field_data, all_data):
print field_data
if len(field_data["content"] > 50) : # 500,000 bytes (500kB)
raise validators.ValidationError, "Le fichier ne dois 
pas depasser
500kb"

#def save(self,data):
#Object= recettes.get_object(pk=self.id)
#for field in self.fields:
#if field.field_name+'_id' in Object.__dict__:
#actual_field_name=field.field_name+'_id'
#else:
#actual_field_name=field.field_name
#Object.__setattr__(actual_field_name,data[field.field_name])
#   Object.save()

def save(self, new_data):
p =