Re: OperationalError: no connection to the server using Django and gunicorn

2011-07-01 Thread Adrián Ribao Martínez
I think that the error comes only when starting the server.

Reload the page about 10 times and check if you still get the error.

Regards,

Adrián

> Hi Adrian,
> 
> Have you solved this weird issue?
> 
> if yes, please tell me how.
> 
> Best regards,
> Andrey Makhnach
> 
> On May 27, 12:53 pm, Adrián Ribao <ari...@gmail.com> wrote:
> > I'm doing it manually because I'm just testing:
> >
> > ./manage.py run_gunicorn -c gunicorn.conf.py
> >
> > where gunicorn.conf.py
> >
> > # -*- coding: utf-8 -*-
> > import multiprocessing
> >
> > bind = "127.0.0.1:8000"
> > workers = multiprocessing.cpu_count() * 2 + 1
> > worker_class = 'gevent'
> >
> > On 27 mayo, 02:23, Shawn Milochik <sh...@milochik.com> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > What's the command you're using to run it?
> >
> > > Are you in screen? Are you using supervisor or anything like that?
> 
> 

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



Re: OperationalError: no connection to the server using Django and gunicorn

2011-05-27 Thread Adrián Ribao
I'm doing it manually because I'm just testing:

./manage.py run_gunicorn -c gunicorn.conf.py

where gunicorn.conf.py

# -*- coding: utf-8 -*-
import multiprocessing

bind = "127.0.0.1:8000"
workers = multiprocessing.cpu_count() * 2 + 1
worker_class = 'gevent'


On 27 mayo, 02:23, Shawn Milochik  wrote:
> What's the command you're using to run it?
>
> Are you in screen? Are you using supervisor or anything like that?

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



OperationalError: no connection to the server using Django and gunicorn

2011-05-26 Thread Adrián Ribao
Hello,

I'm testing gunicorn in the server, and I get this error in every
request:

Traceback (most recent call last):
  File "project/env/lib/python2.6/site-packages/gunicorn/workers/
async.py", line 62, in handle_request
respiter = self.wsgi(environ, resp.start_response)
  File "project/env/lib/python2.6/site-packages/django/contrib/
staticfiles/handlers.py", line 68, in __call__
return self.application(environ, start_response)
  File "project/env/lib/python2.6/site-packages/django/core/handlers/
wsgi.py", line 273, in __call__
response = self.get_response(request)
  File "project/env/lib/python2.6/site-packages/django/core/handlers/
base.py", line 168, in get_response
receivers =
signals.got_request_exception.send(sender=self.__class__,
request=request)
  File "project/env/lib/python2.6/site-packages/django/dispatch/
dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
  File "project/env/lib/python2.6/site-packages/django/db/
__init__.py", line 101, in _rollback_on_exception
transaction.rollback_unless_managed(using=conn)
  File "project/env/lib/python2.6/site-packages/django/db/
transaction.py", line 133, in rollback_unless_managed
connection.rollback_unless_managed()
  File "project/env/lib/python2.6/site-packages/django/db/backends/
__init__.py", line 193, in rollback_unless_managed
self._rollback()
  File "project/env/lib/python2.6/site-packages/django/db/backends/
__init__.py", line 50, in _rollback
return self.connection.rollback()

Is working ok with mod_wsgi.

I'm using Debian 6.0 with Django 1.3, postgis for geodjango, the
latest stable version of gunicorn 0.12.1 and gevent. I've been trying
with a sync worker but I got the same error.

I have no idea what's wrong.

Any ideas?

Thank you!

Adrian

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



Logging Handler AdminEmailHandler not working

2010-12-15 Thread Adrián Ribao
I get an error when using AdminEmailHandler.

The error message is: __init__() takes at least 5 non-keyword
arguments (2 given)

is in django/django/utils/log.py in emit line 90:

reporter = ExceptionReporter(request, is_email=True, *exc_info)

where exc_info = ()

Is it a bug or I'm missing something?

Thank you,

Adrian

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



Thread safety, transactions and best practices

2010-05-08 Thread Adrián Ribao
Hello,

I have a question about transactions and thread safe applications.

I have an invoice app, where I have a model like this:

class Counter(models.Model):
   client = models.ForeignKey(Client)
   number = models.CharField(max_length=10, db_index=True)
   class Meta:
unique_together = (("client", "number"),)

Where number is the number of the invoice: "2010/321"

What I need is to create a view that takes the last invoice number of
a client, parse it and add 1. ie: "2010/321" -> "2010/322"

I have something like this:

@transaction.commit_on_success
def increment_counter(name, client):
counter = Counter.objects.filter(client=client).order_by('-id')[0]
#Step 2: Parse format and Increment the counter

newcounter = "2010/322"
counter.count = newcounter
#Step 3: Save the new counter
counter.save()


I don't know if this is the best approach.

Imagine that when the first thread (thread1) is in step2, the second
thread (thread2) just inserted a new value in the database, so the
counter is already on "2010/322" but thread1 will try to write the
same value. It will fail because there is already a row with that
value in the ddbb.

How can I solve this problem? Can I use the F() function for this?
Should I use SQL "SELECT ... FOR UPDATE" ?

Thank you very much,

Adrian Ribao

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



Re: Big issue serving big files through a view

2009-11-23 Thread Adrián Ribao
I have implemented something included in django:

from django.core.servers.basehttp import FileWrapper

wrapper = FileWrapper(file(filepath))
response = HttpResponse(wrapper, mimetype=type)

It works great, but anyway I'm gonna study your solutions.

Which would you recommend me?

Regards,
Adrian.


On 23 nov, 18:38, Bill Freeman <ke1g...@gmail.com> wrote:
> 1. You could read (and thus write) in smaller chunks, by giving read() an
> argument indicating the number of bytes to read:
>
>    f = open(file)  # The mode 'r' is default
>    for buf in read(1024*32):
>       response.write(buf)
>    f.close()
>
> 2. You could, instead, let Apache serve the files in encrypted form,
> and sell the
> user a decryption key.
>
> On Mon, Nov 23, 2009 at 12:18 PM, Adrián Ribao <ari...@gmail.com> wrote:
> > Hello,
>
> > I have created a website where you can buy and download some files.
> > For security reasons all the files are served through a view, where
> > comprobations are made in order to assure that the user bought the
> > product.
>
> > The problem is that the files are at least 400Mb and some of them are
> > nearly 1Gb. Using this view is inefficient since all the content is
> > loaded into memory and it kills the server:
>
> > type, encoding = mimetypes.guess_type(file)
> > name = os.path.basename(file)
> > response = HttpResponse(mimetype=type)
> > response['Content-Disposition'] = 'attachment; filename=%s' %
> > (smart_str(name),)
>
> > f = open(file, 'r')
> > response.write(f.read())
> > f.close()
> > return response
>
> > How could I solve this problem?
>
> > Regards,
>
> > Adrian.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=.

--

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




Big issue serving big files through a view

2009-11-23 Thread Adrián Ribao
Hello,

I have created a website where you can buy and download some files.
For security reasons all the files are served through a view, where
comprobations are made in order to assure that the user bought the
product.

The problem is that the files are at least 400Mb and some of them are
nearly 1Gb. Using this view is inefficient since all the content is
loaded into memory and it kills the server:

type, encoding = mimetypes.guess_type(file)
name = os.path.basename(file)
response = HttpResponse(mimetype=type)
response['Content-Disposition'] = 'attachment; filename=%s' %
(smart_str(name),)

f = open(file, 'r')
response.write(f.read())
f.close()
return response

How could I solve this problem?

Regards,

Adrian.

--

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




NoReverseMatch raised after upgrading django to trunk

2009-11-03 Thread Adrián Ribao

Hello,

I've just updated django to the las revision and suddenly I'm getting
a NoReverseMatch when using the reverse funcion.

This is the line of the code:

return HttpResponseRedirect(reverse('app.views.info', args=[p.id,]))

And this is the url:

(r'^any-path-(?P\d)\.html$', 'info'),

Does anybody know what's going on?

Regards,

Adrian

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



best approach for using email as username

2009-10-29 Thread Adrián Ribao

Hello,

I need to use the email field as the username. I neet these:

* Email must be unique
* I should authenticate against the email
* The admin should work I I should be able to create users with
username = email address.

I have a custom authentication method but I need more. I need to tell
Django to make the email unique, and I need to login and create users
from the admin with the @ character.

What is the best approach for this?

I've been searching in google but no one of the solutions can
accomplish the three points I need.

Thank you!

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



Avoid queryset caching

2009-10-01 Thread Adrián Ribao

Hello,

I need to disable the queryset caching in two situations:
 * When I process a huge amount of rows, and for each one I have to
perform a new queryset. The script memory increases very quick and the
system run out of memory.
 * When I generate a form dinamically from a queryset.

Is there any way I could disable the caching system for a certain
queryset?

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



[Internationalization] javascript catalog

2009-07-29 Thread Adrián Ribao

Hello,

I'm trying to use the javascript catalog in a project. The
documentation says:

Those translation strings are taken from the application, project or
Django core, according to what you specify in either the info_dict or
the URL.

Well, I need to load the strings from the project. I mean, All my
translations are located under myproject/locale/ dir, not in the
myproject/myapp/locale dirs

My js_info_dict looks like this:
js_info_dict = {
'packages': ('', ),
}

I've also tried:

js_info_dict = {
'packages': ('myproject',),
}

but the strings in the myproject/locale/LANG/djangojs file are not
loaded

Could anyone help me with this please?

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



Cached forms when changing language- Is this a bug?

2009-07-17 Thread Adrián Ribao

Hello everybody,

I have an multi language site with a form in the home. If I change the
language of the site everything changes but the form takes a few
minutes before I see it in the right language.

If I reload the server the form is visualized ok, but this is not the
right behaviour.

The code of the form is somethin like:
from django.utils.translation import ugettext as _
class RuedaForm(forms.Form):
puntuacion_hogar = forms.ChoiceField(label=_(u'Value'), choices=
[('', '')] + [(i, i) for i in range(11)], help_text=_(u'help text'),
required=False)

I've noticed that if you change a form in the fly, the changes don't
appear in the site inmediatly, For example when I hidde form fields
depending of the permissions of the users.

We are really worried with the behaviour of the forms when changing
the language, something is wrong with it.

You can have a look at: http://autocoaching.info/

We really need help with this issue.

Thank you very much,

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



Re: PostgreSQL full text engine support

2009-06-10 Thread Adrián Ribao

I'm sorry! This messages was suppose to go to the haystack.org list.

Please, dismiss this message.

On 10 jun, 13:57, Adrián Ribao <ari...@gmail.com> wrote:
> I'd like to suggest the fulltext search engine of PostgreSQL as a
> backend.
>
> PostgreSQL is the favourite ddbb of the django developers, and it
> includes full text search engine.
>
> http://www.postgresql.org/docs/8.3/static/textsearch.html
>
> It doesn't require extra software installation and it works great.
>
> Regards,
>
> Adrian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



PostgreSQL full text engine support

2009-06-10 Thread Adrián Ribao

I'd like to suggest the fulltext search engine of PostgreSQL as a
backend.

PostgreSQL is the favourite ddbb of the django developers, and it
includes full text search engine.

http://www.postgresql.org/docs/8.3/static/textsearch.html

It doesn't require extra software installation and it works great.

Regards,

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



Database Error

2009-04-19 Thread Adrián Ribao

Hello,
I have a model using extra fields in M2M relationships as described
in:
http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships

When I try to do something I get this:

"psycopg2.OperationalError: currval of the sequence
«metodo_factorencadena_id_seq» is not defined in this session

and I have no idea what does it mean. Could anyone help me please?

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



Re: Need help with models

2009-01-24 Thread Adrián Ribao

Do you use a custom Model Manager or something similar to make it
optimal? I'm using this approach now but it needs to make a query for
every element, which is not very efficient.
I'd be happy if one of the django "brains" tell us how could we do
this.

Thank you.

On 24 ene, 21:07, Kless <jonas@googlemail.com> wrote:
> I also was looking for a solution for it and I found that the most
> optimal is the first approach --at least for me--.
>
> You have a normal table with data entered into a language by default,
> and then it's used another one to translating the text fields from
> that main table.
>
> The difference with yours is that I use:
>
>    lang = models.ForeignKey('Language')
>
> On 24 ene, 17:41, Adrián Ribao <ari...@gmail.com> wrote:
>
> > Hello everybody,
>
> > I need to create dinamic content in several models. I have 3
> > approaches:
>
> > approach 1:
>
> > class News(models.Model):
> >     date = ...
> >     visible = ...
> >     text = models.CharField(max_length=255)
>
> > class NewsTrans(models.Model):
> >     news = models.ForeignKey(News)
> >     lang = models.CharField(max_length=5, choices=settings.LANGUAGES)
> >     text = models.CharField(max_length=255)
>
> > approach 2:
> > class News(models.Model):
> >     lang = models.CharField(max_length=5, choices=settings.LANGUAGES)
> >     date = ...
> >     visible = ...
> >     text = models.CharField(max_length=255)
>
> > approcah 3:
> > class NewsBase():
> >     date = ...
> >     visible = ...
>
> > class News(NewsBase):
> >     lang = models.CharField(max_length=5, choices=settings.LANGUAGES)
> >     text = models.CharField(max_length=255)
>
> > (Any other approaches are welcome.)
>
> > The one I like the least is the second one.
>
> > I really need help here, please tell me how to implement translations
> > in ddbb in the most efficient way.
>
> > Thank you.
>
> > P.S. I hope Django can manage this problem, hopefully in 1.3!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Need help with models

2009-01-24 Thread Adrián Ribao

Hello everybody,

I need to create dinamic content in several models. I have 3
approaches:

approach 1:

class News(models.Model):
date = ...
visible = ...
text = models.CharField(max_length=255)

class NewsTrans(models.Model):
news = models.ForeignKey(News)
lang = models.CharField(max_length=5, choices=settings.LANGUAGES)
text = models.CharField(max_length=255)


approach 2:
class News(models.Model):
lang = models.CharField(max_length=5, choices=settings.LANGUAGES)
date = ...
visible = ...
text = models.CharField(max_length=255)

approcah 3:
class NewsBase():
date = ...
visible = ...

class News(NewsBase):
lang = models.CharField(max_length=5, choices=settings.LANGUAGES)
text = models.CharField(max_length=255)

(Any other approaches are welcome.)

The one I like the least is the second one.

I really need help here, please tell me how to implement translations
in ddbb in the most efficient way.

Thank you.

P.S. I hope Django can manage this problem, hopefully in 1.3!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



login django using curl

2008-12-13 Thread Adrián Ribao

Hello, I'm writing a script and I'd like to login into a django webapp
using pycurl or urllib.
I've problems with the cookies, and every time the message is: "The
session has expired"

Does anybody know how can I make it?

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



Re: Best practice to build a multilingual site

2008-10-13 Thread Adrián Ribao

I have the same question as you.
Translation of dynamic content is not a feature for Django 1.1. I
wonder if I can insert this feature in the wiki.
I'd like to know the best approach for translating some fields of a
model to different languages.

Thank you.


On 13 oct, 17:48, "Alex Rades" <[EMAIL PROTECTED]> wrote:
> Hi,
> if we have a model like:
>
> class News(models.Model):
>     title = models.CharField(..)
>     content = models.TextField(...)
>
> Imagine i want to work with different language (this means adding
> multilingual content via admin and retrieving it from views/templates)
> What is the best way to develop this kind of multi language support?
> (Of course I dont want to add title_en title_es... )
>
> Thank  you
--~--~-~--~~~---~--~~
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: GeoDjango question

2008-09-04 Thread Adrián Ribao

Thank you Ludwig!

> Regarding your SRS questions you need to be aware that if you use different
> SRS for different tables that unless you reproject to a common one distance
> computations make no sense.

So I guess I have to use the default srid in both models. Right?
If I set the default srid, is the following code correct?
qs = Places.objects.filter(location__distance_lte=(pnt, D(km=500)))
or
qs = Places.objects.filter(location__distance_lte=(pnt, 50)

> There are routines in Postgis add-ons that will compute a great-circle 
> distance,
> which I guess you are after.

Do you know where can I find an example? I suppose you mean
distance_sphere, but as I'm new to all this geographic stuff I have no
idea how to use it.


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



GeoDjango question

2008-09-04 Thread Adrián Ribao

Hi,

I've been checking geodjango and it looks very well, but I have some
questions about it.



If I have two models like:



class UserProfile(models.Model):



location = models.PointField(srid=2062)

objects = models.GeoManager()





class Places(models.Model):



location = models.PointField()

objects = models.GeoManager()



I have the location of the user and I'd like to operate with the
Places model.
1-) Can be the SRID of the location in places be different? SRID are
places around the world so I think the best is use the default SRID

2-) Is the next code working as expected:
qs = Places.objects.filter(location__distance_lte=(pnt, D(km=500)))
or
qs = Places.objects.filter(location__distance_lte=(pnt, 50)
I need a queryset that contains all the places available in less than
500Km.

3-) I need to calculate some distances. I have a queryset with several
places and I need to know the distance to the user, we are talking
about distances in the earth. Do I have to use geopy or exists
something implemented in geodjango?

4-) userprofile.location.distance(place.location) is returning a very
small value, probably because the result is expressed in degrees. Is
there any way to return the value in Km or m? This question is related
to 3. It would be perfect if the value returned was the distance in Km
or m.

5-) Is available any widget to insert the points using GoogleMaps? As
far as I know I have to implement it all by myself.

We'd appreciate if someone could write a short tutorial using this
capabilities as this is the most common use of geodjango.

I'm using a Debian lenny machine, latest django SVN (today is 1.0!),
and PostgreSQL.

Thank you very much.
--~--~-~--~~~---~--~~
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: ANNOUNCE: Django 1.0 released

2008-09-04 Thread Adrián Ribao

Excelent work! Well done!
--~--~-~--~~~---~--~~
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: Don't mix *args and **kwargs in call to reverse()!

2008-09-01 Thread Adrián Ribao

I'll write an example of the problem. All my urls are prepared
following the best SEO rules, so in many places I have urls like:
(r'^(.*)-f(?P\d+)\.html$','view_photo')

this would make the url:
my-photo-f2.html

I get the url using:
reverse('app.views.view_photo', args=[slugify(photo.title),],
kwargs={'id':id} )
(Note: I don't want to use a slug field.)

Now this won't work. Well, IMHO this is a bug, I don't see the point.
Besides this makes rev:8760 backwards incompatible and it wasn't
suppose to.

I really need some more information about this.

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Don't mix *args and **kwargs in call to reverse()!

2008-09-01 Thread Adrián Ribao

Change in rev:8760 introduced this exception: "Don't mix *args and
**kwargs in call to reverse()!"

-- django/trunk/django/core/urlresolvers.py --
...
def reverse(self, lookup_view, *args, **kwargs):
if args and kwargs:
raise ValueError("Don't mix *args and **kwargs in call to
reverse()!")
 ...
Why is not possible to mis args and kwargs? I don't understand the
reason, and all of my reverse funcions will fail because of this.

I'd like some help with this.

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



SQL data not loaded in testing suite

2008-07-22 Thread Adrián Ribao

Hello, I'm writing a test suite, and when the database is created,
everything seems ok, I can even see the:
Installing custom SQL for 

but the data is not inserted in the db.

Is it a bug?

Thank you.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Roadmap to 1.0 and internationalization in db

2008-06-13 Thread Adrián Ribao

Hello,
Here I'm again with the same subject, internationalization in db.
I think this should be included in 1.0, it's not so hard, I have
thought a way to make it work:

We have a class like this:

class Book(models.Model):
 name = models.CharField( max_length=255, i18n=True)

And the following line in settings.py
LANGUAGES = (
   'en', ugettext(u'English'),
'es', ugettext(u'Spanish') )


Note that name field has an attribute i18n= True.

when creating the columns in the db, if i18n=True is found, the extra
name_es,... columns is created. I don't like to have separate tables
for this for many reasons:
1.- Not easy to interact with the db from a client
2.- Not needed
3.- Decreasing performance

the column name contains the string in the first language defined in
LANGUAGES, in this case: English. name_i18n_es will contain the name
in Spanish language.

When the object is accessed:
name = Book.objects.get( id=1 )
book.name = 'Name of the book'

book.name gets the value of the default language, the first one
defined in LANGUAGES, and:
book.name_i18n_es = 'Nombre del libro' is stored the string in a
different language.

book.name should be a function instead of an attribute where you pass
the language and get the string. If none is passed you get the string
of the first LANGUAGE.

Some extra arrays should be added to the _meta options class named
i18n_fields and i18n_languages.

Using this approach ordering and even full-text with multiple
languages is possible. For creating an object:
book = Book( name='Name of the book') or:
book = Book( name='Name of the book', name_i18n_es='Nombre del libro')


With this it would be easier to implement different languages in the
newforms.FormForModel and nfa-branch.

Filtering could be done in the first approach:
field_name = 'name_i18n_%s__contains' % ( language_id )
kwargs={ field_name:'text to search'}
I'm not convinced of this but something else could be done inside the
django.db

I think I can make this work in three weeks, If I do, could it be
considered for Django 1.0?

Let's be honest, English is not the only language in the world and I
have known some companies that didn't switch to django because of
this.

Any suggestions are welcome.
--~--~-~--~~~---~--~~
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: Recursion in templates... again

2007-03-02 Thread Adrián Ribao Martínez

Sorry, I didn't find a perfect solution, but I think that it can be done.
You can use the "unordered list" filter in the template and fill an array in 
the view using recursive methods. Then you pass the array to the filter and 
it's done. You can also create your own filter tag, is not difficult, you can 
find some info in the section "extending the template system"
http://www.djangoproject.com/documentation/templates_python/#extending-the-template-system
and in the several files under the django installation path:
 They're in django/template/defaultfilters.py and 
django/template/defaulttags.py, respectively.

I hope this help you.

Adrian Ribao.

El Viernes, 2 de Marzo de 2007 15:14, Jens Diemer escribió:
> Grupo Django schrieb:
> > Hello, I have been looking around about some information about how to
> > do recursion in templates but what I found didn't help me.
> > ...
> >
> > And the plan is to create a menu like this:
> > - Entry 1
> > -- Subentry 1_1
> > -- Subentry 1_2
> >  sub_Subentry 1_2_1
> > - Entry 2
> > ...
>
> I have the same Problem:
> http://groups.google.com/group/django-users/browse_thread/thread/3bd2812a3d
>0f7700/e97a9cd4348b0471?#e97a9cd4348b0471
>
> Did you find a solution?
>
>
> I found this:
> https://svn.greenpeace.org/projects/custard/browser/production/trunk/melt/a
>pps/custard/templatetags/customtags.py But the code is for an older django
> version. I don't know how to update it...
>
>
> So, if there is no solution, i must use jinja...

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