[Zope3-Users] TestRequest
Hi i'm trying some of the doc tests in the modules,but everytime i try to use TestRequest igot lots of errors. My code is : from zope import interface from zope import schema class IKisi(interface.Interface): Insan evladi first=schema.TextLine(required=False,title=u'First Name') last=schema.TextLine(required=True,title=u'Last Name') name=['makkalot','makov'] class Dataci(object): Bisiler yapcak iste insan falan def getData(self): global name return {'first':name[0],'last':name[1]} def setData(self,data): global name name[0]=data['first'] name[1]=data['last'] return u'Saved changes' if __name__==__main__: from zope.app.form.browser.formview import FormView View = type('View', bases=(Dataci, FormView),dict={'schema': IKisi}) print View from zope.publisher.browser import TestRequest request=TestRequest() view=View(None,request) print view What is the problem??? ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: TestRequest
xor exor wrote: Hi i'm trying some of the doc tests in the modules,but everytime i try to use TestRequest igot lots of errors. Which ones? We can't help you w/o error descriptions (and don't expect anybody to execute some random code of yours, it just takes way too long). My code is : from zope import interface from zope import schema class IKisi(interface.Interface ): Insan evladi first=schema.TextLine(required=False,title=u'First Name') last=schema.TextLine(required=True,title=u'Last Name') name=['makkalot','makov'] class Dataci(object): Bisiler yapcak iste insan falan def getData(self): global name return {'first':name[0],'last':name[1]} def setData(self,data): global name name[0]=data['first'] name[1]=data['last'] return u'Saved changes' if __name__==__main__: from zope.app.form.browser.formview import FormView zope.app.form isn't actively used anymore. I suggest using zope.formlib or z3c.form instead. View = type('View', bases=(Dataci, FormView),dict={'schema': IKisi}) Shrug! Why are you doing this instead of simply inheriting Dataci from FormView, e.g.: class Dataci(FormView): schema = IKisi print View from zope.publisher.browser import TestRequest request=TestRequest() view=View(None,request) print view What is the problem??? I don't know, you haven't said anything about a problem. You just pasted code. Note that you probably want to say print view() at the end. View objects need to be called to obtain their output. -- http://worldcookery.com -- Professional Zope documentation and training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: z3c.formdemo fails upon ./bin/buildout
Stephan Richter wrote: On Wednesday 12 September 2007 16:27, Fernando Correa Neto wrote: I think there was a mistake in the last version of z3c.form demo. (trunk) After running ./bin/buildout, it fails due to a develop = . z3c.form in buildout.cfg. I think z3c.form was supposed to be pulled from svn with a svn:externals set to z3c.form in the z3c.formdemo directory. Checking out z3c.form inside z3c.formdemo seems to solve the problem. You probably used the trunk version. Since the trunk version depends on unreleased packages, I list them as develop eggs. My typical folder layout looks as follows: zope/ packages/ z3c.form/ z3c.formui/ z3c.formdemo/ z3c.form (symlink to version above) z3c.formui (symlink to version above) ... ... The whole idea of buildout is, however, its repeatability. Just because you have a special way of setting up your sandboxes doesn't mean that others do it that way, too. In fact, the whole point of buildout is that everybody has the same, *self-contained* sandbox that you can set up with one command. Not to mention that Windows users would be out of luck with the symlink approach. I suggest svn:externals or ripping it out of the develop= line, depending on whether z3c.formdemo needs cutting edge z3c.form{ui} or not. -- http://worldcookery.com -- Professional Zope documentation and training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
AW: [Zope3-Users] Re: z3c.formdemo fails upon ./bin/buildout
Hi Stephan, Philipp Betreff: [Zope3-Users] Re: z3c.formdemo fails upon ./bin/buildout [...] I suggest svn:externals or ripping it out of the develop= line, depending on whether z3c.formdemo needs cutting edge z3c.form{ui} or not. Using svn:externals is the right thing for setup develope dependencies. That make sense to me. Regards Roger Ineichen _ END OF MESSAGE -- http://worldcookery.com -- Professional Zope documentation and training ___ 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] Implementing a DropdownWidget for a country-code vocabulary
Hello!I'm trying to implement a DropdownWidget for my country list. In my app i'd like to have a dropdown menu where a user can choose a country (for my main content object, a job). My vocabulary is created from a list of strings, and stored in a local utility: SimpleVocabulary.fromValues( [u'AD', u'AE', 'AF', ...] ) But in my dropdown widget i want to display the country name for each option too.. and not just the same value on both the value attribute and inside the element: option value=ADAndorra/option So i send in a different vocabulary.. one that looks like this: [(u'AD', u'Andorra'),...] So i coded this: - class CountryDropDown(DropdownWidget): def __init__(self, field, request): #This returns a dict: {'countrycode':'countryname'} territories = request.locale.displayNames.territories # Invert the territories dict: keys=names, values=ccodes self.territories = sorted(territories.items(), key=itemgetter(1)) #not using this any longer.. #voc = getUtility(IVocabularyFactory, u'Country codes') voc = SimpleVocabulary.fromItems(self.territories) super(CountryDropDown, self).__init__(field, voc, request) def textForValue(self, term): return term.value - But it seems like when i choose a country, e.g Andorra, the constraint fails. I think it is because my modified vocabulary that i sent in which it is now checking constraints against fails. I want the constraints to be checked in my ordinary vocabulary but i want to use a different one when populating the dropdown.. any ideas? -- Instant Foo - Naturally Flavoured ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Implementing a DropdownWidget for a country-code vocabulary
Hello Jesper, That should be solved already. Look for z3c.widget.country. svn://svn.zope.org/repos/main/z3c.widget/trunk/src/z3c/widget/country Saturday, September 15, 2007, 6:08:19 PM, you wrote: Hello! I'm trying to implement a DropdownWidget for my country list. In my app i'd like to have a dropdown menu where a user can choose a country (for my main content object, a job). My vocabulary is created from a list of strings, and stored in a local utility: SimpleVocabulary.fromValues( [u'AD', u'AE', 'AF', ...] ) But in my dropdown widget i want to display the country name for each option too.. and not just the same value on both the value attribute and inside the element: option value="AD"Andorra/option So i send in a different vocabulary.. one that looks like this: [(u'AD', u'Andorra'),...] So i coded this: - class CountryDropDown(DropdownWidget): def __init__(self, field, request): #This returns a dict: {'countrycode':'countryname'} territories = request.locale.displayNames.territories # Invert the territories dict: keys=names, values=ccodes self.territories = sorted(territories.items (), key=itemgetter(1)) #not using this any longer.. #voc = getUtility(IVocabularyFactory, u'Country codes') voc = SimpleVocabulary.fromItems(self.territories) super(CountryDropDown, self).__init__(field, voc, request) def textForValue(self, term): return term.value - But it seems like when i choose a country, e.g Andorra, the constraint fails. I think it is because my modified vocabulary that i sent in which it is now checking constraints against fails. I want the constraints to be checked in my ordinary vocabulary but i want to use a different one when populating the dropdown.. any ideas? -- Instant Foo - Naturally Flavoured -- Best regards, Adam mailto:[EMAIL PROTECTED] ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Implementing a DropdownWidget for a country-code vocabulary
Hello Adam, Great, thanks On 9/15/07, Adam Groszer [EMAIL PROTECTED] wrote: Hello Jesper, That should be solved already. Look for z3c.widget.country. svn://svn.zope.org/repos/main/z3c.widget/trunk/src/z3c/widget/country Saturday, September 15, 2007, 6:08:19 PM, you wrote: Hello! I'm trying to implement a DropdownWidget for my country list. In my app i'd like to have a dropdown menu where a user can choose a country (for my main content object, a job). My vocabulary is created from a list of strings, and stored in a local utility: SimpleVocabulary.fromValues( [u'AD', u'AE', 'AF', ...] ) But in my dropdown widget i want to display the country name for each option too.. and not just the same value on both the value attribute and inside the element: option value=ADAndorra/option So i send in a different vocabulary.. one that looks like this: [(u'AD', u'Andorra'),...] So i coded this: - class CountryDropDown(DropdownWidget): def __init__(self, field, request): #This returns a dict: {'countrycode':'countryname'} territories = request.locale.displayNames.territories # Invert the territories dict: keys=names, values=ccodes self.territories = sorted(territories.items (), key=itemgetter(1)) #not using this any longer.. #voc = getUtility(IVocabularyFactory, u'Country codes') voc = SimpleVocabulary.fromItems(self.territories) super(CountryDropDown, self).__init__(field, voc, request) def textForValue(self, term): return term.value - But it seems like when i choose a country, e.g Andorra, the constraint fails. I think it is because my modified vocabulary that i sent in which it is now checking constraints against fails. I want the constraints to be checked in my ordinary vocabulary but i want to use a different one when populating the dropdown.. any ideas? -- Instant Foo - Naturally Flavoured -- Best regards, Adammailto:[EMAIL PROTECTED][EMAIL PROTECTED] ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] dumping a component registry
I'm having a bit of trouble debugging a failed browser view lookup. It has something to do with environment, because lookups for the view work in one of my sandboxes, and fail in another, even though both seemingly has the same ZCML and code. Does anyone have any scripts already written that, say, at zopectl run time dump the various component registries to a human-consumable format so problems like this can be debugged more simply? - C ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
[Zope3-Users] Re: dumping a component registry
Chris McDonough wrote: I'm having a bit of trouble debugging a failed browser view lookup. It has something to do with environment, because lookups for the view work in one of my sandboxes, and fail in another, even though both seemingly has the same ZCML and code. Does anyone have any scripts already written that, say, at zopectl run time dump the various component registries to a human-consumable format so problems like this can be debugged more simply? from zope.component import getSiteManager reg = getSiteManager() from pprint import pprint for info in reg.registeredAdapters(): ... pprint((info.required, info.provided, info.factory, info.name)) ... This will probably drown you with information, though. One step would be to constrain the output only to browser views, in other words, 2-way multi-adapters whose second required interface is or extends IBrowserRequest: from zope.publisher.interfaces.browser import IBrowserRequest for info in reg.registeredAdapters(): ... if (len(info.required) == 2 and ... info.required[1].isOrExtends(IBrowserRequest)): ... pprint((info.required, info.provided, info.factory, ... info.name)) ... For better findability, you might want to search by name now. This is left up to the skilled reader as an exercise ;) In my experience, failed adapter lookups are mostly due to * configuration simply not getting loaded, * things being registered for one thing but objects providing another (this can be especially confusing if the two things that are separate have similar or equal names, therefore making you believe they're the same. Python's is operator will do wonders). * in case of browser views, missing layers applied to the request. -- http://worldcookery.com -- Professional Zope documentation and training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: [Zope3-Users] Re: dumping a component registry
On Saturday 15 September 2007 19:04, Philipp von Weitershausen wrote: from zope.component import getSiteManager reg = getSiteManager() from pprint import pprint for info in reg.registeredAdapters(): ... pprint((info.required, info.provided, info.factory, info.name)) ... This will probably drown you with information, though. One step would be to constrain the output only to browser views, in other words, 2-way multi-adapters whose second required interface is or extends IBrowserRequest: from zope.publisher.interfaces.browser import IBrowserRequest for info in reg.registeredAdapters(): ... if (len(info.required) == 2 and ... info.required[1].isOrExtends(IBrowserRequest)): ... pprint((info.required, info.provided, info.factory, ... info.name)) ... For better findability, you might want to search by name now. This is left up to the skilled reader as an exercise ;) For more specific searches on global site managers, you can use the apidoc apis. They implement a lot of the searches that are commonly interesting: from zope.app.apidoc import presentation for reg in presentation.getViews(IFolder): ...print reg.required, reg.provided, reg.factory, reg.name There are a lot more helpful functions there and they are all well-documented. Regards, Stephan -- Stephan Richter CBU Physics Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users