Re: Exception in template

2008-04-12 Thread Juanjo Conti

Perfect, I want the empty string :) I was just asking myself if I was 
forcing some extra processing. Seems not.

Thanks both of you.

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Templates won't translate

2008-04-12 Thread Kenneth Gonsalves


On 12-Apr-08, at 10:15 PM, Basti wrote:

> Probably I'm only being stupid but I can't get my templates to be
> translated. Everything else (translation in views etc.) works fine.

does the template stuff appear in django.po?

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Exception in template

2008-04-12 Thread Erik Vorhes

>  {% for a in list %}
> a.foo   a.bar
>  {% endfor %}

If you really need something to happen other than an empty string, you
can always use the "if" tag:

{% for a in list %}
{% if a.foo %}{{ a.foo }}{% else %}Whatever exception text you
want{% endif %} {{ a.bar }}
{% endfor %}


Erik
-- 
portfolio: http://textivism.com/
blog: http://erikanderica.org/erik/

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Exception in template

2008-04-12 Thread Malcolm Tredinnick


On Sat, 2008-04-12 at 22:13 -0300, Juanjo Conti wrote:
> Suppose this template code:
> 
> {% for a in list %}
>   a.foo   a.bar
> {% endfor %}
> 
> The point is that only some elements of the "list" sequence have the 
> "foo" attribute, so a exception is thrown, but the template engine 
> silence it.
> 
> Is may template code correct or some check should be done to avoid the 
> exception throw?

It depends on what you want to happen.

The template rendering is designed to behave as you are describing. It
actually makes it easier to write reusable templates because you can
access the "foo" attribute on something without worrying about whether
it is present or not -- meaning the templates work for a broader range
of objects. Any missing attributes are replaced with the empty string.

So why is this a bad thing in your case and what do you want to have
happen instead?

Malcolm

-- 
Atheism is a non-prophet organization. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Tag

2008-04-12 Thread Malcolm Tredinnick


On Sat, 2008-04-12 at 18:45 -0300, Claudio Escudero wrote:
> Hi,
> 
> Please, is there any way to put tag inside tag?

No, this isn't possible. Use a block-like tag (something with a start
tag and an end tag) if you want to do something like this.

Regards,
Malcolm

-- 
The cost of feathers has risen; even down is up! 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Exception in template

2008-04-12 Thread Juanjo Conti

Suppose this template code:

{% for a in list %}
a.foo   a.bar
{% endfor %}

The point is that only some elements of the "list" sequence have the 
"foo" attribute, so a exception is thrown, but the template engine 
silence it.

Is may template code correct or some check should be done to avoid the 
exception throw?

Thanks and regards,

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Images and Stylesheets

2008-04-12 Thread greg

Thanks to everyone for the replies.  Static content now makes sense to
me, and I have things up and working.

--greg
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Caching doesn't seem to work

2008-04-12 Thread Julien

Hi there,

I've implemented caching on my site. It works on the local development
environment as well as on the test online server. However it doesn't
seem to work on the production server. Files are being created in the
cache directory (I'm using file caching), but the page keeps being
refreshed at each call.

Would you have any pointer on how to debug this?

Thanks!

Julien
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: alternative to (r'^house/edit/(\d+)/$',ediHouse)?

2008-04-12 Thread J. Clifford Dyer

Heh.  It should also be pointed out that security is not obfuscation.
If your slug is a social security number, I don't care if you're using a
one time pad for authentication, you're still going to have social
security numbers in your browser history for the world to see.  :)  A
mix of obfuscation and security is a wise course of action.

Cheers,
Cliff

On Sat, 2008-04-12 at 11:28 -0700, ydjango wrote:
> Agreed, for MLS records, newspaper stories, blogs entries etc. most
> likely there is no security issue with incrementing db ids in url, and
> might actually be useful in some cases as you pointed out.
> But substitute MLS for accounts, health records, employee records with
> salary information etc, and potential issue appears for sites not
> having strong data/object level authorization.
> 
> I fully agree with other people (Cliff and Ned) on this thread that
> obfuscation should not mistaken for real security. and I thank them
> for pointing this out as I might have made that mistake.
> 
>  But in my case, my decision is to go with both obfuscation of id in
> url and security through proper authentication and authorization.
>  Security - more levels you have , harder and costlier it is to break.
> 
> thank
> Ashish
> 
> On Apr 12, 10:03 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> > On Fri, Apr 11, 2008 at 6:28 PM, ydjango <[EMAIL PROTECTED]> wrote:
> > >  currently I am using constructing url as /house/edit/123/
> > >  where 123 is house data base primary key for that house.
> >
> > >  Can exposing the primary key in url be any security issue?
> >
> > >  (r'^house/edit/(\d+)/$',editHouse)
> >
> > >  Is there alternative way without exposing the primary key in url?
> >
> > There is no security issue unless you care about people knowing how
> > many houses are in your system.
> >
> > However, if you're looking for an alternative, and if you have access
> > to an MLS[1] or similar database, the listing number will be unique
> > within a given MLS database. This makes for a useful identifier,
> > particularly if your users are realtors or work in the real-estate
> > industry since they'll already be familiar with the system and telling
> > them to just visit "/house//" is easy ;)
> >
> > [1]http://en.wikipedia.org/wiki/Multiple_Listing_Service
> >
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of 
> > correct."
> > 


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Tag

2008-04-12 Thread Claudio Escudero
Hi,

Please, is there any way to put tag inside tag?
For example:

{% formajax {"action": {% url inn %} } %}

Displays this error:
too many values to unpack

Thanks

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



Re: alternative to (r'^house/edit/(\d+)/$',ediHouse)?

2008-04-12 Thread ydjango

Agreed, for MLS records, newspaper stories, blogs entries etc. most
likely there is no security issue with incrementing db ids in url, and
might actually be useful in some cases as you pointed out.
But substitute MLS for accounts, health records, employee records with
salary information etc, and potential issue appears for sites not
having strong data/object level authorization.

I fully agree with other people (Cliff and Ned) on this thread that
obfuscation should not mistaken for real security. and I thank them
for pointing this out as I might have made that mistake.

 But in my case, my decision is to go with both obfuscation of id in
url and security through proper authentication and authorization.
 Security - more levels you have , harder and costlier it is to break.

thank
Ashish

On Apr 12, 10:03 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Fri, Apr 11, 2008 at 6:28 PM, ydjango <[EMAIL PROTECTED]> wrote:
> >  currently I am using constructing url as /house/edit/123/
> >  where 123 is house data base primary key for that house.
>
> >  Can exposing the primary key in url be any security issue?
>
> >  (r'^house/edit/(\d+)/$',editHouse)
>
> >  Is there alternative way without exposing the primary key in url?
>
> There is no security issue unless you care about people knowing how
> many houses are in your system.
>
> However, if you're looking for an alternative, and if you have access
> to an MLS[1] or similar database, the listing number will be unique
> within a given MLS database. This makes for a useful identifier,
> particularly if your users are realtors or work in the real-estate
> industry since they'll already be familiar with the system and telling
> them to just visit "/house//" is easy ;)
>
> [1]http://en.wikipedia.org/wiki/Multiple_Listing_Service
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Templates won't translate

2008-04-12 Thread Basti

Never mind. I was being stupid after all.

I forgot to restart the test server. Plus there was a
#, fuzzy
in my django.po file that led to the block not being translated.

On 12 Apr., 18:45, Basti <[EMAIL PROTECTED]> wrote:
> Hi there!
>
> Probably I'm only being stupid but I can't get my templates to be
> translated. Everything else (translation in views etc.) works fine.
>
> I have the following structure for my project
>
> root
>  |\__ blog
>  |\__ some_other_app
>  |\__ locale
>  |  \__ de
>  |\__ ...
>  \__ templates
>|\__ blog
>\__ some_other_app
>
> What am I doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: alternative to (r'^house/edit/(\d+)/$',ediHouse)?

2008-04-12 Thread James Bennett

On Fri, Apr 11, 2008 at 6:28 PM, ydjango <[EMAIL PROTECTED]> wrote:
>  currently I am using constructing url as /house/edit/123/
>  where 123 is house data base primary key for that house.
>
>  Can exposing the primary key in url be any security issue?
>
>  (r'^house/edit/(\d+)/$',editHouse)
>
>  Is there alternative way without exposing the primary key in url?

There is no security issue unless you care about people knowing how
many houses are in your system.

However, if you're looking for an alternative, and if you have access
to an MLS[1] or similar database, the listing number will be unique
within a given MLS database. This makes for a useful identifier,
particularly if your users are realtors or work in the real-estate
industry since they'll already be familiar with the system and telling
them to just visit "/house//" is easy ;)

[1] http://en.wikipedia.org/wiki/Multiple_Listing_Service


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: template IndexError (list index out of range)

2008-04-12 Thread Jonathan Lukens

Of course.  Thank you.  I'm nearly braindead from doing taxes.

On Apr 12, 11:12 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sat, Apr 12, 2008 at 9:28 AM, Jonathan Lukens <[EMAIL PROTECTED]>
> wrote:
>
>
>
>
>
> > I started getting an IndexError on a page today that has worked fine
> > in the past.  The uses a wrapped object_list generic view to render a
> > template with the following loop:
>
> >{% for baby in object_list %}
> >{% if baby.photo %}
> > > />
> >{% endif %}
> >
> >
> >{{ baby.display_name }} {{ baby.last_name }}...
> >
> >... is {{ baby.age }}
> >{% endfor %}
>
> > I tried generating the same list in shell and was able to run a for
> > loop on it without any trouble.  I compared the model and the template
> > with the last commit to svn (which worked) and nothing was different
> > except a couple of custom methods on the model being looped over.  I
> > commented out those methods and restarted the server but got the same
> > error.  Here is the traceback:
>
> > File "/usr/lib/python2.5/site-packages/django/template/debug.py" in
> > render_node
> >  71. result = node.render(context)
> > File "/usr/lib/python2.5/site-packages/django/template/defaulttags.py"
> > in render
> >  149. nodelist.append(node.render(context))
> > File "/usr/lib/python2.5/site-packages/django/template/defaulttags.py"
> > in render
> >  239. value = bool_expr.resolve(context, True)
> > File "/usr/lib/python2.5/site-packages/django/template/__init__.py" in
> > resolve
> >  518. obj = self.var.resolve(context)
> > File "/usr/lib/python2.5/site-packages/django/template/__init__.py" in
> > resolve
> >  659. value = self._resolve_lookup(context)
> > File "/usr/lib/python2.5/site-packages/django/template/__init__.py" in
> > _resolve_lookup
> >  694. current = current()
>
> This is the line of code causing the problem:
>
> File "/home/jonathan/workspace/datababy/src/datababy/child/models.py"
>
> > in photo
> >  96. return self.photo_set.all()[0]
>
> It is assuming there is at least one photo in the set, but apparently there
> are none.  This would seem to be coming from the {% if baby.photo %} line in
> your template.  Your code needs to handle the case where
> self.photo_set.all() is empty.
>
> Karen
>
> > File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in
> > __getitem__
> >  157. return list(self._clone(_offset=k,
> > _limit=1))[0]
>
> > Exception Type: IndexError at /users/jonathan/
> > Exception Value: list index out of range
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeDecodeError: markdown failing to parse data fed by django

2008-04-12 Thread Ivan Sagalaev

fizban wrote:
> On 12 Apr, 12:54, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>> It sounds like you're using markdown 1.7. We haven't yet incorporated
>> the patch necessary to handle markdown 1.7 along with the earlier
>> versions. That will go in soon, though -- there's already a ticket in Trac 
>> for it.
> 
> Ok, that sounds cool (the pending fix, not the backwards incompatible
> changes); thank you for the reply

BTW, there is [python-markdown2][1] that doesn't have problems with 
neither unicode, nor byte strings in utf-8.

[1]: http://code.google.com/p/python-markdown2/

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Templates won't translate

2008-04-12 Thread Basti

Hi there!

Probably I'm only being stupid but I can't get my templates to be
translated. Everything else (translation in views etc.) works fine.

I have the following structure for my project

root
 |\__ blog
 |\__ some_other_app
 |\__ locale
 |  \__ de
 |\__ ...
 \__ templates
   |\__ blog
   \__ some_other_app

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



Re: OS X install help --I think I broke something...

2008-04-12 Thread fizban

On 12 Apr, 18:10, superavit <[EMAIL PROTECTED]> wrote:
> I have the same issues with my Leopard installation. I do have the
> template loader settings as suggested and still nothing...

I use Leopard on my mac as a test field for my code and I've never had
an issue with it.

I just grab django off the svn and then create the symlink from /
Library/Python/2.5/site-packages/django to $SOMEPATH/django-trunk/
django and the last step is to create a symlink for django-admin.py

Create a project and then I'm all set

Going back to the question "how do I start from scratch", open up a
terminal and then:

sudo rm /Library/Python/2.5/site-packages/django
which django-admin.py

Then use the output of the which command to rm the symlink. In my case
it'd be:

sudo rm /usr/local/bin/django-admin.py

Hope it helps



--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeDecodeError: markdown failing to parse data fed by django

2008-04-12 Thread fizban

On 12 Apr, 17:06, Jens Diemer <[EMAIL PROTECTED]> wrote:
>
> btw. ticket:http://code.djangoproject.com/ticket/6387

Thanks, got the .diff
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: OS X install help --I think I broke something...

2008-04-12 Thread superavit

I have the same issues with my Leopard installation. I do have the
template loader settings as suggested and still nothing...

On Apr 9, 7:09 pm, "Justin Fagnani" <[EMAIL PROTECTED]> wrote:
> Oops... it's the admin site... sorry 'bout that :/
> Check to see if you have:
>
> 'django.template.loaders.app_directories.load_template_source',
>
> in your TEMPLATE_LOADERS setting.
>
> -Justin
>
> On Wed, Apr 9, 2008 at 4:05 PM, Justin Fagnani <[EMAIL PROTECTED]>
> wrote:
>
> > Sounds like you just need to set the TEMPLATE_DIRS setting
>
> >http://www.djangoproject.com/documentation/templates_python/#the-temp...
>
> > -Justin
>
> > On Wed, Apr 9, 2008 at 3:01 PM, mw <[EMAIL PROTECTED]> wrote:
>
> > > Hello,
>
> > > I'm having problems with my installation of django on OS X leopard.  I
> > > followed the manual for the installation and installed Django from the
> > > svn repository.
>
> > > Some things seem to be working while others do not.  I have reached
> > > the point in the tutorial where I am supposed to access the admin page
> > > for the site.  Up until this point, everything has worked well.
>
> > > Unfortunately, the admin site just displays a page with an exception
> > > that the template cannot be found.  Since I'm not doing anything
> > > fancy, and  I have been trying to follow the tutorial as much as
> > > possible, I'm pretty sure that I must have simply missed something or
> > > done symlinks incorrectly or something like that.
>
> > > Is anyone on the list knowledgeable enough about OS X and Django to
> > > help me out?  I'm OK with just deleting the install and starting over
> > > again, but being new to OS X and Django, I'm not even sure where
> > > everything is to delete and start over.  (What symlinks I need to
> > > delete, etc)
>
> > > Thanks for any help or advice in advance,
> > > mw
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: alternative to (r'^house/edit/(\d+)/$',ediHouse)?

2008-04-12 Thread J. Clifford Dyer

If your concern is people randomly (or intentionally) hitting your URLs,
you might try creating a checksum of some kind on your primary key
concatenated with a hidden salt string.  Just make sure you keep that
checksum in an index to your DB, so performance doesn't suffer as a
result.  There is a benefit in having clean readable memorable URLs
(like using street addresses for real estate listings), but there's also
times when obfuscation is called for.  (but don't mistake it for real
security!)

Cheers,
Cliff


On Fri, 2008-04-11 at 21:24 -0700, ydjango wrote:
> Thanks, I will use Slug, which will be unique and alphanumeric but
> will not be sequential.
> 
> I agree best protection is proper authorization, and that I check on
> each page/request if the user is authorized to view this data or not.
> 
> I just hate the idea of some user just incrementing ids in url and
> trying to view the data, he is not supposed to. (eg. putting boss's
> employee id in url to see his salary)
> 
> I am restricting the data viewed through use of restrictive parameters
> in queries  which can be defeated by changing the ids in url, if I use
> primary ids.
> 
> thanks
> Ashish
> 
> 
> On Apr 11, 8:06 pm, Ned Batchelder <[EMAIL PROTECTED]> wrote:
> > Strictly speaking, exposing the primary key is not a security issue.
> > Primary keys are not a secret, just an id.  You need to secure your data
> > based on authenticated credentials and some sort of authorization system
> > that controls who can do what with each piece of data.
> >
> > Some people don't like using sequential primary keys because they are
> > exposing information about their system.  For example, with your system,
> > I can tell how many houses you have in your database by probing URLs.  I
> > guess you might consider that a security concern.  If so, use a
> > randomized slug as others have suggested.
> >
> > --Ned.http://nedbatchelder.com/blog
> >
> >
> >
> > ydjango wrote:
> > > I am displaying a list of houses and on clicking on one of the houses
> > > I want to show/edit details
> >
> > > currently I am using constructing url as /house/edit/123/
> > > where 123 is house data base primary key for that house.
> >
> > > Can exposing the primary key in url be any security issue?
> >
> > > (r'^house/edit/(\d+)/$',editHouse)
> >
> > > Is there alternative way without exposing the primary key in url?
> >
> > > Ashish
> >
> > --
> > Ned Batchelder,http://nedbatchelder.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?hl=en
-~--~~~~--~~--~--~---



Re: template IndexError (list index out of range)

2008-04-12 Thread Karen Tracey
On Sat, Apr 12, 2008 at 9:28 AM, Jonathan Lukens <[EMAIL PROTECTED]>
wrote:

>
> I started getting an IndexError on a page today that has worked fine
> in the past.  The uses a wrapped object_list generic view to render a
> template with the following loop:
>
>{% for baby in object_list %}
>{% if baby.photo %}
> />
>{% endif %}
>
>
>{{ baby.display_name }} {{ baby.last_name }}...
>
>... is {{ baby.age }}
>{% endfor %}
>
> I tried generating the same list in shell and was able to run a for
> loop on it without any trouble.  I compared the model and the template
> with the last commit to svn (which worked) and nothing was different
> except a couple of custom methods on the model being looped over.  I
> commented out those methods and restarted the server but got the same
> error.  Here is the traceback:
>
> File "/usr/lib/python2.5/site-packages/django/template/debug.py" in
> render_node
>  71. result = node.render(context)
> File "/usr/lib/python2.5/site-packages/django/template/defaulttags.py"
> in render
>  149. nodelist.append(node.render(context))
> File "/usr/lib/python2.5/site-packages/django/template/defaulttags.py"
> in render
>  239. value = bool_expr.resolve(context, True)
> File "/usr/lib/python2.5/site-packages/django/template/__init__.py" in
> resolve
>  518. obj = self.var.resolve(context)
> File "/usr/lib/python2.5/site-packages/django/template/__init__.py" in
> resolve
>  659. value = self._resolve_lookup(context)
> File "/usr/lib/python2.5/site-packages/django/template/__init__.py" in
> _resolve_lookup
>  694. current = current()



This is the line of code causing the problem:

File "/home/jonathan/workspace/datababy/src/datababy/child/models.py"
> in photo
>  96. return self.photo_set.all()[0]


It is assuming there is at least one photo in the set, but apparently there
are none.  This would seem to be coming from the {% if baby.photo %} line in
your template.  Your code needs to handle the case where
self.photo_set.all() is empty.

Karen



> File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in
> __getitem__
>  157. return list(self._clone(_offset=k,
> _limit=1))[0]
>
> Exception Type: IndexError at /users/jonathan/
> Exception Value: list index out of range
>
> >
>

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeDecodeError: markdown failing to parse data fed by django

2008-04-12 Thread Jens Diemer

fizban schrieb:
> On 12 Apr, 12:54, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>> It sounds like you're using markdown 1.7. We haven't yet incorporated
>> the patch necessary to handle markdown 1.7 along with the earlier
>> versions. That will go in soon, though -- there's already a ticket in Trac 
>> for it.
> 
> Ok, that sounds cool (the pending fix, not the backwards incompatible
> changes); thank you for the reply

btw. ticket: http://code.djangoproject.com/ticket/6387

-- 
Mfg.

Jens Diemer



A django powered CMS: http://www.pylucid.org


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Django API interface adapter for Google App Engine

2008-04-12 Thread Chris Hoeppner

After looking into that for a while, I can't seem to understand what
works and what not...

** From the file README within the project's checkout:
The helper provides the following functionality:

  * The ability to use most manage.py commands
  * A BaseModel class that appears the same as the standard Django Model
class.
  * The ability to serialize and deserialize model instances to JSON,
YAML and XML.
  * Access to Django's test framework with a test datastore and support
for fixtures.

Right. What does the BaseModel do then? Can I use it, inherit my models
from it, and code them the django-way and everything works? Is that the
intended way, but not-yet-working?

~ Chris

El sáb, 12-04-2008 a las 05:07 -0700, Eric escribió:
> Here's a project being developed by Google.  Guido is even involved:
> http://code.google.com/p/google-app-engine-django/
> 
> On Apr 12, 5:58 am, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> > Great stuff, man!
> >
> > I'll try to have an in-depth look this weekend and I'll se if I can help
> > with anything.
> >
> > This seems like a nice solution, until someone pokes up a proper backend
> > (stating that I'm not sure if that's possible, bearing in mind that
> > GAE's datastore is not a RDBM).
> >
> > ~ Chris
> >
> > El vie, 11-04-2008 a las 12:02 -0700, Siddhi escribió:
> >
> > > Hi,
> >
> > > I'm working on an interface adapter for Google App Engine's datastore.
> > > I've just started out and have created a project for it here with some
> > > basic code -http://code.google.com/p/django-gae-helpers/
> >
> > > The intro page has an explanation of what I'm trying to do -
> > >http://code.google.com/p/django-gae-helpers/wiki/Intro
> >
> > > And you can get the current code from the repository -
> > >http://code.google.com/p/django-gae-helpers/source/browse/trunk/gaead...
> >
> > > It is released under MIT license.
> >
> > > So far a few of the methods have been implemented, basically those
> > > that I needed to port one of my projects. I think it would be pretty
> > > cool if we could adapt most of the API like this. Any thoughts?
> >
> > > --
> > > Siddharta Govindaraj
> > >http://siddhi.blogspot.com
> > >http://www.silverstripesoftware.com/blog/
> > 


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



template IndexError (list index out of range)

2008-04-12 Thread Jonathan Lukens

I started getting an IndexError on a page today that has worked fine
in the past.  The uses a wrapped object_list generic view to render a
template with the following loop:

{% for baby in object_list %}
{% if baby.photo %}

{% endif %}


{{ baby.display_name }} {{ baby.last_name }}...

... is {{ baby.age }}
{% endfor %}

I tried generating the same list in shell and was able to run a for
loop on it without any trouble.  I compared the model and the template
with the last commit to svn (which worked) and nothing was different
except a couple of custom methods on the model being looped over.  I
commented out those methods and restarted the server but got the same
error.  Here is the traceback:

File "/usr/lib/python2.5/site-packages/django/template/debug.py" in
render_node
  71. result = node.render(context)
File "/usr/lib/python2.5/site-packages/django/template/defaulttags.py"
in render
  149. nodelist.append(node.render(context))
File "/usr/lib/python2.5/site-packages/django/template/defaulttags.py"
in render
  239. value = bool_expr.resolve(context, True)
File "/usr/lib/python2.5/site-packages/django/template/__init__.py" in
resolve
  518. obj = self.var.resolve(context)
File "/usr/lib/python2.5/site-packages/django/template/__init__.py" in
resolve
  659. value = self._resolve_lookup(context)
File "/usr/lib/python2.5/site-packages/django/template/__init__.py" in
_resolve_lookup
  694. current = current()
File "/home/jonathan/workspace/datababy/src/datababy/child/models.py"
in photo
  96. return self.photo_set.all()[0]
File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in
__getitem__
  157. return list(self._clone(_offset=k,
_limit=1))[0]

Exception Type: IndexError at /users/jonathan/
Exception Value: list index out of range

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: alternative to (r'^house/edit/(\d+)/$',ediHouse)?

2008-04-12 Thread Ned Batchelder
But this is exactly my point: the case you describe is not one of 
discovering ids by probing.  If the employee knows the bosses' id, and 
can use it to see his salary, then you haven't got a secure system.  
Replacing the id with some random slug doesn't make it a secure system.  
You are talking about security through obscurity, which is no security 
at all.

--Ned.

ydjango wrote:
> Thanks, I will use Slug, which will be unique and alphanumeric but
> will not be sequential.
>
> I agree best protection is proper authorization, and that I check on
> each page/request if the user is authorized to view this data or not.
>
> I just hate the idea of some user just incrementing ids in url and
> trying to view the data, he is not supposed to. (eg. putting boss's
> employee id in url to see his salary)
>
> I am restricting the data viewed through use of restrictive parameters
> in queries  which can be defeated by changing the ids in url, if I use
> primary ids.
>
> thanks
> Ashish
>
>
> On Apr 11, 8:06 pm, Ned Batchelder <[EMAIL PROTECTED]> wrote:
>   
>> Strictly speaking, exposing the primary key is not a security issue.
>> Primary keys are not a secret, just an id.  You need to secure your data
>> based on authenticated credentials and some sort of authorization system
>> that controls who can do what with each piece of data.
>>
>> Some people don't like using sequential primary keys because they are
>> exposing information about their system.  For example, with your system,
>> I can tell how many houses you have in your database by probing URLs.  I
>> guess you might consider that a security concern.  If so, use a
>> randomized slug as others have suggested.
>>
>> --Ned.http://nedbatchelder.com/blog
>>
>>
>>
>> ydjango wrote:
>> 
>>> I am displaying a list of houses and on clicking on one of the houses
>>> I want to show/edit details
>>>   
>>> currently I am using constructing url as /house/edit/123/
>>> where 123 is house data base primary key for that house.
>>>   
>>> Can exposing the primary key in url be any security issue?
>>>   
>>> (r'^house/edit/(\d+)/$',editHouse)
>>>   
>>> Is there alternative way without exposing the primary key in url?
>>>   
>>> Ashish
>>>   
>> --
>> Ned Batchelder,http://nedbatchelder.com
>> 
> >
>
>   

-- 
Ned Batchelder, http://nedbatchelder.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?hl=en
-~--~~~~--~~--~--~---



Re: I'd like to learn more about Django internals

2008-04-12 Thread Tim Chase

> You might be thinking of this flowchart:
> http://www.djangobook.com/en/1.0/chapter03/#cn60

Yes, indeed.  Must have had the wrong list of search-terms in 
Google's image-search. :)

Thanks,

-tim



--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: How we can integrate Django app in Google appengine.

2008-04-12 Thread rajiv bammi
Oopsthanx a lot..great help ;) Got it..

i m trying to create and app with django in webapp ;)

Catch u guys if face any issue ;)

Thanks again

On Sat, Apr 12, 2008 at 8:54 AM, shabda <[EMAIL PROTECTED]> wrote:

>
> [Shameless plug :)]
> http://www.42topics.com/dumps/django/docs.html
> http://www.42topics.com/dumps/appengine/doc.html
>
> On Apr 12, 4:49 pm, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> > I'm not sure wether you're asking how to run django on GAE [1], or how
> > to do that using appengine's webapp framework [2].
> >
> > [1]http://code.google.com/appengine/articles/django.html
> > [2]http://code.google.com/appengine/docs/gettingstarted/
> >
> > Bear in mind that AFAIK right now there's no official way to make django
> > components that use the ORM work. Beside that, there's a ticket with a
> > patch for a GAE DS session backend [1], and there are efforts to make
> > the whole thing tie together too [2].
> >
> > [1]http://code.djangoproject.com/ticket/7008
> > [2]http://code.google.com/p/google-app-engine-django/
> >
> > ~ Chris
> >
> > El sáb, 12-04-2008 a las 08:42 -0400, rajiv bammi escribió:
> >
> > > Dear developers,
> >
> > > Just a basic query, i am still not able to understand that how we can
> > > integrate Django app with Google appengine..
> >
> > > Let say we have a simple program in Django which says hello world..
> > > how using django i can do it in Google Appengine..
> >
> > > Thanks & Regards
> > > Rajiv
> >
>

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: I'd like to learn more about Django internals

2008-04-12 Thread shabda

I have been meaning to learn the code in django.db, but I can never
get my head around metaclasses enough to do so. Anything you can
suggest, Malcom?

On Apr 12, 5:52 pm, "Erik Vorhes" <[EMAIL PROTECTED]> wrote:
> You might be thinking of this 
> flowchart:http://www.djangobook.com/en/1.0/chapter03/#cn60
>
> Erik
>
> On Sat, Apr 12, 2008 at 7:00 AM, Tim Chase
>
> <[EMAIL PROTECTED]> wrote:
>
> >  > As the subject says, I'd love to learn more about how django
> >  > works internally.
>
> >  One of the best pages I've found detailing this:
>
> >  http://www.b-list.org/weblog/2006/jun/13/how-django-processes-request/
>
> >  There was a nice image/flowchart I stumbled across once, but I
> >  can't disinter it from the web.  Perhaps someone else on the list
> >  will know where to find it.
>
> >  -tim
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: How we can integrate Django app in Google appengine.

2008-04-12 Thread shabda

[Shameless plug :)]
http://www.42topics.com/dumps/django/docs.html
http://www.42topics.com/dumps/appengine/doc.html

On Apr 12, 4:49 pm, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> I'm not sure wether you're asking how to run django on GAE [1], or how
> to do that using appengine's webapp framework [2].
>
> [1]http://code.google.com/appengine/articles/django.html
> [2]http://code.google.com/appengine/docs/gettingstarted/
>
> Bear in mind that AFAIK right now there's no official way to make django
> components that use the ORM work. Beside that, there's a ticket with a
> patch for a GAE DS session backend [1], and there are efforts to make
> the whole thing tie together too [2].
>
> [1]http://code.djangoproject.com/ticket/7008
> [2]http://code.google.com/p/google-app-engine-django/
>
> ~ Chris
>
> El sáb, 12-04-2008 a las 08:42 -0400, rajiv bammi escribió:
>
> > Dear developers,
>
> > Just a basic query, i am still not able to understand that how we can
> > integrate Django app with Google appengine..
>
> > Let say we have a simple program in Django which says hello world..
> > how using django i can do it in Google Appengine..
>
> > Thanks & Regards
> > Rajiv
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: I'd like to learn more about Django internals

2008-04-12 Thread Erik Vorhes

You might be thinking of this flowchart:
http://www.djangobook.com/en/1.0/chapter03/#cn60

Erik

On Sat, Apr 12, 2008 at 7:00 AM, Tim Chase
<[EMAIL PROTECTED]> wrote:
>
>  > As the subject says, I'd love to learn more about how django
>  > works internally.
>
>  One of the best pages I've found detailing this:
>
>  http://www.b-list.org/weblog/2006/jun/13/how-django-processes-request/
>
>  There was a nice image/flowchart I stumbled across once, but I
>  can't disinter it from the web.  Perhaps someone else on the list
>  will know where to find it.
>
>  -tim
>
>
>
>
>
>
>  >
>

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: How we can integrate Django app in Google appengine.

2008-04-12 Thread Chris Hoeppner

I'm not sure wether you're asking how to run django on GAE [1], or how
to do that using appengine's webapp framework [2].

[1] http://code.google.com/appengine/articles/django.html
[2] http://code.google.com/appengine/docs/gettingstarted/

Bear in mind that AFAIK right now there's no official way to make django
components that use the ORM work. Beside that, there's a ticket with a
patch for a GAE DS session backend [1], and there are efforts to make
the whole thing tie together too [2].

[1] http://code.djangoproject.com/ticket/7008
[2] http://code.google.com/p/google-app-engine-django/

~ Chris

El sáb, 12-04-2008 a las 08:42 -0400, rajiv bammi escribió:
> Dear developers,
> 
> Just a basic query, i am still not able to understand that how we can
> integrate Django app with Google appengine..
> 
> Let say we have a simple program in Django which says hello world..
> how using django i can do it in Google Appengine..
> 
> Thanks & Regards
> Rajiv
> 
> > 


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



How we can integrate Django app in Google appengine.

2008-04-12 Thread rajiv bammi
Dear developers,

Just a basic query, i am still not able to understand that how we can
integrate Django app with Google appengine..

Let say we have a simple program in Django which says hello world.. how
using django i can do it in Google Appengine..

Thanks & Regards
Rajiv

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: I'd like to learn more about Django internals

2008-04-12 Thread Chris Hoeppner

Thanks for your kind reply, Malcolm.

I think I'll just take the "roll up your sleeves" way and dive in. Try
to poke at the code, change things, see what happens (as in, what is
affected by the change I've made, discover dependencies and usage of
code pieces), and maybe give things like backends (sessions or db, don't
care) a try.

I've been using django for a while now, and would eventually like to
give something back.

Maybe trying to give in to the hype and build my way to get django
sessions working on GAE would be a nice learning process? I bet
something will be published before I can get my head around how a
backend works, but it should be a nice personal experience.

Aside: While typing this I discovered ticket #7008 [1]

[1] http://code.djangoproject.com/ticket/7008

El sáb, 12-04-2008 a las 21:34 +1000, Malcolm Tredinnick escribió:
> 
> On Sat, 2008-04-12 at 11:15 +0100, Chris Hoeppner wrote:
> > Hi there,
> > 
> > As the subject says, I'd love to learn more about how django works
> > internally. I've been doing python stuff for about a year or more, but
> > still can't seem to get my head around a big part of the black magic. I
> > wonder if there's something I'm missing?
> 
> If you're asking "is there a silver bullet", then... well... no.
> 
> There are at least a couple of ways to become familiar with a random
> bunch of code that you're interested in. One is to start out with a
> problem, say, a traceback and work outwards from there. The traceback
> will give you a call stack and then you can investigate the code
> surrounding that to work out what might be going on. Another approach is
> to follow data paths. Track a piece of data as it enters the system all
> the way through until it exits.
> 
> In Django, that means tracking a request. So start from one of the
> request handlers (django.core.handlers.wsgi, for example) and trace
> through what happens to the incoming HTTP request. This will be
> decidedly easier if you have a small application that interacts with
> Django, because at some point URL resolution will take place, then a
> view function will be called, you might access some model stuff
> (entering the ORM) and then it's back to the handler for returning the
> response. Without an application of some sort being involved, you won't
> be able to trace the path from request to view to ORM to template, etc.
> 
> Alternatively, although Django is large codebase, most of the components
> are reasonably self-contained. Pretty much all the directories under
> django/ represent self-contained pieces (utils/ -- containing things
> that are used across Django's internals -- is the real exception there).
> So you could pick a directory with an interesting sounding name and
> start reading the code. Split up django/db into a couple of pieces:
> django/db/models/ and django/db/backends, since they are slightly
> different responsibilities.
> 
> Your question is a little general, so if you have some specific area
> you're interested in, or if you're trying to work out which piece is
> responsible for some piece of functionality, ask a more specific
> question. If you're just wanting to learn about the code in general,
> though, the only trick is to roll up your sleeves and dive in. Learn
> about a little piece at a time and you'll slowly build up knowledge.
> 
> 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?hl=en
-~--~~~~--~~--~--~---



Re: Django API interface adapter for Google App Engine

2008-04-12 Thread Eric

Here's a project being developed by Google.  Guido is even involved:
http://code.google.com/p/google-app-engine-django/

On Apr 12, 5:58 am, Chris Hoeppner <[EMAIL PROTECTED]> wrote:
> Great stuff, man!
>
> I'll try to have an in-depth look this weekend and I'll se if I can help
> with anything.
>
> This seems like a nice solution, until someone pokes up a proper backend
> (stating that I'm not sure if that's possible, bearing in mind that
> GAE's datastore is not a RDBM).
>
> ~ Chris
>
> El vie, 11-04-2008 a las 12:02 -0700, Siddhi escribió:
>
> > Hi,
>
> > I'm working on an interface adapter for Google App Engine's datastore.
> > I've just started out and have created a project for it here with some
> > basic code -http://code.google.com/p/django-gae-helpers/
>
> > The intro page has an explanation of what I'm trying to do -
> >http://code.google.com/p/django-gae-helpers/wiki/Intro
>
> > And you can get the current code from the repository -
> >http://code.google.com/p/django-gae-helpers/source/browse/trunk/gaead...
>
> > It is released under MIT license.
>
> > So far a few of the methods have been implemented, basically those
> > that I needed to port one of my projects. I think it would be pretty
> > cool if we could adapt most of the API like this. Any thoughts?
>
> > --
> > Siddharta Govindaraj
> >http://siddhi.blogspot.com
> >http://www.silverstripesoftware.com/blog/
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: I'd like to learn more about Django internals

2008-04-12 Thread Tim Chase

> As the subject says, I'd love to learn more about how django
> works internally.

One of the best pages I've found detailing this:

http://www.b-list.org/weblog/2006/jun/13/how-django-processes-request/

There was a nice image/flowchart I stumbled across once, but I 
can't disinter it from the web.  Perhaps someone else on the list 
will know where to find it.

-tim




--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: I'd like to learn more about Django internals

2008-04-12 Thread Malcolm Tredinnick


On Sat, 2008-04-12 at 11:15 +0100, Chris Hoeppner wrote:
> Hi there,
> 
> As the subject says, I'd love to learn more about how django works
> internally. I've been doing python stuff for about a year or more, but
> still can't seem to get my head around a big part of the black magic. I
> wonder if there's something I'm missing?

If you're asking "is there a silver bullet", then... well... no.

There are at least a couple of ways to become familiar with a random
bunch of code that you're interested in. One is to start out with a
problem, say, a traceback and work outwards from there. The traceback
will give you a call stack and then you can investigate the code
surrounding that to work out what might be going on. Another approach is
to follow data paths. Track a piece of data as it enters the system all
the way through until it exits.

In Django, that means tracking a request. So start from one of the
request handlers (django.core.handlers.wsgi, for example) and trace
through what happens to the incoming HTTP request. This will be
decidedly easier if you have a small application that interacts with
Django, because at some point URL resolution will take place, then a
view function will be called, you might access some model stuff
(entering the ORM) and then it's back to the handler for returning the
response. Without an application of some sort being involved, you won't
be able to trace the path from request to view to ORM to template, etc.

Alternatively, although Django is large codebase, most of the components
are reasonably self-contained. Pretty much all the directories under
django/ represent self-contained pieces (utils/ -- containing things
that are used across Django's internals -- is the real exception there).
So you could pick a directory with an interesting sounding name and
start reading the code. Split up django/db into a couple of pieces:
django/db/models/ and django/db/backends, since they are slightly
different responsibilities.

Your question is a little general, so if you have some specific area
you're interested in, or if you're trying to work out which piece is
responsible for some piece of functionality, ask a more specific
question. If you're just wanting to learn about the code in general,
though, the only trick is to roll up your sleeves and dive in. Learn
about a little piece at a time and you'll slowly build up knowledge.

Regards,
Malcolm

-- 
Always try to be modest and be proud of it! 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



I'd like to learn more about Django internals

2008-04-12 Thread Chris Hoeppner

Hi there,

As the subject says, I'd love to learn more about how django works
internally. I've been doing python stuff for about a year or more, but
still can't seem to get my head around a big part of the black magic. I
wonder if there's something I'm missing?

~ 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-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?hl=en
-~--~~~~--~~--~--~---



Re: Using property fields in Models:'_QuerySet' object has no attribute 'new_summary' error

2008-04-12 Thread Malcolm Tredinnick


On Fri, 2008-04-11 at 22:11 -0700, ydjango wrote:
> I defined two property fields in my model as below
> 
> but TableName.objects.all() or filter() is not retrieving them.
> It is retrieving only the regular model fields.

What do you mean by "not retrieving them"? They are properties defined
on the Python class. They will always exist when the Python class is
created. More importantly, they are not stored in the database, so what
are you expecting to be retrieved here?

Malcolm

-- 
Everything is _not_ based on faith... take my word for it. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeDecodeError: markdown failing to parse data fed by django

2008-04-12 Thread fizban

On 12 Apr, 12:54, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> It sounds like you're using markdown 1.7. We haven't yet incorporated
> the patch necessary to handle markdown 1.7 along with the earlier
> versions. That will go in soon, though -- there's already a ticket in Trac 
> for it.

Ok, that sounds cool (the pending fix, not the backwards incompatible
changes); thank you for the reply
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Django API interface adapter for Google App Engine

2008-04-12 Thread Chris Hoeppner

Great stuff, man!

I'll try to have an in-depth look this weekend and I'll se if I can help
with anything.

This seems like a nice solution, until someone pokes up a proper backend
(stating that I'm not sure if that's possible, bearing in mind that
GAE's datastore is not a RDBM).

~ Chris

El vie, 11-04-2008 a las 12:02 -0700, Siddhi escribió:
> Hi,
> 
> I'm working on an interface adapter for Google App Engine's datastore.
> I've just started out and have created a project for it here with some
> basic code - http://code.google.com/p/django-gae-helpers/
> 
> The intro page has an explanation of what I'm trying to do -
> http://code.google.com/p/django-gae-helpers/wiki/Intro
> 
> And you can get the current code from the repository -
> http://code.google.com/p/django-gae-helpers/source/browse/trunk/gaeadapter.py
> 
> It is released under MIT license.
> 
> So far a few of the methods have been implemented, basically those
> that I needed to port one of my projects. I think it would be pretty
> cool if we could adapt most of the API like this. Any thoughts?
> 
> --
> Siddharta Govindaraj
> http://siddhi.blogspot.com
> http://www.silverstripesoftware.com/blog/
> 
> > 


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeDecodeError: markdown failing to parse data fed by django

2008-04-12 Thread Malcolm Tredinnick


On Sat, 2008-04-12 at 03:24 -0700, fizban wrote:
> I've fixed my issue by replacing smart_str with force_unicode in
> django.contrib.markup (the portion about markdown obviously).
> 
> Why is django (latest svn trunk) passing bytestring to markdown, which
> is supposed to be fed by ascii or unicode? :\
> 
> Should I fill a ticket or is there a valid reason to do so? I mean, as
> far as i can see it's just plain wrong..

It sounds like you're using markdown 1.7. Markdown recently made a
massively backwards incompatible change: they used to accept only
bytestrings, then they accepted bytestrings (UTF-8, ASCII, UTF-16, and
some others) and now they only take unicode.

We haven't yet incorporated the patch necessary to handle markdown 1.7
along with the earlier versions. That will go in soon, though -- there's
already a ticket in Trac for it.

Regards,
Malcolm

-- 
I don't have a solution, but I admire your problem. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: UnicodeDecodeError: markdown failing to parse data fed by django

2008-04-12 Thread fizban

I've fixed my issue by replacing smart_str with force_unicode in
django.contrib.markup (the portion about markdown obviously).

Why is django (latest svn trunk) passing bytestring to markdown, which
is supposed to be fed by ascii or unicode? :\

Should I fill a ticket or is there a valid reason to do so? I mean, as
far as i can see it's just plain wrong..
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



UnicodeDecodeError: markdown failing to parse data fed by django

2008-04-12 Thread fizban

Hi,

I'm having some trouble using django.contrib.markup -- I try to use
the markdown filter and eveything works fine until I try to feed it
"weird" chars (accented letters). When I do so (via the admin
interface) and I access the page, markdown fails miserably and the
template won't show the portion of text it's supposed to filter
through markdown.

The error I get is: MARKDOWN-CRITICAL: "UnicodeDecodeError: Markdown
only accepts unicode or ascii  input."

The error is pretty clear. However I am feeding input via the admin
interface (utf-8) with a normal browser (safari - using utf-8 too),
and all the project/application files are written with textmate
(defaults to utf-8) so I don't get why is django failing in feeding
markdown.py unicode stuff.

Now: if it was for me I'd just feed the admin interface html entities
but since I have to filter comments via markdown as well, I can't ask
people to type in entities instead of chars.

Am I missing something? Am I supposed to sanitize "object.whatever"
somehow before applying the markdown filter? If it's supposed to work
as is, what could be the cause that leads markdown.py to fail?
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Caching generic views

2008-04-12 Thread Julien

Hi there,

I've been able to cache some views individually using the cache_page
decorator, for example:

@cache_page(60 * 15)
def frontpage(request):
blabla...

But now I'd like to cahe some generic views that I'm using. Here are
the url patterns:

urlpatterns = patterns('django.views.generic.date_based',
(r'^(?P\d{4})/(?P\d{2})/(?P\d{2})/(?P[-\w]+)/
$', 'object_detail', info_dict_month),
(r'^(?P\d{4})/(?P\d{2})/(?P\d{2})/$',
'archive_day',   info_dict_day),
(r'^(?P\d{4})/(?P\d{2})/$', 'archive_month',
info_dict_day),
(r'^(?P\d{4})/$', 'archive_year',  info_dict_list),
(r'^$', 'archive_index', info_dict_index),
)

Would you have any pointer for caching those generic views?

Thanks a lot!

Julien
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Images and Stylesheets

2008-04-12 Thread andy baxter

Greg Lindstrom wrote:
> Hello Everyone-
>
> I started learning Django at PyCon in Chicago and have worked most of 
> the way through the "Django Book" and Sams "Teach Yourself Django", as 
> well as "Head First HTML with CSS and XHTML".  It's been quite a lot 
> for this old dog, but I'd like to take a crack a writing my own web 
> site using Django.  I have two problems, and I think they are 
> related.  The first is how to get images in my site and the next is 
> how to use css.
>
> I wrote Jacob about images and he was kind enough to point me to 
> documentation on how to get the web server to "serve" the images.  I 
> hate to put it this bluntly, but I don't know what that means (I've 
> been programming database applications for 20 years and all this web 
> stuff is still pretty new to me).  Is there something that explains to 
> someone like me how to get images into the site?  Though I'm running 
> Django on my Ubuntu laptop, I would like to eventually have it 
> hosted.  I would like to know how to "do" images locally, then what I 
> need to do when I host my site.
>
> The other problem is getting css to work with my site.  I have set up 
> a base.html template (I love the templates, thank-you) and extend it 
> with other templates, call one greg.html.  The html generates just as 
> I expect it to (overriding blocks just as it should), but it doesn't 
> "see" the style sheet.  One it gets "in" the template I'm OK; the 
> "Head First" book did a pretty good job explaining it.  I even put a 
> syntax error in my view  so Django would list out the settings, but 
> couldn't find where Django is looking for the css file.  I suspect it 
> is a similar problem to the images, but I just don't know.
The basic point here is that while django is good for generating dynamic 
pages which are created in code from a database, it's not so good (quick 
/ reliable / secure) for just serving static pages that don't change. So 
the preferred solution is to have django do the bit it's good at, and 
use a standard webserver to do the static pages (including images and 
css). There is a django module for serving static content, but the docs 
say this should only be used during development, not in your final site.

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Looking for Conferences/Events on Django, Python, MySQL, etc in Europe 2008?

2008-04-12 Thread Nicola Larosa (tekNico)

Simone Brunozzi wrote:
> I'm looking for conferences or events about Django, Dabatases, Mysql,
> PHP, Python, Ruby in Europe in 2008.

The second Italian Python conference, with two talks on Django, one on
Google App Engine, lots of other good stuff, and instant English
translation of many talks: http://www.pycon.it/ .

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