Code Monkey home page Code Monkey logo

Comments (8)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
are thinking of just a "read-only" flag per model, or something more 
fine-grained?

Original comment by [email protected] on 25 Aug 2009 at 12:26

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

from appengine-rest-server.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
good question, personally I only have value in read only.  I don't know if 
denying
updates or deletes is valuable too.  It probably would run the same codepath 
though,
so maybe it'd be worthwhile just to add in the generic support

rest.Dispatcher.add_models({"things": (models.Thing,["GET","DELETE])})

Original comment by [email protected] on 25 Aug 2009 at 2:13

from appengine-rest-server.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
I'd love to have something like that: a list of supported operations.

Along the lines of Richard's suggestion:

* defining method types (rest.GET, rest.DELETE, rest.POST, rest.PUT)
* support for an optional 'supported methods' list, eg:
  * rest.Dispatcher.add_models({"things": (models.Thing,[rest.GET, rest.DELETE])})
  * rest.Dispatcher.add_models({"widgets": (models.Widget,[rest.GET])})
  * rest.Dispatcher.add_models({"thingamies": models.Thingamie})

I'm happy to give it a shot myself and submit it as a patch.

Just let me know where to start (I already have a copy of the latest 1.0.2 zip 
file).

Original comment by [email protected] on 9 Jul 2010 at 7:30

from appengine-rest-server.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
This should be pretty straightforward.  every type gets associated with a 
ModelHandler.  you basically just need to store the "allowed" operations in the 
ModelHandler and check that collection in the Dispatcher.get_model_handler 
method (where that method would have an extra param indicating the intended 
operation).

Original comment by [email protected] on 9 Jul 2010 at 12:32

from appengine-rest-server.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
Done.  I made the changes so that they were optional and will have no impact on 
existing users.

The following is now possible:

    # add specific models (with given names) and restrict the supported methods
    rest.Dispatcher.add_models({
      'foo' : (FooModel, ["GET"]),
      'bar' : (BarModel, ["GET", "POST", "PUT"],
      'cache' : (CacheModel, ["GET", "DELETE"] })

(that's from the example I added to the doc string of __init__.py)

I didn't do the check in Dispatch.get_model_handler as that would have meant 
adding special-case code for the metadata stuff.  Instead, I simply check the 
desired method is in the list of supported methods after calling 
get_model_handler.  If the method is not supported, I return error 405 Method 
Not Allowed.

I've attached the updated __init__.py.

Original comment by [email protected] on 10 Jul 2010 at 1:23

Attachments:

from appengine-rest-server.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
Before I forget, I also changed some of the logging.info calls.  They weren't 
using % to construct the format strings.

Original comment by [email protected] on 10 Jul 2010 at 1:26

from appengine-rest-server.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
so, i incorporated these changes with some slight mods.  i did put the check in 
the get_model_handler method, and i added support for a synthetic 
"GET_METADATA" method which allows controlling of retrieval of the object 
metadata.  there are also 2 list constants in the package which incorporate 
some common scenarios:

ALL_MODEL_METHODS = ["GET", "POST", "PUT", "DELETE", "GET_METADATA"]
READ_ONLY_MODEL_METHODS = ["GET", "GET_METADATA"]

Original comment by [email protected] on 12 Jul 2010 at 1:36

  • Changed state: Fixed

from appengine-rest-server.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 18, 2024
That's great!  Thanks!

Original comment by [email protected] on 12 Jul 2010 at 12:19

from appengine-rest-server.

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.