GithubHelp home page GithubHelp logo

Comments (8)

cdent avatar cdent commented on June 24, 2024

That seems like a reasonable feature. Is it something you could create yourself and provide a pull request? Or at least a starting point from which we can collaborate?

One area where things might get a bit messy is that the fundamental architecture of wsgi-intercept is rather old so we'd need to decide if we just want to hack something into that structure, or tune up things in general (for example there's been discussion of using context managers throughout).

Anyway: Do you want the callbacks to happen directly before and after an intercepted request happens, or before the intercept it established? I assume the former?

from wsgi-intercept.

vmalloc avatar vmalloc commented on June 24, 2024

Assuming you only support 2.6 and above, I think a general overhaul of the code is due, which is good. However, I think a basic callback can be established even with the existing codebase. I will try to hack on it and see what I come up with.

Regarding your question -- what I want is a hook to be called after we've decided a request is to be intercepted, but before calling the actual backing wsgi app to handle the request, and also a hook to call just before returning the data to the mocked interfaces (requests/urllib2/whatever)

from wsgi-intercept.

cdent avatar cdent commented on June 24, 2024

@vmalloc did you ever make any headway on this?

I'm still wanting to do a general overhaul on the code but haven't had the time or head space to do so but maybe able to eek some time now that I've created gabbi and it uses wsgi-intercept and thus both are getting some use within OpenStack.

from wsgi-intercept.

vmalloc avatar vmalloc commented on June 24, 2024

@cdent nope, couldn't find the time to hack on it - it requires a lot of work. I'm using our own Flask-Loopback for now, which is less flexible but gets the job done for our needs...

from wsgi-intercept.

cdent avatar cdent commented on June 24, 2024

It has occured to me while working on 9d73597 that perhaps the easiest way to make this happen is to not use hooks at all. Instead just wrap the wsgi app being tested in another wsgi app callable? That covers the use case doesn't it? The ability to add code before and after the app is run?

If not, could you provide a bit more clarity on what you're trying to do? Thanks.

from wsgi-intercept.

vmalloc avatar vmalloc commented on June 24, 2024

I currently use Flask-Loopback to simulate a 3rd party product, and want to be able to change its state before each request is made to it. All this should be done without changing any client code - so I keep all of my simulation code in the test setup area. I guess we can make it work with a wsgi wrapper, but it would be nice to add a dedicated hook because the library knows when it intercepts a call anyways.

from wsgi-intercept.

cdent avatar cdent commented on June 24, 2024

I'll continue thinking about this but right now I don't have a clear idea on how to best implement it. If you've got some ideas please add them here.

In the meantime I'm releasing a new version today that has the context manager stuff referenced above. I'm hoping that's going to start a process of refactoring that will make things like hooks a bit easier.

from wsgi-intercept.

kataev avatar kataev commented on June 24, 2024

Perhaps for your needs is suitable a special module https://pypi.python.org/pypi/before_after

from wsgi-intercept.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.