uvicorn and ASGI

2022-06-05 Thread Dan Davis
I am doing some work comparing various ASGI frameworks, SQL Alchemy, just writing the SQL, and that sort of thing, in order to determine what I think. Speed isn't every thing, but speed is a thing. Anyway, I was reading about this at https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/

Re: Periodic Execution of django functions or tasks

2022-03-07 Thread Dan Davis
If celery is too much, consider django-background-tasks. To be totally honest, I am an old dog, and I generally do the following: * Write a management command. * Deploy a crontab to run my management command. This is not so container or cloud friendly, but none of my cloud deployments run "long"

Re: Wrapping dbshell and invoking procedures and such

2021-10-22 Thread Dan Davis
This will allow me to have my Django management commands act as wrappers for the SQL stored procedures. On Friday, October 22, 2021 at 6:58:04 PM UTC-4 Dan Davis wrote: > I've succeeded over the last few years in creating a Django app that > everyone likes that uses a "tip of the

Wrapping dbshell and invoking procedures and such

2021-10-22 Thread Dan Davis
I've succeeded over the last few years in creating a Django app that everyone likes that uses a "tip of the iceberg" out of a 20 year old database. Now I've inherited the SQL development as well, and I want to cleanup and move towards more Django. There are lots of small, non-DRY scripts run fr

Re: Scaling dumpdata and loaddata

2020-10-22 Thread Dan Davis
I have found an answer of sorts in a previous thread. Fred says: > Just for the follow-up, I ended up using pgloader and after some argument tweaking, it worked. Cheers. On Thursday, October 22, 2020 at 6:48:57 PM UTC-4 Dan Davis wrote: > dumpdata and loaddata work for me on some s

Scaling dumpdata and loaddata

2020-10-22 Thread Dan Davis
dumpdata and loaddata work for me on some smaller applications, but I am wondering whether any of you have strategies to scale it up to more data. My DevOps doesn't really give developers access to much - not even RDS snapshots. The larger applications have written some logic to move data, bu

Expire session after N minutes of inactivity

2020-07-14 Thread Dan Davis
Does anyone know of a django pypi package that implements something like this so that I can steal the code? I know I need to think about "what does inactivity mean" in the era of SPA and Ajax, but a module could save me some time. -- You received this message because you are subscribed to the

Re: connection queries_log when DEBUG is False

2020-07-08 Thread Dan Davis
() signals.request_started.connect(reset_queries) On Wednesday, July 8, 2020 at 7:03:48 PM UTC-4, Dan Davis wrote: > > This has to do with Django internals, but is nonetheless a user question. > > Various packages force_debug_cursor as illustrated in > https://www.webucator.c

connection queries_log when DEBUG is False

2020-07-08 Thread Dan Davis
This has to do with Django internals, but is nonetheless a user question. Various packages force_debug_cursor as illustrated in https://www.webucator.com/blog/2015/08/python-clocks-explained/. Other packages monkey patch the cursor wrapper to be used. Does Django clear connection.queries_log af

Re: Updating the concept of Django

2020-06-15 Thread Dan Davis
Since Django is written in Python, you should know enough Python to understand it do really good code. If you are well versed in other computer languages, I recommend the book Fluent Python. It is not for newbies to programming however. I find the Django Tutorial from the project itself, https

Path parameters and security scanners best practice

2020-06-15 Thread Dan Davis
I have an odd question. When I have a path parameter that is validated to be alphanumeric, and a security scanner sends a non-alphanumeric value, Django properly validates and then returns 404. However, this gives the security scanner the mistaken impression that there is some some sort of s

Re: Django-React with webpack or create-react-app

2020-03-09 Thread Dan Davis
If you wish to use cache busting, or create-react-app sets that up by default, you can configure some special logic for loading the bundles. Mine is per-process based, and assumes that since the bundle will be cached, it reasonable not to create a new static file loader: https://gist.github.com/

CONN_MAX_AGE and Oracle

2020-03-09 Thread Dan Davis
One or my power users claims that CONN_MAX_AGE is not working properly with Oracle. I've written a minimal backend to wrap the standard Oracle backend, and to log connection creation. I am seeing multiple connections sometimes in the same second with a CONN_MAX_AGE of 300. I am currently atte

AdminEmailHandler logging filter, formatting, and false positives

2020-01-16 Thread Dan Davis
My team uses the django.utils.log.AdminEmailHandler, but along with a filter I wrote - infrastructure.log.SkipNessusScanFilter So, the security team moved its Tenable Nessus scanner from on-premise to the cloud (for public sites), and as usual, the scanner is misconfigured to use an IP address

Re: Making tests fast

2019-09-03 Thread Dan Davis
I will just use fixtures, natural-keys, and an in-memory database. -- 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

Making tests fast

2019-09-03 Thread Dan Davis
I'm wondering how to make my tests fast while also having a lot of data defined in the models. This project is already using sqlite3 and the tests are single-threaded. My ideas are: - Specify a different sqlite3 file and keepdb for different tests - presumably with @override_settings

Re: Package that helps update only changed fields

2019-06-24 Thread Dan Davis
Thanks, I wrote a mixin class for most of my forms that works a lot like this, although it combines self.changed_fields and self.model._meta.fields to discover which fields to update, rather than the two stages you have above. I discovered when trying to generalize this mixin that some of my

Re: architecture for Blue/Green deployments

2019-06-24 Thread Dan Davis
A related discussion on django-developers has turned up this module, written by one of the participants in the discussion there: https://github.com/aspiredu/django-safemigrate >> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe

Re: call a view several times in another view

2019-06-18 Thread Dan Davis
I don't think it is a a good idea to call a view from another view, but if you have an underlying function that used to be a view, and you want to call it to do the secondmethod, then that's a good way to begin to do more with Django. Another good way is to practice using the generic class-ba

Re: Saving OnetoOne Field

2019-06-18 Thread Dan Davis
Shreejith Unnikrishnan Nair, Is this in a ModelForm or the intsance itself? That would help to give guidance... On Tuesday, June 18, 2019 at 11:40:53 AM UTC-4, Lutalo Bbosa joseph wrote: > > A foreignKey with aunique attribute is same as using a OnetoOneField so > either can suit your needs

Package that helps update only changed fields

2019-06-18 Thread Dan Davis
So, I recently observed that a Django ModelForm updates all columns when it is updating a model instance. This is appropriate for a typical situation where Django is also in control of the schema. I also see that you can control this behavior by passing update_fields

Re: My developers have run amok

2019-06-05 Thread Dan Davis
> > Are you sure? > My (possibly flawed) understanding is that if you can make the change in > a single transaction, no-one else can see what is happening until it is > committed. Effectively that would be an instantaneous change. > Depending on your data architecture you might need to make some pa

Re: My developers have run amok

2019-05-22 Thread Dan Davis
Sure - setting it up is easy. There are hard questions about database mutations however. If you drop column bar from table Fubar, then the old code is still querying for buth Fu and Bar: SELECT id, fu, bar FROM fubar On-premise, this is the case for maybe 10 seconds, tops. In the clo

Question on logging best practices and ALLOWED_HOST

2019-05-22 Thread Dan Davis
*First Question - How valuable is the check on ALLOWED_HOST? * How many folks out there simply have settings: ALLOWED_HOSTS = ['*'] *Second Question - What is the best practice for enriching the log record?* On-premise, we've struggled with the interaction of the AdminEmailHandler and secur

Oracle ORA-03124 Two-task internal error

2019-05-08 Thread Dan Davis
Running my migrations with Django 1.11. (1.11.20), fails with the Oracle error ORA-03124 Two-task internal error. I have tried this with Oracle instantclient 12.1.0.1 and 18.5.0.0., and several other versions of cx_Oracle. There are no migrations to make, but I get the following error, always in

Re: My developers have run amok

2019-03-04 Thread Dan Davis
ou are doing; rather look > to extract specific fields that you know you want to display/access. I > would imagine that the only time you are going to want to retrieve that > BLOB (assuming you stick to your current design) is per individual record > "on request". > > >

Re: Max function and grouping with Oracle

2019-02-26 Thread Dan Davis
> That is not the case on MySQL and PostgreSQL for. example. +1 Insightful. I'm still trying to get my Ops guys to let us drop and re-create databases for Postgres/MySQL. They are very afraid to give that permission because they worry about production databases, and it is hard for them to mana

Re: My developers have run amok

2019-02-26 Thread Dan Davis
For the group, the eventual culprit was not complicated. It is a model with a BinaryField that holds a file's contents. The Django documentation advises against this, but why? Well, on-premise with big-iron database like Oracle, storing the file in the database is attractive. So, what's the

Re: Is Django logging multi-process safe?

2019-02-26 Thread Dan Davis
So, there are some issues in managing the files. It is not very 12-factor to have the application worry about such things. The issues with using a FileHandler or TimedRotatingFileHandler from multiple processes/kernel threads are less important, but still exist. If a file is append-only, the

Re: django command logging levels

2019-02-15 Thread Dan Davis
The common verbosity will be passed to the handler: class Command(BaseCommand): ... def handler(**kwargs): verbosity = kwargs['verbosity'] I tried to get clever once and not have **kwargs, but Django sends that common stuff, like '--settings", and it is good for me to pay atten

Re: Preparing for 2.2LTS - testing for Deprecation Warnings

2019-01-17 Thread Dan Davis
I will then try like this in my manage.py: if len(sys.argv)>1 and sys.argv[1] = 'test': warnings.filterwarnings(...) Thanks, -Dan On Thu, Jan 17, 2019 at 1:08 PM Simon Charette wrote: > You can use the category kwarg of filterwarnings[0] to pass the Django > deprecation > warni

Re: Django 2.2 alpha 1 released

2019-01-17 Thread Dan Davis
Now I see it... On Thursday, January 17, 2019 at 11:31:24 AM UTC-5, Dan Davis wrote: > > Great - I want to add it to some tox tests that I only run on demand. It > isn't yet on pypi, right? > > On Thursday, January 17, 2019 at 10:40:21 AM UTC-5, Carlton Gibson wrote: >&g

Re: Django 2.2 alpha 1 released

2019-01-17 Thread Dan Davis
Great - I want to add it to some tox tests that I only run on demand. It isn't yet on pypi, right? On Thursday, January 17, 2019 at 10:40:21 AM UTC-5, Carlton Gibson wrote: > > We've made the first release on the way to Django's next major > release, Django 2.2! > > With about two and a half

Preparing for 2.2LTS - testing for Deprecation Warnings

2019-01-17 Thread Dan Davis
PYTHONWARNINGS=error is too much. How can I call warnings.filterwarnings() to make all *Django* DeprecationWarnings into errors? -- 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,

Re: Is Django logging multi-process safe?

2018-12-21 Thread Dan Davis
u > want to. > > > Regards > > > Eric > > > ------ > *From:* django-users@googlegroups.com on > behalf of Dan Davis > *Sent:* Friday, December 21, 2018 5:55:35 PM > *To:* Django users > *Subject:* Re: Is Django logging multi-process safe? > > Looks like I

Re: Is Django logging multi-process safe?

2018-12-21 Thread Dan Davis
Looks like I should use a WatchedFileHandler and then have logrotate do the logging. If the file pointer is moved by another process, then it will work. Does gunicorn patch this for me? Will I be better off using syslog or something? On Friday, December 21, 2018 at 11:51:16 AM UTC-5, Dan

Is Django logging multi-process safe?

2018-12-21 Thread Dan Davis
I just came across this: https://docs.python.org/3.5/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes This suggests that log messages sent to a StreamHandler will be processed properly, but log messages sent to a standard logging.handlers.TimedRotatingFileHandler ar

Re: Max function and grouping with Oracle

2018-11-26 Thread Dan Davis
Looks like there is no problem here. Django groups by whatever is in the query, so that this would be done as follows: Parent.objects.values('id').annotate(child_updated_timestamp=models.Max('child_updated_timestamp')) On Monday, November 26, 2018 at 12:32:09 PM UT

Max function and grouping with Oracle

2018-11-26 Thread Dan Davis
I have a parent model that has a relationship to some data that is changing: class Parent(models.Model): name = models.CharField(...) created_timestamp = models.DateTimeField(auto_now_add=True, null=True) updated_timestamp = models.DateTimeField(auto_now=True, null=True) class Ch

Checking for reference leaks

2018-11-09 Thread Dan Davis
So, my application apparently is the largest on our Django servers. This doesn't mean that a reference leak exists, but it could mean that a reference leak exists. I've been trying to find some generalizable way to search for such a problem. I have difficulties drawing help from within the

Re: My developers have run amok

2018-11-06 Thread Dan Davis
This will likely do it - tracking as a django middleware, I suspect too much will still be lazy: https://pypi.org/project/wsgi-objgraph/ On Tue, Nov 6, 2018 at 6:39 PM Dan Davis wrote: > I am less certain this is the problem now. It may simply be that my > project is one of the larger

Re: My developers have run amok

2018-11-06 Thread Dan Davis
I am less certain this is the problem now. It may simply be that my project is one of the larger on the server. I did a quick audit, and although they are new to django, they either used connection.cursor() as a context manager, or called close explicitly. I will try to develop a middleware ar

Re: My developers have run amok

2018-11-06 Thread Dan Davis
On Tuesday, November 6, 2018 at 2:32:52 PM UTC-5, Jason wrote: > > refactor to use the ORM for those bits? and implement a team styleguide > that says no direct connections unless its proven to work better? > I'm looking to identify the memory consuming bits to allow refactor. Not a bad ide

My developers have run amok

2018-11-06 Thread Dan Davis
My developers, who have come from ColdFusion, are fond of this: cursor = connection.cursor() cursor.execute() data = [r for r in cursor] return render(request, some_template_name, {'data': data}) The problem with this is that the database cursor reference will be leaked. How do I integrate into

Re: Left outer join rather than subquery.

2018-11-02 Thread Dan Davis
models/querysets/#django.db.models.FilteredRelation The uniqueness constraint is actually already there in my actual model, and Django supports that through unique_together = ('journal', 'issn_type'). On Tuesday, October 30, 2018 at 2:05:58 PM UTC-4, Dan Davis wrote: > > > Suppo

Re: Using django on kubernetes

2018-11-01 Thread Dan Davis
if your configuration involves multi-nodes load balancing. > > > Eric > -- > *From:* django...@googlegroups.com < > django...@googlegroups.com > on behalf of Dan Davis < > dans...@gmail.com > > *Sent:* Tuesday, October 30, 2018 6:56:32 PM > *To:* D

Left outer join rather than subquery.

2018-10-30 Thread Dan Davis
Suppose you have a setup like this: class Journal(models.Model): title = models.CharField(max_length=200) issn_type_choices = ( ('E', 'Electronic'), ('P', 'Print'), } class Issn(models.Model): ELECTRONIC='E' PRINT='P'

Re: Using django on kubernetes

2018-10-30 Thread Dan Davis
Andreas, I don't know terribly much about Kubernetes, only Docker, however it seems that Kubernetes must natively provide some metrics collection, i.e https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/. It would be nice to correlate particular views and the

Handling Database Tables without a unique column

2018-10-29 Thread Dan Davis
I am currently leading a team handling a 16 year old database filled with junk. I think it has existed since its HTML application was served by Oracle forms. We are in production with Django, and turning off the more recent ColdFusion version this Thursday. However, some of our ways of working

Re: RemoteUserMiddleware stay logged in

2015-12-02 Thread Dan Davis
Thanks, I can probably just install it and use it. If I must stay in 1.8 for some arcane reason, I can read the code at https://github.com/django/django. On Monday, November 30, 2015 at 8:29:00 PM UTC-5, Tim Graham wrote: > > Does the PersistentRemoteUserMiddleware added in Django 1.9 help? >

RemoteUserMiddleware stay logged in

2015-11-30 Thread Dan Davis
So, where I work we have a CAS server we like to use. We like to use it with mod_auth_cas.So far, so good - RemoteUserMiddleware is my friend. The problem here is that REMOTE_USER will not be set unless the URI is protected by CAS, and if the URI is protected by CAS, then the user will b

Re: Oracle XMLType and AES_Encrypt() field

2015-09-15 Thread Dan Davis
Indeed. That works. On Tuesday, September 15, 2015 at 2:49:06 PM UTC-4, Carl Meyer wrote: > > On 09/15/2015 12:44 PM, Dan Davis wrote: > > I'm wondering how I would get python to run an interactive shell similar > > to what I'd get from running ./manage.py

Re: Oracle XMLType and AES_Encrypt() field

2015-09-15 Thread Dan Davis
On Saturday, September 12, 2015 at 2:23:15 PM UTC-4, Carl Meyer wrote: > > Hi Dan, > > ... ... Yes, this is possible, and not even that hard (at least in Django 1.8, > where Field classes gained more control over SQL generation; I suspect > it would be quite a bit more difficult if you need t

Oracle XMLType and AES_Encrypt() field

2015-09-12 Thread Dan Davis
I'm working on a Django project template to be used by a sub-department of my employer. We are an Oracle shop, and make reasonably heavy use of Oracle's XMLType.Another issue that has come up is encryption. It is trivial to create an EncryptedTextField field type. What I want to do is