Re: Python 2.6 Decompile --- I lost my views.py but have the views.pyc

2009-12-17 Thread Sean Perry


On Thu Dec 17 11:28 , Bill Freeman  sent:

>I saw a demo of a byte code disassembler once.  It won't get you the
>source code back, but you could conceivably construct equivalent from
>it.  You can, for example, see what it's calling, and sketch out the
>contiditionals and any loops.  You could google for it, or ask on the
>python tutor mailing list.
>

There was decompyle, but the author decided to turn it into a service. Last
released source works on 2.3. You can get it from packages.debian.org or
elsewhere. If the original poster is desperate enough, he could try the service.

unpyc is an attempt to continue decompyle. Apparently it has issues with code
using iterators and still needs work. If anyone out there is interested, all of
the pieces exist it just needs work.

That said, Bill's suggestion of asking on tutor is spot on. That is a fabulous
mailing list for general Python questions. Lots of bright people, some involved
in Python directly, answer there.

--

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




Re: Sick of defining urls

2009-12-03 Thread Sean Perry


On Thu Dec  3  8:42 , Todd Blanchard  sent:

>
>I've read the little poem.  I disagree with about half of it.  If you can't 
>take
constructive criticism of your toolkit (I have plenty negative to say about 
rails
and any of the other dozen web app development environments I know too) then you
should maybe put down the kool-aid and walk away.  No environment is perfect.
>

You are welcomed to disagree with it, all of us hackers view things differently.
That said, understanding what Tim is saying will help you understand Python and
the people who use it. Most of us agree with most of Tim's points. I believe 
this
was mentioned not to tell you to walk away, but that you should learn to use the
tools as intended instead of forcing a screw driver to be a chisel.

Maybe the standard Rails URLs make sense to you. But I suspect many if not most
of the Django projects actually do not have URLs that directly bind to their
internals. Remember it grew up out of reporting where the URLS are dictacted by
other people or even how stories are organized. There is a lot of flexibility in
any URL can go anywhere you want.

Here is the page on Amazon for Learning Python:
http://www.amazon.com/Learning-Python-Animal-Guide-Mark/dp/0596158068/ref=sr_1_1?ie=UTF8=books=1259864161=8-1

That does not map to model/view/blah directly. When amazon decides to use
/books/Oreilly/Python/dp/0596158068 they can and only by adjusting urls.py and
maybe their views indirection routine.

Sure, mapping things directly to code and models is fast for initial 
development.
But real websites do not exist to make the hackers happy. They exist to get 
ideas
out to people who probably have no idea how a website is run, and yeah maybe 
make
some money at the time. Simple urls like 'http://example.com/xmas/toys' do not
come from convention. Now, you may point out that this would be a special 
holiday
thing and easily to add. You'd be right, but the "use pretty URLS" concept is a
driving force behind Django. Giving people simple URLs they can type in, see on 
a
billboard, etc. are the main driving force, not some last minute requirement 
from
Marketing.

Ponder this, consider why Django does what it does. Look at where and who the
focus is. You are free to disagree and do it some other way. But don't assume
Django has somehow missed this or chosen not to because the developers just like
to waste their time typing.



--

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




Re: Any one knows equivalent non php plugin for this?

2009-09-28 Thread Sean Perry



On Mon Sep 28 15:04 , ydjango  sent:

>
>http://www.frontpageslideshow.net/
>
>
>Anyone knows equivalent plugin of above which I can use in python/
>django site.
>
>The plugin above is in jquery and php.

Most of the magic is in the javascript (they use jQuery) and CSS, integrating
that with Django should not be too hard. There may be some hard coded GET's that
you will need to adapt.

They list a whole bunch of sites using this style of slideshow. Grab the
Javascript and HTML and see what is going on.


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



Re: Expression Engine for Django?

2009-01-29 Thread Sean Perry



On Thu Jan 29 13:49 , "maltebeckm...@mac.com"  sent:

>
>I am an Expression Engine (CMS) fan who recently got convinced that
>Python is way cooler than PHP. Problem is that Expression Engine is
>written in PHP.
>
>Is there an Expression Engine for Django, i.e. an installation package
>that can be deployed by people with less development experience?
>
>I am bringing this up because I love what I have seen of Django so
>far! Thanks for reading!
>

Switching this conversation to the users list where it belongs.

There is no Expression Engine interface for Django that I am aware of and a 
quick
google search does not show anything.

Of course, nothing is stopping someone from duplicating the Expression Engine
functionality in Python for Django (-: There are quite a few blogs powered by
Django these days and writing your own is a great learning opportunity


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



Re: advice on table joins

2008-01-10 Thread Sean Perry


Ken wrote:
> I need some advice.  I'm struggling with a query that spans 4 tables.
> "Struggling" is a bad word; I'll explain later.  Django uses a model-
> oriented query system together with a Foreign Key manager to get to
> the "next" joining table.  A query that spans several tables results
> in a deeply nested loop.  Hence, my struggle.  I have an aversion to
> writing deeply nested loops.  It's an indication that I dont quite
> understand my problem.  In SQL, you join the tables you need depending
> on the query and you filter out entries you are interested in with a
> WHERE clause.  It's an idea I'm familiar with; it's "flat", ie, not
> nested.  When I see deeply nested loops, I tend to think recursion.
> But that doesnt work either since at each level, the operation is
> model-specific.  I need some general advice on how folks handle
> queries on joined tables within the django framework.  Since queries
> are model based, is it better to forget about constructing related but
> orthogonal tables and simply throw everything in a model?
> 

I have models: Artist, Track, Album, MultiAlbum (think box set).
Artist.tracks is actually the Django created reverse mapping of 
Track.artist. Once I fully understood the foo__bar__baz notation I found 
it easier to read and create than the equivalent SQL.

The line of code below returns all of the Artists in the chosen 
multi-album where self.title is the box set's title.

Artist.objects.filter(tracks__album__multi__title=self.title).distinct()

Hope this helps. If not, perhaps you have some examples of your own to 
share.

--~--~-~--~~~---~--~~
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 is more?

2008-01-05 Thread Sean Perry

Jeff Anderson wrote:
> Does anyone else use django for a  framework?
> 
> Jeff Anderson
> 

Django is the back end for my home multimedia system (-:

The web interface is nice, but during initial design I have simple 
scripts like the following which plays a random 3 songs from each artist 
in the database.

from audio.models import Artist, Track

while 1:
 for artist in Artist.objects.order_by('?'):
 for track in artist.track_set.all().order_by('?')[:3]:
 try:
 os.system("ogg123 '%s'" % track.fullname())
 except:
 sys.stderr.write("Exception occurred for track %s.\n" % 
track)


Django is still Python and it is quite powerful for that reason.

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



custom ordering on related objects

2007-12-10 Thread Sean Perry

Say we have:

class Foo(models.Model):
 title = models.CharField(max_length=128)
 number = models.PositiveSmallIntegerField()
 bar = models.ForeignKey('Bar')

 class Meta:
 ordering = ['title',]

class Bar(models.Model):
 title = models.CharField(max_length=128)

 class Meta:
 ordering = ['title',]

when I do A.objects.all() I want to sort by title. But when 
B.foo_set.all() I would like to always order by A.number.

It seems like a custom manager is the path here, but there does not 
appear to be a way to define one when defining the relationship.

I know I could have a method on Bar like:

def my_foos(self):
 return self.foo_set.all().order_by('number')

But that means the user of the model has to always remember to use the 
method instead of the related name which to me at least does not seem 
much better than always remembering to use order_by().

Ideas?

Is there a reason why custom managers can not be specified for 
relations? It seems like simply passing related_manager=MyCustomManager 
would work and make sense within the existing framework. Quickly looking 
at Trac I see #3871 with an old patch and no real traction. I'd be 
willing to work with the Django team if this is something that would be 
accepted.

--~--~-~--~~~---~--~~
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: Do away with django's support for python 2.3?

2007-12-01 Thread Sean Perry

AmanKow wrote:
>>  Also, in practice, there are a *lot* of
>> installations still running Python 2.3. Sometimes it's just not
>> convenient to upgrade your Python installation every couple of years.
> 
> I understand that.  But, with 2.6 coming soon and 3.0 on the horizon,
> it seems that continued support of older versions could get
> expensive.  I did a quick search of django tickets for "python 2.3"
> and found over two hundred hits, the vast majority of those dealing
> with compatibility issues with 2.3.  That seems to be a significant
> amount of django work from contributors who could be working on other
> things.

ah and there you prove the point against your suggestion. LOTS of people 
still use Python 2.3. Lots. 2.4 is just now becoming relatively common. 
Most people are not running 2.5.

Remember a lot of Django users use hosting services. It is not trivial 
for many of these people to get the latest and greatest Python.

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



question about custom orderings

2007-11-30 Thread Sean Perry

say I have the following classes:

class Foo(models.Model):
 name = models.CharField(max_length=30)
 number = models.PositiveSmallIntegerField()

 def __unicode__(self):
 return u"%s(%d)" % (self.name, self.number)

 class Meta:
 ordering = ['name',]

class FooCollection(models.Model):
 name = models.CharField(max_length=30)
 foos = models.ManyToManyField(Foo)

 def __unicode__(self):
 return name

When code looks at Foo objects, the expected ordering is by name. But 
when a FooCollection returns its Foo objects I would like them to be 
ordered by their number, not their name.

My first instinct was a custom Manager but I do not know how to specify 
the manager for ManyToMany relations.

Suggestions?

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



Re: Can I run Django on my Sun-Ray?

2007-11-24 Thread Sean Perry

walterbyrd wrote:
> I'm running Solaris 10. I have Python. I am not looking to build a
> production site. Just trying to learn some django during dead time.
> 
> I'm not sure what to do about a database. I don't think I can install
> mysql or postgresql - maybe sqlite.

Django runs on the Nokia web pads. If you can afford 64 - 128MB and have 
some disk space all is well. It of course works in far less memory but 
for real performance more is better.


sqlite is perfectly reasonable until the db is getting a good work out. 
Then you could transition to an external db server.

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



Re: does is_valid handle unique=True

2007-11-09 Thread Sean Perry

Kenneth Gonsalves wrote:
> hi,
> 
> I was using form_for_model with one field which has unique=True. This  
> form passes the is_valid test, but postgres barfs on the duplicate  
> entry - am I doing something wrong, or does is_valid not handle  
> unique=True?

is_valid simply validates that the form data is correct -- a string or 
int depending on what you specified, filled in and not empty, etc.

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



newforms and multiple forms objects in one html form question

2007-11-03 Thread Sean Perry

I have a html form which will create an instance of a model plus its  
m2m relations. So you have something like:

MainModelField1
MainModelField2
MainModelField3
...
m2mModelField1a, m2mModelField1b, m2mModelField1c
m2mModelField2a, m2mModelField2b, m2mModelField2c
...
hidden_count
 

In my view I have code like this:
count = 
m2ms = []
for i in count:
 m2ms.append(m2mModelForm(request.POST, prefix="m2m%d" % i)
main_model_form = MainModelForm(request.POST)

The issue comes when I try to validate the forms. Clearly some of the  
m2m model forms may be empty and this is OK as long as at least some  
(one) of them has data. However the is_valid() will fail since there  
are indeed required fields that are not populated.

My question is how do I differentiate between an invalid form object,  
i.e. one with incomplete data versus one with NO data? I tried  
looking at m2ms[i].data but it has ALL of the fields from  
request.POST so it is not {} as expected. What am I missing?


--~--~-~--~~~---~--~~
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: keeping SECRET_KEY secret

2007-11-03 Thread Sean Perry

On Nov 2, 2007, at 6:02 AM, James Bennett wrote:
> Personally I wonder if this is due to a conception that the *project*
> is somehow the deliverable; I can understand how that conception would
> be easy to form from the documentation, and I've suggested more than
> once that the docs should emphasize applications, mentioning projects
> only as per-installation wrappers for a set of apps being used
> together. If that's what's happening here, it just adds more fuel to
> my campaign against emphasizing projects :)

+2


--~--~-~--~~~---~--~~
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 to implement funky caching

2007-09-22 Thread Sean Perry

On Sep 22, 2007, at 10:26 AM, julian.bash wrote:

>
> Thanks a lot for your answers!
>
> The even greater thing with funky caching is that the webserver only
> has to serve html (if there is a cached version) and doesn't have to
> run django. So, django's normal caching is good, but when the server
> only has to serve already-generated html-files, the whole thing would
> be even faster. If you know the Rails-blog Mephisto, it does exactly
> this.
>
> Julian
>

I understand what you are asking now. But maybe there are other ways  
to get there.

option A:
What if you had a webserver running django at place A and a desire to  
serve pages from location B. You could use a tool like wget to  
recursively mirror your site from A to B. Then run a webserver  
pointing at B and blammo "cached", static pages from relatively un- 
dynamic content.

option B:
using some piece of Django, I think likely a custom middleware,  
output a copy of the requested page to a pre-determined section of  
the filesystem. Then have a piece of middleware that serves those  
static pages over dynamic ones.

I happen to like A because it means almost no changes to the site,  
you get a mirror of the data so this scales to really big sites, etc.  
It also means almost no code has to be written.

Something like this has been discussed on this lists several months  
ago (like maybe 6), sorry I do not remember all of the options  
discussed.

--~--~-~--~~~---~--~~
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: non-event driven method called?

2007-08-23 Thread Sean Perry

On Aug 23, 2007, at 12:12 PM, John Menerick wrote:

> Inside my django app, regardless of the events of my django- 
> application, I would like to call a method every minute.  Since  
> Django is heavily event driven, I'm at a loss as how to make this  
> work.  I'm looking for a way to make this happen.  Any ideas?
>
>

umm, cron?



--~--~-~--~~~---~--~~
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: Row level security

2007-08-20 Thread Sean Perry

On Aug 20, 2007, at 6:41 PM, Catriona wrote:
>
> Hello
>
> Is there a way to implement row level security where a user can
> determine who can do what to particular records - ie invoices? The
> default would be full access only to the creater.
>
> I am looking at implementing a ContactInvoiveRole table but wonder if
> this is the way to go.
>

Personally, I would add a "creator" to the invoice model and check is  
user == creator before allowing any writes. Keep it simple and all that.

Besides, you probably want to know the creator anyways.


--~--~-~--~~~---~--~~
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: url styling

2007-08-10 Thread Sean Perry

On Aug 9, 2007, at 10:21 PM, james_027 wrote:

>
> hi,
>
> is there any advantage or disadvantage or best practices in forming
> urls? like which set are much better?
>
> domain/employee/1
> domain/edit_employee/1
> domain/inactive_employee/1
>
> or
>
> domain/employee/1
> domain/employee/1/edit/
> domain/employee/1/inactive/
>


Better is always subjective. From a technical perspective, here is  
what the URL patterns look like:

a)
simple form
r'domain/(?:(\w+)_)?(\w+)/(\d+)'

one where you get all of the items nicely named:
r'domain/(?:(?P\w+)_)?(?P\w+)/(?P\d+)'

b)
r'domain/(\w+)/(\d+)(?:/(\w+))?'

r'domain/(?P\w+)/(?P\d+)(?:/(?P\w+))?'

I see the first URL set as being function oriented and the second set  
being more object oriented. Just depends on how you prefer to see the  
world I suppose.

Personally, I would probably do the second one.

May I suggest the first choice get turned around slightly:
domain/employee_edit/1
Like I said, I see the first grouping as more functional style and it  
is good practice to name the object first in function names. You end  
up with a regex like this:
r'domain/(?P\w+)(?:_(?P\w+))?/(?P\d+)'
which reads better in my opinion.

BTW, the (?:) syntax lets you group things without adding more items  
to the groupdict result. Purely optional, I just like to be really  
explicit about my regexes.

--~--~-~--~~~---~--~~
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: age in years calculation

2007-08-03 Thread Sean Perry


On Aug 3, 2007, at 9:57 AM, Doug Van Horn wrote:

 def age(d, bday):
> ... return (d.year - bday.year) - \
> ... ((d.month, d.day) < (bday.month, bday.day) and 1 or 0)

Or to be a little more explicit about it:

def age(d, bday):
 return (d.year - bday.year) - \
 int((d.month, d.day) < (bday.month, bday.day))

int(True) => 1, int(False) => 0


--~--~-~--~~~---~--~~
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: Looping through my POST data?

2007-07-28 Thread Sean Perry

On Jul 27, 2007, at 10:36 PM, Greg wrote:
> AssertionError at /rugs/cart/addpad/
> [u'0']
>
> Does that mean that the value is 0?  below is my view function and
> template code:

That little 'u' in front of the '0' means unicode so the value is the  
unicode string "0" not the number zero. Very different as far as  
Python is concerned. You may be used to other scripting languages  
that auto-convert. Python is not one of them.

try:
 num = int(values)
 if num == 0:
 deal_with_zero()
 else:
 deal_with_number(num)
except ValueError:
# hmm, values is a string, not a number
deal_with_a_string(values)

Hope that 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: confusion with ManyToMany relation on self

2006-09-04 Thread Sean Perry

http://code.djangoproject.com/ticket/2653

--~--~-~--~~~---~--~~
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: confusion with ManyToMany relation on self

2006-09-04 Thread Sean Perry

Russell Keith-Magee wrote:
> On 9/4/06, Sean Perry <[EMAIL PROTECTED]> wrote:
>>
>> So according to this, I am doing things correctly and should not get an
>> error. Bug? Code change without document update?
> 
> 
> Yes, this seems to be a bug. The documentation is correct, and agrees with
> the actual model implementation. It looks like the problem is the model
> validator in manage.py being overly vigilant. In addition, it looks like the
> 'invalid_models' unit test doesn't currently check this particular
> condition.
> 
> This should definitely be logged.
> 

I dropped a ticket on Trac, will see if it shows up.

Looking at the code myself, it seems that the problem boils down to 
get_accessor_name(). Most of the django code seems to know not to use 
this method if the relationship is symmetrical. However it is not clear 
from the code is ALL of django honors this.

Perhaps if symmetrical is true get_accessor_name should return None or 
some similarly bogus value. This would also make the test in 
core/management.py work as planned.

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



confusion with ManyToMany relation on self

2006-09-04 Thread Sean Perry

Consider:

class Foo(models.Model):
 related = models.ManyToManyField('self')
 suggestions = models.ManyToManyField('self')

Both should be symmetrical. If A suggests B, B suggests A (for this code 
base anyways).

What I expected to happen is adding B to A would add A to B. Instead I get:

app.foo: Accessor for m2m field 'menu_suggestions' clashes with related 
m2m field 'Foo.foo_set'. Add a related_name argument to the definition 
for 'suggestions'.
app.foo: Accessor for m2m field 'related' clashes with related m2m field 
'Foo.foo_set'. Add a related_name argument to the definition for 'related'.

Doesn't matter whether I set symmetrical to false or true.

The confusion stems from model-api.txt which states:
``symmetrical`` Only used in the definition of ManyToManyFields on self.
 Consider the following model:
class Person(models.Model):
 friends = models.ManyToManyField("self")

  When Django processes this model, it identifies that it has
  a ``ManyToManyField`` on itself, and as a result, it
  doesn't add a ``person_set`` attribute to the ``Person``
  class. Instead, the ``ManyToManyField`` is assumed to be
  symmetrical -- that is, if I am your friend, then you are
  my friend.

  If you do not want symmetry in ``ManyToMany`` relationships
  with ``self``, set ``symmetrical`` to ``False``. This will
  force Django to add the descriptor for the reverse
  relationship, allowing ``ManyToMany`` relationships to be
  non-symmetrical.


So according to this, I am doing things correctly and should not get an 
error. Bug? Code change without document update?

--~--~-~--~~~---~--~~
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: manage.py: error: no such option: -u

2006-09-04 Thread Sean Perry

petrov wrote:
> Hi,
> 
> i am not sure how everyone else does this but here goes.
> 
> I have some sample data in xml. so, i converted added the "insert into
> ...values(..) " format and placed into the myapp/sql/myapp.sql
> 
> at this pont i wanted to clear the table and add the sample data.
> however, doing:
> 
> python manage.py sqlreset myapp > mysql dbname -u username -p
> 
> doesn't work. i get this error: "manage.py: error: no such option: -u"
> 

you mean 'python manage.py sqlreset myapp | mysql dbname -u username 
-p'. Note the | symbol instead of the > symbol. '>' and '<' mean output 
to this file (stdin and stdout count as files). '|' means use the output 
of the first program as the input of the second program.


--~--~-~--~~~---~--~~
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: Rolling my own basic authentication?

2006-08-26 Thread Sean Perry

magus wrote:
> Yes, but "cheapness" is only one of my concerns. I have two bigger
> concerns:
> 
>  1. By limiting the external dependencies (i.e. the number of django
> modules I use) I will lower the risk of being hit by a bug that I don't
> control.
>  2. AFAICS the session is represented by a cookie, for me this is
> totally unnecessary since there will be no session. The webservice will
> have no server-side state to keep track of. Also, there's a lot of
> smart people out there and they keep on comming up with new and
> interesting ways to use session cookies (session hijacking, session
> fixation, etc.).
> 

if you never ask it to set a cookie, no cookie is ever created.

--~--~-~--~~~---~--~~
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: Rolling my own basic authentication?

2006-08-25 Thread Sean Perry

magus wrote:
> I'd like to roll my own basic authentication for a web service, i.e. I
> don't want to use the contrib.auth module. If possible I'd like to
> avoid relying on the server for this. Anyone who can offer some
> pointers on how to raise a 401 on a request that doesn't contain the
> Authentication: header?
> 
> The 401 also needs to contain the realm, how would I do that?
> 

Forgive the possibly stupid question, but why not just use htaccess / 
apache auth? (or insert the method supported by your web server here). 
It is simple, requires almost no code and you will get the user name as 
an environment variable.

Beyond that, look into what Jacob said. The session layer is supposed to 
be cheap if you never ask for anything from 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
-~--~~~~--~~--~--~---



Re: Django Models, DRY, Scalability

2006-08-22 Thread Sean Perry

bayerj wrote:
> As soon as I change my database schema, I have several possibilites to
> get my app up again:
> (a) Change the model. Then drop the current db schema, fire up the new
> one. Drawback: I lose my data.
> (b) Change the model and change the schema manually. Drawback: I am
> repeating myself.
> (c) Make everything right from the start. Drawback: Can only be reached
> asymptotical. (I won't argue about that :)
> 

I have just been dumping the data to a sql file, fixing for the new 
fields and using django initial sql support (myapp/sql/model.sql) to 
import the data each time. Works, is relatively easy and lets me twiddle 
and experiment.

--~--~-~--~~~---~--~~
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: Alternative to PIL (Python Imaging Library)?

2006-07-13 Thread Sean Perry

Carlos Yoder wrote:
>>> Is there a way around PIL? Can Django use another kind of library? If
>>> not, has anyone got around this? Maybe by getting a precompiled Linux
>>> PIL?
> 
>> http://packages.debian.org/unstable/python/python-imaging
>> ?
> 
> Don't think so. I don't have root access to my box in Bluehost. Can
> anythone think of an alternative, short of telling support to install
> it themselves?
> 

Technically all PIL is needed for is determining height, width and what 
not of the image. If you do not need it or can ask the user, then PIL is 
nice but not required. May take a little hacking, but it should be 
feasible to ignore the warning.

Another option is to see if imagemagick / graphicsmagick is installed 
and write a wrapper which uses that instead of PIL. Also feasible and 
should be relatively easy.

--~--~-~--~~~---~--~~
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: Tutorial 2 - Admin

2006-05-03 Thread Sean Perry

Luke Plant wrote:
> On Wednesday 03 May 2006 17:51, Kenneth Gonsalves wrote:
> 
>> when making major upgrades, sometimes old .pyc files remain giving
>> errors like this. Nuking subversion is the best solution
> 
> Or, if you use *nix this will be a bit less drastic and faster:
> 
> find your/django/src/dir -name '*.pyc' | xargs rm
> 
> Luke
> 

or without the pipe: find /path -name '*.pyc' -exec rm {} \;

Note the escaped semicolon.

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



trunk doc confusion

2006-05-03 Thread Sean Perry

Following the new tutorial this morning I ran into a few problems:
* tutorial and other docs go back and forth between Poll and Blog apps. 
Choosing one would be nice.

* __str__ vs __repr__
The tutorial01 says defining __str__ will then cause Model.objects.all() 
to show a human readable string, i.e. Poll.question. But it doesn't. I 
have to define __repr__ or I get the  text instead. __str__ 
does work in the Admin interface as promised though.
 From tutorial02: By default, Django displays the ``repr()`` of 
each object. But it'd be more helpful if we could display individual 
fields.
But it uses __str__ if that is defined.

* the tutorial03 example for urls.py removes the admin site from the 
list. 04 continues this trend of ignoring the Admin urls.

As an aside, when I specify --pythonpath to django-admin startproject it 
would be nice if the resulting manage.py inherited the setting. (Will 
add this one to the bug system).

--~--~-~--~~~---~--~~
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: create models from the admin page?

2006-05-03 Thread Sean Perry

James Bennett wrote:
> Going further, it seems to me that, rather than encouraging the design
> of good, well-thought-out models, building models through a web
> interface would encourage a slapdash "if we get it wrong we'll just go
> into the web interface and change it" mentality, which would be a
> certifiable Bad Thing(TM).
> 

+1,

Besides this only gets you the models and really simple views. Real 
working apps really do need some code. I don't see what the time spent 
on adding models to the admin UI would save long term.

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



db-api.txt bug

2006-05-03 Thread Sean Perry


save_FOO_file(filename, raw_contents)
-

For every ``FileField``, the object will have a ``get_FOO_filename()`` 
method,
where ``FOO`` is the name of the field. This saves the given file to the
filesystem, using the given filename. If a file with the given filename 
already
exists, Django adds an underscore to the end of the filename (but before the
extension) until the filename is available.


That get_FOO_filename should be save_FOO_filename.

--~--~-~--~~~---~--~~
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: Upcoming project... 0.91 or svn or magic-removal?

2006-02-08 Thread Sean Perry


ToddG wrote:

I'm going to be starting a project in the next few weeks, and I was
wondering what people recommend building on at this point. I've been
exploring with the svn of trunk, but I'm not sure on what version of
the codebase would be best to start a "real" project with. Any
suggestions?



You do say "weeks" here. The magic removal branch may well be 0.92 by 
then. If so, start there. Otherwise, go with 0.91 and be ready to shift 
to 0.92.


'magic removal' will become the standard once it is released. Might as 
well plan for it.


Re: rss problem

2006-01-26 Thread Sean Perry


While on the subject, my Nokia 770's RSS reader always believes there 
are new versions available of the main Django and the Django community 
blogs.


Re: making photo gallery

2006-01-05 Thread Sean Perry


Sean Perry wrote:


Kevin wrote:


return map(*([None] + [value[i::cols] for i in range(0,
cols)]))



Nice, but why use all of that magic?

return [value[i:i+cols] for i in range(0, len(value), 4)]

your version actually returns [(1,2), (3,4)], iow a list of tuples.



where that last 4 is 'cols'. pasted my test version, doh.



Re: making photo gallery

2006-01-05 Thread Sean Perry


Kevin wrote:

return map(*([None] + [value[i::cols] for i in range(0,
cols)]))


Nice, but why use all of that magic?

return [value[i:i+cols] for i in range(0, len(value), 4)]

your version actually returns [(1,2), (3,4)], iow a list of tuples.



Re: understanding regroup

2005-11-15 Thread Sean Perry


Robert Wittams wrote:

Would:

{% regroup user.get_thing_list|dictsort:"category_id" by category_id as
grouped %}
 {% for category in grouped %}
 
 {{ category.list.0.get_category.description }}
 {% for entry in category.list %}
 
 {% endfor %}
 
 {% endfor %}

work?



looks promising, I had no idea that I could do that. Seems a bit heavy 
handed. Will play around it with it some more, see how I feel about it. 
I also plan to try adding code to the view, see how that works out too. 
Maybe the answer is I end up coding some custom template stuff and 
sending in some patches. Or maybe there is another way hiding under a 
different rock.