Scaling/Parallel patterns for a View executing complex database transaction

2015-05-14 Thread Me Sulphur
Stack: Django 1.7 + Postgres 9.3 + Linux (No caching)

Our application has a view which is called/executed very frequently. The
view receives, parses and responds a JSON.

In between request and response, there are about 3-5 inserts and around
1200-5000 look ups depending upon some if..else business logic. At around
2-4 seconds the view is very slow.

However, a lot of the look ups (which are the bottlenecks) can be
parallelized. But I do not know how can I do the same within a
request-response cycle.

If it was a web UI, I could use celery+polling, since it a machine-machine
API call, the parallelisation has to be possible within a View's life cycle.

If parallelisation is not possible, what alternatives do I have for scaling
and reducing response time.


Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABSvzZCGjY4DH2D2VtbsVDDHTAk-m%2BReJJ_BwmK_jn0wCDp%3DMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Scaling/Parallel patterns for a View executing complex database transaction

2015-05-14 Thread Me Sulphur
Hi Russ,

Thanks! While there are some pointers that we can pick up from your answer, 
let me add some more details.

* It is a large key-value pair table (approaching ~ 1 bn rows) with an MD5 
key and JSON  for value. The look ups depend on the business logic but are 
necessary. Nevertheless, there are no more than 10-12 queries executed by 
combining key look ups using WHERE IN queries and pg is surprisingly good 
with IN queries.

* Pre-computation is theoretically possible but the permutations can be 
very limiting. Over the top of my head, I think it will be M^n where M and 
n are very large (and growing) integers.

* You are right, celery+polling can be done but the API is already deployed 
and in use in environments where there is strong resistance to rework a 
code base which is stable and changing them (consumers of the API) is 
beyond control.


Thanks!

 
On Friday, 15 May 2015 06:06:57 UTC+5:30, Russell Keith-Magee wrote:
>
>
> On Thu, May 14, 2015 at 6:03 PM, Me Sulphur  > wrote:
>
>> Stack: Django 1.7 + Postgres 9.3 + Linux (No caching)
>>
>> Our application has a view which is called/executed very frequently. The 
>> view receives, parses and responds a JSON.
>>
>> In between request and response, there are about 3-5 inserts and around 
>> 1200-5000 look ups depending upon some if..else business logic. At around 
>> 2-4 seconds the view is very slow. 
>>
>> However, a lot of the look ups (which are the bottlenecks) can be 
>> parallelized. But I do not know how can I do the same within a 
>> request-response cycle.
>>
>> If it was a web UI, I could use celery+polling, since it a 
>> machine-machine API call, the parallelisation has to be possible within a 
>> View's life cycle.
>>
>> If parallelisation is not possible, what alternatives do I have for 
>> scaling and reducing response time.
>>
>> The short answer is "it depends".
>
> There isn't a single answer - everything will depend on the specifics of 
> your problem space. All I can offer is some vague suggestions of places you 
> might be able to look for some extra speed.
>
>  * Do you *really* need to do 1200-5000 lookups? It's faster to do 1 query 
> returning 10 rows than 10 queries returning 1 row each. Can you optimise 
> the queries on the database to minimise the number of queries needed? 
> Depending on circumstances, it may even be faster to do 1 query returning 
> 15 rows, and then post-process in the view to throw away the 5 rows you 
> don't need.
>
>  * Better still - can you optimize the database structure so that 
> 1200-5000 calls aren't needed? Modern relational databases are *really* 
> good at query optimisation - if you give it the right query, and the right 
> database.
>
>  * Can you work your algorithm another way? In a previous job, I worked on 
> a tool that would look at a database of thousands of news articles received 
> in a given day, and then, for each of thousands of users, work out which 
> articles were "interesting" so they could be sent out in a daily alert 
> email. The obvious algorithm for this is "for user in users: 
> find_articles(user)" - but, for a variety of reasons, it turned out that 
> doing "for article in articles: find_users(article)" was almost 2 orders of 
> magnitude of faster. The less obvious algorithm allowed much greater 
> caching, and massively cut down the number of queries that were required. 
> The tradeoff was a lot more memory (memory vs speed is almost always the 
> tradeoff), and it wasn't only faster if you computed the results for *all* 
> users at the same time - but this was an daily offline process, so these 
> were limitations we were willing to accept.
>
>  * To that end - is there anything that can be precomputed? Can you cache 
> pieces of the response? Is there anything you can put into a memory store, 
> rather than the database. Databases are great, but if you have a small 
> amount of frequently re-used, easily keyed data, it may be better to put 
> that data into a location where it can be obtained quickly, rather than 
> hitting the database.
>
>  * If you *must* parallelize, and your algorithm is conducive to it, 
> threads are probably your best option - work out what part of your 
> algorithm can be parallelized, and put each part in a thread, and merge the 
> results once all the threads complete. If you're on Python 3, look into the 
> concurrent.futures module (or the "futures" module if you're on Python 2) 
> to help make this easier to manage. However, threads aren't magic fairy 
> dust - my "limited knowledge of your situation" guess is that 
> parallelization won

Adding LocaleMiddleware does not show pretty error pages

2014-08-10 Thread Me Sulphur
Django usually renders prettified error pages when DEBUG and TEMPLATE_DEBUG
are True in settings.py.

However, when I add the LocaleMiddleware, The template only outputs: 'A
server error occurred. Please contact the administrator.' and prints the
traceback in the runserver terminal instead.

*Stack*:
Django = 1.6.5
Python = 2.7.6
Ubuntu Trusty (14.04)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABSvzZBQx0F1kJdoYkNKOKKRjW4WkcULtA5C7PTPxcxxtqo0jQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: 1.7: module has no attribute

2014-08-10 Thread Me Sulphur
It is SlugField (F is capital) and not Slugfield

Refer:
https://docs.djangoproject.com/en/dev/ref/models/fields/#slugfield



On Monday, 11 August 2014 10:06:20 UTC+5:30, Malik Rumi wrote:
>
> I am trying to make my first django project using 1.7. When I try to run 
> python manage.py * (runserver, makemigrations, shell, validate - it doesn't 
> matter) I get the same error: 
>
> slug = models.Slugfield(max_length=50, unique=True)
> AttributeError: 'module' object has no attribute 'Slugfield'
>
> Here is what I have done to try to correct this:
>
> 1. Shortened the max_length on Slugfield to 50 from 100
> 2. Created an apps.py for AppConfig, as laid out in 
> https://docs.djangoproject.com/en/dev/ref/applications/#django.apps.apps 
> 3. Changed INSTALLED APPS to include 'apps.appnameConfig'
> 4. Checked the capitalization of my models, classes, modules, and app names
> 5. Copied the slug field from my model's Articles class and pasted it into 
> apps.py
>
> When I did that, I got:
>
> NameError: name 'models' is not defined
>
> This did not make any sense to me at all. What was I supposed to do now, 
> import models?
>
> 6. Figuring I had nothing to lose, I did import models, and got:
>
> AttributeError: 'module' object has no attribute 'Slugfield'
>
> Right back where I started from. 
>
> Please help. Thx. 
>
> ps - I don't know if this is an appconfig issue or not, but while we are 
> at it, let me confess that I don't get it. Yes, I read the docs. I don't 
> get it. I don't understand the benefit. I have never used ready(), but of 
> course I am still quite new to all this.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/49c5a915-994d-4f9d-9c63-0d6b8dd3fcab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


m2m_changed (How to get only the affected/changed fields in pk_set)

2014-01-30 Thread Me Sulphur
The docs say (for the param *pk_set* in m2m_changed signal)
For the pre_add, post_add, pre_remove and post_remove actions, this is a 
set of primary key values that have been added to or removed from the 
relation.

But it seems, that pk_set contains all values and not only the 
affected/changed once. Am I interpreting the docs wrong or could my 
execution be inappropriate?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/72f2207b-0528-4cdc-a259-a1105a6574ae%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Password reset not working.

2014-01-30 Thread Me Sulphur
url(r'^password/reset/(?P[0-9A-Za-z_\-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
auth_views.password_reset_confirm,
name='password_reset_confirm'),

Try setting 'name' for the above url block as 'auth_password_reset_confirm' 


On Thursday, 30 January 2014 18:39:12 UTC+5:30, heidi wrote:
>
> I'm using Django 1.6.1, and password reset is not working. When users 
> enter their email, 502 occurs and this is sent to me:
>
> Traceback (most recent call last):
>
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 
> 114, in get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 
> 99, in _wrapped_view
> response = view_func(request, *args, **kwargs)
>
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/views.py", line 
> 158, in password_reset
> form.save(**opts)
>
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/forms.py", line 
> 256, in save
> email = loader.render_to_string(email_template_name, c)
>
>   File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", 
> line 164, in render_to_string
> return t.render(Context(dictionary))
>
>   File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", 
> line 140, in render
> return self._render(context)
>
>   File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", 
> line 134, in _render
> return self.nodelist.render(context)
>
>   File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", 
> line 840, in render
> bit = self.render_node(node, context)
>
>   File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", 
> line 854, in render_node
> return node.render(context)
>
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", 
> line 447, in render
> six.reraise(*exc_info)
>
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", 
> line 433, in render
> url = reverse(view_name, args=args, kwargs=kwargs, 
> current_app=context.current_app)
>
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 
> 509, in reverse
> return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, 
> **kwargs))
>
>   File 
> "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 
> 429, in _reverse_with_prefix
> (lookup_view_s, args, kwargs, len(patterns), patterns))
>
> NoReverseMatch: Reverse for 'auth_password_reset_confirm' with arguments 
> '('MQ', u'3op-83ceb0bee07385a12e2a')' and keyword arguments '{}' not found. 
> 0 pattern(s) tried: []
>
>
> Relevant parts of urls.py:
>
> url(r'^login/$',
> auth_views.login,
> {'template_name': 'registration/login.html'},
> name='auth_login'),
> url(r'^logout/$',
> auth_views.logout,
> {'template_name': 'registration/logout.html'},
> name='auth_logout'),
> url(r'^password/change/$',
> auth_views.password_change,
> name='auth_password_change'),
> url(r'^password/change/done/$',
> auth_views.password_change_done,
> name='password_change_done'),
> url(r'^password/reset/$',
> auth_views.password_reset,
> name='auth_password_reset'),
> 
> url(r'^password/reset/(?P[0-9A-Za-z_\-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
> auth_views.password_reset_confirm,
> name='password_reset_confirm'),
> url(r'^password/reset/complete/$',
> auth_views.password_reset_complete,
> name='auth_password_reset_complete'),
> url(r'^password/reset/done/$',
> auth_views.password_reset_done,
> name='password_reset_done'),
>
> As far as I can see I have it correctly updated for the latest version of 
> Django. What's wrong, and how do I fix it?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8208563a-0805-4f93-bcd1-b736d4c6ae4a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Password reset not working.

2014-01-30 Thread Me Sulphur
On an alternative note, it is always good to follow some kind of consistent 
conventions for things like naming. You might also want to prefix 
'password_change_done' and 'password_reset_done' with 'auth_' for the sake 
of consistency.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d6686f02-0f93-4999-872b-98afd0a5e3f0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Proxy problem (permissions denied)

2014-01-30 Thread Me Sulphur
Hopefully you have included the csrfmiddleware token in your POST request 
payload or data. Overlooking same is usually one of the frequent causes of 
403 in development.
Read here: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/

BTW, you can also consider using 
GeoDjango to 
manipulate and query spatial data from within Django.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/79d4b02e-2ab1-4cb1-aeaa-6f51ebdd4e86%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django with Ubuntu Cloud

2014-01-30 Thread Me Sulphur
Django is a fairly flexible web framework. See read more about STATIC and 
MEDIA files in Django. The Ubuntu cloud API is documented here 
https://one.ubuntu.com/developer/files/store_files/cloud, you can interact 
with it using libraries like requests.

https://docs.djangoproject.com/en/dev/howto/static-files/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d132b6ad-1f34-4585-888e-20801e020ad0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django with Ubuntu Cloud

2014-01-31 Thread Me Sulphur
So - I can use Ubuntu One ( which seems to be like Drop box if I understand
it correctly ) as a media file storage?

Indeed you UO is like DB and you can use their APIs to programatically PUT
and/or GET files on their system.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABSvzZC5oJ5yebxqp3w85hWsXHnZMvrdTgnBm9WUPkPePGCerw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question About South And Migrating to Production

2014-02-01 Thread Me Sulphur
We have used South for staging and production for a while now (what good 
otherwise it is?). Our deployment flow is something on the lines of:
(Note: Tasks are automated using Fabric)

1. Have a production_settings.py file in the git repo 
2. Migrations are also commited to the repo
3. When changes need to be deployed, a git pull is executed on the server
4. production_settings.py is renamed to settings.py (simple "mv" command on 
linux)
5. The fabfile contains a list of apps that need to be migrated (ex: 
['app1', 'app2', 'aap2'])
6. Migrations are then executed for the apps in the list on the server 
(./manage.py migrate )

(Note: branches are used to segregate dev and production migrations)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e8bc6af7-7939-445d-b062-6e30af2a460e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Model field's verbose_name from database?

2014-02-04 Thread Me Sulphur
Why not use dictionary to Map user-level names to database-fields

mapping = {
'My Name': first_name,
'Surname': last_name,
'Personal Email': email
}

u = User.objects.get(pk=1)
key = 'My Name'
try:
  val = getattr(u, mapping[key])
except AttributeError:
  val = ''




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1ed11234-acfb-4d7a-b67e-631e583dc51b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Model field's verbose_name from database?

2014-02-04 Thread Me Sulphur
Correction: Values should also be strings

mapping = {
'My Name': 'first_name',
'Surname': 'last_name',
'Personal Email': 'email'
}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d9406eda-388d-41d2-a488-c39862e6ea0f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Model field's verbose_name from database?

2014-02-05 Thread Me Sulphur
You could easily convert mappings to JSON and store it in a model like:

Class VerboseNameMaps(models.Model):
map  = models.TextField()
user = models.ForeignKey(User)


When you wish to use the same, you could:

map_obj = VerboseNameMaps.objects.get(user=request.user)
mapping = json.loads(map_obj.map)
# Now you can use getattr() along with mapping as in my earlier mail

You can create a forms or interfaces for user to Create, Read, Update and
Delete (CRUD) these maps, so user need not write python files.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABSvzZDPeTMxwRAtfP7mMn%2B2PLgumhopDUdEz_-swETVS4Z96A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Integrate with an ADFS Server for Login

2014-02-25 Thread Me Sulphur
Hi,

For one of our new deployments we need to replace our authentication 
(django's default) with the client's Single Sign On (SSO). The client uses 
ADFS 2.0 for SSO.
None of us have ever worked on .NET/Windows techologies; we tried to look 
up at many places but no leads on where to start. Possibly, the apps -  
djangosaml2 or pysaml2 - can help but could not figure out how to use them 
for our use case.

Please if someone can provide the lead on how to proceed, I'd be thankful.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/22f86263-5c57-4244-ad63-67f9f528df68%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Integrate with an ADFS Server for Login

2014-02-26 Thread Me Sulphur
Hi Tom,

You understood our requirements precisely. We do not have significant time
or ability to dig deep into platforms like C & SWIG. We have agreed to have
a C# intermediay to do all the ADFS/Windows stuff and use another callback
URL from C# to Django for logging the user in.


Thanks & Regards


On 25 February 2014 18:17, Tom Evans  wrote:

> On Tue, Feb 25, 2014 at 10:44 AM, Me Sulphur  wrote:
> > Hi,
> >
> > For one of our new deployments we need to replace our authentication
> > (django's default) with the client's Single Sign On (SSO). The client
> uses
> > ADFS 2.0 for SSO.
> > None of us have ever worked on .NET/Windows techologies; we tried to
> look up
> > at many places but no leads on where to start. Possibly, the apps -
> > djangosaml2 or pysaml2 - can help but could not figure out how to use
> them
> > for our use case.
> >
> > Please if someone can provide the lead on how to proceed, I'd be
> thankful.
>
> This area isn't well served - for future posters, he is not trying to
> authenticate against LDAP, nor against AD. He wants users to be
> identified by their own organization and identity information passed
> back to his site from the partners AD.
>
> The thing with SAML is that there are lots of different Profiles and
> Transports that describe precisely how to communicate with an Identity
> Provider. The plus side for you is that you are implementing a Service
> Provider (SP) and not as an Identity Provider (IdP) - ie you have a
> site that people log in to, not a site that stores and provides
> identity information.
>
> You will need to determine what interop support ADFS has for SAML 2.0,
> what Profiles and Transports it expects to use.
>
> I don't know much about the libraries you mentioned. We used py-lasso,
> which is a library for producing, interpreting, signing/validating and
> encrypting/decrypting SAML messages. The documentation was . less
> than good. In the most part we relied on reading the C sources to
> lasso and the SWIG bindings to determine what functions to call and
> when.
>
> Plus, we were not doing interop, we were writing our own IdP that
> talked to our own SPs, so we had complete blanket choice over what
> Profiles to use.
>
> I do not think you can achieve this by simply "Install this package,
> add this setting". Happy to be told otherwise!
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/Xkvwii1_HBs/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFHbX1J1e9JMOPaYfKGaWPVcJ%2BWNQyhn0JHxHXqRpNL1HPoA3w%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABSvzZA2vOpY5Uv7C8JRLYEJDaXBTY1ZqiB8b%2BV8CpL%2BoCfKRw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Proxy problem (permissions denied)

2014-05-26 Thread Me Sulphur
Sorry, logging in after a while. Hopefully you have solved the problem by
now. Answering just in case some one stumbles upon through Google.

The problem is not the proxy, it is that you are accessing SITE B
(localhost:*8080*) from SITE A (localhost:*8000*) from within the browser,
which is disallowed by default and can be permitted by setting appropriate
HTTP Headers. (SO
Answer<http://stackoverflow.com/questions/1653308/access-control-allow-origin-multiple-origin-domains>
).

Alternatively you can have SITE A "play" reverse
proxy<http://en.wikipedia.org/wiki/Reverse_proxy>for SITE B.


On 28 March 2014 11:46, rmu  wrote:

> Hi, I have been stuck in the same *proxy* thing. While I tried to get wfs
> point layer from geoserver in openlayers i got error in the chrome console:
>
>1. OPTIONS http://localhost:8080/geoserver/EMIS/wfs No
>'Access-Control-Allow-Origin' header is present on the requested resource.
>Origin 'http://localhost:8000' is therefore not allowed access.
>
> OpenLayers.js:1188<http://localhost:8000/site_media/Openlayers/OpenLayers.js>
>
> XMLHttpRequest cannot load http://localhost:8080/geoserver/EMIS/wfs. No
> 'Access-Control-Allow-Origin' header is present on the requested resource.
> Origin 'http://localhost:8000 <http://localhost/>' is therefore not
> allowed access.
> I believe you have solved it using GeoNodes Proxy. I am just starting
> django and Geodjango. I have few questions:
> 1. Is the Proxy an app of the GeoNode?
> a. Can I copy the Proxy folder inside by project directory and include
> it in installed apps of the settings.py file.
> 2. Would you guide me to use the proxy/view.py. How did you use it?
>
> please help me!!
> Sincerely,
> Ram Shrestha
>
> On Saturday, February 1, 2014 9:17:27 PM UTC+5:45, Gkpetrak wrote:
>>
>> Hi Me Sulphur,
>>
>> Thank you so much my friend !
>> A two weeks problem solved !!
>> The problem was the csrfmiddleware token in my POST request.
>>
>> Thank you in advance,
>> George
>>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/u57bbBirVuY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f246303b-4eca-4e59-a9b7-3bcc90f6814f%40googlegroups.com<https://groups.google.com/d/msgid/django-users/f246303b-4eca-4e59-a9b7-3bcc90f6814f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABSvzZD%3DLuqfEo_vHmBdg8b2HfT3DGOsRs5AXv-VpRZ_J3kz4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: A question of signals and ATOMIC_REQUESTS

2018-01-31 Thread Me Sulphur
Thanks! For the response.

In that scenario, what would explain old_copy (in the code example) having 
updated values and not the stale ones from the DB.

Postgres Doc Reference: 
https://www.postgresql.org/docs/current/static/sql-set-transaction.html




On Wednesday, 31 January 2018 16:41:16 UTC+5:30, Jason wrote:
>
> It seems that your inference is correct
>
> https://stackoverflow.com/a/41522066/214892 
> <https://www.google.com/url?q=https%3A%2F%2Fstackoverflow.com%2Fa%2F41522066%2F214892&sa=D&sntz=1&usg=AFQjCNH5G1ZX5ELAIgVANGA39tXOTaMogA>
>
> On Wednesday, January 31, 2018 at 12:54:29 AM UTC-5, Me Sulphur wrote:
>>
>> When ATOMIC_REQUESTS=True is set, are ORM signals - post_save and 
>> pre_save - also executed within the transaction?  Per my inference, they 
>> seem be to a part of the transaction. 
>>
>> Assuming my inference is correct, then consider the following code 
>>
>>
>> @receiver(post_save, sender=MyModel) 
>> def log_and_notify_change(sender, instance, created, **kwargs): 
>>  if not created: 
>>  old_copy = MyModel.objects.get(id=instance.id) 
>>  diff_fn(old_copy, new_copy) 
>>
>>
>> Since Postgresql only supports READ COMMITTED, implying that reading a 
>> row inside a transaction should always return the older value. However, 
>> in the code above, old_copy always has updated values meaning that the 
>> signal was executed outside transaction (after it was committed.) 
>>
>> Is this the correct behavior? I tried to reason by looking at the code 
>> but again not sure. 
>>
>> Thanks! 
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1a4ca355-be4a-441e-a858-6ab478be9766%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.