Re: [Zope3-Users] Where to start?
On Jan 1, 2006, at 4:30 PM, Maciej Zięba wrote: Is there a ZopeBook or something similiar for Zope 3? Zope3Book is about development of the framework. Could you please recommend some place I could start learning it (articles, tutorials, etc.)? Here is the zope 3 book at zope.org: http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/ FrontPage/Zope3Book It is also available in book-form: http://www.amazon.com/exec/obidos/ASIN/0672326175/ref=rm_item This is another very excellent zope book: http://worldcookery.com/WhereToBuy Here is a nice quick-start guide: http://www.benjiyork.com/quick_start/ Good luck! Happy New Year! Duncan ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] list archives for zope3-users
On Nov 30, 2005, at 11:41 AM, Brad Allen wrote: If anyone else has thoughts on the best way to search the mailing list archives, I'd appreciate hearing about it. I'd prefer to avoid asking questions that others have already asked. Hey Brad, I feel like we're becoming best friends ;-) I use google. Here's a google search string example for searching the zope3-users maillist for ZODB: site:http://mail.zope.org location:pipermail/zope3-users ZODB d ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] list archives for zope3-users
On Nov 30, 2005, at 11:49 AM, Duncan McGreggor wrote: If anyone else has thoughts on the best way to search the mailing list archives, I'd appreciate hearing about it. I'd prefer to avoid asking questions that others have already asked. Hey Brad, I feel like we're becoming best friends ;-) I use google. Here's a google search string example for searching the zope3-users maillist for ZODB: site:http://mail.zope.org location:pipermail/zope3-users ZODB Doh. My bad, that should have been: site:http://mail.zope.org inurl:pipermail/zope3-users ZODB ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] need guidance
On Nov 30, 2005, at 12:13 PM, Brad Allen wrote: Hmm, again, I think you *might* want to stay away from an approach that interacts directly with the ZODB. Unless you're not using z3/Zope 2... I didn't see this posting until after I started a new thread called Direct ZODB access in a Zope3 instance. So, why is it a bad idea? Well, it's a great idea if your application is non-zope python with a need for versioned storage. It's not such a good idea if your application is a zope app because those app servers do so much of the work for you, with many years of honing put into them. The best thing to do is learn how to use the app server/framework such that your work is minimized (both short- and long-term) and such that the final product is a stable as possible (building on prior, tested, and proven work). Direct access in a z3 app is usually made for debugging purposes, and used with the pdb, can be very effective for hunting down and solving issues. As per your other email, the reason you had problems was because your z3 instance was already running. If you are not using ZEO, you need to stop z3 in order to gain access to the ZODB. Have you seen Benji's quick start guide? In addition to Stephan Richter's book, you ought to read Philipp von Weitershausen's book too. As of zope3.1, it's a little out of date, but only in a few areas. The conceptual explanations and careful, hands-on, examples-based approach is pure gold. His and Stephan's book are the perfect couple ;-) Links: http://worldcookery.com/ (Philipp's book is here) http://www.benjiyork.com/quick_start/ In addition, I've written a python script that auto-generates a starter z3 project for you, after asking a couple questions. If you want to use it, I'd be more than willing to answer any questions about it (an thus improve it) off-list. You can download it here: http://www.zope.org/Members/adytumsolutions/z3project_starter I'll got back to your original post and try to do a better job of answering your questions. d ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] need guidance
On Nov 29, 2005, at 3:45 PM, Brad Allen wrote: I'm still in the midst of an effort at learning Zope 3, while try to build a real website for it. I have ambitions for using Zope 3 in several different projects, and am actively working on a Zope 3 website that I hope to have looking presentable if not fully functional by mid-December. Do you have a zope2 background? With a background in zope2 and twisted, I found z3 very easy (delightful) to learn. My first z3 site was done from scratch, with graphic design, custom user-editable content in under 3 weeks. I was an instant z3 fan. Another Zope 3 project for the future is to convert an ecommerce site I had previously built in PHP. I've been using Python at my day job now for a couple of years, and have decided I no longer have time for PHP--I want to switch the site to Python, probably using Zope 3. This site's main purpose is to allow customers to search, view, and purchase from a catalog of auto parts. You will definitely want to start getting familiar with pythonic site creation in z3, particularly, setting up a catalog (IntId, Catalog, Index-creation, etc.). All of my query needs are met (so far) by simple python calls to catalog.SearchResults and then a lambda for sorting. Martijn Faassen wrote a great query wrapper called hurry that you will almost certainly want to investigate/use: http://faassen.n--tree.net/blog/view/weblog/2005/09/09/0 For the auto parts site, I am thinking about designing an AutoPart content component. This will allow the business owner to edit his catalog of auto parts via the web. Suppose he starts instantiating a lot of auto parts, and editing them. Later, we decide we need to refactor the base class, and maybe create a few child classes. That leaves me with a big cleanup chore, because a lot of old AutoPart instances are sitting around in the database. As Chris mentioned before, to my understanding, this is a perfect use-case for generations, so you should be covered (if it's up to date...). I'm trying to come to an understanding of when it's best to keep data in the ZODB, and when it's best to use SQL instead. Maybe there are tools for handling ZODB data that I don't know about. As a general trend, people that have highly-relational data tend to prefer using RDBMSs. I have no current projects for which I use an RDBMS, but I have in the past. I also have a very strong preference for object databases ;-) Another question about ZODB is whether to use it to store page templates. If I build a lot of ZPT pages and macros and store them through the ZMI, and then later want to rearrange the folder structure, I'm guessing it will be a pain to change a lot of hard-coded path references. If I use text files outside the ZODB, then I can use a host of text editor tools for searching across multiple files. I think this has been answered. There's no current TTW dev. But you will come to dearly love filesystem dev, especially with multiple developers working on the same code ;-) I like the idea of letting end users have something like the ZMI for editing content, and am hoping it will be possible avoid putting much TAL and METAL markup in documents in the ZMI, but rather have the .pt files pull content from the ZODB. However, it's not clear to me how to make that work. The examples in the books have the .pt files in the filesystem; I don't recall seeing any the ZMI/ZODB. Perhaps I can clarify with a typical example: * you have a z3 project, all the code is on the file system * you will create custom content objects * you will create a skin for the project -- this is how it will look to end users * you can use the ZMI for administration tasks (such as creating/editing content) -- you can customize the ZMI to look like anything you want * you can modify your custom skin to present various editing/management options to the end users Perhaps this makes thins more clear? Here is another question. Suppose I'm working with a team of developers. Should we each set up our own separate Zope3 instance, and do SVN checkouts into our own separate, local /lib/python directories inside the instance? IMO, definitely ;-) HTH, d ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Windows binary psycopgda-1.0.0.tgz
On Oct 27, 2005, at 9:45 PM, Bobby Brewster wrote: Thanks for your help. However I am still not able to install the database adapter. I copied the file psycopg-configure.zcml into package-includes and folder psycopgda into .\lib\python C:\PyZope\ZopeHome ├───bin ├───etc │ └───package-includes ├───lib │ └───python │ └───psycopgda ├───log └───var I get the following errors. ==ConfigurationError: ('Invalid value for', 'class', Couldn't import psycopgd a.adapter, No module named psycopg) == LAST FEW LINES= File C:\PyZope\Python24\Lib\site-packages\zope\configuration\config.py, line 1393, in toargs args[str(name)] = field.fromUnicode(s) File C:\PyZope\Python24\Lib\site-packages\zope\configuration\fields.py, line 141, in fromUnicode raise schema.ValidationError(v) zope.configuration.xmlconfig.ZopeXMLConfigurationError: File C:\PyZope\ZopeHome \etc\site.zcml, line 7.2-7.55 ZopeXMLConfigurationError: File C:\PyZope\ZopeHome\etc\package-includes\psy copgda-configure.zcml, line 1.0-1.31 ZopeXMLConfigurationError: File C:\PyZope\ZopeHome\lib\python\psycopgda\con figure.zcml, line 6.2 ConfigurationError: ('Invalid value for', 'class', Couldn't import psycopgd a.adapter, No module named psycopg) == LAST FEW LINES= So do I have to install psycopg as well? PHP+Postgres+Apache was a piece of cake. Why am I having so much trouble with this. I guess I need to spend more time on this. First question: did you install psycopg? Second question: which python did you install it for? Because it doesn't look like it's been installed for the python that is running your z3 instance. My bet is that you have more than one python binary (and thus different python site-packages directories), and the one that you used to install psycopg is not the one that runs z3. d ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Compound Form Elements
On Oct 21, 2005, at 12:16 PM, James Allwyn wrote: Following Christian's tweaks to the browser.py file (creating a CustomSequenceWidget), I've got this working well in isolation - I can add a ContactData object on its own no problem. However, I've hit a brick wall about how to use the ContactData item as a form element within another schema (say, IPerson). I've tried to access it with variations upon: [...] contact_data = Tuple( title = u'Contact Details', value_type = Object( schema=IContactDatum, title=u'Contact Datum')) To me, this or List() are the only ones that make any sense... Here's why: One of the things you're doing with this interface is implicitly telling z3 how you want this field to be displayed (because, by default, it makes that decision based on the field type. With a List(), etc., you get the sub-schema displayed and then the option to add * or removed checked -- an auto-generated multi-widget. It it's not a standard field type, z3's not going to know what do do with it, and I think you'd have to use the widget sub-config in your zcml to tell it explicitly what widget to use when building add/edit forms. and invoking the browser class for the add view in the configure.zcml for the User: class=.contactdata.browser.ContactDataAddView In effect, this method doesn't use ContactData at all, it replicates its functionality out of a Tuple of ContactDatum objects in the IPerson itself. But what I want to do is be able to put a ContactData element into IPerson and have it 'just work', in the same way I can for, say, TextLine, or Bool. Hmm, we'll need some more details here... what do you mean by just work? In what context? Add/edit? Final rendering? If the later, I believe you will need to add your view class that processes the list so that ZPT can handle it with repeat (at least, that's what I would do...). d ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Compound Form Elements
On Oct 6, 2005, at 2:29 AM, James Allwyn wrote: On 04/10/05, James Allwyn [EMAIL PROTECTED] wrote: Hello, I wish my users to be able to register various contact details. For each, I would record the type (e.g. email, landline tel, mobile tel, fax...), the value (e.g. [EMAIL PROTECTED]) and a True/False value on whether it is to be visible on the site. I've tried to implement this zopeishly, and the stumbling block I've hit seems to be specifying the key and value_type pairs in the dict. So, for example: [snip] This barfs when it hits the second value_type in the dict. Look at the zope.schema sources it seems I can only specify one value_type and one key_type. What I want to do is specify three pairs of keys and value_types - note, specifying the actual keys, not just their types. Is this possible? Or am I barking up the wrong tree!? Any hints gratefully received. Hey James, What you probably want to explore is the Object field. This lets you define a sub-schema, as it were, and use that in your main schema. An example (untested)... maybe in yourproject/types/interfaces.py: from zope.interface import Interface from zope.schema import List, Text, TextLine, Int, Choice from zope.schema import Object from zope.i18nmessageid import MessageIDFactory _ = MessageIDFactory('yourproj') # sub-schema class IContactData(Interface): show = Bool(title = _(uShow Data?)) type = TextLine(title = _(uData Type)) value = TextLine(title = _(uData Value)) # main schema class IUser(Interface) name_first = TextLine( title = _(uFirst Name) ) name_last = TextLine( title = _(uLast Name) ) contact_info = List( title = _(uContact Info), value_type = Object( schema=IContactData, ), ) Then (maybe in user.py, ): ... class ContactData(object): implements(IPageSection) # and whatever else you might want to # put in here class User(PortalContent): implements(IUser) # and whatever else you might want to # put in here ... Then you're going to have to do some extra work with a custom widget (a good place would be ./browser/userview.py): from zope.app.form.browser import ObjectWidget from zope.app.form.browser.editview import EditView from zope.app.form import CustomWidgetFactory from yourproject.types import ContactData from yourproject.types.interfaces import IUser parts_w = CustomWidgetFactory(ObjectWidget, ContactData) class ContactDataEditView(EditView): View for editing a page section. __used_for__ = IUser parts_widget = parts_w In your browser/configure.zcml, your going to need something like this: browser:editform schema=yourproject.types.interfaces.IUser class=.userview.ContactDataEditView label=Edit User name=edit.html menu=zmi_views title=Edit permission=zope.ManageContent / I may be forgetting something here... but this should certainly give you a head start. There's a bunch of very good information on this in these files: zope/app/form/browser/widgets.txt zope/app/form/browser/objectwidget.txt Hmmm, looking through these again, these are really good examples. Pay more attention to them than to what I wrote above ;-) By the way, (and irrespective of the structure of the data) this data you are adding seems to me a good candidate for annotations. You might want to explore that... Happy trails! d ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: worldcookery Christmas Dinner
On Oct 3, 2005, at 12:32 AM, Joel Moxley wrote: * RecipeFolder Views. In a RecipeFolder page template file, how would you view both parameters on the parent RecipeFolder as well as specific child Recipes within the container? * RecipeFolder Controllers. How would you access an external python method for compiling statistics on this container and then update the view? I think for both of these, what you're looking for is the catalog. It might mean writing your own custom index, based on your needs... (but you should be able to at least prototype it with just the field and text indices that are a part of the catalog by default). If, with your content objects, you are storing or annotating the data you want to analyze, you'll just need to add indices in your site catalog for those schema fields/attributes. For your first bullet item above... hmm, maybe catalog + checking for children? Never done anything directly with the children of a particular container before. For the second one, I think just catalog should do the trick. What I'd do is 1) create a class in browser (e.g., myproject.browser.stats.Stats) where in I write the catalog queries. I put mine in browser because I mentally associate my queries with displaying data with page templates. Arguably, they might be better the next level up, since data queries really should be agnostic as to the final medium (http, webdav, ftp, etc.). For every type of processed stats I would want, I'd write a method in the Stats class. As Alen and I discussed in a recent thread, perhaps something like from zope.app.publisher.browser import BrowserView from zope.app.catalog.interfaces import ICatalog from zope.app import zapi class Stats(BrowserView): def getParentAndChildStats(self): catalog = zapi.getUtility(ICatalog) results = catalog.searchResults(index_name_for_field=[some, list, of, criteria]) # process your results # do child checks? efficiency issues? I'm sure there's a better way... My queries are typically associated with a particular content type (as it sounds like yours will be... particularly RecipeFolder). So then I'd 2) add something like this to the browser/configure.zcml file: browser:page for=myproject.containers.IRecipeFolder name=index.html template=recipefolderview.pt class=.stats.Stats permission=zope.Public / Then, 3) use view/method_name in your page templates to access the the Stats methods you wrote. Data presentation gets messy in HTML/ZPT, so I typically separate that out into a macro so I can keep my *view.pt files clean. You'd have something like this in your recipefolderview.pt (or macro that recipefolderview.pt calls): ul tal:stats repeat=stat view/getParentAndChildStats !-- display stat and/or its attributes /-- /tal:stats Hope that helps... d ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] zope.app.catalog doc question
I am curious about the documented catalog method searchResults(). Starting at line 223 of zope/app/catalog/README.txt (3.1 rc3 download, not svn co), there is the following usage of the method: result = cat.searchResults(size=5) len(result) 2 list(result) == [o4, o5] True When trying to implement this with my own catalog, I got the following (partial) traceback: File /Users/oubiwann/Desktop/2CD/AdytumSolutions/Projects/Zope3Work/ zope310_r3/lib/python/accumacsite/browser/homepageview.py, line 18, in inventoryInStock return catalog.searchResults(equipment_in_stock=True) File /usr/local/zope310/lib/python/zope/app/catalog/catalog.py, line 105, in searchResults results = self.apply(searchterms) File /usr/local/zope310/lib/python/zope/app/catalog/catalog.py, line 84, in apply r = index.apply(index_query) File /usr/local/zope310/lib/python/zope/index/field/index.py, line 99, in apply return multiunion(self._fwd_index.values(*query)) TypeError: values() argument after * must be a sequence Indeed, after looking at the code, it seems that instead of writing this: return catalog.searchResults(equipment_in_stock=True) I should be writing this: return catalog.searchResults(equipment_in_stock=[True]) since apply() does expect the rhs of the parameter to be a sequence. With this change, my code now works (no errors, anyway), but I wanted to see if this was a misunderstanding on my part or a documentation typo... Thanks, Duncan ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] images in a content object
On Sep 27, 2005, at 12:21 PM, Duncan McGreggor wrote: On Sep 27, 2005, at 12:09 PM, Jean-Marc Orliaguet wrote: http://svn.nuxeo.org/trac/pub/file/z3lab/cpsskins/branches/jmo- perspectives/browser/caching.py On Sep 27, 2005, at 12:13 PM, Benji York wrote: Chapter 35 of Stephan's book. I couldn't find traverse in the index of Philipp's book, but I'm sure he covers it somewhere. Also note that it might be better to create a content space image object instead and just keep a reference to it in your other content object, then you *could* use absolute URL. You guys are awesome -- these were just the tips I needed to get past this block -- thanks for your help! In addition to these fine suggestions, I'll add another. From Stephan Richter's code in the schoolbell repository: http://tinyurl.com/83bg8 There is a person content object that has a photo attached. To use it, I only needed to: 1) add some browser view code, and 2) add the zcml configuration for it. The original part of my schema that I had posted was this: class IPage(Interface): ... ... image_file = Bytes( title=uImage, description=uUpload an associated image here, required=False) Then I added this browser view code: from zope.app.file.image import Image class ImageView(BrowserView): View that returns a page image. __used_for__ = IPage def __call__(self): data = self.context.image_file image = Image(data) if not image: raise NotFound(self.context, u'image_file', self.request) self.request.response.setHeader('Content-Type', image.contentType) return data The final step was the zcml: browser:page name=image_file for=.interfaces.IPage class=.browser.ImageView permission=zope.View / I was then able to create an instance of my content object (a Page, implementing IPage), and access the attached image via the url http://localhost/mypage.html/image_file Thanks again for all the help, and I hope this is useful for others :-) d ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] images in a content object
On Jun 3, 2005, at 3:28 PM, Stephan Richter wrote: On Saturday 14 May 2005 14:21, [EMAIL PROTECTED] wrote: A direction to a working example would be very much appreciated. Playing with Z3 is nice, but it is much harder than Z2 when it comes to getting where I want. But, I'm not giving up! I think the books are as much direction as we can give you without having a traceback of what's going wrong. I would also like to see the interfaces. Hey everyone, I'm having similar trouble with a content object that contains an image. Thee pertinent part of my schema is this: image_file = Bytes( title=uImage, description=uUpload an associated image here, required=False) My problem is that I haven't figured out how to point to this image, as it is part of the content object itself. Ideally, I would like to be able to refer to it in a ZPT via a URL. Something on the order of img tal:attributes=src string:${context/@@absolute_url}/image_file / Any ideas or code to which I could be pointed? Thanks! Duncan ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] images in a content object
On Sep 27, 2005, at 11:54 AM, Benji York wrote: Duncan McGreggor wrote: My problem is that I haven't figured out how to point to this image, as it is part of the content object itself. Ideally, I would like to be able to refer to it in a ZPT via a URL. Something on the order of img tal:attributes=src string:${context/@@absolute_url}/image_file / Any ideas or code to which I could be pointed? You could make the content object traversable, so you could do http://path_to_object/image_file. Man, that sounds perfect... But! *sheepish grin* I've never done that before... is there someplace you could point me (and future readers of the list archives) where I could read about doing that (chapter of a book?) or some code in svn that shoes an example in a zcml file (I'm assuming this would be done in zcml?). Thanks, man! d ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] practical example of migrating from services to utilities
Hey all, I just wanted to check to make sure I was doing this right, and if so, provide a resource that would turn up on subsequent googling. This example involves the getting menus items with the getService/getUtility functions and is taken from Philip's worldcookery example code. Here's the pertinent zcml (worldcookery/browser/configure.zcml): browser:menu id=alternate_views title=Menu containing a list of alternative views for an object / browser:addMenuItem title=[label-recipe] Recipe class=worldcookery.recipe.Recipe permission=worldcookery.EditRecipes view=AddRecipe.html / Here's the original code (worldcookery/browser/recipe.py): def alternateViews(self): menu_service = zapi.getService(servicenames.BrowserMenu) menu_id = 'alternate_views' return menu_service.getMenu(menu_id, self.context, self.request) Here's the modified example that I'd want to check if I am doing correctly: def alternateViews(self): browser_menu = zapi.getUtility(IBrowserMenu, 'alternate_views') return browser_menu.getMenuItems(self.context, self.request) Am I doing this properly? Thanks! d ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users