cache.set could be more functional

2009-08-29 Thread Chris McCormick

Hi *,

I always find myself using this idiom:

cache.get(key, set_cached(key, KeyValue.objects.get(user=request.user, 
key=key)))

Which basically sets the key upon fetching it. It requires me to define
set_cached to be something like this though:

def set_cached(key, value):
""" Functional version of cache.set which returns the value """
cache.set(key, value, 300)
return value

It would be nice if cache.set returned the value by default, or even better
if something like this existed:

cache.get_and_set(key, default)

Which would set the key to the default and return the default if the key isn't
in the cache, or return the value if it is.

Chris.

---
http://mccormick.cx

--~--~-~--~~~---~--~~
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: Single sign-in

2009-08-28 Thread Chris McCormick

Hi All,

My workmate just pointed out that somebody has now done this. Hooray!
<http://github.com/uswaretech/Django-Socialauth/tree/master>

Chris.

On Tue, May 05, 2009 at 05:15:16PM +0100, Chris McCormick wrote:
> 
> Hi All,
> 
> I am sensing a need for a library which allows for a user to sign into Django
> apps using any of their existing credentials with another site, and I wanted 
> to
> start a library project for providing this to Django programmers. I thought I
> would ask here first and see if there is something existing before I start.
> Essentially this will give the Django site creator the ability to let their
> users sign in with Facebook Connect, Google Friend Connect, Yahoo sign-in,
> Twitter Sign-in, Open ID, or generic OAuth. The module will automatically
> create a local Django user linked to whatever the Profile module is after the
> user signs in to the Django driven site.
> 
> I'd like it to be as simple to use as possible, and use as much existing code
> as possible. For example, the Open ID sign in would use the existing Open ID
> Django code which is out there. The Facebook Connect sign in would use all the
> great exising Django Facebook code that's out there. I'd also like it to be as
> modular and fail-proof as possible, so that if someone hasn't yet (for 
> example)
> set up their Facebook API key or whatever, they can still support some of the
> other login methods on their site.
> 
> I guess this will be a package consisting of mostly some different
> authentication backends, but probably a bunch of other glue code and templates
> to support the myriad of different sign-on methods which are out there.
> 
> Will this be useful to others? Does anyone want to help me by integrating 
> their
> existing external-sign-in-code into this library?
> 
> Best,
> 
> Chris.
> 
> ---
> http://mccormick.cx
> 
> > 
---
http://mccormick.cx

--~--~-~--~~~---~--~~
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: Displaying username on every page

2009-08-20 Thread Chris McCormick

On Wed, Aug 19, 2009 at 09:39:23PM -0700, John Barham wrote:
> 
> On Aug 19, 9:27 pm, Kenneth Gonsalves wrote:
> 
> > > Yes, I'd read about RequestContext but from what I understand you have
> > > to pass it explicitly to render_to_response().  Is that the case?
> >
> > yes
> 
> Thanks for the confirmation.  In that case I'll have to write my own
> render_to_response() wrapper.

Or you can use direct_to_template().

Best,

Chris.

---
http://mccormick.cx

--~--~-~--~~~---~--~~
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: OT: Drawing lines in the browser

2009-08-18 Thread Chris McCormick

On Tue, Aug 18, 2009 at 07:40:00AM -0700, Ian McDowall wrote:
> On Aug 18, 8:53 am, Thomas Guettler  wrote:
> > Hi,
> >
> > this is offtopic: How can you draw lines in a (django) web application?
> >
> > I think you need to use flash or java to do it. I googled for it, but found 
> > only beta
> > quality projects.
> >
> > Has anyone experience with this?
> 
> Depends on what type of line.  It is technically possible to use SVG.
> You can embed an SVG image in HTML and then draw lines (or circles
> etc.) in it. The SVG is just XMl and Django's templating works fine
> for that.  There are some technical catches about the type of the
> document and namespaces but I can provide a worked example. The
> drawback is that not all browsers support SVG well. This appears to
> work well in recent versions of Firefox but not well in IE.

Even better is the  element and it has good coverage on recent browsers
with the help of explorercanvas  for
Internet Explorer, although the drawing must be done dynamically with
javascript.   is an example of a library which
uses the  element to draw graphs.

Chris.

---
http://mccormick.cx

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



Non-intrusive way to authenticate phpBB against Django

2009-08-04 Thread Chris McCormick

Hi All,

Just uploaded this:
http://code.google.com/p/phpbb-json-auth/

Hope it's useful to someone else.

Best,

Chris.

---
http://mccormick.cx

--~--~-~--~~~---~--~~
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: Changing domain cookie

2009-08-04 Thread Chris McCormick

On Tue, Aug 04, 2009 at 09:14:42AM +1000, Malcolm Tredinnick wrote:
> 
> On Mon, 2009-08-03 at 17:51 +0100, Chris McCormick wrote:
> > I have a strange issue happening with domain cookies. On the site I'm 
> > working
> 
> Python's Cookie module doesn't handle multiple cookies of the same name
> very well, so there might be something going on there. But I'm not going
> to spend too much time thinking about this, since there's an easy
> solution: In addition to changing the cookie domain, change the session
> cookie's name. That way you will no longer be looking for the old cookie
> at all (Django won't care about it) and you can just work with the new
> name that will only exist with one domain setting. Everybody will appear
> to be logged out the next time they use the site, but that shouldn't be
> too onerous.

Great, thanks for the advice, Malcolm, I think this should work for our
use-case. We're pretty keen to not log existing users out since we have a weird
"anonymous user" thing happening, which are actually real users who are
automatically logged in. I will have to come up with some way of copying their
old session cookie to the newly named one, but at least having a differently
named one will mean I can tell them apart.

Best,

Chris.

---
http://mccormick.cx

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



Changing domain cookie

2009-08-03 Thread Chris McCormick

Hi All,

I have a strange issue happening with domain cookies. On the site I'm working
on we previously didn't have SESSION_COOKIE_DOMAIN set and so the cookie
defaulted to "Host: mysite.com" We have a bunch of users logged in with that
cookie set. Then we decided we wanted to share the cookie with our subdomains
and so we change SESSION_COOKIE_DOMAIN to be ".mysite.com" which seemed to work
at first. We are now getting a weird issue which I have narrowed down to users
having two of the same sessionid cookie set, but one has "Host: mysite.com" and
one has "Domain: .mysite.com" which seems to be confusing Django. The
"confusing Django" behaviour I am experiencing is that when the user logs in,
the cookie seems to switch to use the one I don't want and won't log them in.
E.g. on the Django side the login seems to work, but the user just gets a
logged out screen. Does anyone have any tips on what Django is doing
internally, and how I can fix this issue? Oh yeah, in some of my views I am
doing request.session.set_expiry(distant_future()) - is there a chance this
could be messing with the login process? I have stopped the weirdness by
unsetting SESSION_COOKIE_DOMAIN, so people can log in again successfully now,
but I'd really like to be able to use the wildcard subdomain thing.

Best,

Chris.

---
http://mccormick.cx

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



Bloxsom in Django

2009-06-09 Thread Chris McCormick

Hi,

I present for you, a half-implemented, possibly buggy implementation of the
text-file based blogging engine PyBloxsom, re-done in Django. Maybe this will
be useful to someone else who has a pybloxsom blog and wants to transition to
something more manageable/hackable (with no offense to the PyBloxsom
developers, and thanks for their software which gave me a year of good
service!).



Best,

Chris.

---
http://mccormick.cx

--~--~-~--~~~---~--~~
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: Single sign-in

2009-05-23 Thread Chris McCormick

Hi Lakshman,

I haven't yet started or made any progress on this library. I was a bit put off
by the underwhelming response on this mailing list. Maybe I'll set up a Google
Code repository this week, and import the working Facebook code I have, and
then start integrating some of the other systems. There's a chance that I might
be able to convince my client to let me do this work on a paid basis - will
report back here if and when I get this off the ground.

Best,

Chris.

On Fri, May 22, 2009 at 11:57:59AM -0700, Lakshman wrote:
> 
> Hi,
> 
> I now have this exact same requirement.
> 
> Is there any development and/or any existing code/module/app that
> implements sign-in using Google/Facebook/Twitter/OpenID/EmailID/UserID
> something that friendfeed did just recently.
> 
> On May 5, 9:15 pm, Chris McCormick <ch...@mccormick.cx> wrote:
> > Hi All,
> >
> > I am sensing a need for a library which allows for a user to sign into 
> > Django
> > apps using any of their existing credentials with another site, and I 
> > wanted to
> > start a library project for providing this to Django programmers. I thought 
> > I
> > would ask here first and see if there is something existing before I start.
> > Essentially this will give the Django site creator the ability to let their
> > users sign in with Facebook Connect, Google Friend Connect, Yahoo sign-in,
> > Twitter Sign-in, Open ID, or generic OAuth. The module will automatically
> > create a local Django user linked to whatever the Profile module is after 
> > the
> > user signs in to the Django driven site.
> >
> > I'd like it to be as simple to use as possible, and use as much existing 
> > code
> > as possible. For example, the Open ID sign in would use the existing Open ID
> > Django code which is out there. The Facebook Connect sign in would use all 
> > the
> > great exising Django Facebook code that's out there. I'd also like it to be 
> > as
> > modular and fail-proof as possible, so that if someone hasn't yet (for 
> > example)
> > set up their Facebook API key or whatever, they can still support some of 
> > the
> > other login methods on their site.
> >
> > I guess this will be a package consisting of mostly some different
> > authentication backends, but probably a bunch of other glue code and 
> > templates
> > to support the myriad of different sign-on methods which are out there.
> >
> > Will this be useful to others? Does anyone want to help me by integrating 
> > their
> > existing external-sign-in-code into this library?
> >
> > Best,
> >
> > Chris.
> >
> > ---http://mccormick.cx
> > 
---
http://mccormick.cx

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



Single sign-in

2009-05-05 Thread Chris McCormick

Hi All,

I am sensing a need for a library which allows for a user to sign into Django
apps using any of their existing credentials with another site, and I wanted to
start a library project for providing this to Django programmers. I thought I
would ask here first and see if there is something existing before I start.
Essentially this will give the Django site creator the ability to let their
users sign in with Facebook Connect, Google Friend Connect, Yahoo sign-in,
Twitter Sign-in, Open ID, or generic OAuth. The module will automatically
create a local Django user linked to whatever the Profile module is after the
user signs in to the Django driven site.

I'd like it to be as simple to use as possible, and use as much existing code
as possible. For example, the Open ID sign in would use the existing Open ID
Django code which is out there. The Facebook Connect sign in would use all the
great exising Django Facebook code that's out there. I'd also like it to be as
modular and fail-proof as possible, so that if someone hasn't yet (for example)
set up their Facebook API key or whatever, they can still support some of the
other login methods on their site.

I guess this will be a package consisting of mostly some different
authentication backends, but probably a bunch of other glue code and templates
to support the myriad of different sign-on methods which are out there.

Will this be useful to others? Does anyone want to help me by integrating their
existing external-sign-in-code into this library?

Best,

Chris.

---
http://mccormick.cx

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



Order_by number of foreign key joins

2009-03-10 Thread Chris McCormick

Hi,

I want to do something like:

Thing.objects.all().order_by("otherthing__count")

So there's a many-to-many between Thing and Otherthing, and I want to get a
list of Things in the order of most-otherthings joined - is there some easy,
Djangoish way to do it, or should I create a new field in Thing which holds the
number of Otherthings it's joined to?

Chris.

---
http://mccormick.cx

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



Undocumented comment setting

2009-02-27 Thread Chris McCormick

Hi,

The COMMENTS_ALLOW_PROFANITIES setting is undocumented at
http://docs.djangoproject.com/en/dev/ref/contrib/comments/settings/

This really tripped me up on the website I am building which only allows
users to compose comments made up entirely of swear words.

Best,

Chris.

---
http://mccormick.cx

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