Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Core::Context in favor of smarter Core::Request #589

Closed
xsawyerx opened this issue May 20, 2014 · 12 comments
Closed

Remove Core::Context in favor of smarter Core::Request #589

xsawyerx opened this issue May 20, 2014 · 12 comments
Assignees

Comments

@xsawyerx
Copy link
Member

One thing that bugs me is Core::Context. It is created in the app from the request, contains a reference back to the app, and the app contains a reference to itself. It holds both data and actions, but neither on itself.

Until now I wasn't even sure what the hell it is exactly meant for. Now I understand it better, and it seems like we could actually remove it (and some duplicate code that exists there) in favor of making the Core::Request object more aware of able.

I'd like to get some opinions on this.

@xsawyerx
Copy link
Member Author

@mickeyn and I are hacking on it.

@xsawyerx
Copy link
Member Author

We've done a ton of work on this, available in a branch.

We were basically able to remove from the codebase the biggest part of the Core::Context variable, which is its request attribute. That's the majority of what's used in it. Friday we will continue and try to detach more and more strings.

All tests pass so far.

@mickeyn
Copy link
Contributor

mickeyn commented Jun 30, 2014

so, https://github.com/PerlDancer/Dancer2/tree/feature/untangle-context is fully functional and context-less.
we need reviewing before merging it, anyone want to assist with that?

@xsawyerx
Copy link
Member Author

I am willing to offer $something in exchange. Just please someone review this. @mickeyn and I will be happy to help lend our explanation and assistance.

I'd prefer not to push it without another person (or more) reviewing this.

@veryrusty
Copy link
Member

I'll review it. It may take a week, but I will get there (there's a lot to get through)!

/me starts thinking about what $something to ask @xsawyerx for...

@mickeyn
Copy link
Contributor

mickeyn commented Jun 30, 2014

@veryrusty don't be shy, he actually meant $anything :)

@veryrusty veryrusty assigned veryrusty and mickeyn and unassigned mickeyn and veryrusty Jul 1, 2014
@veryrusty
Copy link
Member

Ok - got through that branch! @mickeyn++ for the AWESOME commit messages!!

I've made comments inline and/or on individual commits as necessary. There are two things that need addressing before attempting a merge (I'm probably repeating myself):

  1. A change to Core::Role::DSL in 9c3b21b removes the distinction between DSL keywords that can be used within or outside a route definition.
  2. Moving Core::App->session method to the DSL in 61a47fd will break any plugin that currently does $app->session(...).

We may also wish to log a warning (deprecate) the context DSL keyword.

There has also been a pass method added to the context object since this work was started. An almost identical commit to e1989ca (with s/halt/pass/) should suffice.

@xsawyerx
Copy link
Member Author

xsawyerx commented Jul 5, 2014

I just want to note I coerced @mickeyn to write longer commit messages, other than "fixed shit". :)

@veryrusty
Copy link
Member

Looking at @mickeyn's "merged" branch (mickey/merging_context_untangle_-_still_broken), for the failing t/dsl/pass.t the issue is in the Dispatcher.

  1. if pass is used, we look for the next matching route; in this case its not required to do the $app->cleanup in Line 79.
  2. That leaves the possibility of a route passing, but there is no further matching routes. We'd need an $app->cleanup after iterating through all the routes after here. Though you then can't pass between routes defined in different apps and have parts of the response (like headers) propagate.

@mickeyn
Copy link
Contributor

mickeyn commented Jul 12, 2014

@veryrusty - spot on! fixed.
thanks ;)

@xsawyerx
Copy link
Member Author

Last fail is simply the Mutable Serializer trying to resolve the content type using the request information from the context. Because it has no context, it can't do that.

It makes sense for a serializer to have access to the content type (or resolved content type, which is derived from multiple headers), maybe even the request. I'm still not sure how to do this, since the serialization and deserialization methods are called from the response, which doesn't have the request either.

@xsawyerx
Copy link
Member Author

Merged. Releasing now as development version. We need to get working on cleaning up the plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants