[Twisted-web] Freeform/formless doesn't work with deferred properties?

Christopher Armstrong twisted-web@twistedmatrix.com
Wed, 24 Dec 2003 04:31:13 -0500


This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig847E35B05378A0DB689268A2
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Gavrie Philipson wrote:

> The attached patch solves the problem with freeform not dealing with 
> deferreds in attribute value.

...
> +
> +        if isinstance(value, Deferred):
> +            value.addCallback(self._cb_call, context, data)
> +            return value
> +        else:
> +            return self._cb_call(value, context, data)
> +
> +    def _cb_call(self, value, context, data):
> +        request = context.locate(iwoven.IRequest)
>          try:
>              _, fbn = calculateFullBindingName(context, context.locate(formless.IBinding))
>          except KeyError:


To whoever commits this patch (i.e., dp ;), two things: 1) if necessary, 
add an errback (?) 2) there's defer.maybeDeferred for reducing those 5 
lines of code in the "isinstance(value, Deferred)" block to 2 (or 1, if 
you're xtreme)::

d = defer.maybeDeferred(defaults.getDefault, context.key, context)
d.addCallback(self._cb_call, context, data)

-- 
  Twisted | Christopher Armstrong: International Man of Twistery
   Radix  |          Release Manager,  Twisted Project
---------+           http://radix.twistedmatrix.com/

--------------enig847E35B05378A0DB689268A2
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQE/6VzrNp279O1/OG4RAmU/AJ4xHYEmvTcJCaDGjkhA2Jt7BNDpYwCeJ3yE
58N+MEuThwOSi+2xPYgJY4E=
=HW4b
-----END PGP SIGNATURE-----

--------------enig847E35B05378A0DB689268A2--