Re: Multiple Relationships Associativity and Admin

2007-04-22 Thread Russell Keith-Magee

On 4/23/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Thanks in advance to anyone who replies to this.
>
> Individually these are simple, but the part I can't quite figure out
> is how to simply ensure via the admin interface that if I create a new
> tag for an entry that the tag also become associated with the blog for
> the entry.

Sounds like you might need to play with a custom save() method. If you
override the default save() method on Tag, you can insert logic so
that every time a Tag is saved, the appropriate Entry/Blog object is
also updated.

This approach would have effect outside the admin interface - any
usage of Tag objects would inherit the same behaviour.

> Also if this doesn't seem possible, can I run two separate instances
> of a blog application on the same server? Given the database structure
> it seems if I duplicate the code as another application it will work,
> but this slightly voids the DRY principle as I'll have two or more
> copies of the same code.

Yes, you can do this, in many different ways.

As you noted, the obvious (non-DRY) way is to just copy the full
project directory.

One way to avoid duplication is to only duplicate the project
structure - i.e., settings.py, manage.py, and so on. The application
itself (the models, views, urls, etc) can be kept in a single location
and referenced from each copy of the settings file.

A third way is to set up your setting.py file to use environment
variables (e.g., define DATABASE_NAME as an environment variable,
rather than statically in the file), and set up multiple Apache site
profiles, each defining a different set of environment variables.

Yet another option is to use the Sites framework. This framework
allows you to deploy multiple 'sites' within a single application
server. More details here:

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

Yours,
Russ Magee %-)

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



Re: n00b to Django - simple Django example crashes :-(

2007-04-22 Thread Malcolm Tredinnick

On Mon, 2007-04-23 at 04:19 +, z0ltan wrote:
[...]
> and then navigate to the child directories from thence.
> Apparently it was using "/" as the root directory even though mine was
> a Windows box. So when I manually changed the root directory to "c:
> \", it worked fine. Am planning to raise a new ticket
> on this one... thanks again for the help!

Please always try to search existing tickets, including closed ones,
before doing this (opening a new ticket). In this case, you will
hopefulyl discover that the problem has been reported and was fixed
shortly after the 0.96 release.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: n00b to Django - simple Django example crashes :-(

2007-04-22 Thread z0ltan

robin_percy,

  Many thanks for pointing out the defect! It was just like you had
said, the example worked fine with Django 0.96! However, an
interesting fact I noticed was that
Django 0.96's installer wouldn't install on my Windows box. It was
throwing up and error "couldn't find directory \django" and stuff like
that! So I decided to hack around a bit and found that the problem was
in the "setup.py" file where it tries to extract the "root directory"
and then navigate to the child directories from thence.
Apparently it was using "/" as the root directory even though mine was
a Windows box. So when I manually changed the root directory to "c:
\", it worked fine. Am planning to raise a new ticket
on this one... thanks again for the help!

Regards,

Timmy Jose.

On Apr 22, 10:53 pm, robin_percy <[EMAIL PROTECTED]> wrote:
> This is most likely because you're using 0.95 instead of 0.96.  The
> error is documented here:http://code.djangoproject.com/wiki/IrcFAQ#WeirdError1
>
> On Apr 22, 10:25 am, z0ltan <[EMAIL PROTECTED]> wrote:
>
> > Hi folks,
> >      I have been bitten by the Python bug and have decided to jump
> > into web development using Python and what can I say, I found Django's
> > charms too hard to resist! But there seems to be some trouble in
> > paradise ... lemme explain in brief -
>
> > I setup up Django 0.95 on my system alongwith Python 2.5. Installation
> > went off smoothly without any errors. To test the configuration, I
> > started following the steps and examples given in "The Django Book".
> > The code is basically the following:
> >        from django.http import HttpResponse
> >        from mysite.views import current_daytime
>
> >       def current_datettime(request):
> >               now = datetime.datetime.now()
> >               html = "The current time is %s. > html>" % now
> >               return HttpResponse(html)
>
> > "mysite" being, of course, the project created using the command
> > "manage.py startproject mysite" from the ...\django\bin directory. I
> > started the built-in Django server using the command "manage.py
> > runserver 8001" (note:
> > as required, I had suitably modified the 'urls.py' file in the mysite
> > directory).
>
> > The server runs fine. I even get the initial server screen (before
> > making the above modifications). However when I access the server
> > through the browser as "http://127.0.0.1:8001/now; ( note: the
> > 'urls.py file reads as:
>
> > from django.conf.urls.defaults import *
> > from mysite.views import current_datetime
>
> > urlpatterns = patterns('',
> >                 (r'^now/$',current_datetime),
> >                 )
>
> > )
>
> > However, the browser ( I tried on both IE and Mozilla Firefox ) throws
> > up the following error :
> > (Sorry, it's quite a bit long!!!)
>
> > 
>
> > AttributeError at /now/
> > 'function' object has no attribute 'rindex'
> > Request Method:         GET
> > Request URL:    http://127.0.0.1:8001/now/
> > Exception Type:         AttributeError
> > Exception Value:        'function' object has no attribute 'rindex'
> > Exception Location:     C:\Python25\lib\site-packages\django-0.95.1-
> > py2.5.egg\django\core\urlresolvers.py in get_mod_func, line 23
> > Traceback (innermost last)
> > Switch to copy-and-paste view
>
> >     * C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
> > \handlers\base.py in get_response
> >         58. for middleware_method in self._request_middleware:
> >         59. response = middleware_method(request)
> >         60. if response:
> >         61. return response
> >         62.
> >         63. resolver = urlresolvers.RegexURLResolver(r'^/',
> > settings.ROOT_URLCONF)
> >         64. try:
> >         65. callback, callback_args, callback_kwargs =
> > resolver.resolve(path) ...
> >         66.
> >         67. # Apply view middleware
> >         68. for middleware_method in self._view_middleware:
> >         69. response = middleware_method(request, callback,
> > callback_args, callback_kwargs)
> >         70. if response:
> >         71. return response
> >       ▶ Local vars
> >       Variable  Value
> >       exceptions
> >        > packages\django-0.95.1-py2.5.egg\django\core\exceptions.py'>
> >       mail_admins
> >       
> >       middleware_method
> >        >  > 0x01143910>>
> >       path
> >       '/now/'
> >       request
> >       , POST: > {}>, COOKIES:{}, META:{'ALLUSERSPROFILE': 'C:\\Documents and Settings\
> > \All Users', 'APPDATA': 'C:\\Documents and Settings\\Timmy Jose\
> > \Application Data', 'CLASSPATH': 'C:\\Program Files\\Java\\jre1.5.0_06\
> > \lib\\ext\\QTJava.zip', 'CLIENTNAME': 'Console', 'COMMONPROGRAMFILES':
> > 'C:\\Program Files\\Common Files', 'COMPUTERNAME': 'HOZEY', 'COMSPEC':
> > 'C:\\WINDOWS\\system32\\cmd.exe', 'CONTENT_LENGTH': '',
> > 'CONTENT_TYPE': 'text/plain', 'DJANGO_SETTINGS_MODULE':
> > 'mysite.settings', 'FP_NO_HOST_CHECK': 'NO', 'GATEWAY_INTERFACE': 'CGI/
> > 1.1', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Documents 

Re: n00b to Django - simple Django example crashes :-(

2007-04-22 Thread z0ltan

robin_percy,

  Many thanks for pointing out the defect! It was just like you had
said, the example worked fine with Django 0.96! However, an
interesting fact I noticed was that
Django 0.96's installer wouldn't install on my Windows box. It was
throwing up and error "couldn't find directory /django" and stuff
like
that! So I decided to hack around a bit and found that the problem
was
in the "setup.py" file where it tries to extract the "root directory"
and then navigate to the child directories from thence.
Apparently it was using "/" as the root directory even though mine
was
a Windows box. So when I manually changed the root directory to "c:
\", it worked fine. Am planning to raise a new ticket
on this one... thanks again for the help!

Regards,

Timmy Jose.

On Apr 22, 10:53 pm, robin_percy <[EMAIL PROTECTED]> wrote:
> This is most likely because you're using 0.95 instead of 0.96.  The
> error is documented here:http://code.djangoproject.com/wiki/IrcFAQ#WeirdError1
>
> On Apr 22, 10:25 am, z0ltan <[EMAIL PROTECTED]> wrote:
>
> > Hi folks,
> >      I have been bitten by the Python bug and have decided to jump
> > into web development using Python and what can I say, I found Django's
> > charms too hard to resist! But there seems to be some trouble in
> > paradise ... lemme explain in brief -
>
> > I setup up Django 0.95 on my system alongwith Python 2.5. Installation
> > went off smoothly without any errors. To test the configuration, I
> > started following the steps and examples given in "The Django Book".
> > The code is basically the following:
> >        from django.http import HttpResponse
> >        from mysite.views import current_daytime
>
> >       def current_datettime(request):
> >               now = datetime.datetime.now()
> >               html = "The current time is %s. > html>" % now
> >               return HttpResponse(html)
>
> > "mysite" being, of course, the project created using the command
> > "manage.py startproject mysite" from the ...\django\bin directory. I
> > started the built-in Django server using the command "manage.py
> > runserver 8001" (note:
> > as required, I had suitably modified the 'urls.py' file in the mysite
> > directory).
>
> > The server runs fine. I even get the initial server screen (before
> > making the above modifications). However when I access the server
> > through the browser as "http://127.0.0.1:8001/now; ( note: the
> > 'urls.py file reads as:
>
> > from django.conf.urls.defaults import *
> > from mysite.views import current_datetime
>
> > urlpatterns = patterns('',
> >                 (r'^now/$',current_datetime),
> >                 )
>
> > )
>
> > However, the browser ( I tried on both IE and Mozilla Firefox ) throws
> > up the following error :
> > (Sorry, it's quite a bit long!!!)
>
> > 
>
> > AttributeError at /now/
> > 'function' object has no attribute 'rindex'
> > Request Method:         GET
> > Request URL:    http://127.0.0.1:8001/now/
> > Exception Type:         AttributeError
> > Exception Value:        'function' object has no attribute 'rindex'
> > Exception Location:     C:\Python25\lib\site-packages\django-0.95.1-
> > py2.5.egg\django\core\urlresolvers.py in get_mod_func, line 23
> > Traceback (innermost last)
> > Switch to copy-and-paste view
>
> >     * C:\Python25\lib\site-packages\django-0.95.1-py2.5.egg\django\core
> > \handlers\base.py in get_response
> >         58. for middleware_method in self._request_middleware:
> >         59. response = middleware_method(request)
> >         60. if response:
> >         61. return response
> >         62.
> >         63. resolver = urlresolvers.RegexURLResolver(r'^/',
> > settings.ROOT_URLCONF)
> >         64. try:
> >         65. callback, callback_args, callback_kwargs =
> > resolver.resolve(path) ...
> >         66.
> >         67. # Apply view middleware
> >         68. for middleware_method in self._view_middleware:
> >         69. response = middleware_method(request, callback,
> > callback_args, callback_kwargs)
> >         70. if response:
> >         71. return response
> >       ▶ Local vars
> >       Variable  Value
> >       exceptions
> >        > packages\django-0.95.1-py2.5.egg\django\core\exceptions.py'>
> >       mail_admins
> >       
> >       middleware_method
> >        >  > 0x01143910>>
> >       path
> >       '/now/'
> >       request
> >       , POST: > {}>, COOKIES:{}, META:{'ALLUSERSPROFILE': 'C:\\Documents and Settings\
> > \All Users', 'APPDATA': 'C:\\Documents and Settings\\Timmy Jose\
> > \Application Data', 'CLASSPATH': 'C:\\Program Files\\Java\\jre1.5.0_06\
> > \lib\\ext\\QTJava.zip', 'CLIENTNAME': 'Console', 'COMMONPROGRAMFILES':
> > 'C:\\Program Files\\Common Files', 'COMPUTERNAME': 'HOZEY', 'COMSPEC':
> > 'C:\\WINDOWS\\system32\\cmd.exe', 'CONTENT_LENGTH': '',
> > 'CONTENT_TYPE': 'text/plain', 'DJANGO_SETTINGS_MODULE':
> > 'mysite.settings', 'FP_NO_HOST_CHECK': 'NO', 'GATEWAY_INTERFACE': 'CGI/
> > 1.1', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Documents 

Bush Family Nazi Connections

2007-04-22 Thread micen

Bush Family Nazi Connections

http://video.google.com/videoplay?docid=3961840602642450187


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



View this page "Bush Family Nazi Connections"

2007-04-22 Thread micen



Click on 
http://groups.google.com/group/django-users/web/bush-family-nazi-connections
- or copy & paste it into your browser's address bar if that doesn't
work.


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



Re: Django Urls object_id/xxxxxx/object_id

2007-04-22 Thread Michael Trier

Great blog post.

Michael

On 4/20/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Fri, 2007-04-20 at 22:26 +0100, Oliver Charles wrote:
> > Just write your own view that in turn calls a generic view? Create a new
> > view, with a similiar signiture, but change the object_id for team_id
> > AND result_id. Then, do a bit of logic to find the query set you need a
> > view of, and pass this through to a generic view, and then return this.
>
> This would be my standard approach. You are already capturing all the
> parameters (once you stop calling two of them object_id), so use those
> to construct the "real" queryset you want inside a wrapper function and
> then call the generic view.
>
> I wrote up an example of this here:
> http://www.pointy-stick.com/blog/2006/06/29/django-tips-extending-generic-views/
>  .
>
> It still seems to be a frequently viewed article, so either a robot is
> stuck looking at that page or it's something that really isn't as
> intuitive (yet) as it might be. I need to come up with some cooler
> examples.
>
> Regards,
> Malcolm
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: newforms.BooleanField needs a required=False?

2007-04-22 Thread Esau Rodriguez

Yes I do. I'm using the svn version.

On 4/21/07, Terji7 <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'm making my first 0.96 application, a Faroe Islands tax calculator
> (it's at gladsheinur.webfactional.com/skattur/, check it out, it's a
> work in progress).
>
> I'm trying to use a BooleanField, but GET requests send nothing back
> to the server if the checkbox is unchecked. That makes the form return
> a "This field is required', although it IS being used (it's only set
> to 'off').
>
> To make things work, I have to hack around using
>
> class MyForm(forms.Form):
> bool = forms.BooleanField(label="boolean", required=False)
>
> which isn't good. Anyone else have this problem with newforms?
>
>
> >
>


-- 
===
Saludos,
Esaú Rodríguez
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
===

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



regroup, dictsort and ordering objects

2007-04-22 Thread chrominance

I feel like maybe I've stretched the templating system to the breaking
point, but I'll ask anyways in case there's a solution.

I'm putting together templates for a calendar app, specifically one to
hold sports games/results. The first trick is I want to use the same
model for games already played and games in the future (DRY). The
second trick is I want to pass to my template a single list of
calendar items containing both games with scores and future games
without scores.

The model:

class SportsCalendarItem(models.Model):
sport = models.ForeignKey('SportType')
start_time = models.DateTimeField()
(...)

def is_played(self):
# determines whether a game has started or not, based on
start_time
(...)

class Meta:
ordering= ('start_time', 'sport')

The template (or at least the bits I think are relevant):

{% regroup items|dictsortreversed:"is_played" by is_played as times %}
{% for time in times %}
{% if time.grouper %}




Scoreboard
{% regroup time.list|dictsort:"sport" by sport as sports %}
{% for sport in sports %}
{{ sport.grouper }}
(...)

The basic idea is that I split the list of calendar items first by
is_played (so I can show scores for finished games and times for
upcoming games) and then by the sport itself (basketball, hockey,
etc.). This works great, except that for whatever reason, the order in
which the sports appear is random, when it should be alphabetically
sorted, or at least maintain a consistent sorting instead of changing
on every reload. I thought ordering the SportsCalendarItem by 'sport'
would do the trick, but apparently not; neither does the
dictsort|"sport".

Is there something else I'm missing, or is this one of those cases
where I'm trying to do way too much work with templates?


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



Newforms linked dropdowns (ajax/javascript/etc)

2007-04-22 Thread sime

Hi all, wondering if anyone has setup linked dropdowns using newforms?

Example. Country, state dropdowns. State has no options on initial
rendering. User first selects country. The state list is then
populated by an ajax / json type call. The user can then select a
state.


--~--~-~--~~~---~--~~
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: Accessing named URL patterns from views

2007-04-22 Thread Chris Lee-Messer

On Apr 21, 1:53 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> [snip]
> We haven't documentedreverse() anywhere, as far as I know. So worth
> filing a ticket.
>
I realize that urlresolvers.reverse() was not documented earlier, but
does the addition of named urls mean that the old behavior is still
going to be broken or will it be preserved for unambiguous matches?

I had been using
   urlresolvers.reverse('viewname', kwargs={ 'captured_arg': myarg})
to avoid putting hardcoded urls in my view's Http redirects.

-Chris

BTW: many thanks for all the django teams great work!



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



import problem

2007-04-22 Thread kamil

Hi. I installed Django on Python 2.5
and I receive following error on the built in server:

Exception Type: ImportError
Exception Value:No module named utils.text
Exception Location: /usr/lib/python2.5/site-packages/django/core/
urlresolvers.py in _get_urlconf_module, line 178

however utils.text exist in Django directory and importing in shell
works fine.
Please help.


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



Multiple Relationships Associativity and Admin

2007-04-22 Thread [EMAIL PROTECTED]

Thanks in advance to anyone who replies to this.

I just started using Django and I'm creating a sample blog application
in which within this application more than one blog is represented,
and each blog has a one-to-many relationship with tags, as well as a
one-to-many relationship with entries.

Individually these are simple, but the part I can't quite figure out
is how to simply ensure via the admin interface that if I create a new
tag for an entry that the tag also become associated with the blog for
the entry.

Also if anyone has done this could I easily add some ajax into the
administration panel so if when I'm adding an Entry and I select via
the dropdown the blog to associate with it a ajax request is sent to
the server to get the list of tags already associated with the blog?
The idea here is that as an author of one blog I am only listed tags
that are associated with my blog.

As a previous php web developer I could manually code this up, however
I don't know where to begin in Django.

Also if this doesn't seem possible, can I run two separate instances
of a blog application on the same server? Given the database structure
it seems if I duplicate the code as another application it will work,
but this slightly voids the DRY principle as I'll have two or more
copies of the same code.

The relavant code I currently am using:

class Blog(models.Model):
title = models.CharField(maxlength=200)
class Admin:
pass

class Tag(models.Model):
title = models.CharField(maxlength=20,core=True)
blog = models.ForeignKey(Blog, edit_inline=models.TABULAR,
num_in_admin=1)

class Entry(models.Model):
blog = models.ForeignKey(Blog)
title = models.CharField(maxlength=200)
tags = models.ManyToManyField(Tag)

class Admin:
pass


Thanks,
Bryce Boe
http://www.bryceboe.com


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



Re: get the latest # of objects

2007-04-22 Thread Oliver Charles

Try Entries.objects.order_by('a_field_that_you_want_to_order_by')[:5]

Entries.objects is a query set manager, not a query set, so you can't 
slice that.

--
Ollie
> hm. I'm trying to do this in a context processor and its not working:
>
> def entry_latest(request):
> from app.entries.models import Entries
> return {'entry_latest': Entries.objects[:5]}
>
>
> On Apr 22, 2:35 pm, "Honza Král" <[EMAIL PROTECTED]> wrote:
>   
>> just slice it:
>> entry_list[:5]
>>
>> just bear in mind that slicing will actually query the database, so
>> you need to do it when working with the data (e.g. not in urls.py when
>> providing parameters for generic views)
>>
>> On 4/22/07, drackett <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>>
>>
>> 
>>> I love the ability to get the latest object in a collection..
>>>   
>>> entry_list.latest()
>>>   
>>> and was curious if there is a way to get more than 1 object. For
>>> example, if I want the last 5 entries of a blog, is there something
>>> like
>>>   
>>> entry_list.latest(5)
>>>   
>>> I know that doesn't work, but is there an easy way to do this?
>>>   
>> --
>> Honza Kr?l
>> E-Mail: [EMAIL PROTECTED]
>> ICQ#:   107471613
>> Phone:  +420 606 678585
>> 
>
>
> >   


--~--~-~--~~~---~--~~
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: SQL Debug middleware

2007-04-22 Thread aaloy

2007/4/22, Honza Král <[EMAIL PROTECTED]>:
> Hi,
> try http://www.djangosnippets.org/snippets/93/ with the standard debug
> context preprocessor shipped with django (see the snippet for how-to)
>
> it seems cleaner to add this to your base template than to hackishly
> replace the  tag.
The use the Jesse idea and kdiff3 to see what had changed between
optimizations. So it's more fast for me to use his approach. But it's
nice to have more than one way to make the same thing.

Regards,

-- 
Antoni Aloy López
Binissalem - Mallorca
http://www.trespams.com
Soci de Bulma - http://www.bulma.cat

--~--~-~--~~~---~--~~
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: get the latest # of objects

2007-04-22 Thread Honza Král
On 4/22/07, drackett <[EMAIL PROTECTED]> wrote:
>
> hm. I'm trying to do this in a context processor and its not working:
>
> def entry_latest(request):
> from app.entries.models import Entries
> return {'entry_latest': Entries.objects[:5]}
yeah, you have to slice the queryset:
Entries.objects.all()[:5]

see
http://www.djangoproject.com/documentation/db-api/#limiting-querysets
for details
>
>
> On Apr 22, 2:35 pm, "Honza Kr�l" <[EMAIL PROTECTED]> wrote:
> > just slice it:
> > entry_list[:5]
> >
> > just bear in mind that slicing will actually query the database, so
> > you need to do it when working with the data (e.g. not in urls.py when
> > providing parameters for generic views)
> >
> > On 4/22/07, drackett <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> > > I love the ability to get the latest object in a collection..
> >
> > > entry_list.latest()
> >
> > > and was curious if there is a way to get more than 1 object. For
> > > example, if I want the last 5 entries of a blog, is there something
> > > like
> >
> > > entry_list.latest(5)
> >
> > > I know that doesn't work, but is there an easy way to do this?
> >
> > --
> > Honza Kr?l
> > E-Mail: [EMAIL PROTECTED]
> > ICQ#:   107471613
> > Phone:  +420 606 678585
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

--~--~-~--~~~---~--~~
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: get the latest # of objects

2007-04-22 Thread drackett

hm. I'm trying to do this in a context processor and its not working:

def entry_latest(request):
from app.entries.models import Entries
return {'entry_latest': Entries.objects[:5]}


On Apr 22, 2:35 pm, "Honza Král" <[EMAIL PROTECTED]> wrote:
> just slice it:
> entry_list[:5]
>
> just bear in mind that slicing will actually query the database, so
> you need to do it when working with the data (e.g. not in urls.py when
> providing parameters for generic views)
>
> On 4/22/07, drackett <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > I love the ability to get the latest object in a collection..
>
> > entry_list.latest()
>
> > and was curious if there is a way to get more than 1 object. For
> > example, if I want the last 5 entries of a blog, is there something
> > like
>
> > entry_list.latest(5)
>
> > I know that doesn't work, but is there an easy way to do this?
>
> --
> Honza Kr?l
> E-Mail: [EMAIL PROTECTED]
> ICQ#:   107471613
> Phone:  +420 606 678585


--~--~-~--~~~---~--~~
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: get the latest # of objects

2007-04-22 Thread Honza Král
just slice it:
entry_list[:5]

just bear in mind that slicing will actually query the database, so
you need to do it when working with the data (e.g. not in urls.py when
providing parameters for generic views)

On 4/22/07, drackett <[EMAIL PROTECTED]> wrote:
>
> I love the ability to get the latest object in a collection..
>
> entry_list.latest()
>
> and was curious if there is a way to get more than 1 object. For
> example, if I want the last 5 entries of a blog, is there something
> like
>
> entry_list.latest(5)
>
> I know that doesn't work, but is there an easy way to do this?
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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



get the latest # of objects

2007-04-22 Thread drackett

I love the ability to get the latest object in a collection..

entry_list.latest()

and was curious if there is a way to get more than 1 object. For
example, if I want the last 5 entries of a blog, is there something
like

entry_list.latest(5)

I know that doesn't work, but is there an easy way to do this?


--~--~-~--~~~---~--~~
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: filtering by if a date field is empty

2007-04-22 Thread drackett

yep, thanks!

On Apr 22, 1:38 pm, "Honza Král" <[EMAIL PROTECTED]> wrote:
> On 4/22/07, drackett <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am trying to grab objects from a model only if they are not complete
> > using a context processor. This is the code I have right now, but it
> > doesn't work. Is there an easy way to filter by if a date field is
> > empty/null?
>
> > def event_open(request):
> > from app.events.models import Event
> > return {'event_open': Event.objects.filter(date_closed)}
>
> is
>  return {'event_open': Event.objects.filter(date_closed__isnull=True)}
> what you are looking for?
>
> you will find a list of available db lookups 
> onhttp://www.djangoproject.com/documentation/db-api/#field-lookups
>
>
>
> --
> Honza Kr?l
> E-Mail: [EMAIL PROTECTED]
> ICQ#:   107471613
> Phone:  +420 606 678585


--~--~-~--~~~---~--~~
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: filtering by if a date field is empty

2007-04-22 Thread Honza Král
On 4/22/07, drackett <[EMAIL PROTECTED]> wrote:
>
> I am trying to grab objects from a model only if they are not complete
> using a context processor. This is the code I have right now, but it
> doesn't work. Is there an easy way to filter by if a date field is
> empty/null?
>
> def event_open(request):
> from app.events.models import Event
> return {'event_open': Event.objects.filter(date_closed)}

is
 return {'event_open': Event.objects.filter(date_closed__isnull=True)}
what you are looking for?

you will find a list of available db lookups on
http://www.djangoproject.com/documentation/db-api/#field-lookups
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

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



اصدقاء واخوه

2007-04-22 Thread الحربي
الصداقه شي محب الى القلب فبها نتعلم الحياة ونمارسها بشكل صحيح كيف كل
انسان ليس معصوم من الاخطاء وراي واحد لايكفي لابدان يكون هناك اصدقاء
واخوه يعطونك ارأئهم وبالاخر يتفقون على رأي واحد وهو الصحيح لابدمن
هذاوامور كثيره تتعلق بي هكذا مواقف هل رأي صحيح الصديق الوفي يخاف على
صديقه مثل مايخاف على نفسه فياريت ان نكون اصدقاء واخوه دائما
وابدأ. هل توافقوني على هذا الموضوع وساكون بنتظاركم اخ
وصديق دائم انشاء اللـــه تعالى

--~--~-~--~~~---~--~~
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: contrib.auth logins "randomly" complaining about cookies being disabled

2007-04-22 Thread plungerman

greetings,

i have been experiencing the same problem.  we have a login page, and
you can always log in from that page.  in the header of each page, you
can log in as well, and that form, when submitted, throws the afore
mentioned "cookies" error.  oddly enough, i cannot replicate this
problem in IE and it is consistent with firefox 2.

have you had any luck with solving this problem?



On Mar 22, 10:27 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Thank you both for your replies!
>
> On Mar 21, 6:56 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > There is nothing special about that app. The login which is failing is
> > the standarddjangoone (The app just adds code for new account
> > creation, e-mailing the registerant, and enabling the account with a
> > unique key).
>
> Correct. The app is merely used to add e-mail confirmation to the
> registration process.
>
>
>
> > I believe the problem you are running into is because the page is
> > stale. That is you are using the back button and not reloading the
> > page with the login form fresh. When the page loads a new temporary
> > cookie is set. If that cookie is not present on the login submission,
> > then you get the cookies enabled error. Other parts of the system will
> > delete the cookie if they see it (including logout).
>
> > So you go to the main page wich has a login form (cookie created)
> > You load a different page with the login form (cookie created, again)
> > You log in (cookie is seen, you are logged in and the cookie is
> > deleted)
> > You log out (cookie doesn't exist, nothing to do)
> > You go 'back' to main page with login (page is not reloaded from the
> > server, so still no cookie)
> > You log-in (no cookie - Error message)
> > If yo reload the page (hold the shift key down on reload), then try
> > again - Works.
>
> The problem persists on several computers and I've restarted the
> browser, development server and I navigate through the page
> navigation, not the back button. And it does not work if I reload the
> front page with the shift key.
>
> > Also you can run into this problem if you are using the cache
> > middleware.
> > Make sure the session middleware occurs BEFORE the cache middleware,
> > in your middleware list.
>
> I am not using the caching middleware (yet).
>
> > -Doug
>
> > On Mar 21, 12:56 pm, "ashwoods" <[EMAIL PROTECTED]> wrote:
>
> > > have you tried contacting the project maintainer? this is third party
> > > code and unless anybody happens to use it, to answer you they would
> > > have to go through his code. on the wiki page it says:
>
> > > >Questions? Problems?
> > > >If you've got a question that isn't covered here or in the comments and 
> > > >docstrings in the code, or if you run into a bug, swing on over to this 
> > > >app's Google >Code project page and file a new "issue". I'll do my best 
> > > >to respond promptly.
>
> > > so i would try that first :)
> > > if that doesnt work, i guess i'll have to go through the code ;)
>
> > > cheers,
> > > ashley
>
> > > On Mar 21, 1:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > > > Hi!
>
> > > > I've recently implementedhttp://code.google.com/p/django-registration/
> > > > to support user registration and authentication on a project.
>
> > > > I've also created a form in a template that extends ALL other
> > > > templates on the site.
>
> > > > I'm facing the following problem:
>
> > > > If I fire thedjangodevelopment server up and enter my login
> > > > credentials on the site's front page, the login fails with the
> > > > following message: "Your Web browser doesn't appear to have cookies
> > > > enabled.Cookies are required for logging in.".
>
> > > > What's weird is that I do have cookies enabled. What's even more weird
> > > > is that ...
>
> > > > ... If I try to login AGAIN using the same form on the page that shows
> > > > me this message, I can login just fine.
>
> > > > If I then go to the front page and log out, I can login from the front
> > > > page without a problem. BUT if I logout, go to a random location on
> > > > the site, and then back to the front page, I can't login again.
>
> > > > The same behavior is present on all pages (~5), except the actual
> > > > login-page.
>
> > > > I've tested on both apache with mod_python and using theDjango
> > > > development server and on several different client computers. Browsers
> > > > tested: FF 2.0.0.2 and Safari 2.0.0.4.
>
> > > > Would greatly appreciate any help!
>
> > > > Thanks in anticipation,
> > > > Gustaf Sjöberg


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



Re: Django Schema Migration

2007-04-22 Thread Jeremy Dunck
On 4/20/07, Mike H <[EMAIL PROTECTED]> wrote:
> It seems to be working well for the developers here, so here's hoping
> it's useful for some other people too :)

This is interesting-- migrating django apps using django.  Are there
cases where Django or the DB could become so broken that the migrator
couldn't run?  I wasn't sure, so I took the coward's way.

I'm attaching my db_upgrade.py for comparison.  (I've attached it
on-list a time or two before, but there are many migration threads.
:)) It uses numbers instead of names for migrations, and has a custom
db_version table (no django model for it).  It supports only python
upgrade steps, but those steps are handed a connection to work with if
they want to use SQL directly.   Finally, it runs against Ye Olde
Django (0.91) and probably needs some tweaks to run against 0.96.

If I'm reading your code right, the migrations could be applied out of
order, depending on which ones you have already run.  Since schema is
stateful, I think strict order is better.

Consider developers Mike and Jeremy, starting with the same DB.  Mike
creates a migration, "HalfPrice" and runs it locally.  Jeremy creates
a migration, "FullPrice" and runs it locally.  Each then update their
checkouts and run syncdb.

The migrator conflict is update like this, say:
migrations = [
  "HalfPrice",
  "FullPrice"
]

The changes of FullPrice will be run for Mike (since that's not in the
applied list in his DB), and the changes of HalfPrice will be run for
Jeremy (for the same reason).

Now, this probably isn't an issue outside of development, but it was
this situation that led me to use migration numbers rather than names
and have my migration script halt if the DB rev was at or higher than
the highest migration step.

Cheers,
  Jeremy

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

#!/usr/bin/python
import sys, os
import psycopg
from django.core.db import db
from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG, TIME_ZONE, UPGRADE_STEPS_PATH, DEBUG

def usage():
sys.stderr.write("%s [--nobackup] \n Expects DJANGO_SETTINGS_MODULE to be set.\n")

if len(sys.argv) == 1:
do_backup = True
else:
if sys.argv[1] == "--nobackup":
do_backup = False
else:
usage()
sys.exit()


try:
os.environ['DJANGO_SETTINGS_MODULE']
except KeyError:
usage()
sys.exit()

def get_conn_string():
if DATABASE_NAME == '':
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "You need to specify DATABASE_NAME in your Django settings file."
conn_string = "dbname=%s" % DATABASE_NAME
if DATABASE_USER:
conn_string = "user=%s %s" % (DATABASE_USER, conn_string)
if DATABASE_PASSWORD:
conn_string += " password='%s'" % DATABASE_PASSWORD
if DATABASE_HOST:
conn_string += " host=%s" % DATABASE_HOST
if DATABASE_PORT:
conn_string += " port=%s" % DATABASE_PORT
return conn_string

def get_db():
log("Opening DB for upgrade")
cur = db.cursor()
conn = db.connection
return conn, cur

def get_current_version(cur):
"""
Assumes:
create table db_version (branch varchar(50), version integer);
insert into db_version values ('trunk', 1);

"""
try:
cur.execute('select branch, version from db_version')
except psycopg.ProgrammingError, e:
logerr("Couldn't find db_version \n%s\n:\n  perhaps you forgot to restore a DB dump or should create the table with ('trunk', 1)?" % e)
return cur.fetchone()

def log(s):
sys.stderr.write('info: %s\n' % s)

def logerr(s):
sys.stdout.write('error: %s\n' % s)
sys.stdout.write('error: You probably want to restore the DB!\nQuitting.\n')
sys.exit()

def backup_db(init, final) :
import subprocess
from time import gmtime, strftime
dumpfile = "db_preupgrade_%s_from_%d_to_%d_at_%s_dump" % \
   (DATABASE_NAME, init, final, strftime("%Y%m%dT%H%M%S", gmtime()))
log("If you're asked for the DB password, it's: %s" % DATABASE_PASSWORD)
#FIXME: use subprocess.Popen and tie pg_dump output to gzip input.
ret = subprocess.call(["pg_dump", "-f", dumpfile, "-U", DATABASE_USER, "-h", DATABASE_HOST, DATABASE_NAME])

if ret != 0:
raise RuntimeError, "Failed to create pg_dump %d" % ret
return dumpfile

if __name__ == '__main__':
sys.path.insert(0, UPGRADE_STEPS_PATH)
import upgrade_steps

conn, cur = get_db()

label, initial_version = get_current_version(cur)

log("Starting at version %d of 

Re: Django Schema Migration

2007-04-22 Thread Mike H

Hi Jeremy,

I see your point, and yes, migrations can be run out of sequence - 
although in practice I've found that it is rarely an issue and if it is, 
it can be resolved fairly simply. Let's take a couple of examples. I'm 
not trying to be condescending, just thinking it through outloud ;)

1) Mike wants to add " favourite_colour" attribute to a Profile object, 
and Jeremy wants to add "shoe_size". There are two migrations that CAN 
be applied out of order - they do not depend on each other at all. When 
Mike updates, he will get the code and migration for "shoe_size". When 
Jeremy updates, he will get the code and migration for 
"favourite_colour". No problems there.

2) Jeremy wants to abstract some information (let's say shoe_size) from 
the Profile object into a separate 'Clothing' class and add a reference 
in Profile to the new class. At the same time, Mike alters the shoe_size 
attribute to be a different type. Now we get a situation where the 
migrations depend on each other but are not available to both developers.

So, if we used a migration number instead of just the name, the commit 
would flag the conflict as the two migration files would conflict. 
Great! We've seen the problem immediately!

If we just used the name, our pre-commit update and test would flag the 
problem.

Lets say that Jeremy has committed his code first.

Before he commits, Mike updates runs his tests. As part of the test run, 
the database is dropped and rebuilt - using the newly merged migrations. 
Depending on how SVN merged the migration list, one of them is going to 
fail. Mike can see the problem and go and fix it.

3) Five developers are working on a project. Each of them produce a 
migration. None of the migrations depend on each other.

If we just use names, none of the migrations will conflict and none of 
them depend on each other so all will run without problems.

If we just use numbers, 4 developers will see a conflict after the first 
developer commits, even though their code is not broken. They've just 
taken the next migration number without being aware that other people 
needed to commit migrations too. So they increment their migration 
number and commit. Now the first one to commit will cause a conflict for 
the rest, and so on until they all contact each other and agree what 
their migration numbers will be.

On the other hand, it's a much more efficient way to see if a schema has 
all migrations run on it in the right order if we use a number. Although 
with a descriptive name, it's much easier to track down what each one is 
doing and find an offending migration if there is a problem with the 
code that depends on it.

Perhaps a combination of both would be good?

By the way, my dbmigration should have no problems with older versions 
of django, I just haven't tested it with them. The patch for 
management.py would need changing though.

Cheers,

Mike





Jeremy Dunck wrote:
> On 4/20/07, Mike H <[EMAIL PROTECTED]> wrote:
>   
>> It seems to be working well for the developers here, so here's hoping
>> it's useful for some other people too :)
>> 
>
> This is interesting-- migrating django apps using django.  Are there
> cases where Django or the DB could become so broken that the migrator
> couldn't run?  I wasn't sure, so I took the coward's way.
>
> I'm attaching my db_upgrade.py for comparison.  (I've attached it
> on-list a time or two before, but there are many migration threads.
> :)) It uses numbers instead of names for migrations, and has a custom
> db_version table (no django model for it).  It supports only python
> upgrade steps, but those steps are handed a connection to work with if
> they want to use SQL directly.   Finally, it runs against Ye Olde
> Django (0.91) and probably needs some tweaks to run against 0.96.
>
> If I'm reading your code right, the migrations could be applied out of
> order, depending on which ones you have already run.  Since schema is
> stateful, I think strict order is better.
>
> Consider developers Mike and Jeremy, starting with the same DB.  Mike
> creates a migration, "HalfPrice" and runs it locally.  Jeremy creates
> a migration, "FullPrice" and runs it locally.  Each then update their
> checkouts and run syncdb.
>
> The migrator conflict is update like this, say:
> migrations = [
>   "HalfPrice",
>   "FullPrice"
> ]
>
> The changes of FullPrice will be run for Mike (since that's not in the
> applied list in his DB), and the changes of HalfPrice will be run for
> Jeremy (for the same reason).
>
> Now, this probably isn't an issue outside of development, but it was
> this situation that led me to use migration numbers rather than names
> and have my migration script halt if the DB rev was at or higher than
> the highest migration step.
>
> Cheers,
>   Jeremy
>
> >
>   
> 
>
> #!/usr/bin/python
> import sys, os
> import psycopg
> from django.core.db import db
> from 

Re: how to connect Django to objects served over xml-rpc?

2007-04-22 Thread Forest Bond
On Sun, Apr 22, 2007 at 04:43:27AM -0700, Joe wrote:
> It sounds like you shouldn't be using Django, honestly.  You would be
> fighting against/hacking around most of the functionality of django
> because django is an MVC framework and you guys basically are trying
> to re-write the model architecture.  If you really really really want
> to use django, you should probably just stick to using the controller/
> view portion, which would suck because you couldn't use the admin
> application.

I don't think this is true.  Django's various layers of functionality are
de-coupled relatively well.  I would still use Django even if my data access
back-end is pure XML-RPC.  I just probably wouldn't use Django's ORM.

Of course, using the ORM does allow you to abstract your web code even further,
but you can probably write wrapper classes around your XML-RPC calls to get som
eof that.  (For instance, you might implement a class that, to a limited extent,
emulates the QuerySet class; I think you need this to use generic views, but
correct me if I'm wrong).

-Forest


signature.asc
Description: Digital signature


Re: how to connect Django to objects served over xml-rpc?

2007-04-22 Thread Joe

It sounds like you shouldn't be using Django, honestly.  You would be
fighting against/hacking around most of the functionality of django
because django is an MVC framework and you guys basically are trying
to re-write the model architecture.  If you really really really want
to use django, you should probably just stick to using the controller/
view portion, which would suck because you couldn't use the admin
application.

On Apr 20, 1:58 pm, [EMAIL PROTECTED] wrote:
> I want to try out Django for a small project, hoping to discover that
> it will be the web framework of my dreams, but I need some advice.
>
> My project group has written an xml-rpc API in front of our database
> and password stores.  This means that when we want to, say, create a
> campus guest account, we call xml-rpc functions like create_guest(),
> set_guest_info(), and set_account_password(), and those functions do
> all of the database operations (and sometimes operations on other
> systems) needed to perform each operation consistently (creating a
> guest requires at least six tables to be updated, for example).
>
> This is great in two ways.  First, our business logic is all in one
> place, where complex operations get written once, correctly.  Second,
> we wrote it in simple, plain Python that we could all agree upon, so
> that now each front-end and client can be written in the favorite
> language and framework of the group deploying it (so long as it talks
> xml-rpc), avoiding the need for a religious war and everyone being
> forced to use One True Platform.
>
> The problem is that Django seems to really, really want to talk to the
> database by itself. :-)
>
> At what level, then, would I subvert Django if, say, a Guest were not
> a row in a database table, but an entity that I get information about
> from an xml-rpc call, and for which some other xml-rpc calls let me
> set information?  Thanks for any guidance!
>
> I'll be happy to write up my solution for the Django documentation
> page, which already discusses connecting to a legacy database - but
> not a ... what would one call it?  A "legacy non-database."
>
> --
> Brandon Craig Rhodeshttp://www.rhodesmill.org/brandon
> Georgia Tech[EMAIL PROTECTED]


--~--~-~--~~~---~--~~
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: Another take on auto-history

2007-04-22 Thread Oliver Charles

Damnit, that's what you get for trying to run several projects under one 
vhost on apache! It's fixed now, sorry about that

http://acid2.user.openhosting.com/static/history-latest.zip

The history app itself is in a directory called history_contrib - that 
zip files contains the whole example app as well.


--
Ollie
> Looks like the download link is broken.
>
> On Apr 21, 4:24 am, Oliver Charles <[EMAIL PROTECTED]> wrote:
>   
>> Morning all
>>
>> I've been meaning to post this to the list for a while, and I think my
>> code is now ready to be shown. I've been working on a small bug tracker
>> type project for myself - as I have 3 Django projects on the go at the
>> moment. Anyway, I wanted a way to track changes made to bugs/tickets so
>> I made this automatic history decorator. It works by logging revisions
>> of fields on a model, so you can specific which fields should have a
>> history, etc.
>>
>> I haven't included rollback support yet, but if people are interested, I
>> will happily look into offering it (shouldn't be hard!) Without furthor
>> ado, here is the website, with a mini example application too:
>>
>> http://acid2.user.openhosting.com/history/
>>
>> The way that my auto history module works is through decorating the
>> save() method of a model. Everytime you save a model, it looks up the
>> model in the database first. Then, each field is compared and log
>> entries are made. You can then retrieve a list of these changes through
>> the models provided (see the example in the zip).
>>
>> This was mainly an experiment to learn introspection and metaprogramming
>> type stuff in Python, but if anyone has any ideas on what could improve
>> this, I'd love to hear them.
>>
>> Thanks, hope someone finds it useful!
>>
>> --
>> Oliver Charles
>> 
>
>
> >   


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