Re: a simple django CMS anyone?

2007-01-13 Thread spacedman


ashwoods wrote:


a simple open and free CMS would be good for a lot of people, specially
the newcomers. the problem is how to design a CMS that doesn't limit
the freedom you learn to love when you choose to use django over some
cms.



Someone looks like they tried to start a project like this, there's
something on the google code site:

http://code.google.com/p/dynamite-cms/

and one thread I started when I stumbled upon it:

http://groups.google.com/group/dynamite-developers/topics?lnk=li

but there's no actual code yet...

A nice TTW-editable CMS in Django would indeed be quite fine, but I do
fear it bloating up to Zope/Plone proportions. But hopefully it could
still be kept manageable...

Barry


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



Re: Singleton model instance

2006-12-07 Thread spacedman

My slightly graceless method is to override .save and .delete:

http://groups.google.com/group/django-developers/browse_frm/thread/2caa976249783fae/#

Then whatever model you define, it can only ever have one row (well, it
will have zero rows before you put anything it).

Barry


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



Re: Best way to administer static configuration data?

2006-12-06 Thread spacedman

Ah, and you also have to override the .delete() method!

http://groups.google.com/group/django-developers/browse_frm/thread/2caa976249783fae/#


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



Re: Best way to administer static configuration data?

2006-12-06 Thread spacedman


[EMAIL PROTECTED] wrote:

> I could create a model and then only have one row, but that seems
> clunky.

 I did exactly this and overrode the .save() method so that the model
was constrained to only have one row by resetting self.id to 1 in the
.save() (I think...). Effect was that if you added a second row in the
admin - and this is the only clunkiness I perceived - you just got one
row with your new data. You could also edit the existing one row.

Barry


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



Re: Saving arbitrary data without database

2006-10-24 Thread spacedman

This sounds like you want to use my 'single row database' trickery
pokery:

http://groups.google.com/group/django-developers/browse_frm/thread/2caa976249783fae/#

Just create a Django model 'Properties' with your 'threshold' as one
field, then access it just like a normal Django model. The database
will only ever have one row, which is the single value you want.

Barry


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



Re: sharing session information with plone

2006-10-02 Thread spacedman


ashwoods wrote:
> does anybody have experience of sharing session information from a
> plone site. I want our intranet users that are authenticaded in plone
> to be able to access django without having to relog.

 Haven't done this directly, but what you'd have to do is get the __ac
cookie that plone uses for sessions and use that.

 So, your django site would have to be on the same domain as your plone
site.

 Then your django code would get the __ac cookie from the request.

 Then it would have to use something in the zope/plone API to get the
username.

 Tricky bit would be talking to zope - I'm not sure how deep in the
zope authentication system you'd have to go. It might be something we'd
want to do on our site, so I might ponder it more later. If you get any
ideas yourself, share them!

Barry


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



Re: Download counter?

2006-09-19 Thread spacedman


Malcolm Tredinnick wrote:

> The minor problem with that approach is that it means people can avoid
> the Django counter and directly fetch the URL. So if counting is a
> requirement, that solution needs an extra tweak to ensure that you have
> first visited the counter page. This can be done with a nonce in the URL
> or a session setting.

 Good spot. Note that I did a double take on 'nonce' since I've only
seen it as (UK?) prison slang for a sex offender.

 My thinking now is that if you are going to have to set up something
on the apache side of things to handle nonces then you may as well find
an apache-side download counter that increments on each GET.

 What not to do is to grep access_log every time you want a count.
Especially if you have one of those 'Downloaded 634234 times' badges.
Ick.

Barry


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



Re: Download counter?

2006-09-18 Thread spacedman


frank wrote:
>  Sure, I could create a download button for each
> item, but that would be an extra step for the user.  'It would be nice'
> if that weren't necessary.
> BTW the downloads are static files, served by Apache.  That extra
> button
> is looking more and more likely...

 At some point the user is going to click on a link to download the
file. What you do is make that a URL to a django app that increments a
counter and then sends a redirect HTTP message to the actual file which
apache then spits back.

 So you have a Django model called 'Downloads' with an integer 'Count'
field and a text 'Filename' field. This could be initially empty...

 ..then your URL would be:

 http://mymachine.com/downloads/package/version/file-1.0.tar.gz

 ...then your  urls.conf  would match /downloads/(.*)

 ...the associated view then increments the counter for
/package/version/file-1.0.tar.gz, or creates it if new...

 ...then sends a redirect (http code 304?) message to
http://mymachine.com/files/package/version/file-1.0.tar.gz, which is
the path to the file on the apache server.

 You might want to check the file exists in the Django view first

 ...so that the browser goes and gets that without asking the user.

 The only thing I'm unsure of is the exact HTTP message to send and how
to get Django to do it, but it should be in the docs somewhere

Barry


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



Re: Mac vs. PC for Django work.

2006-09-14 Thread spacedman

I use Windows at home for video and audio editing, and getting Django
things to work on there can be annying at times - its usually file
paths to python, and things like #!/bin/env and all that, and whether
you run from cygwin or DOS shell. Aaargh, the horror. I wrote my poker
blog at home on Windows. My IDE was emacs.

At work where we do real Django stuff our current developer is using
Eclipse on Windows, but his replacement will be Linuxing.

I'd be tempted to say to do your development on the platform that most
closely matches your deployment platform. We're using Apache and
mod_python on our own Linux web server here, so that's the best thing
for development for us. 

Barry


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



Re: How about a Django apps public repository?

2006-09-07 Thread spacedman


Sean Schertell wrote:

> Am I alone on this? If I created such a repository would anyone use it?

 Why not just use SourceForge[1] as repository and just keep a list of
django-related projects on the django main site?

Barry

[1] Or similar.


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



Re: Dynamic Menus...

2006-08-25 Thread spacedman

And (obviously?) dont rely on the correct make and model coming back
from your form. You'll eventually get someone constructing their own
POST data for a laugh and seeing what happens if they had selected
Renault Impala... :)


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



Re: extract keywords from model

2006-08-22 Thread spacedman


[EMAIL PROTECTED] wrote:
> thanks,
>
> that worked
>
> richard

 Ah, now I see my confusion. What you wanted was the 'field names', not
'keywords', and you said: [result_id,lab_id] when you really meant
['result_id','lab_id'].

Barry


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



Re: extract keywords from model

2006-08-21 Thread spacedman


[EMAIL PROTECTED] wrote:

> suppose i have a model with 2 keywords like
>
> class Test(models.Model):
>result_id = models.IntegerField(maxlength=10)
>   lab_id = models.IntegerField(maxlength=10)
>
> is there a method to extract all the keywords from this class.
> So in this example i actually want [result_id,lab_id]

 I dont see any 'keywords' here. Just some integer fields. Are you sure
you dont really want to make it a CharField with some "choices"
argument?

class Foo(models.Model):
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
)
gender = models.CharField(maxlength=1, choices=GENDER_CHOICES)

Barry


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



Re: django <-> cms like typo3

2006-08-17 Thread spacedman

Someone is working on a Django CMS:

http://groups.google.com/group/dynamite-developers?lnk=li

but there's no code available yet...

Barry


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



Re: How to build a tree on the page?

2006-08-16 Thread spacedman


一首诗 wrote:
> I have a table like this
>
> id  | name | parentid
>
> And parentid is a Foreign Key to ID.
>
> So I have a tree in my database.  My question is that, how can I
> represent it on the web as a tree.

If you can rework your database slightly you can use Modified Preorder
Tree Traversal, which is a really slick way of doing trees in
relational databases. You can get everything you need to know to
present a tree diagram with ONE database call. If you store parent-id
then you can end up hitting the database many many more times as you
climb up and down the tree.

See
http://code.djangoproject.com/wiki/ModifiedPreorderTreeTraversal

And
http://www.sitepoint.com/print/hierarchical-data-database

It takes a bit of thinking about, but once it 'clicks' you'll see how
neat it is.

Barry


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



Re: imbricated tags

2006-08-12 Thread spacedman


[EMAIL PROTECTED] wrote:
> I just tried two loops "for" imbricated, it does'nt seems to work.

Imbricated? That's a new one on me. I just looked it up and it means
overlapping like roof tiles, edge over edge, which makes me think of
two for loops like this:

for i = 1 to 10
for j = 1 to 10
print i, j
next i
next j

This is an error in most programming languages, and syntactically
impossible in many cases too - I had to think how to do loops in BASIC
to give that example above!

What you have done is usually called 'nested' for-loops, but thanks for
introducing me to a brand new word! I shall try and use it today!

I think someone else pointed out the missing % already...

Barry


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



Re: Google-like API keys

2006-08-11 Thread spacedman


Felix Ingram wrote:

> Well that's true but 128 bits still gives you 3 x 10^38 possible
> strings, so you could probably give everyone on the planet a key an
> still not have a collision.

 Understatement of the week! The human population is currently about
6.5x10^9. You could give every teaspoon of the earth (right down to the
liquid iron core) a key and still probably not have a collision.

 I think I'm going to rewatch Powers Of Ten: http://www.powersof10.com/
now :)

Barry

[earth mass: 6x10^27 g]


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



Re: session management

2006-08-10 Thread spacedman


ihomestore wrote:

> A simple case would be: once users login, if we do not keep track of
> user session, how do we know it is the same user once he / she diverts
> to other pages (we do not want to ask user to login for every new page
> s/he visits).

 Okay, so duplicating the functionality of django's authentication
framework for the same purpose - customising access to things and so
on.

> > The only other way I can think of to keep some state between web pages
> > is to have a form with some hidden fields and make every request a
> > POST. Eeeyuck.
>
> This is better than URL fiddling.

 Well I wish you luck in implementing it! Personally I'd rather go
visit everyone who doesn't have a browser that can handle cookies and
install a browser that can for them!

Barry


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



Re: session management

2006-08-10 Thread spacedman

Well, you could encode the information that is normally transferred in
the cookie by adding a parameter to the URL all the time, so that your
URLs are always something like:

/foo/bar/info?session_id=0873556323

BUT if anyone gets that URL they get that person's session. Which is a
BAD thing. So don't do that.

What precisely do you mean by 'track users session'? Just keep a log of
where they are going on your site? You might be able to do that with a
bit of URL fiddling since its not really security-related.

The only other way I can think of to keep some state between web pages
is to have a form with some hidden fields and make every request a
POST. Eeeyuck.

Barry


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



Re: Template to Render Unknown Number of Arguments

2006-06-22 Thread spacedman


> On Thu, 2006-06-22 at 12:47 +, Paul Childs wrote:

> > I have tried a number of ways of doing this but can't come up with a
> > solution. I don't think pre-processing the data will help since the
> > template still doesn't know how many keys there will be. Changing the
> > structure of the data is not possible.

 Why not? It would be two lines of python to restructure that data to
something the template tags can handle nicely. Then your template will
also read nicely, and wont have code bundled away in a template tag
that could break something somewhere any time later.

 Get the data right, and everything else should follow...


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



Re: Recursive delete problem

2006-06-19 Thread spacedman

Indeed! Perhaps nobody thought anyone would ever override the delete()
method...

I'm not sure why the strategy is to gather together all the related
objects and then do the SQL rather than call the delete() method on
each of them. Perhaps its more efficient. Perhaps it avoids possible
loops where two objects refer to each other, or perhaps its all done in
one transaction to keep the DB consistent.

I can't see a simple way of doing what would seem to be the 'right
thing'. What you really need is some sort of 'pre_delete' method. Oh
dear, those things seem to have disappeared with the 'magic-removal'
code...

Probably worth filing this as a bug... If its not there already, I cant
find it!


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



Re: Recursive delete problem

2006-06-19 Thread spacedman


Viktor wrote:

> But when I delete a round, with round.delete(), all games conected with
> that round are also deleted, but the Score table isn't updated, that is,
> the delete method from the game objects is not called?!?!

Looking at the code I see that when an objects is .delete()d all the
related objects are gathered up and then it calls delete_objects:

[django/db/models/base.py]
# Actually delete the objects
delete_objects(seen_objs)

 which does the actual deletion from the DB. Hence the .delete() method
wont be called for related objects.

 So I'd say you weren't doing something terribly wrong, but it might
not be a bug either. If this behaviour is desirable (and I cant see why
it isn't) then it needs a bit of rewriting...

Barry


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



Re: Generating models from a class diagram

2006-06-13 Thread spacedman

I'd rather go the other way - generate a class diagram from django
model source!

If you generate model code from a diagram you'll probably still have to
edit the source to add new methods or tweak verbose_names, or add Admin
meta classes, so then if you change the model you will lose all those
changes unless you either put the code into your class diagram editor
or have a smart UML-Python generator that preserves code sections -
this is the approach of ArchgenXML which produces Python code for Plone
content types.

But I find the models.py code is as easy to construct as drawing a
diagram, but it would be nice to get a diagram of all the foreignkey
relationships. This shouldn't be too hard. Just need to introspect your
model class and follow the related fields... Hmmm


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



Re: Problems interating through arrays passed through render to response

2006-06-08 Thread spacedman


fyleow wrote:

>   keyword = books.objects.get(headline__icontains=keyword)

 I would then split/reshape this list into a list of (keyword,
list_of_books) tuples, so you have a structure like this:

 keywordsearch = [('python', [,]), ('coding',[,])]

 then in the template you loop "for kwmatch in keywordsearch". Then
kwmatch.0 gives you the keyword, and kwmatch.1 gives you the list of
books which you then loop over.
 
Is that about right?

Barry


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



Re: Using AJAX to deal with slow views

2006-06-02 Thread spacedman


Jay Parlar wrote:

> The thing is, I'm not sure how to fit that into Django. Currently, my
> view function just blocks on the generation/compilation. To do this
> with AJAX, it feels like I'd have to spawn a thread from Django to do
> the processing, and let the view return immediately. But when the
> resulting page does the first XMLHTTPRequest, how can I guarantee that
> it'll hit the same mod_python interpreter that's running my thread?

 Howsabout having a database table that keeps the state of the current
generation/compilation things going on. Your spawned thread just
updates its entry as it progresses. This could even be a Django model
of course! Just make sure your database handles concurrency correctly.

 Then your main template could have a block that queries that table for
any activity related to the current user and lists it. You could use
some ajax/timeouts to update it, or give the user an 'Update' button.
You'd probably have to write a custom tag to do this.

Barry


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



Re: Django and daemon?

2006-05-31 Thread spacedman


DavidA wrote:

> An alternative that stays inside Django is to setup a trigger in cron
> (or NT's Task Scheduler) that gets a URL every few minutes and the view
> code for that URL does the email processing you mention. You avoid
> creating a true daemon/service just by "waking" up periodically and
> doing any work that needs to be done.

 This is simple if the view doesn't need any authentication, but you'd
have to login and muck with session cookies if the view is protected by
some access rights. Python's cookielib might help here, or if you are
writing it in shell, use wget with its various cookie options, and use
its --post-* options to send the login form response.

Probably simpler to write a python script that imports django and runs
on the server!

Barry


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



Re: users editing only their own info

2006-05-30 Thread spacedman

Ground up would be my way of doing it. Lets break it down...

You need an 'update' view that only shows the fields you want changing.
That means a custom manipulator that only mentions the fields you want
to modify. Protect this view by making sure the logged-in user is the
user mentioned in the URL (/edit/123 where 123 is the id in the User
model).

Then write a template that shows the form that this manipulator is
controlling.

As for the 'approval', well, add a field 'Approved' to your user data.
When the form is posted back, set it to False.

Write another view only visible to Admin users that lists non-Approved
users, giving a link to the admin page for that user - then the Admin
can reset the Approved flag if the data is okay.

Sketchy, but there's a few things going on here.


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



Re: Django and daemon?

2006-05-30 Thread spacedman

Wouldn't it be better to setup 'procmail' to process incoming emails as
they arrive. Then your procmail script could update the database. As
long as you are using a decent database server (*cough*POSTGRES*cough*)
then concurrency shouldnt be a problem.


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



Re: How to automatically generate a password input field

2006-05-27 Thread spacedman

just use PasswordField() in your model.

Might be a recent introduction. Its literally a two-liner in
django.forms:

class PasswordField(TextField):
input_type = "password"

http://code.djangoproject.com/browser/django/trunk/django/forms/__init__.py

Barry


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



Re: Authentication by email+pass

2006-05-25 Thread spacedman

This is to avoid duplicate usernames? My idea is to call them all
userXXX where XXX is the id value (the primary key in the User table).

Another thought that came to me yesterday was whether there are any
issues if a user wants to change his or her email address. I don't
think it causes any problems - foreign keys into the User table are
using the primary key id so thats not a problem.

B


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



Authentication by email+pass

2006-05-24 Thread spacedman

I dont want my users to have to bother with a username. I want them to
authenticate with their email as their username. But django wont allow
valid @ signs (and other stuff) in a username. I could patch that but
that could bite me badly. So I found a better way.

First I create a manipulator:

from django.contrib.auth.forms import AuthenticationForm
class LoginManipulator(AuthenticationForm):

 and override the  __init__ and isValidUser methods. The __init__
method replaces the username field with an EmailField with name
'email'. Its just a cut n paste and replace job from django's code.
Then the 'isValidUser' validator looks like this:

def isValidUser(self, field_data, all_data):
"""
This is a modification of the AuthenticationForm validator that
uses
the email rather than the username
"""
try:
self.user_cache = User.objects.get(email=field_data)
except User.DoesNotExist:
raise validators.ValidationError, _("Please enter a correct
email and password. Note that both fields are case-sensitive.")

 The only difference being the User.objects.get() line which gets the
User record by email rather than username.

 Then your login template form has this in it:

Email:{{
form.email}}

along with the password field. All seems to work nicely.

Possible problems occur if email isnt unique in the User table. We'll
be enforcing that at registration time, and I guess we can put that in
the database conditions too.

Anyone think of any other things that could go horribly wrong?

Barry


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



Re: Admin Functionality Enhancement

2006-05-07 Thread spacedman

I've had a few thoughts on this:

1. on the main admin page, just list the names of the apps and not the
db tables as well.

2. clicking an app takes you to a per-app admin page, by default it
would just be the one pretty blue-headed box for the app.

3. then it would be easy to have a custom per-app admin interface.

4. if you really want apps and tables on the main page, use a bit of
CSS/JS to make the tables hide/expand as a drop-down or other UI
element. This would also make django more web 2.0 compliant :)

I have had a quick play at some of this, trying to factor out the list
of tables for each app, but then magic-removal came along... As well as
real work... It does that...

Barry


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



Re: Forking a new process

2006-04-28 Thread spacedman

I did something like this in perl using HTML::Mason. However I used
'system' to start the background process, and files for
communication...

Its an on-demand backup system. The HTML::Mason code creates a temp
file and then uses 'system' to run the backup job, passing the
filename. The backup then noodles away for however long, sticking stuff
in the temp file. Once its finished, it moves the tempfile to a log
directory.

 Meanwhile an auto-refresh page is on the users' browser. It checks the
presence of the temp file and shows the last ten lines if its there, or
goes 'Hey, your backup is finished' if its gone.

 I dont see why you couldn't do this in Django - start a totally new
process with os.system which can 'import django' and access the model.
Then communicate with files... Perhaps :)


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