AGX neither a method nor a callable

11 messages Options
Embed this post
Permalink
bad_my84 () AGX neither a method nor a callable
Reply Threaded More More options
Print post
Permalink
Hi all,

I'm developing my own product in archgenxml but I'm running into problems with a default_method.
I have 2 simple classes: 'Medewerker' and 'Afspraken'. 'Afspraken' is contained in 'Medewerker' (composition).
In agreement there is a StringField (called 'medewerker') which I want to give the default of 'Medewerker'-title.

To the 'medewerker' StringField I added the tagged value 'default_method: findParentTitle'
In Afspraken.py I added the following code to the 'code-section after-local-schema':

    security.declarePublic('findParentTitle')
    def findParentTitle(self):
        """
        Populates the field with the title of its parent.
        """
        return self.aq_parent.getTitle()

What am I missing here?

Thanks in advance!

Traceback:
Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module Products.CMFPlone.FactoryTool, line 368, in __call__
  Module Products.CMFPlone.FactoryTool, line 152, in __getitem__
  Module Products.CMFPlone.PloneFolder, line 348, in invokeFactory
  Module Products.CMFCore.TypesTool, line 716, in constructContent
  Module Products.CMFCore.TypesTool, line 276, in constructInstance
  Module Products.CMFCore.TypesTool, line 450, in _constructInstance
  Module Products.PFPOnline.content.Afspraken, line 7, in addAfspraken
  Module OFS.ObjectManager, line 348, in _setObject
  Module zope.event, line 23, in notify
  Module zope.component.event, line 26, in dispatch
  Module zope.component._api, line 130, in subscribers
  Module zope.component.registry, line 290, in subscribers
  Module zope.interface.adapter, line 535, in subscribers
  Module zope.component.event, line 33, in objectEventNotify
  Module zope.component._api, line 130, in subscribers
  Module zope.component.registry, line 290, in subscribers
  Module zope.interface.adapter, line 535, in subscribers
  Module Products.CMFCore.CMFCatalogAware, line 249, in handleContentishEvent
  Module Products.Archetypes.CatalogMultiplex, line 36, in indexObject
  Module Products.CMFPlone.CatalogTool, line 385, in catalog_object
  Module Products.ZCatalog.ZCatalog, line 536, in catalog_object
  Module Products.ZCatalog.Catalog, line 339, in catalogObject
  Module Products.ZCatalog.Catalog, line 277, in updateMetadata
  Module Products.ZCatalog.Catalog, line 416, in recordify
  Module Products.CMFPlone.CatalogTool, line 110, in __getattr__
  Module Products.CMFPlone.CatalogTool, line 214, in getObjSize
  Module Products.Archetypes.BaseObject, line 588, in get_size
  Module Products.Archetypes.Field, line 817, in get_size
  Module Products.Archetypes.Field, line 728, in getRaw
  Module Products.Archetypes.utils, line 160, in mapply
  Module Products.Archetypes.ClassGen, line 56, in generatedAccessor
  Module Products.Archetypes.Field, line 839, in get
  Module Products.Archetypes.Field, line 710, in get
   - __traceback_info__: ('medewerker', <Afspraken at /Plone/med2/portal_factory/Afspraken/afspraken.2009-09-08.7926306464>, {'field': <Field medewerker(string:rw)>, 'schema': <Products.Archetypes.Schema.Schema object at 0xa417f8c>, 'encoding': None})
  Module Products.Archetypes.Field, line 590, in getDefault
ValueError: medewerker.default_method is neither a method of <class 'Products.PFPOnline.content.Afspraken.Afspraken'> nor a callable
Maurits van Rees-3 () Re: AGX neither a method nor a callable
Reply Threaded More More options
Print post
Permalink
bad_my84, on 2009-09-08:

>
> Hi all,
>
> I'm developing my own product in archgenxml but I'm running into problems
> with a default_method.
> I have 2 simple classes: employee and agreement. Agreement is contained in
> employee (composition).
> In agreement there is a StringField (called employee) which I want to give
> the default of employee title.
>
> To the employee StringField I added the tagged value 'default_method:
> findParentTitle'
> In Agreement.py I added the following code to the 'code-section
> after-local-schema':
>
>     security.declarePublic('findParentTitle')
>     def findParentTitle(self):
>         """
>         Populates the field with the title of its parent.
>         """
>         return self.aq_parent.getTitle()
>
> What am I missing here?

Try:
    return self.aq_parent.Title()

The title and description fields are exceptions to the rule that the
generated 'getter' of the field is 'get' plus the capitalized
fieldname.  The getters of these two fields are Title and Description.

I would expect a different error message though, so maybe this is
unrelated.

--
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
bad_my84 () Re: AGX neither a method nor a callable
Reply Threaded More More options
Print post
Permalink

Maurits van Rees-3 wrote:
bad_my84, on 2009-09-08:
>
> Hi all,
>
> I'm developing my own product in archgenxml but I'm running into problems
> with a default_method.
> I have 2 simple classes: employee and agreement. Agreement is contained in
> employee (composition).
> In agreement there is a StringField (called employee) which I want to give
> the default of employee title.
>
> To the employee StringField I added the tagged value 'default_method:
> findParentTitle'
> In Agreement.py I added the following code to the 'code-section
> after-local-schema':
>
>     security.declarePublic('findParentTitle')
>     def findParentTitle(self):
>         """
>         Populates the field with the title of its parent.
>         """
>         return self.aq_parent.getTitle()
>
> What am I missing here?

Try:
    return self.aq_parent.Title()

The title and description fields are exceptions to the rule that the
generated 'getter' of the field is 'get' plus the capitalized
fieldname.  The getters of these two fields are Title and Description.

I would expect a different error message though, so maybe this is
unrelated.
I already tried Title() and 'get' plus capitalized fieldname.
Does it have something to do with security?
bad_my84 () Re: AGX neither a method nor a callable
Reply Threaded More More options
Print post
Permalink

Found part of the problem... me! (shame shame)

If I added the method in the right place, inside the class that is, it
wouldn't have had the error.
Now I can get the values from all fields from it's parent, except the title.
With .Title() there is no value and with .getTitle() there's an error?
--
View this message in context: http://n2.nabble.com/AGX-neither-a-method-nor-a-callable-tp3603494p3616397.html
Sent from the Product Developers mailing list archive at Nabble.com.

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
bad_my84 () Re: AGX neither a method nor a callable
Reply Threaded More More options
Print post
Permalink
In reply to this post by bad_my84
Found part of the problem... me! (shame shame)

If I added the method in the right place, inside the class that is, it wouldn't have had the error.
Now I can get the values from all fields from it's parent, except the title.
With .Title() there is no value and with .getTitle() there's an error?
Maurits van Rees-3 () Re: AGX neither a method nor a callable
Reply Threaded More More options
Print post
Permalink
In reply to this post by bad_my84
bad_my84, on 2009-09-10:
>
> Found part of the problem... me! (shame shame)
>
> If I added the method in the right place, inside the class that is, it
> wouldn't have had the error.
> Now I can get the values from all fields from it's parent, except the title.
> With .Title() there is no value and with .getTitle() there's an error?

getTitle does not exist so I would expect an attribute error.  Title
*should* work.

The names Title and Description do not have the 'get' in front of them
as the Dublin Core metadata standard expects to be able to ask for
Title and Description.  I don't know the details, but this probably
helps when other systems need to interact with Plone, presenting a
familiar interface.

That sais, try self.aq_inner.aq_parent.Title().  Depending on the
exact code path the aq_parent might not be what you expect and the
extra aq_inner should help there.

In your browser you can also go to <url of parent>/Title and see what
that returns.  I wonder if that perhaps returns nothing in your case.

--
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
bad_my84 () RE: Re: AGX neither a method nor a callable
Reply Threaded More More options
Print post
Permalink
I got it!
It was getting its own title and not that of it's parent, found this out
by trying to get the id. It returned the name of the contenttype.
So how do i get the title of the parent and not of itself?

Thanks in advance!


-----Oorspronkelijk bericht-----
Van: [hidden email]
[mailto:[hidden email]] Namens Maurits van
Rees
Verzonden: donderdag 10 september 2009 11:01
Aan: [hidden email]
Onderwerp: [Product-Developers] Re: AGX neither a method nor a callable

bad_my84, on 2009-09-10:
>
> Found part of the problem... me! (shame shame)
>
> If I added the method in the right place, inside the class that is, it

> wouldn't have had the error.
> Now I can get the values from all fields from it's parent, except the
title.
> With .Title() there is no value and with .getTitle() there's an error?

getTitle does not exist so I would expect an attribute error.  Title
*should* work.

The names Title and Description do not have the 'get' in front of them
as the Dublin Core metadata standard expects to be able to ask for Title
and Description.  I don't know the details, but this probably helps when
other systems need to interact with Plone, presenting a familiar
interface.

That sais, try self.aq_inner.aq_parent.Title().  Depending on the exact
code path the aq_parent might not be what you expect and the extra
aq_inner should help there.

In your browser you can also go to <url of parent>/Title and see what
that returns.  I wonder if that perhaps returns nothing in your case.

--
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/ "This is your day, don't let
them take it away." [Barlow Girl]


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers

================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en
de afzender direct te informeren door het bericht te retourneren.
================================================
The information contained in this message may be confidential
and is intended to be exclusively for the addressee. Should you
receive this message unintentionally, please do not use the contents
herein and notify the sender immediately by return e-mail.
================================================

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Maurits van Rees-3 () Re: Re: AGX neither a method nor a callable
Reply Threaded More More options
Print post
Permalink
On Thu, Sep 10, 2009 at 11:32:52AM +0200, Roijen, Bas wrote:
> I got it!
> It was getting its own title and not that of it's parent, found this out
> by trying to get the id. It returned the name of the contenttype.
> So how do i get the title of the parent and not of itself?

Try self.aq_inner.aq_parent.Title().  Depending on the exact
code path the aq_parent might not be what you expect and the extra
aq_inner should help there.

--
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/
"Yes, we study economics,
got to make the money make some kind of sense."  - Geoff Mann

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
bad_my84 () RE: Re: AGX neither a method nor a callable
Reply Threaded More More options
Print post
Permalink
Tried that, but is gives the same result.


-----Oorspronkelijk bericht-----
Van: Maurits van Rees [mailto:[hidden email]]
Verzonden: donderdag 10 september 2009 11:38
Aan: Roijen, Bas
CC: [hidden email]
Onderwerp: Re: [Product-Developers] Re: AGX neither a method nor a
callable

On Thu, Sep 10, 2009 at 11:32:52AM +0200, Roijen, Bas wrote:
> I got it!
> It was getting its own title and not that of it's parent, found this
> out by trying to get the id. It returned the name of the contenttype.
> So how do i get the title of the parent and not of itself?

Try self.aq_inner.aq_parent.Title().  Depending on the exact code path
the aq_parent might not be what you expect and the extra aq_inner should
help there.

--
Maurits van Rees | http://maurits.vanrees.org/
            Work | http://zestsoftware.nl/ "Yes, we study economics, got
to make the money make some kind of sense."  - Geoff Mann
================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en
de afzender direct te informeren door het bericht te retourneren.
================================================
The information contained in this message may be confidential
and is intended to be exclusively for the addressee. Should you
receive this message unintentionally, please do not use the contents
herein and notify the sender immediately by return e-mail.
================================================

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
Yuri-11 () Re: Re: AGX neither a method nor a callable
Reply Threaded More More options
Print post
Permalink
Roijen, Bas ha scritto:
> Tried that, but is gives the same result.
>  

print the aq_parent UID and check if it is correct. If it is, use the
catalog to get the object title.

I've found also problems in getting the parent starting from 3.2.X

>
> -----Oorspronkelijk bericht-----
> Van: Maurits van Rees [mailto:[hidden email]]
> Verzonden: donderdag 10 september 2009 11:38
> Aan: Roijen, Bas
> CC: [hidden email]
> Onderwerp: Re: [Product-Developers] Re: AGX neither a method nor a
> callable
>
> On Thu, Sep 10, 2009 at 11:32:52AM +0200, Roijen, Bas wrote:
>  
>> I got it!
>> It was getting its own title and not that of it's parent, found this
>> out by trying to get the id. It returned the name of the contenttype.
>> So how do i get the title of the parent and not of itself?
>>    
>
> Try self.aq_inner.aq_parent.Title().  Depending on the exact code path
> the aq_parent might not be what you expect and the extra aq_inner should
> help there.
>
> --
> Maurits van Rees | http://maurits.vanrees.org/
>             Work | http://zestsoftware.nl/ "Yes, we study economics, got
> to make the money make some kind of sense."  - Geoff Mann
> ================================================
> De informatie opgenomen in dit bericht kan vertrouwelijk zijn en
> is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
> onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en
> de afzender direct te informeren door het bericht te retourneren.
> ================================================
> The information contained in this message may be confidential
> and is intended to be exclusively for the addressee. Should you
> receive this message unintentionally, please do not use the contents
> herein and notify the sender immediately by return e-mail.
> ================================================
>
> _______________________________________________
> Product-Developers mailing list
> [hidden email]
> http://lists.plone.org/mailman/listinfo/product-developers
>  


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
bad_my84 () RE: Re: AGX neither a method nor a callable
Reply Threaded More More options
Print post
Permalink
Thnx, the UID I get is correct, but how do I use the catalog to get the
title?
This is what I got so far, but it gives the error: LazyMap instance has
no attribute 'Title':
security.declarePublic('findParentTitle')
def findParentTitle(self):
        """
        Return the parents title
        """
        catalog = getToolByName(self, 'portal_catalog')
        uid = self.aq_inner.aq_parent.UID()
        brain = catalog(UID=uid)
        result = brain.Title()
        return results


Met vriendelijke groet,

Bas Roijen
Technisch Applicatiebeheerder
GSM +31 (0)6 27 464 235
E-mail [hidden email]



Cofely Experts BV
Locatie Maastricht-Airport
Amerikalaan 35 6199 AE Maastricht-Airport
Postbus 305 6199 ZN Maastricht-Airport
Alg. +31 (0)43 367 50 00
Fax +31 (0)43 367 59 99
Url www.gti-group.com/experts


-----Oorspronkelijk bericht-----
Van: [hidden email]
[mailto:[hidden email]] Namens Yuri
Verzonden: donderdag 10 september 2009 12:00
Aan: [hidden email]
Onderwerp: Re: [Product-Developers] Re: AGX neither a method nor a
callable

Roijen, Bas ha scritto:
> Tried that, but is gives the same result.
>  

print the aq_parent UID and check if it is correct. If it is, use the
catalog to get the object title.

I've found also problems in getting the parent starting from 3.2.X

>
> -----Oorspronkelijk bericht-----
> Van: Maurits van Rees [mailto:[hidden email]]
> Verzonden: donderdag 10 september 2009 11:38
> Aan: Roijen, Bas
> CC: [hidden email]
> Onderwerp: Re: [Product-Developers] Re: AGX neither a method nor a
> callable
>
> On Thu, Sep 10, 2009 at 11:32:52AM +0200, Roijen, Bas wrote:
>  
>> I got it!
>> It was getting its own title and not that of it's parent, found this
>> out by trying to get the id. It returned the name of the contenttype.
>> So how do i get the title of the parent and not of itself?
>>    
>
> Try self.aq_inner.aq_parent.Title().  Depending on the exact code path

> the aq_parent might not be what you expect and the extra aq_inner
> should help there.
>
> --
> Maurits van Rees | http://maurits.vanrees.org/
>             Work | http://zestsoftware.nl/ "Yes, we study economics,
> got to make the money make some kind of sense."  - Geoff Mann
> ================================================
> De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
> uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
> onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en de

> afzender direct te informeren door het bericht te retourneren.
> ================================================
> The information contained in this message may be confidential and is
> intended to be exclusively for the addressee. Should you receive this
> message unintentionally, please do not use the contents herein and
> notify the sender immediately by return e-mail.
> ================================================
>
> _______________________________________________
> Product-Developers mailing list
> [hidden email]
> http://lists.plone.org/mailman/listinfo/product-developers
>  


_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers
================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is
uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en de
afzender direct te informeren door het bericht te retourneren.
================================================
The information contained in this message may be confidential and is
intended to be exclusively for the addressee. Should you receive this
message unintentionally, please do not use the contents herein and
notify the sender immediately by return e-mail.
================================================
================================================
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en
is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht
onterecht ontvangt, wordt u verzocht de inhoud niet te gebruiken en
de afzender direct te informeren door het bericht te retourneren.
================================================
The information contained in this message may be confidential
and is intended to be exclusively for the addressee. Should you
receive this message unintentionally, please do not use the contents
herein and notify the sender immediately by return e-mail.
================================================

_______________________________________________
Product-Developers mailing list
[hidden email]
http://lists.plone.org/mailman/listinfo/product-developers