Commit Graph

337 Commits

Author SHA1 Message Date
raphael.boucher
33dbc4a184 Replace multiplexer with class demultiplexer
Update documentation
Ensure send is not available on demultiplexed consumer classes
Data binding needs fixing
2017-01-08 18:05:50 -08:00
raphael.boucher
21b08b01b8 Add demultiplexer for class-based consumers (#383)
Avoid coupling between the demultiplexer and consumers.
2017-01-08 18:05:50 -08:00
Artem Skoretskiy
387c73fa27 Fixed import to resolve RemovedInDjango20Warning (#457)
* Fixed import to resolve RemovedInDjango20Warning

That resolves: "RemovedInDjango20Warning: Importing from django.core.urlresolvers is deprecated in favor of django.urls."

* Fixed syntax error

Fixed indent

* Updated import order
2017-01-02 08:14:34 -08:00
scryver
7230708f6f Update utils.py (#455)
Name that thing should not use a metaclass to name a thing.
2016-12-30 09:44:03 +00:00
Drew French
f4c9b02ae3 Valid cookie serialization for the test HTTPClient (#453)
* valid cookie serialization

* Added set cookie test

* delimiter fix

* more cases

* quote fix

* cleanup

* fix

* lint cleanup

* more lint clean up
2016-12-22 22:46:09 +00:00
AlexejStukov
cb0a9bef4b Use save's update_fields in serialize_data (#448)
* pass save's kwargs to serialize

So it can access update_fields

* added short explanation

* added missing kwargs

* use update_fields to filter fields to serialize

* save kwargs on self

* get signal_kwargs from self

* whitespace

* just save signal_kwargs on self+removed left over kwargs
2016-12-16 20:00:11 +00:00
Andrew Godwin
54705915de Make formatting in management tests consistent 2016-12-10 11:57:28 -08:00
Andrew Godwin
3d2426e7b4 Fix root_path in runserver tests 2016-12-10 11:55:49 -08:00
Andrew Godwin
5a38171fc7 Fix #449: root_path was ending up as None 2016-12-10 11:48:11 -08:00
Sam Bolgert
3dddefa845 Delay Protocol Server (#401)
* Add Delay Protocol Server

Add a process that listens to a specific channel
and delays incoming messages by a given time.

* Add custom django command rundelay
* Add test suite
* Implements #115

* Add channels.delay app

* Add AppConfig

* Move rundelay command to channels.delay app

* Refactor DelayedMessage into model

Move login into a database backed model.
* Update Worker
* Add migration

* Add delay docs page

* Add to TOC

* Fix import sorting

* Add ASGI spec document for Delay Protocol

* Update channels.delay doc with new channel name
* remove interval docs

* Refactor Delay to use milliseconds instead of seconds

Use milliseconds as the default unit. Gives more control to developers.

* Remove interval logic from DelayedMessage
* Remove interval tests
* Tweak test logic to use milliseconds
2016-11-24 10:54:03 -08:00
Jan Boysen
fdc80cb269 runserver should respect FORCE_SCRIPT_NAME setting (#435)
* Pass FORCE_SCRIPT_NAME to Daphne server when set

FORCE_SCRIPT_NAME seems not to be honored any more with build-in runserver after activating channels app.
The normal behavior of Django is the FORCE_SCRIPT_NAME is used as prefix when set while generating URLs so its possible to
create a path prefix and determine different Django installations based on the path rather than hostname without having to prefix all paths in urls.py.

* Only strip script_name from path if it starts with it

* make tests happy again after setting kwarg root_path
2016-11-18 06:26:16 -08:00
Tobias Kunze
82f7ff21df Add closing response codes (#426)
Added both to spec and implementation. Regards #414.
2016-11-05 13:39:44 +01:00
Paul
f4f45dbb9f Sort imports and make Travis run isort (#425)
* Sort imports

* Make Travis run isort
2016-11-05 12:08:38 +01:00
Andrew Godwin
c5f047a245 Fix test to look for SERVER_PORT 2016-11-02 08:17:44 +00:00
Andrew Godwin
6d8d3214e6 Fixed #422: No SERVER_PORT in request.META causes errors 2016-11-02 08:15:06 +00:00
Krukov D
e24bc17bbf Documentation of Client/HttpClient and data binding unit tests (#417)
* Added as_route documentation

* Added documentation for client

* Improve tests for binding

* Changes for client docs

* Fix docs indentations at client part

* Added missed imports

* Small fixes and refs

* Fix typos

* Fix errors and typos.
2016-10-31 11:42:10 +00:00
Yatish Bathini
291405afeb Issue#393: Clear session modified flag on enforce_ordering session save (#402) 2016-10-21 11:59:45 -07:00
AlexejStukov
4f517bb9fc check accept fields = '__all__' in serialize_data (#404) 2016-10-19 09:25:34 -07:00
MartinArroyo
12ca598d6b Adds 'exclude' option to data binding (#400) 2016-10-16 22:58:02 -07:00
Jeremy Spencer
51561273ae Fix for issue 398. Converts channels.binding.websockets.WebsocketBinding.fields to list before comparing to ['__all__'] to ensure most common data structures do not cause unexpected failures (i.e. ('__all__',), '__all__') (#399) 2016-10-14 18:54:46 -07:00
Luke Hodkinson
1673be5b75 Found a bug whereby streaming responses would try to be cached (#396)
entirely in memory. Was causing views that stream a lot of data
to timeout.
2016-10-11 22:32:45 -07:00
Rock Howard
c419d01ded added http_timeout as a command line option for runserver (#387)
* added http_timeout as a comand line option for runserver

* possible improvement for input param management

* explicitly set the default http_timeout in add_argument
2016-10-11 13:25:27 -07:00
Andrew Godwin
09b2a12be1 Change to accept being part of send/close 2016-10-05 15:59:55 -07:00
Andrew Godwin
f9ef08b0aa Flake8 fix 2016-10-05 15:37:55 -07:00
Andrew Godwin
0ed04a9c06 Fix tests for new non-immediate sending 2016-10-05 15:32:37 -07:00
Andrew Godwin
0826b7997f Send messages after the end of consumers 2016-10-05 14:49:46 -07:00
Andrew Godwin
db0d2975a0 Remove middleware approach, change to simpler one 2016-10-05 12:06:34 -07:00
Andrew Godwin
0fcb93acc2 Mostly-complete middleware version 2016-10-05 11:42:46 -07:00
Andrew Godwin
dcfaf4122b Work in progress towards accepting websockets explicitly 2016-10-05 10:45:51 -07:00
Sam Bolgert
b115f8fa04 Update channel_session decorator to rehydrate http_session (#348)
* Update channel_session decorator to rehydrate http_session

Update the http_session decorator to write the http session key
to the channel_session when available. This allows the channel_session
decorator to rehydrate the http_session after the initial websocket
connection.

closes #318

* Add persist=True option to http_session

* Add explicit option to store the session key in the channel session
* Update docs
* Add test case

* Add channel_and_http_session decorator

This decorator enables both sessions and maintains
the http_session for the lifetime of the websocket connection.
2016-09-29 11:08:44 -07:00
Carles Barrobés
d4f7125cd5 Fix type for request.META['SERVER_PORT'] (#378)
Django documentation states that it is a string.
Fixes #366
2016-09-23 11:37:45 -07:00
Benjamin Bach
06fd1f8ada Add conventional request.META['PATH_INFO'] - fixes benjaoming/django-nyt#27 (#375) 2016-09-22 13:57:30 -07:00
Krukov D
5464cba742 Iimprovements for test client (#352)
* Json encoding only for not string text at HttpClient

* Decode received content if possible

* Check that content received

* Using json kwarg at receive method to decode message text content

* Wrap decorator function at channel_session_user_from_http

* Cleanup

* Arbitrary indent. sorry
2016-09-12 11:28:12 +01:00
Krukov D
075897d910 Inbound tests (#351)
* Added groups as Binding attr for easy groups_names definition

* Binding: inbound - updating fields that only in fields attribute

* Added tests for inbound part of binding #343

* Fix for flake8 checker

* Revert "Added groups as Binding attr for easy groups_names definition"

This reverts commit 009b4adbee534d4ccbea191ce2523a0edb09d407.

* Using group_names at inbound tests
2016-09-12 11:27:42 +01:00
Luke Hodkinson
079558d5b5 Too many threads bug in threaded worker. (#334)
* Use a mixin for common test-case code. This way we can have both
a regular channels test-case, and a transaction test-case, too.

* Adding a reference to django-cq.

* Adding the ability to launch a number of workers in threads.
This is to try and help reduce memory consumption.

* Adding a signal for process level worker startups.

* Cleaning up the threaded worker code.

* Use Python 2.7 friendly code.

* Making the runworker command show a little more information
about how many threads are running.

* Moving the worker ready signal into a method in order to support
polymorphic behavior.

* Ugh, I'm an idiot. Was launching the wrong run.

* Adding a call to the workers' `ready` in `runserver`.

* Fixed a bug whereby too many threads were being
used when threaded workers were used.
2016-09-02 08:02:29 -07:00
Luke Hodkinson
0d25860cf2 Run workers in threads. (#322)
* Use a mixin for common test-case code. This way we can have both
a regular channels test-case, and a transaction test-case, too.

* Adding a reference to django-cq.

* Adding the ability to launch a number of workers in threads.
This is to try and help reduce memory consumption.

* Adding a signal for process level worker startups.

* Cleaning up the threaded worker code.

* Use Python 2.7 friendly code.

* Making the runworker command show a little more information
about how many threads are running.

* Moving the worker ready signal into a method in order to support
polymorphic behavior.

* Ugh, I'm an idiot. Was launching the wrong run.

* Adding a call to the workers' `ready` in `runserver`.
2016-08-31 21:26:03 -07:00
Krukov D
b62ea7dd0a Naming consumers that are classmethods (#324) 2016-08-29 10:37:09 -07:00
Krukov D
e6236f79e6 Move the groups at class definition (#321) 2016-08-26 12:12:14 -07:00
Frank Pape
c8fdea6460 Add send_and_consume method to HttpClient to match base Client behavior. Change argument ordering in send method to match base client. Fix repeated "live cycle" error in docstrings. (#320) 2016-08-26 12:04:38 -07:00
Tim Watts
39339e66bc Remove invalid test. FileResponse requires a file object. (#311)
* Remove invalid test. FileResponse requires a file object.

* rm unused imports
2016-08-24 17:39:18 -07:00
Andrew Godwin
f699d112b0 Fixed #309: Missed a double decode for header coalescing 2016-08-23 20:10:15 -07:00
AlexejStukov
fcb2875b53 fixed usage of group_names in *_change_receiver (#306)
* fixed usage of group_names in *_change_receiver

group_names was missing second arg (action)

* fixed group_names to include action

* made group_names a classmethod
2016-08-23 10:13:46 -07:00
Luke Hodkinson
6649afce8e Use a mixin for common test-case code. This way we can have both (#305)
a regular channels test-case, and a transaction test-case, too.
2016-08-20 17:53:54 -07:00
Tyson Clugg
57fa3bed67 Implement the data binding behaviour from Django DDP. (#301)
* Implement the data binding behaviour from Django DDP.

Correct dispatch of create/update/delete according to how group_names change
when compared between pre and post save/delete.

* Fix tests for databinding improvements.
2016-08-16 16:49:18 +10:00
Oskar Hahn
32568dc879 Start only one worker with the nothreading option. (#298)
Reuse the nothreading option of the runserver command to only start one
worker.
2016-08-15 11:18:24 +10:00
Francis Mwangi
fb2e9320c2 fixed typo (#296) 2016-08-14 12:08:00 +10:00
AlexejStukov
0f1ac3d08b Fix member serialization in WebsocketBindingWithMembers (#292)
* Fix member serialization in WebsocketBindingWithMembers

* pep fixes

* allow usage of 'dot'-notation in send_members

* replace dots for dictionary

* single quotes
2016-08-10 21:55:51 -07:00
Andrew Godwin
f682298341 Show daphne server logs in runserver 2016-08-05 22:17:59 -07:00
AlexejStukov
0bc1cee103 Easy application of decorators to Bindings (#281)
* Added get_handler

Added a get_handler method that applies decorators to the consumer-classmethod

* added imports for decorators

* Added get_handler to WebsocketBinding

* Fixed missing import

* channel_session_user defaults to True

* removed user-transfer from http

would only work in a connect-method

* removed unused import
2016-08-05 00:12:59 -07:00
Andrew Godwin
2d97ab2cc7 Releasing version 0.17.2 2016-08-04 16:55:43 -07:00