Thursday, September 30, 2010

Re: Possible backwards incompatibility introduced by change 12950 (in upgrade from 1.1.1 to 1.1.2)

On Oct 1, 3:30 am, Russell Keith-Magee <russ...@keith-magee.com>
wrote:
> Not really -- I've tried to reproduce the 2 apps and three models you
> describe, but I don't see any errors on 1.1.1 or 1.1.2.
>
> I appreciate that you can't release your actual source code, but if
> you can generate a minimal test app that reproduces the problem case,
> that would be very helpful.
>
> As I said on twitter, this general class of problem is something we've
> seen before; however, in all the cases we've been able to identify so
> far, it's turned out to be a legitimate error that Django was
> historically (and erroneously) suppressing. Yes, 1.1.2 generates more
> errors, but that's because 1.1.1 masked legitimate errors, not because
> 1.1.2 is broken.
>
> If you can provide a test case that demonstrates otherwise, we're
> happy to investigate.

I managed to create a simulation of the situation (I suggest hitting
the download button or using git, it seems to give the correct
directory structure, the gist is a bit fubar as it doesn't appreciate
directories):

http://gist.github.com/605838

Seems to work exactly like our system does: If the app is started
via ./manage.py runserver it starts up fine and displays the 404. The
admin works fine and I can edit the model C just fine there. However,
if I try to run the runner.py provided in the root directory the
'foobar' newer gets printed and instead the app crashes to an import
error. This is why I'm suspecting there's some difference with the
order of importing stuff and manage.py seems to get the order right.

If I checkout Django version pre-12950 both the admin and runner.py
work just fine (as the ImportError gets swallowed).

- Jyrki

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: UnicodeEncodeError

On Wed, Sep 29, 2010 at 5:32 PM, werefr0g <werefr0g@yahoo.fr> wrote:
Sorry, sorry.... I proposed Jean to send me the actual file to check its encoding. I asked for his OS too in order to see what editor are available and how it allows to "transcode" the text.

Not the contents of the file is irrelevant to this problem: it is the file's name that is causing the problem. The last bit of the traceback is:

 File "/usr/languages/python/2.6/lib/python2.6/genericpath.py", line 18, in exists
   st = os.stat(path)

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in position 53: ordinal not in range(128)

"path" here includes the file name, no file data is involved. Django is passing a unicode string "path" to the os.stat() function. On many operating systems, Python must actually pass a bytestring, not unicode, to the underlying OS routine that implements "stat".  Therefore Python must convert the unicode string to a bytestring using some encoding. The encoding it uses is whatever is returned by os.getfilesystemencoding: http://docs.python.org/library/sys.html#sys.getfilesystemencoding. As noted in that documentation, on Unix the encoding will be:

... the user's preference according to the result of nl_langinfo(CODESET), or None if the nl_langinfo(CODESET) failed.

That's a pretty obscure description but it boils down to the encoding associated with the currently set locale. (And on some systems successfully setting a locale with an encoding like utf-8 requires installing some "extra" language packs.) So the key to fixing this problem is to ensure the locale of the running server is successfully set to one with an encoding such as utf-8, which supports (can encode) the full range of unicode values. Unfortunately details on setting locales differs from machine to machine so it is hard to give specific instructions here.

Karen
--
http://tracey.org/kmt/

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: template syntax errors in production admin site (version problem?)

On Thu, Sep 30, 2010 at 12:39 PM, bobbymanuel <bobby.manuel@gmail.com> wrote:
PROBLEM SOLVED:  upgrade to Python 2.7 on server resolved issue.
Apparrently Django 1.2.3 is not fully compatible with Python 2.5

I suspect it is your application code, not Django 1.2.3, that is not compatible with Python 2.5. The error you mentioned above was:

TemplateSyntaxError at /admin/
In template /usr/lib/python2.5/site-packages/django/contrib/admin/templates/admin/base.html, error at line 31
Caught SyntaxError while rendering: invalid syntax (views.py, line 52)

This is saying that line 52 of a views.py file is where the Python syntax error was encountered.My guess is you have some code on line 52 in some views.py file in your project that uses Python syntax that was not allowed in Python 2.5.

Why was that line even getting referenced from an attempt to load /admin/? Line 31 of the admin/base.html template is:

31                      {% url django-admindocs-docroot as docsroot %}

This {% url %} tag (any {% url %} tag) will cause all of your project's url patterns to get loaded, which will often lead to importing your project's view code.

Karen
--
http://tracey.org/kmt/

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

QuerySet values + annotate + order_by

The background here is that I am trying to modify django-voting to
sort the objects by score, but this is a general question.

The following code works minus the order_by statement on the end:

queryset = self.filter(
object_id__in = object_ids,
content_type = ctype,
).values(
'object_id',
).annotate(
score = CoalesceSum('vote', default='0'),
num_votes = CoalesceCount('vote', default='0'),
).order_by('score')

Without the order_by statement, I get the following result:

[{'score': 1, 'object_id': 2, 'num_votes': 1}, {'score': -1,
'object_id': 3, 'num_votes': 1}, {'score': 1, 'object_id': 4,
'num_votes': 1}]

but when adding order_by, I get the following error:

FieldError: Cannot resolve keyword 'score' into field. Choices are:
content_type
, id, object_id, user, vote

The choices listed belong to the "Vote" model. But why aren't the
available choices 'object_id' (from the values statement) and 'score'
and 'num_votes' (from the annotate statement)? I thought you could do
an order by anything in an annotate statement.

Thanks,
Scott

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Full Text Search

On 9/30/2010 8:26 PM, Nick Arnett wrote:
> Brain is mush, though.

Obviously, otherwise you'd have left it in the hope that someone else
would reply with an answer before you recovered consciousness. Great
heavens, this community is *so* anxious to help. Kudos for trying with a
frazzled brain!

regards
Steve
--
DjangoCon US 2010 September 7-9 http://djangocon.us/

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

Re: Possible backwards incompatibility introduced by change 12950 (in upgrade from 1.1.1 to 1.1.2)

On Thu, Sep 30, 2010 at 8:01 PM, Jyrki Pulliainen <jyrki@dywypi.org> wrote:
> Hi!
>
> We encountered a possible backwards incompatibility with change 12950
> [1]. This was noticed when upgrading from 1.1.1 to 1.1.2.
>
> If I understand correctly the change 12950 removes squelching of
> ImportErrors from AppCache. AppCache in turn provides reverse-
> relations for app introspection, for example in admin interface. This
> change now causes the ImportError in one otherwise fine case to
> propagate and break the application.
>
> Funnily enough, this does not break our application per se. The webapp
> still continues to work with admin interface fully responsive, doing
> all the changes wanted, tests passing etc. This only affects a smaller
> worker script that is run via upstart.
>
> This upstart script imported a single model class (let's say, model
> class A) from a single app. However, this models.py file also had
> another model (class C) and it's admin definitions (there was actually
> no change even if these were moved to separate admin.py, we have a
> custom AdminSite object). For some reason importing this single caused
> the import error to fire. And as said before this behavior doesn't
> surface for example when running ./manage.py runserver, only trying to
> start the worker script causes the ImportError.
>
> Unfortunately this software isn't open source, but I think I can
> describe the module layout a bit though:
>
> Class A -- the "troublemaker" class has a reverse relationship with
> class B from another app, ie. class B has ForeignKeyField to A.
> Neither of these classes has any admin interface and they're not
> registered to the admin site object
> Class C -- another model in the same models.py (and app) as Class A.
> This is registed to the AdminSite.
>
> Now, when the worker starts the importing of class A causes
> ImportError due to the admin site trying to import stuff in AppCache,
> even it is not needed. The models.py it is trying to import when
> crashing is the models.py containing the Class B.
>
> Hopefully this description is even a bit helpful, even though it's a
> hard to get the whole picture without the code.

Not really -- I've tried to reproduce the 2 apps and three models you
describe, but I don't see any errors on 1.1.1 or 1.1.2.

I appreciate that you can't release your actual source code, but if
you can generate a minimal test app that reproduces the problem case,
that would be very helpful.

As I said on twitter, this general class of problem is something we've
seen before; however, in all the cases we've been able to identify so
far, it's turned out to be a legitimate error that Django was
historically (and erroneously) suppressing. Yes, 1.1.2 generates more
errors, but that's because 1.1.1 masked legitimate errors, not because
1.1.2 is broken.

If you can provide a test case that demonstrates otherwise, we're
happy to investigate.

Yours,
Russ Magee %-)

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

Re: Full Text Search



On Thu, Sep 30, 2010 at 8:34 AM, Alessandro Ronchi <alessandro.ronchi@soasi.com> wrote:
Is there any way to make a FULL TEXT search not in BOOLEAN MODE?
I've found only
http://docs.djangoproject.com/en/1.1/ref/models/querysets/#search

It says it uses BOOLEAN MODE as a default, but doesn't tell how to
avoid default..

Um, I hate to do this, but for the moment, I'm going to tell you "yes" - but I can't remember how right now.  Been awake for 30 hours and waiting for a plane to take me home!  Did a demo today for a big client, involving Django/MySQL full text and parametric search and they loved it... so it's on my mind.  If you don't get a real answer by tomorrow afternoon, I may be conscious again then.  You have to use one of the alternative approaches to search, as I recall.  Brain is mush, though.

Nick 

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

URL's and Multi Dimensional Filtering/Searching

Hi all,

I have a table with a list of data that I would like present to a user
and allow them to drill down into the data, but there are multiple
dimensions they may want to drill down into and I am not sure the best
way to do this with DJango URLs.

To give a bit of an example of what I am trying to do, say I have a
table of events which stores some information over time. I have
presented what I think is a reasonable way of designing URL's for
this.

Notice that this is basically single dimensional data, where the
dimension is time over which the data is to be presented:

/events/ (Lists all events over all time)
/events/YYYY-MM-DD/ (Lists all events since date)
/events/YYYY-MM-DD/YYYY-MM-DD/ (Lists all events in time range)

Also I want to allow users to optionally specify a offset + size to
any of the above so they can manually paginate the data (This is an
XML API). I am thinking the cleanest way to do this is allow optional
GET params like:
/events/?offset=0&size=100
/events/YYYY-MM-DD/?offset=0&size=100
/events/YYYY-MM-DD/YYYY-MM-DD/?offset=0&size=100

Now the tricky part comes if i want to filter on another dimension in
the data. Lets say the event is generated from a department within a
company. So we might have something like:

class Event(models.Model):
timestamp = models.DateTimeField()
company = models.CharField(max_length=128)
department = models.CharField(max_length=128)
event = models.CharField(max_length=128)

Now I was thinking of doing something like:
/events/ (Lists all events over all time, for all companies and departments)
/events/YYYY-MM-DD/ (Lists all events since date, for all companies
and departments)
/events/YYYY-MM-DD/YYYY-MM-DD/ (Lists all events in time range, for
all companies and departments)

/events/<company>/ (Lists all events over all time, for all
departments of the given company)
/events/<company>/YYYY-MM-DD/ (Lists all events since date, for all
departments of the given company)
/events/<company>/YYYY-MM-DD/YYYY-MM-DD/ (Lists all events in time
range, for all departments of the given company)

/events/<company>/<department>/ (Lists all events over all time, for
the specific department in a company)
/events/<company>/<department>/YYYY-MM-DD/ (Lists all events since
date, for the specific department in a company)
/events/<company>/<department>/YYYY-MM-DD/YYYY-MM-DD/ (Lists all
events in time range, for the specific department in a company)

Now because YYY-MM-DD is a valid company name, this scheme breaks.

Is there a more general or better way to do something like this?

Thanks,
Brendon.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Can you make a subclass of a model just to alter behavior?

On Fri, Oct 1, 2010 at 2:57 AM, orokusaki <flashdesignpro@gmail.com> wrote:
> I'm looking to do the opposite of what Django's proxy model does. I
> want to subclass Model, add some extra methods to it, add behavior to
> save(), set a default manager that adds some my-application-specific
> methods, and then subclass that to create most of the models in my
> application. Is this possible?

Sounds like you're asking for an abstract base class. Set
abstract=True instead of proxy=True; only the subclasses will be
instantiated as full Django models, but they will inherit all the
methods, managers and fields of their parent.

Yours,
Russ Magee %-)

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

Re: Tabular output

Yes, I know, but what I doesn't know, is how to create these cells when
the for loop ends.


<table id="gallery_images">
<tr>
{% for image in gallery.image_set.all %}
{% if forloop.counter0|divisibleby:gallery_cols %}
</tr>
<tr>
{% endif %}
<td>
<img ...>
</td>
{% endfor %}
</tr>
</table>

Martin


On Thu, 30 Sep 2010 15:29:58 +0200, aid <aid@logic.org.uk> wrote:

>
>
> On Sep 30, 2:14 pm, Martin Tiršel <dja...@blackpage.eu> wrote:
>> Sorry, my bad, I thought that it has to be completed, so it is ok.
>> Problem would be only if I wanted to make cell borderds, around the
>> empty cells too.
>
> For the cells you don't have an <img> object to insert; try inserting
> '&nbsp;' instead. (Minus quotes!) This tends to solve the border
> problems.
>
> Cheers,
>
> aid

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Key based session expiration

Hi there!

I want my registered users to authenticate again to access some parts of my website but without setting the whole session expiration on browser close (which is done by setting set_expiry(0) if I got it correctly).

Let's say that the section I want to secure again is http://domain.tld/users/vault/ I've set my vault view to require a 'has_vault_access' session key and if not, user is redirected to a vault_auth view which asks the user for is password before granting the session key.

The problem is I'd like this key to expire on browser close but just that key and not the whole user session because I'd like my user to stay connected as they would without that vault access thing.

So my questions are :

- Am I thinking correctly with this implementation of my "vault"?
- How can I set a session key to have a different expiration method than the whole session it belongs to?

Thanks in advance for your help,
Thomas Gautier.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

what describes an url?

Hi there!

I have a question about the urls.
What set of attributes of RegexURLPattern makes a "primary key" of all
the url patterns among applications in a Django project? (notice the
"" signs)

what i mean is: what is the minimal set of attributes of
RegexURLPattern that is sufficient to unambiguously describe all
urlpatterns in a Django project.

what im trying to make is an app that can show MyModel object on a
PAGE of other models/apps e.g on /page/A/. and i would like to
associate those two in an unobtrusive way. so i thought i can store in
MyModel some attributes of an url object so that i can resolve '/page/
A/' get some RegexURLPattern attributes and then search for an
appropriate MyModel object.

Is this even clear :/ ?

Regards

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Separating application media from project media

If the ideal solution for you is different sites, one authentication,
I found a reference in...
http://stackoverflow.com/questions/556907/how-to-get-distinct-django-apps-on-same-subdomain-to-share-session-cookie

...pointing to a "django-cas" application that is meant for that
purpose (Single Sign-On).
http://code.google.com/p/django-cas/

You could give it a try. (Disclaimer: didn't try it myself)


On 30 Set, 10:32, Benedict Verheyen <benedict.verhe...@gmail.com>
wrote:
> Anyway, i was able to put the templates and media in the application
> in the end but since it was so much trouble, it probably means it's not
> the way to go. If you want code on how i did it, shoot and I'll post it here.
> There are only 2 things why i want to keep this code structure:
> - the central login shared among applications
> - if feels cleaner to share code if you're working with applications instead of
>    projects.
>
> If i could do the login across projects, i would go for 1 application = 1 project.
>

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Need opinion for an object permission rule backend

Thanks, I already got that :) 

I misunderstood the license, regards
Miguel Araujo

2010/9/30 Steve Holden <holdenweb@gmail.com>
On 9/30/2010 1:55 PM, Miguel Araujo wrote:
> Hi Michael,
>
> I have been looking at your project, django.extauth and I have to say I
> really like its architecture and permission handling. I have to say that
> my rule system is kind of the same thing of your role system, except
> mine is less flexible. I'm going to look a little bit the code, install
> it and see if I can help you with anything.
>
> Only thing that cached my eye is that code is Copyrighted. Why not using
> an Open-source license?
>
There is a copyright on Python itself.  This doesn't stop it being
distributed under an open source license.

regards
 Steve
--
DjangoCon US 2010 September 7-9 http://djangocon.us/

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


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

Re: Can you make a subclass of a model just to alter behavior?

>
> Hmm.. I can't think of any caveats off the top of my head. Did you try that?
> The only thing that smells a little like trouble to me is setting a
> default manager.

If you create a custom manager, then add it to each model as "objects," then it'll be the default (and only) manager and any code that expects a manager to be named 'objects' will work seamlessly.

Shawn

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

Re: Change auth User display name in admin interface

On Sep 30, 6:34 pm, Nathan <nathanwsulli...@gmail.com> wrote:
> I'm using the django User authentication.
>
> I have a model that has a ManyToManyField which allows you to select
> several users to associate with that model. In the django admin site,
> it's set to use the filter_horizontal option.
>
> When adding a new instance of the model through the admin interface,
> it shows you the username of the User. I would like it to show the
> first_name and last_name instead. I tried using a Proxy Model and
> changing the __unicode__(self) with no success, it still shows the
> username in the admin site. I also tried inheriting from the User
> class, but it did not work either and I would rather not do it that
> way.
>
> I'm a relative noob at django, so I could very easily be missing
> something simple. Any suggestions?

The proxy model didn't work because Django has no way of knowing you
want the proxy class, rather than the base User class.

There's a hook in ModelAdmin to that allows you to specify this sort
of thing - formfield_for_foreignkey. See the documentation here:
http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey
You could almost use that example exactly, returning your proxy class
in the queryset kwarg.
--
DR.

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

Re: Can you make a subclass of a model just to alter behavior?

El 30/09/10 15:57, orokusaki escribió:
> I'm looking to do the opposite of what Django's proxy model does. I
> want to subclass Model, add some extra methods to it, add behavior to
> save(), set a default manager that adds some my-application-specific
> methods, and then subclass that to create most of the models in my
> application. Is this possible?
>

Hmm.. I can't think of any caveats off the top of my head. Did you try that?
The only thing that smells a little like trouble to me is setting a
default manager.

--
Gonzalo Delgado <gonzalodel@gmail.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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Need opinion for an object permission rule backend

On 9/30/2010 1:55 PM, Miguel Araujo wrote:
> Hi Michael,
>
> I have been looking at your project, django.extauth and I have to say I
> really like its architecture and permission handling. I have to say that
> my rule system is kind of the same thing of your role system, except
> mine is less flexible. I'm going to look a little bit the code, install
> it and see if I can help you with anything.
>
> Only thing that cached my eye is that code is Copyrighted. Why not using
> an Open-source license?
>
There is a copyright on Python itself. This doesn't stop it being
distributed under an open source license.

regards
Steve
--
DjangoCon US 2010 September 7-9 http://djangocon.us/

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

Can you make a subclass of a model just to alter behavior?

I'm looking to do the opposite of what Django's proxy model does. I
want to subclass Model, add some extra methods to it, add behavior to
save(), set a default manager that adds some my-application-specific
methods, and then subclass that to create most of the models in my
application. Is this possible?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Need opinion for an object permission rule backend

Sorry, I misunderstood it. Then everything looks great

2010/9/30 mhall119 <mhall119@gmail.com>
The license is a 3-clause BSD style license, it's compatible with
Django's license as far as I know.

On Sep 30, 1:55 pm, Miguel Araujo <muchoch...@gmail.com> wrote:
> Hi Michael,
>
> I have been looking at your project, django.extauth and I have to say I
> really like its architecture and permission handling. I have to say that my
> rule system is kind of the same thing of your role system, except mine is
> less flexible. I'm going to look a little bit the code, install it and see
> if I can help you with anything.
>
> Only thing that cached my eye is that code is Copyrighted. Why not using an
> Open-source license?
>
> Thanks for your mail, regards
> Miguel Araujo
>
> 2010/9/30 mhall119 <mhall...@gmail.com>
>
>
>
> > I've recently open-sourced some code that I developed for my work
> > projects that may do at least part of what you need:
> >http://bitbucket.org/mhall119/django-extauth/wiki/Home
>
> > The basic idea is that you define a "role" that is a relationship
> > between a user and an instance of a given Model.  With your example,
> > you would created an "owner" role for your model, that somehow links
> > the user instance to the model instance.  Usually you do this directly
> > via a ForeignKey in your model, but they can be as complex as you want
> > them to be.
>
> > On Sep 30, 9:50 am, Miguel Araujo <muchoch...@gmail.com> wrote:
> > >  Hi everyone,
>
> > > I have been recently thinking about an object permission system. After
> > > reviewing Florian Apolloner (apollo13) patch for ticket
> > > #11010<http://code.djangoproject.com/ticket/11010> and
> > > reading his article at Django
> > > Advent<http://djangoadvent.com/1.2/object-permissions/>.
> > > I though about creating an Object Permission Rule Backend. The purpose of
> > > this message is explain you my idea, so I can receive feedback from
> > Django
> > > users and developers. This way I would like to discern if it's worth
> > coding
> > > it or if it's a good approach to a reusable solution.
>
> > > I will reuse apollo's code to elaborate my idea. My Backend would look
> > > similar to:
>
> > > class ObjectPermBackend(object):
> > >     supports_object_permissions = True
> > >     supports_anonymous_user = True
>
> > >     def authenticate(self, username, password):
> > >         return None
>
> > >     def has_perm(self, user_obj, perm, obj=None):
> > >         if not user_obj.is_authenticated():
> > >             user_obj = User.objects.get(pk=settings.ANONYMOUS_USER_ID)
>
> > >         if obj is None:
> > >             return False
>
> > >         ct = ContentType.objects.get_for_model(obj)
>
> > >         try:
> > >             perm = perm.split('.')[-1].split('_')[0]
> > >         except IndexError:
> > >             return False
>
> > > # Simplified rule system
> > >         # Of course objects should extend an interface
> > > if (perm == "ownage")
> > > return obj.is_owned_by(user_obj)
>
> > > elif (perm == "edit")
> > > return obj.can_be_edited_by(user_obj)
>
> > > # Here be Dragons
>
> > > As I love decorators, I would like to create a permission_required
> > decorator
> > > that accepted more than a parameter, so:
>
> > > @permission_required('app.code_name') would
> > > become @permission_required('app.code_name', FLAG)
>
> > > If the FLAG is set the decorator searches in the model associated to the
> > > content type of the permission, for the name of the field for the PK. For
> > > the example imagine idArticle. Now it instantiates an object of that
> > model
> > > with Model.objects.get(pk=request.idArticle). So it would be necessary to
> > > match request parameters to model fileds (This is the best idea I've come
> > up
> > > with). Once it has the right object, it passes it to the backend for
> > > permission checks.
>
> > > I know I could do a decorator like @own_article but I'm looking for a
> > more
> > > reusable solution, that I would make open source and release at Github.
>
> > > What do you think? Is it feasible and well laid out?
>
> > > Thanks, best regards
> > > Miguel Araujo
>
> > --
> > 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+unsubscribe@googlegroups.com<django-users%2Bunsubscribe@google groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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


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

Re: Need opinion for an object permission rule backend

The license is a 3-clause BSD style license, it's compatible with
Django's license as far as I know.

On Sep 30, 1:55 pm, Miguel Araujo <muchoch...@gmail.com> wrote:
> Hi Michael,
>
> I have been looking at your project, django.extauth and I have to say I
> really like its architecture and permission handling. I have to say that my
> rule system is kind of the same thing of your role system, except mine is
> less flexible. I'm going to look a little bit the code, install it and see
> if I can help you with anything.
>
> Only thing that cached my eye is that code is Copyrighted. Why not using an
> Open-source license?
>
> Thanks for your mail, regards
> Miguel Araujo
>
> 2010/9/30 mhall119 <mhall...@gmail.com>
>
>
>
> > I've recently open-sourced some code that I developed for my work
> > projects that may do at least part of what you need:
> >http://bitbucket.org/mhall119/django-extauth/wiki/Home
>
> > The basic idea is that you define a "role" that is a relationship
> > between a user and an instance of a given Model.  With your example,
> > you would created an "owner" role for your model, that somehow links
> > the user instance to the model instance.  Usually you do this directly
> > via a ForeignKey in your model, but they can be as complex as you want
> > them to be.
>
> > On Sep 30, 9:50 am, Miguel Araujo <muchoch...@gmail.com> wrote:
> > >  Hi everyone,
>
> > > I have been recently thinking about an object permission system. After
> > > reviewing Florian Apolloner (apollo13) patch for ticket
> > > #11010<http://code.djangoproject.com/ticket/11010> and
> > > reading his article at Django
> > > Advent<http://djangoadvent.com/1.2/object-permissions/>.
> > > I though about creating an Object Permission Rule Backend. The purpose of
> > > this message is explain you my idea, so I can receive feedback from
> > Django
> > > users and developers. This way I would like to discern if it's worth
> > coding
> > > it or if it's a good approach to a reusable solution.
>
> > > I will reuse apollo's code to elaborate my idea. My Backend would look
> > > similar to:
>
> > > class ObjectPermBackend(object):
> > >     supports_object_permissions = True
> > >     supports_anonymous_user = True
>
> > >     def authenticate(self, username, password):
> > >         return None
>
> > >     def has_perm(self, user_obj, perm, obj=None):
> > >         if not user_obj.is_authenticated():
> > >             user_obj = User.objects.get(pk=settings.ANONYMOUS_USER_ID)
>
> > >         if obj is None:
> > >             return False
>
> > >         ct = ContentType.objects.get_for_model(obj)
>
> > >         try:
> > >             perm = perm.split('.')[-1].split('_')[0]
> > >         except IndexError:
> > >             return False
>
> > > # Simplified rule system
> > >         # Of course objects should extend an interface
> > > if (perm == "ownage")
> > > return obj.is_owned_by(user_obj)
>
> > > elif (perm == "edit")
> > > return obj.can_be_edited_by(user_obj)
>
> > > # Here be Dragons
>
> > > As I love decorators, I would like to create a permission_required
> > decorator
> > > that accepted more than a parameter, so:
>
> > > @permission_required('app.code_name') would
> > > become @permission_required('app.code_name', FLAG)
>
> > > If the FLAG is set the decorator searches in the model associated to the
> > > content type of the permission, for the name of the field for the PK. For
> > > the example imagine idArticle. Now it instantiates an object of that
> > model
> > > with Model.objects.get(pk=request.idArticle). So it would be necessary to
> > > match request parameters to model fileds (This is the best idea I've come
> > up
> > > with). Once it has the right object, it passes it to the backend for
> > > permission checks.
>
> > > I know I could do a decorator like @own_article but I'm looking for a
> > more
> > > reusable solution, that I would make open source and release at Github.
>
> > > What do you think? Is it feasible and well laid out?
>
> > > Thanks, best regards
> > > Miguel Araujo
>
> > --
> > 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+unsubscribe@googlegroups.com<django-users%2Bunsubscribe@google groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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

Re: Need opinion for an object permission rule backend

Hi Michael,

I have been looking at your project, django.extauth and I have to say I really like its architecture and permission handling. I have to say that my rule system is kind of the same thing of your role system, except mine is less flexible. I'm going to look a little bit the code, install it and see if I can help you with anything.

Only thing that cached my eye is that code is Copyrighted. Why not using an Open-source license? 

Thanks for your mail, regards
Miguel Araujo

2010/9/30 mhall119 <mhall119@gmail.com>
I've recently open-sourced some code that I developed for my work
projects that may do at least part of what you need:
http://bitbucket.org/mhall119/django-extauth/wiki/Home

The basic idea is that you define a "role" that is a relationship
between a user and an instance of a given Model.  With your example,
you would created an "owner" role for your model, that somehow links
the user instance to the model instance.  Usually you do this directly
via a ForeignKey in your model, but they can be as complex as you want
them to be.

On Sep 30, 9:50 am, Miguel Araujo <muchoch...@gmail.com> wrote:
>  Hi everyone,
>
> I have been recently thinking about an object permission system. After
> reviewing Florian Apolloner (apollo13) patch for ticket
> #11010<http://code.djangoproject.com/ticket/11010> and
> reading his article at Django
> Advent<http://djangoadvent.com/1.2/object-permissions/>.
> I though about creating an Object Permission Rule Backend. The purpose of
> this message is explain you my idea, so I can receive feedback from Django
> users and developers. This way I would like to discern if it's worth coding
> it or if it's a good approach to a reusable solution.
>
> I will reuse apollo's code to elaborate my idea. My Backend would look
> similar to:
>
> class ObjectPermBackend(object):
>     supports_object_permissions = True
>     supports_anonymous_user = True
>
>     def authenticate(self, username, password):
>         return None
>
>     def has_perm(self, user_obj, perm, obj=None):
>         if not user_obj.is_authenticated():
>             user_obj = User.objects.get(pk=settings.ANONYMOUS_USER_ID)
>
>         if obj is None:
>             return False
>
>         ct = ContentType.objects.get_for_model(obj)
>
>         try:
>             perm = perm.split('.')[-1].split('_')[0]
>         except IndexError:
>             return False
>
> # Simplified rule system
>         # Of course objects should extend an interface
> if (perm == "ownage")
> return obj.is_owned_by(user_obj)
>
> elif (perm == "edit")
> return obj.can_be_edited_by(user_obj)
>
> # Here be Dragons
>
> As I love decorators, I would like to create a permission_required decorator
> that accepted more than a parameter, so:
>
> @permission_required('app.code_name') would
> become @permission_required('app.code_name', FLAG)
>
> If the FLAG is set the decorator searches in the model associated to the
> content type of the permission, for the name of the field for the PK. For
> the example imagine idArticle. Now it instantiates an object of that model
> with Model.objects.get(pk=request.idArticle). So it would be necessary to
> match request parameters to model fileds (This is the best idea I've come up
> with). Once it has the right object, it passes it to the backend for
> permission checks.
>
> I know I could do a decorator like @own_article but I'm looking for a more
> reusable solution, that I would make open source and release at Github.
>
> What do you think? Is it feasible and well laid out?
>
> Thanks, best regards
> Miguel Araujo

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


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

Change auth User display name in admin interface

I'm using the django User authentication.

I have a model that has a ManyToManyField which allows you to select
several users to associate with that model. In the django admin site,
it's set to use the filter_horizontal option.

When adding a new instance of the model through the admin interface,
it shows you the username of the User. I would like it to show the
first_name and last_name instead. I tried using a Proxy Model and
changing the __unicode__(self) with no success, it still shows the
username in the admin site. I also tried inheriting from the User
class, but it did not work either and I would rather not do it that
way.

I'm a relative noob at django, so I could very easily be missing
something simple. Any 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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

PgWest Talk descriptions are up

Hello,

The talk descriptions for PostgreSQL Conference West 2010 are up,
including a healthy dose of Django content.

https://www.postgresqlconference.org/2010/west/talks

JD
--
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

contrib-admin in a multiuser environment is a bit scary

I've been having bad dreams about the ways in which contrib-admin can
eat your data when you have more than one administrator.

As a worst-case scenario imagine a model with some list_editable
fields:

Admin1 has the changelist open for a considerable length of time
Admin2 makes a load of changes
Admin1 makes one change and wipes all of Admin2's changes (at least
for the number of items specified in ModelAdmin.list_per_page which is
100 by default)

How do other people handle these issues? This must have bitten someone
severely by now?

There isn't much in Trac about this. I found:
http://code.djangoproject.com/ticket/11652
http://code.djangoproject.com/ticket/11313

At the very least there should be giant warnings in letters of flame
in the admin docs.

Has anyone looked into:

a) Optimistic locking for changelist and change forms
b) modifying list_editable to only save the instances that have
changed

or anything similar?

Andy

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Unable to login to admin site in localhost

As reported on :http://stackoverflow.com/questions/3817808/unable-to-
login-to-admin-site-in-localhost

I can't login to the admin site on localhost.

I try with firefox, IE.

I try using the 127.0.0.1:8000 address. Also, I set the
SESSION_COOKIE_DOMAIN to localhost, localhost:8000

I change the host file to:

127.0.0.1 test.com
and set:

SESSION_COOKIE_DOMAIN = 'test.com'

I can login in production (only after the SESSION_COOKIE_DOMAIN
configuration).

I'm using django rev 1.0.1. I can't upgrade to last trunk. The best,
is move to 1.0.2 (I use byteflow and multilingual, and not work with
new trunk)

I try adding to the host file my public domain, and not works (ie:
127.0.0.1 www.mysite.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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Directing User to specific page after login

I was going to mention passing a next variable, but Jurgen responded with a cleaner global solution (:

Learn something new every day.


On Thu, Sep 30, 2010 at 11:59 AM, octopusgrabbus <old_road_farm@verizon.net> wrote:
I am looking for either programming samples or specific documentation
that show how a user is redirected to a page specific to that user,
after login. Given I am just starting out with Django, if this is
really advanced, then I'll settle for getting people logged in and
give them the same page.

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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


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

Re: Django app that uploads media files and servers them through a view?

Hi,

Although I haven't done it, the following link may give you a good overview of how to do it:
http://kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/

Regards,
Xavier.

Le 30 sept. 2010 à 13:34, Thomas Weholt a écrit :

> On Thu, Sep 30, 2010 at 1:20 PM, Stodge <stodge@gmail.com> wrote:
>> Is anyone aware of a Django app that lets you upload media files (not
>> necessarily in the admin site) but serves them through a view instead
>> of as static files via the web server? I need to control access to the
>> media using permissions. Thanks
>
> Serving media using views are very inefficient, but I`m facing the
> same problem; how to serve media using better suited servers like
> nginx for media but still having some way of checking
> permissions/authentication etc. ??
>
> I`m working on a project similar to Windows Home Server, where users
> can upload and backup their media and access it through a web
> interface. Serving static media using django was terrible and using
> nginx was incredibly fast, but I lost all access control to the static
> media.
>
> Any help on this subject would be highly appreciated.
>
> --
> Mvh/Best regards,
> Thomas Weholt
> http://www.weholt.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 django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

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

Re: Django app that uploads media files and servers them through a view?

>> Is anyone aware of a Django app that lets you upload media files (not
>> necessarily in the admin site) but serves them through a view instead
>> of as static files via the web server? I need to control access to the
>> media using permissions. Thanks
>
> Serving media using views are very inefficient, but I`m facing the
> same problem; how to serve media using better suited servers like
> nginx for media but still having some way of checking
> permissions/authentication etc. ??
>
> I`m working on a project similar to Windows Home Server, where users
> can upload and backup their media and access it through a web
> interface. Serving static media using django was terrible and using
> nginx was incredibly fast, but I lost all access control to the static
> media.

Hi there,

while I don't have first-hand experience, I do remember (from
EuDjangoCon) that this can be achieved quite effectively using
perlbal's reproxy feature. It does not handle the "upload" part, but
that should not be difficult to code using Django's file upload
mechanisms or 3rd party packages.

Just my 2 cents, that's where I'd start looking if I needed this...

Cheers

Jirka

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Django app that uploads media files and servers them through a view?

On Thu, Sep 30, 2010 at 1:20 PM, Stodge <stodge@gmail.com> wrote:
> Is anyone aware of a Django app that lets you upload media files (not
> necessarily in the admin site) but serves them through a view instead
> of as static files via the web server? I need to control access to the
> media using permissions. Thanks

Serving media using views are very inefficient, but I`m facing the
same problem; how to serve media using better suited servers like
nginx for media but still having some way of checking
permissions/authentication etc. ??

I`m working on a project similar to Windows Home Server, where users
can upload and backup their media and access it through a web
interface. Serving static media using django was terrible and using
nginx was incredibly fast, but I lost all access control to the static
media.

Any help on this subject would be highly appreciated.

--
Mvh/Best regards,
Thomas Weholt
http://www.weholt.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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: iPhone posting FILEs = "Invalid content length"

On 30 Sep 2010, at 11:55, Danny Bos wrote:
> Basically I've got an iPhone app sending a POST to a django app, it
> contains one FILE.
> Every now and then (very sporadically, about 1 in 5) one fails and I
> get the below message.

> <th>Exception Value:</th>
> <td><pre>Invalid content length: 0<pre></td>

> Any ideas?

This will be a problem with your Objective-C code on the iPhone. Can you paste the code you're using to build the HTTP request?

In want of that, I'd hazard that whatever method you're using to build the request body is returning nil, and that you're then assigning that as the request body. As such you're ending up with a content length of 0.

(Of course it could be something else entirely, but it doesn't sound like a Django issue per se.)

HTH

Regards,
Carlton

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Django app that uploads media files and servers them through a view?

Is anyone aware of a Django app that lets you upload media files (not
necessarily in the admin site) but serves them through a view instead
of as static files via the web server? I need to control access to the
media using permissions. 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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

iPhone posting FILEs = "Invalid content length"

Hey there,
I've got a new error I'm totally stumped on. All searches are saying
it's a "http vs https" or similar.
I'd be keen to hear your thoughts.

Basically I've got an iPhone app sending a POST to a django app, it
contains one FILE.
Every now and then (very sporadically, about 1 in 5) one fails and I
get the below message.

<tr>
<th>Exception Type:</th>
<td>MultiPartParserError</td>
</tr>
<tr>
<th>Exception Value:</th>
<td><pre>Invalid content length: 0<pre></td>
</tr>
<tr>
<th>Exception Location:</th>
<td>/home/72999/data/python/django/django/http/multipartparser.py in
_init_, line 80</td>
</tr>

Any ideas?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Upload above apache web root?

Hi,

To me, it looks like the documentation already gave the answer.

Regards,
Xavier.

Le 30 sept. 2010 à 10:37, Federico Capoano a écrit :

> PS: i'll post a solution so other noobs like me will see how to do
> that..
>
>
> On 30 Set, 10:35, Federico Capoano <nemesis.des...@libero.it> wrote:
>> Yes you're right, I'm trying it out. I'll post a solution when I'm
>> done.
>>
>> On 30 Set, 10:10, Xavier Ordoquy <xordo...@linovia.com> wrote:
>>
>>
>>
>>> Well, the documentation already tells you about it:http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files...
>>
>>> Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :
>>
>>>> Is this not possible? I wonder why Django force to upload files only
>>>> in a certain directory and doesn't allow more flexibility.
>>
>>>> On 29 Set, 19:46, Federico Capoano <nemesis.des...@libero.it> wrote:
>>>>> Hi everyone,
>>
>>>>> is it possible to write a custom model filefield that upload files
>>>>> somewhere above the public directory?
>>
>>>> --
>>>> 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+unsubscribe@googlegroups.com.
>>>> For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

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

Re: Upload above apache web root?

PS: i'll post a solution so other noobs like me will see how to do
that..


On 30 Set, 10:35, Federico Capoano <nemesis.des...@libero.it> wrote:
> Yes you're right, I'm trying it out. I'll post a solution when I'm
> done.
>
> On 30 Set, 10:10, Xavier Ordoquy <xordo...@linovia.com> wrote:
>
>
>
> > Well, the documentation already tells you about it:http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files...
>
> > Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :
>
> > > Is this not possible? I wonder why Django force to upload files only
> > > in a certain directory and doesn't allow more flexibility.
>
> > > On 29 Set, 19:46, Federico Capoano <nemesis.des...@libero.it> wrote:
> > >> Hi everyone,
>
> > >> is it possible to write a custom model filefield that upload files
> > >> somewhere above the public directory?
>
> > > --
> > > 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+unsubscribe@googlegroups.com.
> > > For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

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

Re: Upload above apache web root?

Yes you're right, I'm trying it out. I'll post a solution when I'm
done.


On 30 Set, 10:10, Xavier Ordoquy <xordo...@linovia.com> wrote:
> Well, the documentation already tells you about it:http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files...
>
> Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :
>
>
>
> > Is this not possible? I wonder why Django force to upload files only
> > in a certain directory and doesn't allow more flexibility.
>
> > On 29 Set, 19:46, Federico Capoano <nemesis.des...@libero.it> wrote:
> >> Hi everyone,
>
> >> is it possible to write a custom model filefield that upload files
> >> somewhere above the public directory?
>
> > --
> > 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+unsubscribe@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

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

Re: Separating application media from project media

On 29/09/2010 18:55, Carles Barrobés wrote:
> At some point I also thought this was a good idea. This way I can
> reuse the app and all its visual stuff as well.
>
> But the problem is that for most cases you will want your templates
> and media to be consistent with a site's design and look&feel. This
> means that for two projects (sites) re-using the same application, the
> styles/icons etc are bound to be quite different. On the one hand it
> is already hard to create a template that can be reused in many
> different pages/layouts (normally for each site you will have a
> different base template and a specific template hierarchy, etc). And
> besides including specific stylesheets... which are bound to clash
> with styles from the base site...
>
> Unless you want to do something like the admin, which really looks
> like a different site and doesn't have anything to do with the rest of
> your site's look & feel, but which we don't care because we don't mind
> it really looking like a separate entity, since it is typically not
> available to end users.
>
> I don't know what your use case is and how you are going to tackle the
> difficulties I found. I in fact went the opposite way you're going,
> moving templates and styles to the project and keeping only the
> functionality for the app, because the templates and styles I needed
> ended up being quite coupled with the rest of the site.
>
> I'm interested to know how you solve this, or if it matters to you.
>
> Carles.

Hi Carles,


i find the whole project, app idea a bit confusing for my case.
It might help if I describe my use case first.

I'm building a set of applications that will be available to our users.
Users being company employees so no external users.
The start page is what I call a dashboard. It's basically a page with
tabs that represent different departments.
For instance ICT, Accountancy, and so on.
If you click on a tab, you'll see icons that link to a certain application.
For instance, you click on the ICT tab, you'll see an icon linked
to the calltracking application.

These applications are all very different. The first one, is a calltracking
system for ICT that allows users to see what we are doing for a certain
problem and allows us to follow up the calls.

The first problem i had was login. I want the users to login once
and if they switch to a different application, then they should remain
logged in.

That's how i ended up with a project "dashboard" and an application
"calltracking". The authentication code is located in the project, all
the calltracking files are in the calltracking directory.
Any other application, will be treated the same way as the calltracking.
Making an app and putting all related files in there.
The authentication for a new app is handled already then by the project.

A point of doubt i had when structuring the code was that the whole project/app
concept is clear when you talk about a site having a blog, a news app and so on.
But my applications are totally different and don't necessary belong to a "site".
The application IS a site. The only thing they have in common is the central login.
So style isn't an issue for me and a such, it makes more sense to put the media
and templates in the application directory.
This makes the application more portable.
But it still doesn't feel completely right.

The media is a problem however. I found a solution by putting a settings.py file
in the application directory. That settings file is imported in the projects settings file.
I've defined a MEDIA_URL & MEDIA_ROOT variable in the application settings file.
I actually named them MEDIA_URL_CALLTRACKING and
MEDIA_ROOT_CALLTRACKING and made a template tag that
makes them available in my calltracking templates.

I could have made a template context processor but that would make these
var's available in other applications and that didn't feel right so i choose
to use the template tag approach.
It works OK, but i could even make it simpler but that is very hackish:
in the tag, you can change the MEDIA_URL to the media URL of the caltracking.
Bonus: you can still use {{ MEDIA_URL }} in the templates instead of using
{% MEDIA_URL_CALLTRACKING %}
Like i said, this feels hackish and makes me doubt if i'm using the
whole project/app concept correctly.

If i would want to release my code for other people to use, it makes
more sense to distribute it as an application than as a project.
It's all confusion, that's why I think there should be a page on Django
that explains a few use cases and how code could then best be structured.

Another approach might have been to make a static dashboard page
instead of a project and make a project and app dir for every application.
But I don't know how I could manage a central login system then as
the cookies/sessions aren't shared across projects I think.

Anyway, i was able to put the templates and media in the application
in the end but since it was so much trouble, it probably means it's not
the way to go. If you want code on how i did it, shoot and I'll post it here.
There are only 2 things why i want to keep this code structure:
- the central login shared among applications
- if feels cleaner to share code if you're working with applications instead of
projects.

If i could do the login across projects, i would go for 1 application = 1 project.

Cheers,
Benedict


--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Separating application media from project media

On 29/09/2010 13:58, Benedict Verheyen wrote:
> On 29/09/2010 13:13, David De La Harpe Golden wrote:
>> On 29/09/10 09:34, Benedict Verheyen wrote:
>>
>>> In my template i add this:
>>> <link rel="stylesheet" type="text/css" href="{{MEDIA_URL_CALLTRACKING}}/style/login.css" />
>>>
>>
>> (I'd favour prefix rather than suffix if you're going to pseudo-namespace)
>>
>> Did you introduce such a MEDIA_URL_CALLTRACKING variable into the
>> template context by any means? It's not automatic. For MEDIA_URL, the
>> value in your settings is propagated into the template context by
>> django.core.context_processors.media, which you'll see is a
>> TEMPLATE_CONTEXT_PROCESSORS entry in settings.py
>>
>> If you want to duplicate that functionality for another variable, it's
>> straightforward enough to write a template context processor to do that
>> if you want to, see source.
>>
>> http://code.djangoproject.com/browser/django/trunk/django/core/context_processors.py#L69
>>
>> n.b. template context processors only work for RequestContext contexts,
>> which not everything uses (obviously for your own apps you can just make
>> sure to use them).
>>
>> FWIW, that's not the pattern the admin contrib follows, it uses a
>> custom template tag library that includes a custom tag that resolves to
>> the admin media prefix, so its templates
>> do a
>> {% load adminmedia %} to load the tag library then they use
>> "{% admin_media_prefix %}blah/blah"
>>
>> http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/templatetags/adminmedia.py
>>
>> I have no particular opinion on what approach is better, both work.
>
> Thanks,
>
>
> both seem solutions to what i'm trying to do. I'll try them out and report back
> if it works.
>
> Regards,
> Benedict

Hi,

i went for the template tag approach.
The template context processor would put an application specific variable available
for all other applications in this project and that didn't feel right.

The template tag allows for a certain variable to be available only to the application.
That's why i choose it.
Another benefit is that other developers see that you included something extra and thus
know about the variable. If you use a template context processor, the var is
auto magically added and a developer might miss the fact that this var is
available for use.
Of course you have documentation but the chances are that somebody misses it.

Regards,
Benedict


--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Upload above apache web root?

Well, the documentation already tells you about it:
http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-filesystem-storage-class

Le 30 sept. 2010 à 09:49, Federico Capoano a écrit :

> Is this not possible? I wonder why Django force to upload files only
> in a certain directory and doesn't allow more flexibility.
>
>
>
> On 29 Set, 19:46, Federico Capoano <nemesis.des...@libero.it> wrote:
>> Hi everyone,
>>
>> is it possible to write a custom model filefield that upload files
>> somewhere above the public directory?
>
> --
> 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+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

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

Re: Upload above apache web root?

On Sep 30, 9:49 am, Federico Capoano <nemesis.des...@libero.it> wrote:
> Is this not possible? I wonder why Django force to upload files only
> in a certain directory and doesn't allow more flexibility.
>
> On 29 Set, 19:46, Federico Capoano <nemesis.des...@libero.it> wrote:
>
> > Hi everyone,
>
> > is it possible to write a custom model filefield that upload files
> > somewhere above the public directory?

I haven't tried this myself, but a custom file storage might help you:
http://docs.djangoproject.com/en/dev/howto/custom-file-storage/

or using a callback:
http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield

Regards

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Upload above apache web root?

Is this not possible? I wonder why Django force to upload files only
in a certain directory and doesn't allow more flexibility.

On 29 Set, 19:46, Federico Capoano <nemesis.des...@libero.it> wrote:
> Hi everyone,
>
> is it possible to write a custom model filefield that upload files
> somewhere above the public directory?

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Wednesday, September 29, 2010

Re: ANN: PyMySQL 0.3

The following patch to your application's manage.py will allow you to
use pymysql without patching Django.

#!/usr/bin/env python
+try:
+ import pymysql
+ pymysql.install_as_MySQLdb()
+except ImportError:
+ pass
+

On Sep 10, 12:25 pm, Andy <selforgani...@gmail.com> wrote:
> On Sep 10, 11:18 am, Andy Dustman <farcep...@gmail.com> wrote:
>
> > Uh, no.
>
> > MySQLdb releases the GIL on any blocking call, so other threads can run.
>
> > Django is *not* asynchronous. It's threaded.
>
> The default Django behavior is threaded.
>
> But it can be made to run in async mode, where socket communication
> doesn't block. That way one Django thread can serve multiple users
> concurrently.
>
> Check out gevent for details.

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: passing request.META from view to form

You can just add another keyword argument to your constructor.

If you override the __init__ of your form then just pop that item
off before passing it on to the __init__ in super() and nobody gets hurt.

;o)


Shawn

On Sep 29, 2010, at 6:03 PM, Oivvio Polite wrote:

> I'm creating new users+profiles from a form class.
> The form gets instantiated by a view. I'd like to save the request.META
> header along with the profile so I need to pass it from the view to the
> form.
>
> The form constructor takes the keyword argument data. Is there anyway I
> can pass along my entire request, without overloading the constructor?
>
> oivvio

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: UnicodeEncodeError

On Sep 29, 11:24 pm, werefr0g <weref...@yahoo.fr> wrote:
>   Tu peux m'envoyer ton fichier ? je v�rifie son encodage.

ca y est

> Sinon, quel OS utilises-tu ?

I use ubuntu 9.10 (but problem is the same with osx or windows)

>
> Le 29/09/2010 23:14, jean polo a �crit :
>
> > On Sep 29, 10:38 pm, werefr0g<weref...@yahoo.fr>  wrote:
> >>    Jean,
>
> >> Sorry, the three points are:
>
> >>   >    # -*- coding: utf-8 -*- line
> >>   >  checking the module's file is actually utf-8 encoded
> >>   >  using codecs module for file like read/ write operations.
> > Well, not sure I have the skills to check these (except the first
> > one).
>
> > As all this happens in the admin code, I have no clue about how (or
> > where) to look/change something.
> > Any file that contents any accent (yeah french customer: ��� or �)
> > triggers the error.
>
> > Sorry but I'm still new to django/python.
>
> > cheers,
> > _y

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.