Re: [Zope3-Users] IntID utility not found
On 11.06.2006, at 23:39, Florian Lindner wrote: Hello, suddenly I get this error, the code used to work File /home/xgmde/Zope3//lib/python/zope/component/_api.py, line 207, in getUtility raise ComponentLookupError(interface, name) ComponentLookupError: (InterfaceClass zope.app.intid.interfaces.IIntIds, '') The problem is clear but it should not appear. It occurs upon adding my object. This object performs some initializations: def onObjectAdded(event): if IXGM.providedBy(event.object): if not ISite.providedBy(event.object): # Make it a site xgm = event.object site_manager = LocalSiteManager(xgm) xgm.setSiteManager(site_manager) intid = ensureUtility(xgm, IIntIds, '', IntIds , asObject = True) cat = ensureUtility(xgm, ICatalog, '', Catalog, asObject = True) abbr_index = TextIndex(abbreviation, IAbbreviation) cat[AbbreviationIndex] = abbr_index i think you have to set the site after you have made your object a site from zope.app.component import hooks hooks.setSite(xgm) Regards, Bernd When I trace into that I can see that the intid is really created and also at the correct place. When I comment the catalog creation out it works and I can add the catalog with the ZMI without any problems. But why does it not find the IntID utility when created from code? Anyone knows whats wrong? Thanks, Florian ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: I fold. What are ++etc++ and ++resource++ etc?
On Sun, 2006-11-06 at 02:03 +0300, Michael Dexter wrote: 2. Fall out of search engines. 3. Break existing links. 4. Fail the over-the-phone test of URl's... Just a quick note to address these three. In generall, mostly the ++resource++ stuff is used to access gifs, jpgs, css, etc. For real url's you would give to someone (over the phone) you would never need to refer to these types of url's (imho). The only url's that people might actually type into their browser (and google might index) would possibly have @@'s. So you might reference http://myhost.com/@@somepage.html. But, the reality is in most cases you could reference the same page with http://myhost.com/somepage.html. The only reason you might not refer to it without the @@'s is because if the root of your site contains a content object called 'somepage.html' ... without the @@'s it would get looked up first. Hopefully that sheds a *little* light. - Rocky -- Rocky Burt ServerZen Software -- http://www.serverzen.com News About The Server (blog) -- http://www.serverzen.net signature.asc Description: This is a digitally signed message part ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: Generate view for adapted interface
On Mon, 2006-12-06 at 00:19 +0200, Philipp von Weitershausen wrote: zope.formlib will automatically adapt your object to the form interface if it doesn't provide it. So, when you have form for IMyObject that uses form fields from, say, IDublinCore, it will automatically adapt your object to IDublinCore and save the modifications on the adapter. Well, it will *attempt* to adapt it :) Upon learning how this all works the first thing I banged into was when my class didn't implement the interface (nor did I provide an adapter) I was using for my form and I got component errors ;) - Rocky -- Rocky Burt ServerZen Software -- http://www.serverzen.com News About The Server (blog) -- http://www.serverzen.net signature.asc Description: This is a digitally signed message part ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: I fold. What are ++etc++ and ++resource++ etc?
Michael Dexter wrote: My question is thus very naive: what is the ++xyz++ and @@xyz syntax and can it be avoided? yes... The following are normally all equivalent.. http://host/content/++view++edit.html http://host/content/@@edit.html http://host/content/edit.html This presumes that you've configured (normally via zcml) a (Browser)View class named 'edit.html'. If in a particular circumstance, 'content' is a container object which contains an object with the name (id) 'edit.html', then you can explicitly distinguish between this object and the named view 'edit.html' using the 'view' namespace. Look at the inline doc. in zope/traversal/namespace.py for more info about the (very useful) 'namespace' traversal in zope3. Skin variables in URL would be great during development but suggest that the user can make skin selection. I guess the user can make their own skin selection via the url. This presumes the user has permission to access that skin. To disable the url selection of the skin I 'guess' you'd need to override (knock out) the ++skin++ namespace traversal (sorry I can't help you with this one). Keep in mind I have no idea if ++thisskin++ is required as I cannot find the aforementioned explanation of that syntax. If @@ is for inspection, is this something the public can/should do? Security issues? The introspector.html view (adapter) isn't configured with public access. Also you'll find the url/@@introspector.html and url/introspector.html normally both work as described above. If my Zope2 site uses http://worldcookery.com/About and my Zope3 site uses http://worldcookery.com/++kewlskin++About then the existing links are presumably dead or inaccurate. In practice you would specify your desired skin (to override) in your $INSTANCE/etc/overrides.zcml file. Or you could even wire in the ++skin++ into your (apache) rewrite rules. Happy to once I get it but alas, I still don't. I do sincerely appreciate Zope's overall use of precise terminology but that terminology must be spelled out very carefully in layman's terms if you are to not frustrate the uninitiated. You can always try this mail list if the books and/or zope3 doco. isn't helping... ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: I fold. What are ++etc++ and ++resource++ etc?
Chris Withers wrote: Philipp von Weitershausen wrote: Failing to find a clear explanation, I only see a ways for Zope3-based sites to: 1. Be toyed with by the user. How so? ooo look, pretty shiny things in urls, I wonder what they mean Right. What's the problem though? You can toy with Zope 2 URLs as well. If the app is properly built, it won't be a problem. If it is, your app is vulnerable against URL spoofing and the problem certainly won't lie with @ and +. 2. Fall out of search engines. Why? Search engines don't particularly like weird characters in urls. @ and + are not weird characters in URLs. They're allowed by the spec and I'd be surprised if they actually are a problem. So far, this is all hand-waving. 4. Fail the over-the-phone test of URl's... Can you spell @@ or ++ over the phone? I can. Yeah, but you're one of the leading Zope developers in the world. Try explaining it to someone with an IQ of 50 who just about knows what a / (no, the *other* slash) and a . (yeah, the one without the curly bit on the bottom of it) are ;-) Then you'd have a problem of spelling ANY url or email address to those people. Again, hand-waving. Plus, no one says ++ and @@ have to occur in a public view of Zope 3 site. Go to http://worldcookery.com. You won't see much of @@ or ++. Good, I'd love to know how to produce a whole Zope 3 app without these weird appendages... The same way you produce a Zope 2 app: make sure view names and content names don't clash and you're all set. Philipp ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Vocabularies beyond SimpleVocabulary
Hi, I am trying to figure out how to implement vocabularies. My experimentation app is database of books which has a container for people and one for books. What I need to do is be able to form relations between these such that for a book I can choose from a list of the people in the database who the author(s) is(/are). The actual contentobjects and containers are SQLOS and SQLObjectContainers, but that shouldn't really matter too much I should think. In my schema I then want to define a field which uses Choice that needs to take it's list possible values from a container. I am thinking I just need to make my containers implement IVocabularyTokenized and my contentobjects implement ITitledTokenizedTerm, but I can't seem to figure out the correct way of doing this. I have read both doc/schema/vocabularies.txt and the chapters on vocabularies in Zope 3 Developers Handbook and Web Component Development with Zope 3, but they all use rather static sources (mostly just utilizing SimpleVocabulary) which doesn't really cover my needs. Can anybody tell me the correct way to go about this when my source is a container instance in the ZODB? -- Anders -BEGIN GEEK CODE BLOCK- Version: 3.12 GCS/O d--@ s:+ a-- C++ UL+++$ P++ L+++ E- W+ N(+) o K? w O-- M- V PS+ PE@ Y+ PGP+ t 5 X R+ tv+ b++ DI+++ D+ G e- h !r y? --END GEEK CODE BLOCK-- PGPKey: http://random.sks.keyserver.penguin.de:11371/pks/lookup?op=getsearch=0xD4DEFED0 ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Vocabularies beyond SimpleVocabulary
Anders Bruun Olsen wrote: Hi, I am trying to figure out how to implement vocabularies. My experimentation app is database of books which has a container for people and one for books. What I need to do is be able to form relations between these such that for a book I can choose from a list of the people in the database who the author(s) is(/are). The actual contentobjects and containers are SQLOS and SQLObjectContainers, but that shouldn't really matter too much I should think. In my schema I then want to define a field which uses Choice that needs to take it's list possible values from a container. I am thinking I just need to make my containers implement IVocabularyTokenized and my contentobjects implement ITitledTokenizedTerm, but I can't seem to figure out the correct way of doing this. I have read both doc/schema/vocabularies.txt and the chapters on vocabularies in Zope 3 Developers Handbook and Web Component Development with Zope 3, but they all use rather static sources (mostly just utilizing SimpleVocabulary) which doesn't really cover my needs. Can anybody tell me the correct way to go about this when my source is a container instance in the ZODB? Hi. I am just working on similar code. I'm beginner in zope and python, so I post this code for improvements from other users. I have defined simple factory for my vocabularies (root folder is hardvired in the code, it gets subfolder by name and creates title from given attribute). from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zope.app import zapi from zope.proxy import removeAllProxies def getVocabulary(context, items_container, title_field): list = [] root=zapi.getRoot(context) for (oid, oobj) in root.get(books).get(items_container).items(): obj = removeAllProxies(oobj) list.append( SimpleTerm( obj, str(obj.__dict__[title_field]), obj.__dict__[title_field])) return SimpleVocabulary( list ) def AuthorsVocabulary(context): return getVocabulary(context, authors, name) -- Piotr Chamera ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: Vocabularies beyond SimpleVocabulary
Piotr Chamera wrote: I am just working on similar code. I'm beginner in zope and python, so I post this code for improvements from other users. I have defined simple factory for my vocabularies (root folder is hardvired in the code, it gets subfolder by name and creates title from given attribute). from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from zope.app import zapi from zope.proxy import removeAllProxies def getVocabulary(context, items_container, title_field): list = [] root=zapi.getRoot(context) for (oid, oobj) in root.get(books).get(items_container).items(): obj = removeAllProxies(oobj) Don't remove (security) proxies here! You're totally disabling security with this. list.append( SimpleTerm( obj, str(obj.__dict__[title_field]), obj.__dict__[title_field])) This spelling is very awkward. It's probably also the reason why you wanted to remove proxies above. You should write this as: list.append(SimpleTerm(obj, getattr(obj, title_field), getattr(obj, title_field))) return SimpleVocabulary( list ) Philipp ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: Vocabularies beyond SimpleVocabulary
Philipp von Weitershausen wrote: Piotr Chamera wrote: def getVocabulary(context, items_container, title_field): list = [] root=zapi.getRoot(context) for (oid, oobj) in root.get(books).get(items_container).items(): obj = removeAllProxies(oobj) Don't remove (security) proxies here! You're totally disabling security with this. list.append( SimpleTerm( obj, str(obj.__dict__[title_field]), obj.__dict__[title_field])) This spelling is very awkward. It's probably also the reason why you wanted to remove proxies above. You should write this as: list.append(SimpleTerm(obj, getattr(obj, title_field), getattr(obj, title_field))) return SimpleVocabulary( list ) I have removed proxies because I stored selected objects in attribute of another object with forms generated from schema. But I probably can remove proxy in set method of that attribute (property) or ... what else can I store as reference to object in attribute of another object to be secure? -- Thanks for your explanations Piotr Chamera ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: I fold. What are ++etc++ and ++resource++ etc?
Ursprüngliche Nachricht am: Mon, 12 Jun 2006 20:53:32 +0200 von: Philipp von Weitershausen : [EMAIL PROTECTED] If you can't manage to spell @ over the phone, then good luck spelling your email address. It's a long time ago, but I remember a situation at school where we were learning to solve equations with variables like 3x + 4 = 10 This is not to hard, but when it came to 3n + 4 = 10 someone said: hey, I know how to handle it with 'x' but don't know what to do with 'n'. Everybody knows that '@' is part of an email-address, but by using '@' in URL's you may run into problems in real life ... :) Regards, Klaus ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] list woes
I'm having this stripped-down use case. class IToy(Interface): name = TextLine(title=uToy) class Toy(Persistent): name = FieldProperty(IToy['name']) class IGadget(Interface): name = TextLine(title=uGadget) class Gadget(Persistent): name = FieldProperty(IGadget['name']) def __init__(self,toy): super(Person, self).__init__(self) self.name = toy.name class IBaby(Interface): name = TextLine(title=uName) toys = List(title=utoys,value_type=Object(schema=IToy,title=utoy) class IPerson(Interface): name = TextLine(title=uName) gadgets = List(title=utoys,value_type=Object(schema=IGadget,title=utoy) class Baby(Persistent): name = FieldProperty(IBaby['name']) toys = FieldProperty(IBaby['toys']) class Person(Persistent): name = FieldProperty(IBaby['name']) gadgets = FieldProperty(IPerson['gadgets']) def __init__(self,baby): super(Person, self).__init__(self) self.name = baby.name When IBaby is at the end of its workflow, it should be replaced by an IPerson. So I've made a view that creates a new IPerson based on data from the old IBaby, and replaces the baby with the person on its container. class BabyView(BrowserView): def growup(self): baby = self.context parentfolder = baby.__parent__ id = baby.__name__ person = Person(baby) del parentfolder[id] parentfolder[id] = person self.request.response.redirect(zapi.absoluteURL(person,self.request)+'/@@edit.html') It works, and I see the new object with the name I passed over from IBaby. The trouble is when I add the following to growup() person.gadgets = [ Gadget(toy) for toy in baby.toys ] This creates the gadgets (one per each toy) but the Gadget.name attributes, altough being created, are not persisted. The @@edit and @@index views show the Gadget.name attributes are missing. I did not @@introspect the gadgets because I cannot traverse to them. Is this the right place for a PersistentList? Using it in growup() and __init__ in place of FieldProperty does not make it work. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] list woes
Marco Mariani wrote: class Gadget(Persistent): name = FieldProperty(IGadget['name']) def __init__(self,toy): super(Person, self).__init__(self) Of course it's super(Gadget, self) This is not real code, I've simplified a lot ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Question about ForbiddenAttribute...
Hi, I'm trying to build a sample photos management application for Zope-3.2, with the following interfaces and classes : - class IGalleryPhoto(IContainer) ... - class IGalleryContainer(IContainer) (marker interface used for preconditions) - class IGalleryFolder(IGalleryContainer) def getImages(): ... - class IGallery(IGalleryFolder,IPossibleSite) ... - class GalleryPhoto(BTreeContainer) ... - class GalleryFolder(Folder) def getImages(self): return [item for item in self.values() if IGalleryPhoto.providedBy(item)] - class Gallery(GalleryFolder, SiteManagerContainer) ... Until now, it's OK ! After that, I created a sample view based on a page template for IGalleryFolder, using a view class : - tal:x repeat=image view/getImages ... /tal:x - class FolderInfo: def getImages(self): Get a sorted list of images result = IGalleryFolder(self.context).getImages() result.sort (lambda x,y: cmp(IGalleryPhoto(x).name, IGalleryPhoto(y).name)) return result The view is registered in ZCML like this : page name=images.html for=.interfaces.IGalleryFolder allowed_interface=.interfaces.IGalleryPhoto template=folder_images.pt permission=zope.View class=.folder.FolderInfo menu=zmi_views title=Images / But when trying to display the view, a ForbiddenAttribute exception is raised : File .../browser/folder.py, line 39, in getImages result.sort (lambda x,y: cmp(IGalleryPhoto(x).name,IGalleryPhoto(y).name)) ForbiddenAttribute:('sort',[GalleryPhoto object at 0xa5b378ac,...] So the forbidden attribute seems to be the sort method of the resulting array, which of course isn't part of any of my interfaces. In such a case, I solved the problem by moving the getSortedImages to the folder interface and content class. But that may not always be possible, so how can I get access to such methods ?? Thanks for any help, Thierry -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users