[Zope3-Users] Sqlalchemy and Zope3?
Is anybody using Sqlalchemy (http://www.sqlalchemy.org/) with Z3? If so, any tips /examples to share? I'm building a semi-complicated MySQL database using sqlalchemy for a non-web application. Now, halfway through, we're saying You know, a web interface would really be nice here ... surprise! Any advice or useful links on Z3 with sqlalchemy in particular or rdb integration in general will be much appreciated. -- Wade Leftwich Ithaca, NY ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Please Guido, pick me, pick me!
Guido van Rossum is looking for a web app framework. http://blog.delaguardia.com.mx/index.php?op=ViewArticlearticleId=34blogId=1 Zope is conspicuous by its absence from the discussion. Hardly a mention, and no advocacy at all. Is Zope just too heavyweight for the project he has in mind? Or what? -- Wade Leftwich Ithaca, NY ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] macros from ZPT
John Smith wrote: Dear All, Does anyone know if it is possible to access macros defined in a TTW ZPT from a file-system based view class? I don't know about macros, but a few months ago I did work out a basic way to use a TTW ZPT with a view class. Just in case it can help you out: http://mail.zope.org/pipermail/zope3-users/2005-October/001199.html -- Wade Leftwich Ithaca, NY ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] MySQL
David Johnson wrote: I recently tried to add the MySQL Package. I’m not sure if this is the proper list for this question. I added the package according to: http://www.zope.org/DevHome/Wikis/DevSite/Projects/ComponentArchitecture/AddonPackageInstall When I go into my zope instance (/home/djohnson/zope3-instance): ImportError: No module named MySQLdb What am I missing? Sounds like you're missing the MySQLdb module. The Zope MySQL package relies on this module already being present. You can get it at http://sourceforge.net/projects/mysql-python -- Wade ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] More MySQL
David Johnson wrote: Thanks to everyone for the MySQL assistance. We use Debian and I just installed the python-mysqlda (seems obvious in retrospect). In any case, after I install the python adapater, I get the following when starting zope: ConfigurationError: ('Invalid value for', 'menu', ImportError: Couldn't import add_connection, No module named add_connection) David, I'm pretty sure the Debian python-mysqlda package is specific to Zope 2. I use Ubuntu (derived from Debian), and while I appreciate Brian Sutherland's fine work to provide a Debian package for Zope 3, I have found it quite easy to download the Zope 3 source from zope.org, build it and install it in its own directory. If you do that, you will have an installation like that of most everybody on this list, so good advice will be easier to come by. It's been a few months since I played with MySQL in Zope 3, but it did work. -- Wade Leftwich ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] How come no IView?
Since Zope 3 is all about being self-documenting and discoverable, it seems odd that something as central as a View has the implicit attributes 'context' and 'request'. Is there an architectural reason that we don't say that a View class implements an IView interface that gives the names of the expected attributes? If this question is hopelessly naive, please be gentle. -- Wade Leftwich Ithaca, NY ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] How come no IView?
Chris McDonough wrote: It will probably not comfort you that the concept of a view (at least by that name) is going to disappear sometime post-3.2. I hope I explain this properly; here goes. A view is a registration for a named multiadapter. The thing that is registered (the view) adapts two objects that implement interfaces to a different interface. Part of what makes a view a view is that it's registered to accept two objects in its factory: a content object and a request object. Another kind of named multiadapter might accept three, four, or five objects in its factory. A view happens to accept two, and only by convention are these two objects that are context and request objects. When you look up a view, the two objects you pass to getView (context and request) conventionally implement, respectively, IBrowserRequest and a content class interface. There is a class registered to adapt them to a marker interface (zope.Interface). So when a view is looked up like this: from zapi import getView from zope.interface import Interface from zope.interface import implements from zope.publisher.interfaces.browser import IBrowserRequest class IContent(Interface): pass class Content(object): implements(IContent) content = Content() class Request(object): implements(IBrowserRequest) request = Request() getView(content, u'index.html', request) ... under the hood the lookup is translated to: getMultiAdapter((content, request), Interface, name=u'index.html') ... and you get back a view class instance. The view class constructor is passed content and request in its constructor because that's what getMultiAdapter is wired to do. If you were adapting more than two, the class constructor would be passed three, or four, etc. This is because the registration of a view class (when it happens via ZCML) is essentially: from zope.component import registerAdapter class SomeView(object): def __init__(self, context, request): self.context = context self.request = requests registerAdapter(SomeView, (IContent, IBrowserRequest), Interface, name=u'index.html') The concept of a view is purely convention. getView is actually deprecated in the trunk at least, as a result. I don't know if that makes anything clearer but I for one welcome our new simplification overlords. Thanks Chris, that actually does make things clearer. As a Z3 beginner, longtime Z2 user (ZPTs, scripts, ZSQL), and corporate developer who is trying to promote Z3 in-house, I am all for the current trend toward simplification, especially of ZCML (http://www.z3lab.org/sections/blogs/philipp-weitershausen/2005_12_14_zcml-needs-to-do-less). It seems like view class is a useful concept that gets talked about a lot. We're not going to have to start saying named multiadapter for content and request, are we? -- Wade ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Confused by ITraversable
I guess I don't understand traversal at all. I am trying to come up with the simplest possible class to exercise the ITraversable interface. Here's what I have: ### from zope.interface import implements from zope.app.traversing.interfaces import ITraversable class TravTestFlag(Exception): Raise this flag when traverse() method gets called class TravTest(object): implements(ITraversable) def traverse(self, name, furtherPath): raise TravTestFlag(traverse got called in TravTest with name %s, furtherPath %s % (name, furtherPath)) ### I hook it up to the ZMI with this configure.zcml: configure xmlns=http://namespaces.zope.org/zope; xmlns:browser=http://namespaces.zope.org/browser; i18n_domain=travtest browser:addMenuItem class=.travtest.TravTest title=Traversal Demo permission=zope.ManageContent / /configure I create a TravTest object in my root folder with ID 'tt'. Then I browse http://localhost:8080/tt/1/2/3. I get a stock 404 error, which I guess means that TraversalError is getting raised someplace besides inside my traverse() method. I really expected to see a TravTestFlag. Any hints appreciated. -- Wade Leftwich Ithaca, NY ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Specialized URL traversal.. Best way?
Jeff Shell wrote: [snip] I was wondering - is this the best way to do this? Is there a better recipe floating around out there? I appreciate Zope's direct-to-object URL publishing (been using it since '97!), but custom URL maps past a certain object like a view seem to be quite tricky, whereas Django and generic toolkits like Routes are specializing in ways of managing custom URL maps. I know there are a few places where one can take over this process, but it's not obvious when and how to use them, or which to use. BeforeTraversal event? publishTraverse? ITraversable? ITraversing? Ultimately I'd like to put a couple of views into the root of my app that can do something akin to Django's url_dispatch: http://www.djangoproject.com/documentation/url_dispatch/ where a set of patterns and a name are used to allow for various dynamic queries. The name would be used to look up a component to respond to the matched items in the path. It wouldn't interfere with any other traversal (ie - wouldn't replace the default way of doing it). Doing it from a browser view seems safest, since this is almost exclusively about keeping nice URLs for web browsing. I just want to know the best place to plug in. I don't have an answer, but I am also hoping to get some advice on the best way to get what in a Z2 PythonScript is called 'traverse_subpath'. Chris Withers and I were both asking about this back on Dec 15 in the What's the rationale of @@? thread (http://mail.zope.org/pipermail/zope3-users/2005-December/001684.html), but I didn't see an answer. Still haven't figured it out for myself, still hoping for some help. -- Wade Leftwich Ithaca, NY ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] ZCML, practicality, purity (was Excellent perspective...)
Shane Hathaway wrote: [snip] I have a bunch of coworkers who have coded in Java for a long time and are ready to branch out. They're trying out Python, Ruby, C#, etc. They want to develop web applications quickly while preserving maintainability. I think the best way for them to do that is to use Zope 3. Unfortunately, other frameworks like RoR have a big marketing advantage over Zope 3 in that they don't use XML configuration files. That is the one of the major features that attract developers to the new frameworks. Even if Zope 3 is technically right to use ZCML, I find it hard to convince people to try yet another XML configuration format, especially since I've had a lot of trouble with ZCML myself. So it's very refreshing to see Zope 3 without ZCML. I hope the trend continues. Shane I know that ZCML has been thoroughly debated, and I am a newcomer to Zope 3 (though a longtime user of Zope 2 at the scripting level). But practicality beats purity is a good maxim for business decisions as well as for programming, and marketing requires some business decisions. If ZCML (a/k/a The Right Way) is keeping fairly smart developers from trying Z3, then maybe we need an alternative (a/k/a What People Think They Want). Would it make sense to publish a recommended way to configure Z3 apps completely via Python? Just for people who can't get past ZCML? -- Wade ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Excellent perspectives on Component Architecture by Jeff Shell
Jeff Shell has written a couple of really good essays in his weblog: http://griddlenoise.blogspot.com/2005/12/zope-component-architecture-one-way-to.html http://griddlenoise.blogspot.com/2005/12/zope-component-architecture-interfaces.html I haven't seen these posts mentioned on this mailing list yet, and they have been super helpful to me, so I hope it's ok with Jeff that I draw attention to them. Jeff's essays have really helped me get a handle on how it all fits together (over and above both very good Z3 books). They are also very useful in discussions with my coworkers and a semi-technical manager, who keep asking Why don't we do it in [Django|TurboGears|RoR|PHP]? -- Wade Leftwich Ithaca, NY ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Help us! Calling a Python Script from ZPT
Jean-Marc Orliaguet wrote: Wade Leftwich wrote: Stephan Richter wrote: Why not have those templates on the file system? Is there a need for users to modify those templates? Yes, users with the job description web producers, which is to say people who can do HTML and a bit of scripting, but who do not get access to the file system. Kind of like the Zope 2 model. We even use acquisition. Also, it seemed to me unwieldy to put 50 directories in the filesystem to contain the templates for all the sites. But because of my experience with Zope 2, I assumed TTW was the best way to customize the application for each site, and I guess I should re-examine that assumption. Hi! there is indeed such a category of users, i.e. somewhere between filesystem developers and application users. There will be support for this kind of TTW editing in cpsskins (cf Custom Portlet), but it will be purely limited to simple presentation logic. cf. http://www.z3lab.org/sections/front-page/design-features/custom-portlet the difference with the Zope2 model I think is that web producers are not going to be ZPT programmers, but more like site composers with the ability to do minimal TTW template editing such as shown in the animation. /JM Yes, that's the kind of user I'm talking about, and the Custom Portlet tool looks really good. Cool animation, too. I've been planning to check out the Z3ECM project, but am trying to get a better grasp of Zope 3 itself first. -- Wade Leftwich ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Help us! Calling a Python Script from ZPT
Stephan Richter wrote: On Saturday 29 October 2005 20:50, Wade Leftwich wrote: Stephan Richter wrote: On Saturday 29 October 2005 11:35, Paolo Cilmo wrote: I need to develop a site using ZMI (Zope2 typical using) and especially i want to develop this applications: We do not support TTW development. 1- I've a package with a class and into the class a method 2- with browser:addMenuItem in zcml i can insert a package into zmi from add menu 3- I've a Page Template into ZMI ASK: how i call from the Page Template the script, passig parameters and to have a response from script? Why do you need to have this Page Template in ZMI? Why not on the file system? I'm working on an application where Page Templates belong in the ZMI, at least I think so. The content being displayed is a business directory, with suppliers, products, and categories for those products. We will be implementing 50 different directories, with the same basic content structure but very different designs. Each of those directories will use 5 or 6 page templates, which go in the ZMI. Why not have those templates on the file system? Is there a need for users to modify those templates? Yes, users with the job description web producers, which is to say people who can do HTML and a bit of scripting, but who do not get access to the file system. Kind of like the Zope 2 model. We even use acquisition. Also, it seemed to me unwieldy to put 50 directories in the filesystem to contain the templates for all the sites. But because of my experience with Zope 2, I assumed TTW was the best way to customize the application for each site, and I guess I should re-examine that assumption. It seems like this is a common pattern for content management applications. Maybe, I don't know. Repeating my own posting from 10/9, here's how I made an adapter to use a file system view with a ZMI template: Again, we do not support TTW development. If you do such experiments that's great, but you cannot expect much help. Well, my project is _mostly_ filesystem, and only _partly_ TTW. But OK, I won't expect much help. Regards, Stephan Thanks Wade ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Help us! Calling a Python Script from ZPT
Stephan Richter wrote: On Saturday 29 October 2005 11:35, Paolo Cilmo wrote: I need to develop a site using ZMI (Zope2 typical using) and especially i want to develop this applications: We do not support TTW development. 1- I've a package with a class and into the class a method 2- with browser:addMenuItem in zcml i can insert a package into zmi from add menu 3- I've a Page Template into ZMI ASK: how i call from the Page Template the script, passig parameters and to have a response from script? Why do you need to have this Page Template in ZMI? Why not on the file system? I'm working on an application where Page Templates belong in the ZMI, at least I think so. The content being displayed is a business directory, with suppliers, products, and categories for those products. We will be implementing 50 different directories, with the same basic content structure but very different designs. Each of those directories will use 5 or 6 page templates, which go in the ZMI. It seems like this is a common pattern for content management applications. Repeating my own posting from 10/9, here's how I made an adapter to use a file system view with a ZMI template: class ZPTViewAdapter(ZPTPage): Adapt a ZPTPage instance to set up its namespace like zope.app.pagetemplate.viewpagetemplatefile.ViewPageTemplateFile, so it can be called by a View Class. implements(IPageTemplateSubclassing) adapts(ZPTPage) def __init__(self, ob): self.ob = ob def pt_getContext(self, instance, request, **kw): instance is a View component namespace = super(ZPTViewAdapter, self).pt_getContext(instance, request, **kw) namespace['nothing'] = None namespace['template'] = self.ob namespace['container'] = self.ob.__parent__ namespace['request'] = request namespace['view'] = instance namespace['context'] = context = instance.context namespace['views'] = ViewMapper(context, request) namespace['options'] = kw print 'ZPTPage namespace', namespace.keys() return namespace def __call__(self, instance, *args, **keywords): namespace = self.pt_getContext( request=instance.request, instance=instance, args=args, options=keywords) debug_flags = instance.request.debug s = self.ob.pt_render( namespace, showtal=getattr(debug_flags, 'showTAL', 0), sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0), ) response = instance.request.response if not response.getHeader(Content-Type): response.setHeader(Content-Type, self.ob.content_type) return s # View class that uses the adapter class MessageView(object): A webpage saying hello def message(self): return '%s %s!' % (self.context.greeting, self.context.subject) class KustomView(MessageView): Pick up a template from parent container if available; if not, use the filebased one. def __call__(self): template = self.context.__parent__.get('kustom.pt') if template is not None: template = getAdapter(template, IPageTemplateSubclassing, zptViewAdapter) else: template = ViewPageTemplateFile('stock.pt') return template(self) ### -- Wade Leftwich Ithaca, NY ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Using a ZPTPage with a View Class
Hello, I'm doing a project where different instances of the same content type might need different templates. All the instances in a given folder will share a template. The manager of the site should be able to change the template through the ZMI. I want the TTW templates to have the same namespace keys as a ViewPageTemplateFile, so they can be used interchangeably by a View Class. What I have done for a first cut is make an adapter for ZPTPage = ViewPageTemplateFile. (See below.) The two Template classes actually implement the same interface, but the namespace available to TALES within the template is quite different. My general question is, is this a reasonable way to proceed? It works OK with Benji York's Hello World example; in particular the 'view' and 'context' namespaces seem to be complete. But Hello World doesn't exercise the code much. Is there another pattern I should be using instead? Have I overlooked a perfectly good solution that's already out there? Wade Leftwich Ithaca, NY # View class that uses the adapter class MessageView(object): A webpage saying hello def message(self): return '%s %s!' % (self.context.greeting, self.context.subject) class KustomView(MessageView): Pick up a template from parent container if available; if not, use the filebased one. def __call__(self): template = self.context.__parent__.get('kustom.pt') if template is not None: template = getAdapter(template, IPageTemplateSubclassing, zptViewAdapter) else: template = ViewPageTemplateFile('stock.pt') return template(self) ## # The adapter class ZPTViewAdapter(ZPTPage): Adapt a ZPTPage instance to set up its namespace like zope.app.pagetemplate.viewpagetemplatefile.ViewPageTemplateFile, so it can be called by a View Class. implements(IPageTemplateSubclassing) adapts(ZPTPage) def __init__(self, ob): self.ob = ob def pt_getContext(self, instance, request, **kw): instance is a View component namespace = super(ZPTViewAdapter, self).pt_getContext(instance, request, **kw) namespace['nothing'] = None namespace['template'] = self.ob namespace['container'] = self.ob.__parent__ namespace['request'] = request namespace['view'] = instance namespace['context'] = context = instance.context namespace['views'] = ViewMapper(context, request) namespace['options'] = kw print 'ZPTPage namespace', namespace.keys() return namespace def __call__(self, instance, *args, **keywords): namespace = self.pt_getContext( request=instance.request, instance=instance, args=args, options=keywords) debug_flags = instance.request.debug s = self.ob.pt_render( namespace, showtal=getattr(debug_flags, 'showTAL', 0), sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0), ) response = instance.request.response if not response.getHeader(Content-Type): response.setHeader(Content-Type, self.ob.content_type) return s ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users