Re: is Django too powerful?

2005-12-13 Thread Ian Holsman

it is more about raising the bar and making it more time consuming
than the other guys ;-)

but yeah..hugo already told me to use text-based captcha (and he has
implemented a version of it I think which uses a set of questions that
the human needs to answer.

oh.. the link reminded me of another infrastructure bit

- distributed login via a OpenID system.

The point I was trying to make it that django framework should
concentrate on building the common components that apps use,  and then
concentrate on the full fledged applicaitons after that.

regards
Ian
On 12/14/05, Jeroen Ruigrok van der Werven <[EMAIL PROTECTED]> wrote:
> Hi Ian,
>
> On 12/13/05, Ian Holsman <[EMAIL PROTECTED]> wrote:
> > - captcha (text or images based)
> > - spam and XSS protection
>
> Have you seen/read http://www.w3.org/TR/turingtest/ already?
> Especially the automated circumvention of CAPTCHAs is very
> interesting.
>
> --
> Jeroen Ruigrok van der Werven  / asmodai
> Free Tibet! http://www.savetibet.org/ | Je maintiendrai!
> http://www.in-nomine.org/ | [EMAIL PROTECTED]
> Contentment that derives from knowing when to be content is eternal
> contentment...
>


--
[EMAIL PROTECTED] -- blog: http://feh.holsman.net/ -- PH: ++61-3-9877-0909

If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: is Django too powerful?

2005-12-13 Thread Ian Holsman

personally I'm all for ease of use, and multiple versions of things,
and I'm REALLY happy if it is easy for someone to go and write their
own blog software.

for example.. I've been slowly getting a phpBB-like forum software up
and running for my own uses. and was planning to 'announce/release'
next week when it is a bit more polished.

but for me django isn't powerful as it could be.

what I would like to see being focused on post 1.0 is more the
infrastructure bits, simliar to the admin interface.
here is the list of things I see would help me build my forum software:

- captcha (text or images based)
- row level authorization (ACL)
- auditing
- spam and XSS protection
- user registration
- 2.0 stuff like tagging

now I know people have been working in their own repo's (as I have as
well)  on some of these things, but I for one would like this level to
be standardized first


On 12/14/05, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
>
> On Dec 13, 2005, at 3:58 PM, Rock wrote:
> > Wrong I think. There are already several Djangoids looking at making a
> > discussion forum together as an open project. I expect there will be
> > plenty of similar activities.
>
> Yes.
>
> The major thrust after 1.0 will be to build up a "standard Django
> library" of apps so that it's trivial to install a blog app, or a
> discussion forum, or a wiki, or...  Part of this process will indeed
> be to figure out the best practices for distributing packaged Django
> apps.
>
> (Simon has cool ideas about one-click installs of these apps...)
>
> Jacob
>


--
[EMAIL PROTECTED] -- blog: http://feh.holsman.net/ -- PH: ++61-3-9877-0909

If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: Which user posted the blog entry.

2005-12-12 Thread Ian Holsman

from my understanding there is only way to get at it in the presave,
and that is to either set the field in middleware, or in the custom
manipulator before the object gets 'saved'

I blogged about it here
http://feh.holsman.net/articles/2005/12/07/some-basic-audit-functionality
and provided some code as well ;-)


On 12/13/05, Steffen Glückselig <[EMAIL PROTECTED]> wrote:
>
>
>
> Brett Hoerner wrote:
> > Remember that the Admin screen is under your control.  You could just
> > not display the User bit in the Admin, allow it to be posted as blank
> > (blank=True), and the use _pre_save to grab the current User (session?)
> > and set it.
>
> I am looking for such a solution.
>
> How could I access the session (or more precisely the id of the current
> user) in _pre_save?
>
>
> best regards
> Steffen
>
>


--
[EMAIL PROTECTED] -- blog: http://feh.holsman.net/ -- PH: ++61-3-9877-0909

If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: ANN: Django site on washingtonpost.com

2005-12-06 Thread Ian Maurer

Ha! Congressional voting by astrological sign!

The app overall is great ... nice work!

ian


On 12/6/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 12/5/05, Tom Tobin <[EMAIL PROTECTED]> wrote:
> > BTW, is there any particular reason the Recent Votes feed is in Atom,
> > while all the others are in RSS?  (Not that my aggregator cares; just
> > curious!)
>
> Nice catch! I'd left that code in as a test and forgot to remove it.
> I'll update it on the site tomorrow. Thanks very much.
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com | chicagocrime.org
>


Re: Contrib markup app not to be installed?

2005-12-03 Thread Ian Holsman

shouldn't a warning/informational message be generated in this case.
something like

$ django-admin install markup
INFO: no models found to install.. skipping markup

?

On 12/3/05, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
>
> On Dec 3, 2005, at 5:13 AM, James Bennett wrote:
> > While setting up a new project tonight, I was running through and
> > doing a 'django-admin.py install' for each of the apps from
> > django.contrib I'll be using, and when I got to the markup app, I got
> > the following error:
> >
> > Error: No module named markup. Are you sure your INSTALLED_APPS
> > setting is correct?
> >
> > I've got 'django.contrib.markup' in INSTALLED_APPS, and the markup app
> > certainly seems to be a Python module. Is it not meant to be installed
> > with 'django-admin.py' (since I recall Jacob saying that all you need
> > is to have it in INSTALLED_APPS and then do 'load markup' in your
> > template)?
>
> Yeah, it doesn't get installed -- the markup app has no models, just
> the custom template tag.
>
> Jacob
>


--
[EMAIL PROTECTED] -- blog: http://feh.holsman.net/ -- PH: ++61-3-9877-0909

If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: problem marketing django to php folk

2005-11-25 Thread Ian Holsman
There isn't any found yet?

but seriously.. we should have a 'security' page which covers django
'best-practices' in that area.
there has been some recent discussion on the developer list about how
to accept parameters defensively.

There is also a cross site request forgery  prevention compoent here:
http://lukeplant.me.uk/resources/csrfmiddleware/

regards
Ian.


On 11/26/05, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
>
> hi,
> have been talking to some php folk about switching to django, but
> they have raised a serious concern: Django website does not have a
> page for security alerts and the django team has not released any
> security patches - so they feel very uneasy about the whole thing.
> Can this defect somehow be rectified?
> --
> regards
> kg
>
> http://www.livejournal.com/users/lawgon
> tally ho! http://avsap.org.in
> ಇಂಡ್ಲಿನಕ್ಸ வாழ்க!
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: 2nd database for a specific app

2005-11-22 Thread Ian Holsman

Hi Patrick.

At the moment Django can not talk to 2 different databases.
If you need this, you might be able to get the data out of the 2nd
database via custom functions
which handle the db calls directly, or possibly futz with django/core/db

regards
Ian

but I would wait 12-24 hours until the experts wake up ;-)


On 11/22/05, patrick k <[EMAIL PROTECTED]> wrote:
>
> please help:
> i´m trying to have just ONE table for my app on a different host. all the
> other tables should be on dreamhost (auth, packages ...). so, when trying to
> install my newapp, i get an error like "table .packages not found". i
> basically need 2 setting files for one project (if that works).
>
> is it really possible to have different setting-files for different APPS
> (not projects)?
>
>
> >
> > sorry for being stupid here, but do you mean something like this:
> > django-admin.py startapp mynewapp --settings=myproject.newappsetings
> >
> > can i set the 2nd settings-file with DJANGO_SETTINGS_MODULE?
> >
> >>
> >> On 11/21/05, patrick k <[EMAIL PROTECTED]> wrote:
> >>> i have django installed on dreamhost. now i´d like to build an app with
> >>> tables from a given database on another host, still using my
> >>> dreamhost-installation.
> >>> since the database-settings seem to be global (settings.py) for all apps,
> >>> i´m not quite sure how to do this.
> >>
> >> Hey Patrick,
> >>
> >> Feel free to create a separate settings file for separate
> >> installations. Just point to the appropriate settings file in your
> >> server arrangement.
> >>
> >> Adrian
> >>
> >> --
> >> Adrian Holovaty
> >> holovaty.com | djangoproject.com | chicagocrime.org
> >
>
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: 20 minute wiki, sortof.

2005-11-20 Thread Ian Holsman

hi David.

do you have a SVN url?
I'd love to replace moinmoin with a django wiki (i don't need much
from a wiki, so even a 20 minute one might be ok ;-)

regards
Ian
On 11/18/05, David Ascher <[EMAIL PROTECTED]> wrote:
> After watching the TurboGears 20 minute wiki screencast today, I figured I'd
> try to build the equivalent code in Django to see what it's like.
>
> It took me more than 20 minutes, but since this is my first non-tutorial
> Django app, I'm ok with that.
>
> If anyone is interested, I've put it up at:
> http://da.textdriven.com:8027/sydney/browser/trunk/wiki/
>
> Specifically, I'd love feedback on the views (
> http://da.textdriven.com:8027/sydney/file/trunk/wiki/apps/pages/views.py)
> and the template (
> http://da.textdriven.com:8027/sydney/file/trunk/wiki/templates/pages/page.html).
>  Everything else seems relatively straightforward, although I may be doing
> Bad Things with the urls too (
> http://da.textdriven.com:8027/sydney/file/trunk/wiki/urls.py).
>
> Note that unlike the TurboGears's use of MochiKit to convert JSON to DOM, I
> used the trivial ahah.js code from the microformats folks (
> http://www.microformats.org/wiki/rest/ahah) to do the Ajax
> operation.  Only one line of JS even though there is a maybe a bit more
> stuff going over the wire.
>
> About 70 lines of Python, 23 lines of HTML.
>
> What I liked about the process:
>
>   * the runserver make interactive work really easy.
>   * the tracebacks are very helpful
>
> Stumbling blocks:
>   * figuring out that I had to do "import
> django.contrib.markup.templatetags.markup" to get the
> markup filters registered was harder than it should have been.
>* understanding that the redirects involved in adding trailing /'s threw
> away POST data took me a while to figure out
>   * I was stumped by the fact that I had to setup another web server to
> serve static files.  It'd be nice if it was possible to serve static files
> with the development server.  I'd consider sending in a patch if someone
> could throw suggestions my way on what approach would work best  (or maybe
> it actually _is_ supported, I just didn't find out how!).
>
> Overall, quite an enjoyable experience!
>
> --david
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: Django and Ruby on Rails framework roundtable: Dec. 3 in Chicago

2005-11-17 Thread Ian Maurer

> Full information is here:
>
> http://snakesandrubies.com/event/

Is the site written in Django or Rails?

Just curious :P


Re: Access request object in model's hooks and display methods

2005-11-17 Thread Ian Holsman

couldn't we do something similar to get_active_site() call on the sites table?

that way people who need the 'request' object could just call it and
it wouldn't impact the api of anything else?

On 11/18/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 11/17/05, plisk <[EMAIL PROTECTED]> wrote:
> > Seems like its not possible to access request object in hooks like
> > pre_save and display methods(those are listed in list_display) ? Is it
> > supposed to be like this by design ? If so then hardly its very
> > convinient to use in real applications.
>
> Yes, this is by design. Models have no knowledge of whether they're
> being used in a Web context, or in a shell script, or in a desktop GUI
> app. Coupling models to Web requests would be convenient in some cases
> but a bad design decision overall.
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com | chicagocrime.org
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Sites, how do I use them

2005-11-16 Thread Ian Holsman

hi.

I have a application where sites would be a great fit for.
but I'm not sure how I make use of them.

is it as easy as just adding a 'Site' Field to my model on all the
tables,/classes
and django takes care of the rest?
or do I need to explictly hard code the views so that 'site' is taken
into account?

regards
Ian.
--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: Trouble with Apache 1.3 and FCGI on Mac OS X

2005-11-16 Thread Ian Holsman

Hi Colin.
as a point of reference I use Apache2 + mod-python on my OS/X box and
it works like a charm.
I would recommned people investigate this option as well.

regards
Ian.

On 11/16/05, Colin Howlett <[EMAIL PROTECTED]> wrote:
>
> Georg,
>
> I wasn't really complaining about not getting a reply, just stating a
> fact :-)
>
> Anyway, I did try downloading from
>
> http://www.inoi.fi/open/trac/eunuchs
>
> and it didn't compile for me. Were you using 10.4?
>
> As I said, my problem is solved, but it would be nice to have clear
> guidance for others.
>
> regards
>
> Colin
>
>
> hugo wrote:
> > >Well, I never got a reply, and I never got python-eunuchs working.
> >
> > Maybe giving us a bit more than just one day to react? :-)
> >
> > >However, upgrading my python to 2.4 (and then basically reinstalling
> > >everything in the new site-packages) did the trick. I did have to make
> >
> > Python Eunuchs is found here:
> >
> > http://www.inoi.fi/open/trac/eunuchs
> >
> > It does build on OS X, that's where I did the first experiments with
> > the django-fcgi.py script. But updating to Python 2.4 is another
> > working solution - Python Eunuchs is only needed because Python 2.3
> > doesn't include the socketpair function in the socket module.
> >
> > The documentation on the current version of the django-fcgi.py script
> > is at this URL:
> >
> > https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/wiki/DjangoFcgi
> >
> > bye, Georg
>
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: enforce login on generic views

2005-11-12 Thread Ian Holsman

Hi Adrian.
would it be too hard to just stick the 'user login' views in the main codebase?

regards
ian

On 11/13/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 11/12/05, Bryan Murdock <[EMAIL PROTECTED]> wrote:
> > How do I limit access to a generic view to logged in users?
>
> Hey Bryan,
>
> I've added a section to the docs for you:
>
> Limiting access to generic views
> http://www.djangoproject.com/documentation/authentication/#limiting-access-to-generic-views
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com | chicagocrime.org
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: Generic Views - CRUD

2005-11-04 Thread Ian Holsman

Hi.

I would think some ajax mojo on the lookup field for the foreign key
would be able to populate these fields for you (and also change them
when the user changes the foreign key)

http://code.djangoproject.com/wiki/NewAdminChanges describes some
other enhancements to the default CRUD tables, like being able to do
master-slave input views (eg.. invoice/invoice-item) which makes the
generic views more useful.

as for manipualtors.. you can set it up so that you only have to
validate/manipulate the fields you care about.
I did something like this on
http://feh.holsman.net/articles/2005/10/18/django-custommanipulators
where it adds a custom field to the manipulator to populate another
relationship. this might help.

regards
Ian


On 11/5/05, sarahwithanx <[EMAIL PROTECTED]> wrote:
>
> The generic views seem very limiting.  Is there a way to include
> multiple objects in the same form?
>
> I have an object, which relates to another via a foreign key.  On
> creation, it needs accept input for data to store in the other table
> (and create two additional linked objects).  I need to get information
> for the master object, as well as values to store in the linked
> records.
>
> I can do this using request.POST, but I will have to map and validate
> all the data on my own.  Is there another way to do this?
>
>
> Thanks
>
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: I want to start a django project for a forum

2005-11-03 Thread Ian Maurer

I would like to volunteer to help wherever I can.
-ian

On 11/3/05, Waylan Limberg <[EMAIL PROTECTED]> wrote:
>
> On 11/3/05, Ian Holsman <[EMAIL PROTECTED]> wrote:
> >
> > Hi Luke.
> >
> > my aim is not to do a drop-in replacement for a phpBB. but more for
> > integrating discussions into other parts of applications, and to do
> > this I think it needs to in django.
> >
> > I have got a wiki page up, http://wiki.zilbo.com/ForumDesign (yes it
> > took me this long to get the silly thing running)  to put a list of
> > features up. and just to flesh out the idea a bit more..
> >
> > I don't think this needs to be a 'phpbb' killer to be successful, just
> > something which can:
> > - be used as a sample of how to build a django app
> > - be used/dropped into your django app easily.
> >
>
> You may want to check out the approach they took on this project:
> http://getvanilla.com/
> Its in php, but I'd say its the only forum interface I didn't mind
> using. They were "thinking outside the box" when they developed that
> package. Perhaps it could provide some inspiration.
>
>
> --
> 
> Waylan Limberg
> [EMAIL PROTECTED]
>


Re: I want to start a django project for a forum

2005-11-02 Thread Ian Holsman

Hi Luke.

my aim is not to do a drop-in replacement for a phpBB. but more for
integrating discussions into other parts of applications, and to do
this I think it needs to in django.

I have got a wiki page up, http://wiki.zilbo.com/ForumDesign (yes it
took me this long to get the silly thing running)  to put a list of
features up. and just to flesh out the idea a bit more..

I don't think this needs to be a 'phpbb' killer to be successful, just
something which can:
- be used as a sample of how to build a django app
- be used/dropped into your django app easily.

my main use for this  would be for me  to write applications like
mp3.com and tv.com.

On 11/1/05, Luke Plant <[EMAIL PROTECTED]> wrote:
>
> On Tue, 1 Nov 2005 11:16:14 +1100 Ian Holsman wrote:
>
> >
> > is anyone else interested in joining? I was thinking of similar to
> > what phpBB does.
> >
> > If so I propose we open up a sourceforge project, or perhaps we could
> > even host it on code.djangoproject.com if they let us ;-)
> >
> > any volunteers?
>
> If you need a bbcode parser that outputs valid XHTML, I have one that I
> wrote for my current Django project (surprisingly, I couldn't find one
> written in python on the 'net, and all the PHP ones I found generated
> tag soup).
>
> But, like Jeffrey said, do we need yet another forum, especially if
> it's just a clone?
>
> I think there can be good reasons for writing your own forum.  My
> current Django project has a message board system that
> 1) is quite a bit simpler and less intimidating than phpBB,
> 2) includes features specific to my site,
> 3) is fairly tightly integrated into the rest of the site.
> These things make the forum I've written not at all suitable for re-use
> as a standalone project.
>
> In short, if I wanted a standalone project I can just drop in, I'd use
> phpBB (or similar).  If I need something much more integrated, I'm
> going to write it myself, as a generic forum system probably isn't going
> to cut it, even if it's written in Django.  I guess there could be a
> case for some writing some Django models and views that would be easy to
> drop in to any other Django app, but you would have to think carefully
> about how you designed them I think.
>
> Luke
>
> --
> "I'm at peace with the world. I'm completely serene. I know why I was
> put here and why everything exists. I am here so everybody can do what
> I want. Once everybody accepts it, they'll be serene too." (Calvin and
> Hobbes)
>
> Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: I want to start a django project for a forum

2005-10-31 Thread Ian Holsman

basic reason on why I brought this up now.

1. promote django
2. latest security patch for phpBB was just announced

3. and I think the world does need a alternative designed with
security in mind from the start.

4. lack of non-PHP solutions. I know of several people who refuse to
put php code on their servers

5. most 'community' style applications would need a 'forum' component.
having one which is directly pluggable into the django way of doing
things would allow easier integration with other django components
like for example a review and rating component, or a tagging
component, or a CMS component.

so ideally if this actually came off, and was usable I can see
developing other 'parts' to a generic 'community' application which
could be use. (in django)

On 11/1/05, Jeffrey E. Forcier <[EMAIL PROTECTED]> wrote:
>
> I might be interested (rolled my own phpBB/AcmlmBoard/etc/etc-like
> forum in PHP about five years ago, only got about 75% done but it was
> still fun) but I, and probably others, might want to know more about
> what you have in mind before we join up.
>
> Such as: why do we need yet another forum? ;) What can we offer by
> using Python/Django that the PHP-based boards don't have? Stuff like
> that :)
>
> Regards,
> Jeff
>
> On Oct 31, 2005, at 7:16 PM, Ian Holsman wrote:
>
> >
> > is anyone else interested in joining? I was thinking of similar to
> > what phpBB does.
> >
> > If so I propose we open up a sourceforge project, or perhaps we could
> > even host it on code.djangoproject.com if they let us ;-)
> >
> > any volunteers?
> >
> > regards
> > Ian
> >
> > --
> > [EMAIL PROTECTED] -- ++61-3-9877-0909
> > If everything seems under control, you're not going fast enough. -
> > Mario Andretti
> >
>
>
> --
> Jeffrey E. Forcier
> Junior Developer, Research and Development
> Stroz Friedberg, LLC
> 15 Maiden Lane, 12th Floor
> New York, NY 10038
> [main]212-981-6540 [direct]212-981-6546
> http://www.strozllc.com
>
> This message is for the named person's use only.  It may contain
> confidential, proprietary or legally privileged information. No right to
> confidential or privileged treatment of this message is waived or lost
> by any error in transmission.  If you have received this message in
> error, please immediately notify the sender by e-mail or by telephone at
> 212.981.6540, delete the message and all copies from your system and
> destroy any hard copies.  You must not, directly or indirectly, use,
> disclose, distribute, print or copy any part of this message if you are
> not the intended recipient.
>
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


I want to start a django project for a forum

2005-10-31 Thread Ian Holsman

is anyone else interested in joining? I was thinking of similar to
what phpBB does.

If so I propose we open up a sourceforge project, or perhaps we could
even host it on code.djangoproject.com if they let us ;-)

any volunteers?

regards
Ian

--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: Django presentation slides in Spanish

2005-10-28 Thread Ian Maurer

The original english version is here:

http://itmaurer.com/clepy/htdocs/media/presentation/presentation.html

I am going to try and update it for the new settings stuff this
weekend. If anyone notices any other inaccuracies please send me an
email at [EMAIL PROTECTED]

thanks-
ian

On 10/28/05, rapto <[EMAIL PROTECTED]> wrote:
>
> I have translated Ian's slides into Spanish.
>
> download:
> https://wh2001.sindominio.net/~rapto/pres_django.tbz
>
> online:
> https://wh2001.sindominio.net/~rapto/pres_django/
>
> Thanks to Ian Maurer
>
>


Re: 'Site administration' heading in django admin interface

2005-10-27 Thread Ian Holsman

Have you tried modifying/copying the file
$SRC//django/contrib/admin/templates/admin/base.html

if you modifiy your project settings file you can override this by
simply placing a file called
admin/base.html into your own template directory (before the standard one)

Cheers
Ian

On 10/28/05, Emanuele <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I'm using django automatic admin interface as (only) web-interface for
> a little application already in production/testing [*]. I customized a
> bit the main admin page using "django-admin.py adminindex" output but
> I'm not able to remove the heading "Site administration" on top of it
> because it is embedded in django code,
> contrib/admin/views/main.py :
> ...
> def index(request):
> return render_to_response('admin/index', {'title': 'Site
> administration'}, context_instance=Context
> ...
>
> I don't like touching django code code for now, so is it possible to
> remove or customize that heading from user side?
>
> Thanks,
>
> Emanuele
>
> [*]: I hope to release it freely soon, just as an example of django
> capabilities for newbies like me. Stay tuned.
>
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: meta.OneToOneField() problemo

2005-10-27 Thread Ian Maurer

Adrian,

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

Any progress with this issue? I am going to try and dig through the
code myself this weekend but I wanted to make sure I wasn't repeating
any effort. Also, let me know if there are any tips or ideas on where
to start obviously meta/__init__.py is probably a good place ;).

thanks-
Ian

On 9/19/05, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 9/19/05, Ian Maurer <[EMAIL PROTECTED]> wrote:
> > But, I have a multitude of problems that I don't believe I had before
> > the recent model overhaul. Here are some example things I tried doing
> > with my Waiter class that I believe should work:
>
> Hey Ian,
>
> It'd be a huge help if you could add some unit tests to
> tests/testapp/models/one_to_one.py and post them back to the list.
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com | chicagocrime.org
>


Re: global names undefined in _pre_save() and _post_save()

2005-10-18 Thread Ian Holsman

Hi Qiangning

it has something to do with how django creates it's model classes.

if you look closer at the excpetion, you might be able to add the
import statements into the framework class itself.

personally I like boring.. boring doesn't call you in the middle of
the night ;-)

regards
Ian

On 10/18/05, Qiangning Hong <[EMAIL PROTECTED]> wrote:
>
> it seems the _pre_save() and _post_save() doesn't run under the model
> namescope, am i right?  It ignores all the imports and defs in the model
> level.  i have to import everything and def functions inside the method.
> it's t boring.
>
> --
> Qiangning Hong
> http://www.hn.org/hongqn (RSS: http://feeds.feedburner.com/hongqn)
>
> Registered Linux User #396996
> Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1>
> Thunderbird! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=183>
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: difference between command line and a web-page

2005-10-17 Thread Ian Holsman

ok
I figured out my problem. (I think)

when a update is applied it happens in the following order.. please
correct me if i'm wrong.

..apply the edits on the object in question
_save function called

apply the edits to the one-to-many & many-to-many fields referenced.

my issue is that the many to many has a custom update method which I
am calling in _post_save and not in the actual field's manipulator..

Is this correct?
is it as simple as just moving the code into tags manipulator???

regards
Ian.


On 10/17/05, Ian Holsman <[EMAIL PROTECTED]> wrote:
> hi.
>
> I have a many to many table in django, which I'm having troubles updating.
>
>
> class Keyword( meta.Model ):
> URL = meta.URLField(core=True)
> pagetype = meta.ForeignKey( PageType, verbose_name="the type of page")
> regex = meta.CharField(maxlength=250)
> to_match = meta.BooleanField()
> description = meta.CharField(maxlength=255)
> what_testing = meta.TextField(verbose_name="What are you testing")
> tags = meta.ManyToManyField(Tag,blank=True)
> tagField = meta.CharField(maxlength=255,
> blank=True,verbose_name="List of tags you would like to categorize
> this
> post as")
>
> def _pre_save(self):
> from django.models.conf import *
> tagnames = self.tagField.split()
> taglist = []
> for tagname in tagnames:
> try:
> tag_ref = tags.get_object(name__exact = tagname.lower())
> except tags.TagDoesNotExist,msg:
> tag_ref = Tag(name=tagname.lower())
> tag_ref.save()
> taglist.append(tag_ref.id)
> self.set_tags(taglist)
>
> when I run the following from a python command line it works nicely.
>
> >>> from django.models.conf import *
> >>> a=keywords.get_object(id__exact=1)
> >>> a.tagField="moo baa lah lah"
> >>> a.save()
> >>> a.get_tag_list()
> [moo, baa, lah]
>
> but when I use the generic update view from a  web page it deletes the
> reference (and it also removes the page-type Foreign key as well.
>
> any hints would be appreciated.. this has me stuck ;(
>
> --
> [EMAIL PROTECTED] -- ++61-3-9877-0909
> If everything seems under control, you're not going fast enough. -
> Mario Andretti
>


--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


difference between command line and a web-page

2005-10-16 Thread Ian Holsman

hi.

I have a many to many table in django, which I'm having troubles updating.


class Keyword( meta.Model ):
URL = meta.URLField(core=True)
pagetype = meta.ForeignKey( PageType, verbose_name="the type of page")
regex = meta.CharField(maxlength=250)
to_match = meta.BooleanField()
description = meta.CharField(maxlength=255)
what_testing = meta.TextField(verbose_name="What are you testing")
tags = meta.ManyToManyField(Tag,blank=True)
tagField = meta.CharField(maxlength=255,
blank=True,verbose_name="List of tags you would like to categorize
this
post as")

def _pre_save(self):
from django.models.conf import *
tagnames = self.tagField.split()
taglist = []
for tagname in tagnames:
try:
tag_ref = tags.get_object(name__exact = tagname.lower())
except tags.TagDoesNotExist,msg:
tag_ref = Tag(name=tagname.lower())
tag_ref.save()
taglist.append(tag_ref.id)
self.set_tags(taglist)

when I run the following from a python command line it works nicely.

>>> from django.models.conf import *
>>> a=keywords.get_object(id__exact=1)
>>> a.tagField="moo baa lah lah"
>>> a.save()
>>> a.get_tag_list()
[moo, baa, lah]

but when I use the generic update view from a  web page it deletes the
reference (and it also removes the page-type Foreign key as well.

any hints would be appreciated.. this has me stuck ;(

--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


specifying the name of a many-to-many table

2005-10-16 Thread Ian Holsman

is it possible?
or should I just 'explode' it out into sepearte classes (2 one to many
links to a seperate table)

regards
Ian.

--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: Manipulators that span a relationships?

2005-10-16 Thread Ian Maurer

That fixed that bug. Thanks. Now I can move forward and test the rest.

I will provide more info the next time I run into a problem...

-ian

On 10/15/05, Robert Wittams <[EMAIL PROTECTED]> wrote:
>
> Ian Maurer wrote:
> > I didn't get very far with the new branch. My template is failing to
> > render right off the bat... I haven't had a chance to investigate
> > this, but my templates were/are working just fine under the main
> > branch. Below is the end of my traceback... any thoughts?
> >
> > -ian
> >
> > return render_to_response('forums/category_display', locals())
> >   File "C:\www\django\core\extensions.py", line 12, in render_to_response
> > return HttpResponse(template_loader.render_to_string(*args, **kwargs))
> >   File "C:\www\django\core\template_loader.py", line 38, in render_to_string
> > return t.render(context_instance)
> >   File "C:\www\django\core\template.py", line 122, in render
> > return self.nodelist.render(context)
> >   File "C:\www\django\core\template.py", line 573, in render
> > bits.append(node.render(context))
> >   File "C:\www\django\core\template_loader.py", line 98, in render
> > compiled_parent = self.get_parent(context)
> >   File "C:\www\django\core\template_loader.py", line 93, in get_parent
> > return get_template_from_string(*find_template_source(parent,
> > self.template_dirs))
> >   File "C:\www\django\core\template_loader.py", line 20, in
> > get_template_from_string
> > return template.Template(source, filename)
> >   File "C:\www\django\core\template.py", line 113, in __init__
> > self.nodelist = compile_string(template_string, filename)
> >   File "C:\www\django\core\template.py", line 135, in compile_string
> > return parser.parse()
> >   File "C:\www\django\core\template.py", line 295, in parse
> > self.extend_nodelist(nodelist, compile_func(self, token), token)
> >   File "C:\www\django\core\template_loader.py", line 156, in do_extends
> > nodelist = parser.parse()
> >   File "C:\www\django\core\template.py", line 295, in parse
> > self.extend_nodelist(nodelist, compile_func(self, token), token)
> >   File "C:\www\django\core\template_loader.py", line 125, in do_block
> > raise template.TemplateSyntaxError, "'%s' tag takes only one
> > argument" % bits[0]
> > TemplateSyntaxError: 'block' tag takes only one argument
> >
>
> I think this was a stupid (on my part) lexing bug I just fixed. If
> you've got the time, svn up and give it another try. The fix in question
> is in r882.
>
> Rob
>
>


Re: Manipulators that span a relationships?

2005-10-14 Thread Ian Maurer

I didn't get very far with the new branch. My template is failing to
render right off the bat... I haven't had a chance to investigate
this, but my templates were/are working just fine under the main
branch. Below is the end of my traceback... any thoughts?

-ian

return render_to_response('forums/category_display', locals())
  File "C:\www\django\core\extensions.py", line 12, in render_to_response
return HttpResponse(template_loader.render_to_string(*args, **kwargs))
  File "C:\www\django\core\template_loader.py", line 38, in render_to_string
return t.render(context_instance)
  File "C:\www\django\core\template.py", line 122, in render
return self.nodelist.render(context)
  File "C:\www\django\core\template.py", line 573, in render
bits.append(node.render(context))
  File "C:\www\django\core\template_loader.py", line 98, in render
compiled_parent = self.get_parent(context)
  File "C:\www\django\core\template_loader.py", line 93, in get_parent
return get_template_from_string(*find_template_source(parent,
self.template_dirs))
  File "C:\www\django\core\template_loader.py", line 20, in
get_template_from_string
return template.Template(source, filename)
  File "C:\www\django\core\template.py", line 113, in __init__
self.nodelist = compile_string(template_string, filename)
  File "C:\www\django\core\template.py", line 135, in compile_string
return parser.parse()
  File "C:\www\django\core\template.py", line 295, in parse
self.extend_nodelist(nodelist, compile_func(self, token), token)
  File "C:\www\django\core\template_loader.py", line 156, in do_extends
nodelist = parser.parse()
  File "C:\www\django\core\template.py", line 295, in parse
self.extend_nodelist(nodelist, compile_func(self, token), token)
  File "C:\www\django\core\template_loader.py", line 125, in do_block
raise template.TemplateSyntaxError, "'%s' tag takes only one
argument" % bits[0]
TemplateSyntaxError: 'block' tag takes only one argument


On 10/13/05, Ian Maurer <[EMAIL PROTECTED]> wrote:
> Easy enough. I will let you know if I run into any problems...
>
> thanks again,
> ian
>
> On 10/13/05, Robert Wittams <[EMAIL PROTECTED]> wrote:
> >
> > Ian Maurer wrote:
> > > That's a pretty slick implementation, I'd like to try it out... some 
> > > questions:
> > >
> > > Is it in a usable format?
> > > Are there any directions for pulling this branch down to my local 
> > > environment?
> > > What happens if the main branch gets updated?
> > >
> > >
> > > thanks...
> > > ian
> > >
> > >
> > >
> >
> > Well, I and a few other people are using it.
> >
> > The instructions to check it out are at :
> > http://code.djangoproject.com/wiki/BranchPolicy
> >
> > the branch name is new-admin
> >
> > so basically
> >
> > svn switch http://code.djangoproject.com/svn/django/branches/new-admin/
> >
> > in your checkout of trunk, or
> >
> > svn co http://code.djangoproject.com/svn/django/branches/new-admin/
> >
> > to check it out in another dir.
> >
> > I merge it with trunk pretty often, every couple of days, so it never
> > gets too out of sync. Its probably more unstable than trunk (eg in
> > situations I haven't tested yet).
> >
> >
>


Re: Manipulators that span a relationships?

2005-10-13 Thread Ian Maurer

Easy enough. I will let you know if I run into any problems...

thanks again,
ian

On 10/13/05, Robert Wittams <[EMAIL PROTECTED]> wrote:
>
> Ian Maurer wrote:
> > That's a pretty slick implementation, I'd like to try it out... some 
> > questions:
> >
> > Is it in a usable format?
> > Are there any directions for pulling this branch down to my local 
> > environment?
> > What happens if the main branch gets updated?
> >
> >
> > thanks...
> > ian
> >
> >
> >
>
> Well, I and a few other people are using it.
>
> The instructions to check it out are at :
> http://code.djangoproject.com/wiki/BranchPolicy
>
> the branch name is new-admin
>
> so basically
>
> svn switch http://code.djangoproject.com/svn/django/branches/new-admin/
>
> in your checkout of trunk, or
>
> svn co http://code.djangoproject.com/svn/django/branches/new-admin/
>
> to check it out in another dir.
>
> I merge it with trunk pretty often, every couple of days, so it never
> gets too out of sync. Its probably more unstable than trunk (eg in
> situations I haven't tested yet).
>
>


Re: Manipulators that span a relationships?

2005-10-13 Thread Ian Maurer

That's a pretty slick implementation, I'd like to try it out... some questions:

Is it in a usable format?
Are there any directions for pulling this branch down to my local environment?
What happens if the main branch gets updated?


thanks...
ian



On 10/13/05, Robert Wittams <[EMAIL PROTECTED]> wrote:
>
> Ian Maurer wrote:
> > Is there a way to create a manipulator that will span a foreign key
> > relationship, similar to the "edit_inline" feature in the Admin tool?
> >
> > I know I cannot leverage the edit_inline feature now (ticket #535 may
> > fix that) but is there a "smart" way of leveraging the validation and
> > form processing features of Django across multiple objects until this
> > ticket is finished?
> >
> > thanks...
> > ian
> >
> >
>
> As you say, this is possible in the new admin branch, utilising the
> 'follow' argument to a manipulator. This can also be used to restrict
> which fields are instantiated and can be filled by post data (this fixes
> another ticket, I forget the number).
>
> eg , in a simplistic model about States and Cities,
>
> follow = {
>'description': False, # suppress the description field
>'cities' : True  # follow the foreign key relationship 'cities'
> }
>
> manipulator = states.ChangeManipulator(5, follow=follow)
>
> if you wanted to suppress a field within cities, you can do it with a
> nested version of the follow argument:
>
> follow = {
>'description': False,
>'cities': {
> 'population' : False
>}
> }
>
> There isn't really a good way to do this without the changes in
> new-admin. You could make your own manipulator, but then you are on your
> own with loading and saving all the fields. This was one of the main
> points of the new-admin branch. An unanswered (post 1.0) question here
> is what to do when an object has a very large number of children.
> Currently we just load them all, which is probably suboptimal.
>
> I'll start writing some docs for the changes in new-admin so more people
> can test them out.
>
> Rob
>
>


Manipulators that span a relationships?

2005-10-13 Thread Ian Maurer

Is there a way to create a manipulator that will span a foreign key
relationship, similar to the "edit_inline" feature in the Admin tool?

I know I cannot leverage the edit_inline feature now (ticket #535 may
fix that) but is there a "smart" way of leveraging the validation and
form processing features of Django across multiple objects until this
ticket is finished?

thanks...
ian



Django Unit Testing

2005-10-09 Thread Ian Maurer

I have created a simple write-up on how I am preparing my Django unit
tests to leverage sqlite's in-memory database:

http://itmaurer.com/blog/?p=2

Comments and suggestions welcome...
ian


newbieQ: having different databases for apps, and referencing tables from other applications

2005-10-07 Thread Ian Holsman

Hi.
I was wondering if it was possible to have different app's have
different apps in the same project.

for example if I wnat the forums from 'clepy's'  and the jobmonitor
from greenleaftech in the same project, but have them hit different
backends is this possible.

and the other related question i have is it possible for 2 different
apps to share a 'reference' table.

for exampel a product table which is used for editorial reviews in one app,
as well as a app which uses it to hold the latest prices from multiple
shops in another.


regards
(and thanks for opensoruceing django)

--Ian

--
[EMAIL PROTECTED] -- ++61-3-9877-0909
If everything seems under control, you're not going fast enough. -
Mario Andretti


Re: Oct 3rd: Django Presentation (CLEPY)

2005-10-05 Thread Ian Maurer

The presentation and the zipfile containing my project can be found at my site:

http://itmaurer.com/blog/?p=1

Thanks to all who attended!

Ian

On 9/25/05, Ian Maurer <[EMAIL PROTECTED]> wrote:
> I am going to be doing a presentation on Django at the Cleveland Area
> Python Interest Group (CLEPY) meeting on October 3rd.
>
> The topics that I will be going over will follow a pattern very
> similar to the Django online tutorials:
>
> - Python Web Development Overview
> - History of Django
> - Project Setup
> - Creating a Model
> - Creating a View
> - Creating a Template
> - URL Dispatching
> - Django Admin Tool
> - Generic Views
> - Caching
>
> If you are interested in attending, please reply to this message or
> send me an email so that I can get a head count.
>
> For more information on CLEPY, please check out this website:
> http://clepy.org/
>
> For meeting details, including a link to directions:
> http://www.clepy.org/meetings/2005_10_06_mtg_details
>
> regards,
> Ian Maurer
>


Oct 3rd: Django Presentation (CLEPY)

2005-09-25 Thread Ian Maurer

I am going to be doing a presentation on Django at the Cleveland Area
Python Interest Group (CLEPY) meeting on October 3rd.

The topics that I will be going over will follow a pattern very
similar to the Django online tutorials:

- Python Web Development Overview
- History of Django
- Project Setup
- Creating a Model
- Creating a View
- Creating a Template
- URL Dispatching
- Django Admin Tool
- Generic Views
- Caching

If you are interested in attending, please reply to this message or
send me an email so that I can get a head count.

For more information on CLEPY, please check out this website:
http://clepy.org/

For meeting details, including a link to directions:
http://www.clepy.org/meetings/2005_10_06_mtg_details

regards,
Ian Maurer


Re: How to extend Model ?

2005-09-23 Thread Ian Maurer

Checkout:

http://www.djangoproject.com/documentation/django_admin/

You want the 'sqlclear' option which gives you the SQL needed. I just
copy and paste it into my mysql session or you could dump it into a
file and run that.

good luck!
ian

On 9/23/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> I'm playing around with django and have a question:
> My model changed during development: I added an extra field.
> How do I migrate the existing DB  ?
>
> First I looked at django-admin, but found no help.
>
> As I'm developing there is no need to keep all data, so
> I tried dropping the tables related to my model, but
> that was not enough, the projects db holds some metadata,
> which I did not want to touch.
>
> So, what to do ? I think it is a common tast to modify a
> model during development, so I suppose there is a reasonable
> solution.
>
> Greetings, Uwe
>
>


Re: meta.OneToOneField() problemo

2005-09-23 Thread Ian Maurer

> "svn diff" is great, in most cases. I just created this page, which
> gives more details:
>
> http://code.djangoproject.com/wiki/PatchGuidelines

Great, thanks... I felt dumb not knowing. Glad I asked.

> > First, I ran into an issue with runtests.py since I use MySQL. The DB
> > connection autocommit requires an integer value and the current code
> > throws a TypeError for me.
>
> Hmmm, that shouldn't be happening. Which versions of MySQL and MySQLdb
> (the Python bindings) are you using? The unit tests work here, with
> MySQL 3.23.58 and MySQLdb 0.9.2.

I guess that's our issue... not sure what has changed or why. I
haven't had a chance to investigate it.

MySQL 4.0.24
MySQLdb 1.2
Python 2.4

> > Here are my modifications to one-to-one.py:
>
> Thanks for those unit tests! I'm rolling them in now...

And I watching this ticket...

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

thanks!

Ian


Re: meta.OneToOneField() problemo

2005-09-19 Thread Ian Maurer

First, I am using 'svn diff' for submitting my patches, let me know if
there is a preferred way... especially when posting to Trac.

First, I ran into an issue with runtests.py since I use MySQL. The DB
connection autocommit requires an integer value and the current code
throws a TypeError for me. So the real brain-dead way around this was:

Index: runtests.py
===
--- runtests.py (revision 647)
+++ runtests.py (working copy)
@@ -97,6 +97,8 @@
 db.connection.autocommit()
 except AttributeError:
 pass
+except TypeError:   # For MySQL Users
+db.connection.autocommit(1)
 self.output(1, "Creating test database")
 try:
 cursor.execute("CREATE DATABASE %s" %
TEST_DATABASE_NAME)
@@ -183,6 +185,8 @@
 db.connection.autocommit()
 except AttributeError:
 pass
+except TypeError:   # For MySQL Users
+db.connection.autocommit(1)
 else:
 time.sleep(1) # To avoid "database is being accessed
by other users" errors.
 cursor.execute("DROP DATABASE %s" % TEST_DATABASE_NAME)


Here are my modifications to one-to-one.py:

Index: one_to_one.py
===
--- one_to_one.py   (revision 647)
+++ one_to_one.py   (working copy)
@@ -23,6 +23,13 @@
 def __repr__(self):
 return "%s the restaurant" % self.get_place().name

+class Waiter(meta.Model):
+restaurant = meta.ForeignKey(Restaurant)
+name = meta.CharField(maxlength=50)
+
+def __repr__(self):
+return "%s the waiter at %s" % (self.name,
self.get_restaurant())
+
 API_TESTS = """
 # Create a couple of Places.
 >>> p1 = places.Place(name='Demon Dogs', address='944 W. Fullerton')
@@ -61,4 +68,10 @@
 Demon Dogs the restaurant
 >>> restaurants.get_object(pk=1)
 Demon Dogs the restaurant
+
+# Add Waiter to Restaurant.
+>>> w = r.add_waiter(name="Joe")
+>>> w.save()
+>>> w
+Joe the waiter at Demon Dogs the restaurant
 """

My tests failed spectacularly...

Running tests with database 'mysql'

'one_to_one' module: API test raised an exception
=
Code: 'w = r.add_waiter(name="Joe")'
Line: 40
Exception:   File "C:\www\downloads\trunk\tests\doctest.py", line 1243,
in __run
compileflags, 1) in test.globs
  File "", line 1, in ?
w = r.add_waiter(name="Joe")
  File "C:\www\django\utils\functional.py", line 3, in _curried
return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
  File "C:\www\django\core\meta\__init__.py", line 944, in
method_add_related
obj = rel_mod.Klass(**init_kwargs)
  File "C:\www\django\utils\functional.py", line 3, in _curried
return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
  File "C:\www\django\core\meta\__init__.py", line 755, in method_init
raise TypeError, "Invalid value: %r should be a %s instance, not a
%s" % (f.name, f.rel.to, type(rel_obj))
TypeError: Invalid value: 'restaurant' should be a  instance, not a 


'one_to_one' module: API test raised an exception
=
Code: 'w.save()'
Line: 41
Exception:   File "C:\www\downloads\trunk\tests\doctest.py", line 1243,
in __run
compileflags, 1) in test.globs
  File "", line 1, in ?
w.save()
NameError: name 'w' is not defined


'one_to_one' module: API test raised an exception
=========
Code: 'w'
Line: 42
Exception:   File "C:\www\downloads\trunk\tests\doctest.py", line 1243,
in __run
compileflags, 1) in test.globs
  File "", line 1, in ?
w
NameError: name 'w' is not defined

Let me know if I can improve on how I submit my future contributions...

regards,
Ian


Adrian Holovaty wrote:
> On 9/19/05, Ian Maurer <[EMAIL PROTECTED]> wrote:
> > But, I have a multitude of problems that I don't believe I had before
> > the recent model overhaul. Here are some example things I tried doing
> > with my Waiter class that I believe should work:
>
> Hey Ian,
>
> It'd be a huge help if you could add some unit tests to
> tests/testapp/models/one_to_one.py and post them back to the list.
>
> Adrian
>
> --
> Adrian Holovaty
> holovaty.com | djangoproject.com | chicagocrime.org



Re: meta.OneToOneField() problemo

2005-09-19 Thread Ian Maurer

Sorry Mark,

But I am going to add to your problem since I encountered something
this weekend that was similar. If I add a Waiter class to this example:

class Waiter(meta.Model):
name = meta.CharField(maxlength=50)
restaurant = meta.ForeignKey(Restaurant)

def __repr__(self):
return "%s waits at %s" % (self.name, self.get_restaurant())

But, I have a multitude of problems that I don't believe I had before
the recent model overhaul. Here are some example things I tried doing
with my Waiter class that I believe should work:

from django.models.places import places, restaurants, waiters

# Works Fine
p = places.Place(name='Demon Dogs', address='944 W. Fullerton')
p.save()

# Works Fine
r = restaurants.Restaurant(place=p, serves_hot_dogs=True,
serves_pizza=False)
r.save()

# This Fails:
w = r.add_waiter(name="John Doe")
#Traceback (most recent call last):
#  File "test_places.py", line 13, in ?
#w = r.add_waiter(name="John Doe")
#  File "C:\www\django\utils\functional.py", line 3, in _curried
#return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
#  File "C:\www\django\core\meta\__init__.py", line 944, in
method_add_related
#obj = rel_mod.Klass(**init_kwargs)
#  File "C:\www\django\utils\functional.py", line 3, in _curried
#return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
#  File "C:\www\django\core\meta\__init__.py", line 755, in
method_init
#raise TypeError, "Invalid value: %r should be a %s instance,
not a %s" % (f.name, f.rel.to, type(rel_obj))
#TypeError: Invalid value: 'restaurant' should be a  instance, not a 

# So Does This:
w = waiters.Waiter(restaurant=r, name="John Doe")
#Traceback (most recent call last):
#  File "test_places.py", line 27, in ?
#w = waiters.Waiter(restaurant=r, name="John Doe")
#  File "C:\www\django\utils\functional.py", line 3, in _curried
#return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
#  File "C:\www\django\core\meta\__init__.py", line 755, in
method_init
#raise TypeError, "Invalid value: %r should be a %s instance,
not a %s" % (f.name, f.rel.to, type(rel_obj))
#TypeError: Invalid value: 'restaurant' should be a  instance, not a 

# This Hack Works
w = waiters.Waiter(restaurant_id=r.place_id, name="John Doe")
w.save()

# But Even with a Correct Data Structure this Fails
print w.get_restaurant()
#Traceback (most recent call last):
#  File "test_places.py", line 43, in ?
#print w.get_restaurant()
#  File "C:\www\django\utils\functional.py", line 3, in _curried
#return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
#  File "C:\www\django\core\meta\__init__.py", line 873, in
method_get_many_to_one
#retrieved_obj = mod.get_object(**{'%s__exact' %
field_with_rel.rel.field_name: val})
#  File "C:\www\django\utils\functional.py", line 3, in _curried
#return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))
#  File "C:\www\django\core\meta\__init__.py", line 1083, in
function_get_object
#obj_list = function_get_list(opts, klass, **kwargs)
#  File "C:\www\django\core\meta\__init__.py", line 1123, in
function_get_list
#return list(function_get_iterator(opts, klass, **kwargs))
#  File "C:\www\django\core\meta\__init__.py", line 1105, in
function_get_iterator
#select, sql, params = function_get_sql_clause(opts, **kwargs)
#  File "C:\www\django\core\meta\__init__.py", line 1302, in
function_get_sql_clause
#tables2, join_where2, where2, params2, _ =
_parse_lookup(kwargs.items(), opts)
#  File "C:\www\django\core\meta\__init__.py", line 1231, in
_parse_lookup
#_throw_bad_kwarg_error(kwarg)
#  File "C:\www\django\core\meta\__init__.py", line 1181, in
_throw_bad_kwarg_error
#raise TypeError, "got unexpected keyword argument '%s'" %
kwarg
#TypeError: got unexpected keyword argument 'place__exact'

Originally, I was going to ditch the use of OneToOne because I thought
I was simply using it incorrectly in my design... but after seeing
Mark's post and whipping up this example, I believe there is a bug.

I also hope my post clarifies not confuses Mark's post... because I
believe they are related issues.

regards,
-ian



<    2   3   4   5   6   7