Re: [Zope3-Users] Re: ZopeX3 Component Architecture in comparision to MVC - general question/example

2006-03-01 Thread Darryl Cousins
Hi Reinhold,

Here's another go at answering your case, this came about when last
night I added a source view to a RESTDocument content, it might come
closer to what you are looking at because it doesn't use tal templates
at all and secondly the request is available - so you can pass in
arguments to your calculator. My starting point for the code is from
zope.app.file.browser.file. 

Best regards,
Darryl

  
  

class PortalRestDocumentSourceView(BrowserView):
"""A RestDocument source view."""

def show(self):
"""Call the source view of restdocument"""
request = self.request
if request is not None:
request.response.setHeader('Content-Type',
   'text/plain')

return self.context.body

On Tue, 2006-02-28 at 17:52 +0100, Lennart Regebro wrote:
> On 2/28/06, Reinhold Strobl <[EMAIL PROTECTED]> wrote:
> > Thanks for the reply. But how would you implement previously described task 
> > with
> > the calculator?
> 
> I would implement it as a view on whatever object I want to view it
> on. Which may even be "*", that is any object.
> 
> --
> Lennart Regebro, Nuxeo http://www.nuxeo.com/
> CPS Content Management http://www.cps-project.org/
> ___
> Zope3-users mailing list
> Zope3-users@zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
-- 
Darryl Cousins
Tree Fern Web Services (NZ) Ltd
106 Sandes St
Thames 2801
New Zealand
+64 7 868 3139
[EMAIL PROTECTED]
http://www.treefernwebservices.co.nz/

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: ZopeX3 Component Architecture in comparision to MVC - general question/example

2006-02-28 Thread Darryl Cousins
On Tue, 2006-02-28 at 17:52 +0100, Lennart Regebro wrote:
> On 2/28/06, Reinhold Strobl <[EMAIL PROTECTED]> wrote:
> > Thanks for the reply. But how would you implement previously described task 
> > with
> > the calculator?
> 
> I would implement it as a view on whatever object I want to view it
> on. Which may even be "*", that is any object.

Hi Reinhold,

Here's a go at answering your problem. I gather you don't even need a
component as such - just a piece of code to perform a calculation. I
borrowed a technique from SchoolBell which may help. I think it may help
because it provides a way of performing any variety of python code
within a tal template without using python in the template. Any method
added to TFWSAPI can be accessed in tal with 'tfws:mymethod'. I've not
used XMLRPC calls with Zope so I'm not sure how it will translate. Good
luck.

Best regards,
Darryl

  
  

class TFWSAPI(object):
"""TALES function namespace for TFWS specific actions.

Borrowed from SchoolBell.

"""
implements(IPathAdapter, ITALESFunctionNamespace)

def __init__(self, context):
self.context = context

# as example
def authenticated(self):
"""Check whether context is an authenticated principal.

Sample usage in a page template:



  User title


  Anonymous


"""
if not IPrincipal.providedBy(self.context):
raise TypeError("tfws:authenticated can only be applied"
" to a principal")
return not IUnauthenticatedPrincipal.providedBy(self.context)
authenticated = property(authenticated)

> 
> --
> Lennart Regebro, Nuxeo http://www.nuxeo.com/
> CPS Content Management http://www.cps-project.org/
> ___
> Zope3-users mailing list
> Zope3-users@zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
-- 
Darryl Cousins
Tree Fern Web Services (NZ) Ltd
http://www.treefernwebservices.co.nz/

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: ZopeX3 Component Architecture in comparision to MVC - general question/example

2006-02-28 Thread Lennart Regebro
On 2/28/06, Reinhold Strobl <[EMAIL PROTECTED]> wrote:
> Thanks for the reply. But how would you implement previously described task 
> with
> the calculator?

I would implement it as a view on whatever object I want to view it
on. Which may even be "*", that is any object.

--
Lennart Regebro, Nuxeo http://www.nuxeo.com/
CPS Content Management http://www.cps-project.org/
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users