<div dir="ltr">Well, I agreed with the fact I switched some way the use of this feature to match my needs, but then let me ask you a quick question : how can handle WSME variable request body ?<div><br></div><div>The first glance I have is that WSME is requiring a static API in terms of inputs, could you then confirm ?</div>
<div>Do you have any idea on how I could get my goal, ie. having a static input plus some extra variable inputs ? I was also thinking about playing with __getattr__ and __setattr__ but I'm not sure the Registry could handle that.</div>
<div><br></div><div>One last important point, this API endpoint (Host) is admin-only in case of you mention the potential security issues it could lead.</div><div><br></div><div>Thanks for your help,</div><div>-Sylvain</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-25 18:55 GMT+01:00 Doug Hellmann <span dir="ltr"><<a href="mailto:doug.hellmann@dreamhost.com" target="_blank">doug.hellmann@dreamhost.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-size:small">OK, that's not how that feature is meant to be used.</div>
<div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">
The idea is that on application startup plugins or extensions will be loaded that configure the extra attributes for the class. That happens one time, and the configuration does not depend on data that appears in the request itself.</div>
<span class="HOEnZb"><font color="#888888">
<div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Doug</div></font></span><div><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 25, 2014 at 9:07 AM, Sylvain Bauza <span dir="ltr"><<a href="mailto:sylvain.bauza@gmail.com" target="_blank">sylvain.bauza@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Let me give you a bit of code then, that's currently WIP with heavy rewrites planned on the Controller side thanks to Pecan hooks [1] <div>

<br></div><div>So, L102 (GET request) the convert() method is passing the result dict as kwargs, where the Host.__init__() method is adding dynamic attributes.</div>
<div>That does work :-)</div><div><br></div><div>L108, I'm specifying that my body string is basically an Host object. Unfortunately, I can provide extra keys to that where I expect to be extra attributes. WSME will then convert the body into an Host [2], but as the Host class doesn't yet know which extra attributes are allowed, none of my extra keys are taken.</div>


<div>As a result, the 'host' (instance of Host) argument of the post() method is not containing the extra attributes and thus, not passed for creation to my Manager.</div><div><br></div><div>As said, I can still get the request body using Pecan directly within the post() method, but I then would have to manage the mimetype, and do the adding of the extra attributes there. That's pretty ugly IMHO.</div>


<div><br></div><div>Thanks,</div><div>-Sylvain </div><div><br></div><div>[1] <a href="http://paste.openstack.org/show/69418/" target="_blank">http://paste.openstack.org/show/69418/</a></div><div><br><div>[2] <a href="https://github.com/stackforge/wsme/blob/master/wsmeext/pecan.py#L71" target="_blank">https://github.com/stackforge/wsme/blob/master/wsmeext/pecan.py#L71</a></div>


</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-25 14:39 GMT+01:00 Doug Hellmann <span dir="ltr"><<a href="mailto:doug.hellmann@dreamhost.com" target="_blank">doug.hellmann@dreamhost.com</a>></span>:<div>

<div><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:small"><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">
<div><div>On Tue, Feb 25, 2014 at 6:55 AM, Sylvain Bauza <span dir="ltr"><<a href="mailto:sylvain.bauza@gmail.com" target="_blank">sylvain.bauza@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>Thanks to WSME 0.6, there is now possibility to add extra attributes to a Dynamic basetype.</div>



<div>I successfully ended up showing my extra attributes from a dict to a DynamicType using add_attributes() but I'm now stuck with POST requests having dynamic body data.</div>
<div><br></div><div>Although I'm declaring in wsexpose() my DynamicType, I can't say to WSME to map the pecan.request.body dict with my wsattrs and create new attributes if none matched.</div><div><br></div><div>



Any idea on how to do this ? I looked at WSME and the type is registered at API startup, not when being called, so the get_arg() method fails to fill in the gaps.</div>
<div><br></div><div>I can possibly do a workaround within my post function, where I could introspect pecan.request.body and add extra attributes, so it sounds a bit crappy as I have to handle the mimetype already managed by WSME.</div>



</div></blockquote><div><br></div></div></div><div><div style="font-size:small">I'm not sure I understand the question. Are you saying that the dynamic type feature works for GET arguments but not POST body content?</div>



<div style="font-size:small"><br></div><div style="font-size:small">Doug</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr">
<div><br></div><div><br></div><div>Thanks,</div><div>-Sylvain</div></div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div></div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div></div></div><br></div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org" target="_blank">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div></div></div></div>
<br>_______________________________________________<br>
OpenStack-dev mailing list<br>
<a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a><br>
<a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a><br>
<br></blockquote></div><br></div>