Re: [Zope3-Users] Direct ZODB access in a Zope3 instance

2005-12-01 Thread Johan Carlsson

Brad Allen wrote:



At 11:48 AM +0100 12/1/05, Johan Carlsson wrote:


The ZAPI interface gives you several ways to traverse object
from a context:
For instance getParent, (getParents,) getRoot, traverse, (traverseName)



On my first reading of your posting, I missed "getRoot".
That sounds promising. If I can get the root of the ZODB
then I can use traversal to get to any other object in
the ZODB.

However, getRoot takes an argument. The example in
Philikon's book uses a Location(). I don't think this gets
me the root of the ZODB, does it?


Without checking I think getRoot only does an "inverse travers"
similare to what acquisition would have done in Zope 2.

It takes a object (that should support the ILocation, which
defines the __parent__ attribute, without it you wouldn't be
able to climb back up :-)

E.g. what you most likely would pass is the context (which most
likely will be the object your accessing (through a request of some kind).

As I have mentioned before, in the normal case your probalby
are writing a BrowserView class or an adapter (that will
have a context object) and it will be very likely this
content object is some kind of Content Type object, e.g.
something that probably exists in the ZODB.
(A lot of probabilities :-)

There is another way to get to object though,
through the registry and in most cases you would look
up a Utility. Now utilities will not necessary be a
a ZODB object, but if they are  local utility they are :-)

One of the hardest things to learn about Zope 3 is that
there always is a BrowserView class even if you never
code it in Python. Because it's hidden in the ZCML,
such as the EditView.

Personally I'm trying to avoid high-level ZCML statements,
or at least alway implement a BrowserView, it make think
much clearer in my mine, more explicit :-)

Regards,
Johan




--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Direct ZODB access in a Zope3 instance

2005-12-01 Thread Johan Carlsson

Brad Allen wrote:



At 11:48 AM +0100 12/1/05, Johan Carlsson wrote:


To access an object in the ZODB you need to have a context
(that is a pointer to a object stored in ZODB, it almost alway is but
in some situations it's not! I've learned that the hard way).

If your in a browser class you will have the context of the object
traversed as an instance attribute (self.context).



Ok, this helps, although I'm not completely clear on how context
objects are generated.


If you really what too know you should read "The life of a Request".
http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/Zope3Book/request.html

Or you can just trust me ;-)



From a newbie perspective, the context
object is an elusive beast.  It's not really explained anywhere
that I could find. The Zope 3 Developer's Guide. There's a little
section called "The context Variable" in the ZCML chapter, but
that doesn't explain where the context comes from or what it is.

I've seen how the context object is used in TAL, but have always
understood it to be the local URL context.


Yes that's what it is most of the time, only when you have
view classes (IView) that call each other, for instance
when you use special kind of fields.

Here's the interfaces that define a view:
(zope/component/bbb/interfaces.py)

class IContextDependent(Interface):
"""Components implementing this interface must have a
context component.

Usually the context must be one of the arguments of the
constructor. Adapters and views are a primary example of
context-dependent components.
"""

context = Attribute(
"""The context of the object

This is the object being adapted, viewed, extended, etc.
""")


class IPresentation(Interface):
"""Presentation components provide interfaces to external actors

The are created for requests, which encapsulate external actors,
connections, etc.
"""

request = Attribute(
"""The request

The request is a surrogate for the user. It also provides the
presentation type and skin. It is of type
IPresentationRequest.
""")

So as you see it's not only view that have the context, but adapters 
too, well infact view are adapters now day :-)




There were some examples of using self.context in the MessageBoard
tutorial. For instance, below is an excerpt from page 114.
The self.context is used in a mysterious way here. Nothing in
the class definition binds it. It has no base class. I guess I should
expect a child class, or a factory maybe to add the self.context
when the class get instantiated. However, I had trouble finding that
anywhere in the SVN copy of the MessageBoard tutorial (step 13).


Well, it gets bind when adapted and in this example it occurs
when the object is traversed and it's view is looked up.

I think it gets registered with a view class in ZCML
which turns it in to a browser view

I can agree with you that it's kind of mysterious and implicit,
in fact I think it's a consequence of the aspect-origentation.
(What ever happend to "explicit is better than implicit" ;-)



In some other example MessageBoard classes, context is used
as an init parameter. The doctest examples indicate that
context can be a simple container object, not necessarily something
in ZODB. I guess this makes sense.


Exactly, from above: "context - The context of the object
This is the object being adapted, viewed, extended, etc."


As it always have been with Zope, the source code is the best way
to understand how it works. Unfortunatelly is the Z3 source
extremely co-located, but still it's very useful to learn to find
ones way in it. After over 6 months hard studying I'm starting
to find my way round the source :-)


Here's some tips:

- ZCML is as much part of the code as anything else, so try to
learn how to find the code behind the ZCML statement.
Specially high level things like ContainerView, AddViews, and
EditView etc.

Ah, can think of any thing else at the moment. I have to give you a 
rain-check on that :-)


Regards,
Johan



Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Direct ZODB access in a Zope3 instance

2005-12-01 Thread Johan Carlsson

Hi Brad,
(Sorry if I'm assuming the wrong things about what you want to do, but 
hey that life :-)


To access an object in the ZODB you need to have a context
(that is a pointer to a object stored in ZODB, it almost alway is but
in some situations it's not! I've learned that the hard way).

If your in a browser class you will have the context of the object
traversed as an instance attribute (self.context).
The chanse is that if our going to do programmatic things to the ZODB
your most likely to do it in some kind of view class.
I call them "controllers" myself, because they are the heavy-weigh
lifters of Zope 3, it's in the "controllers" it all happens even though
Zope 3 sometimes tries to hide the fact that there even are controllers.


The ZAPI interface gives you several ways to traverse object
from a context:
For instance getParent, (getParents,) getRoot, traverse, (traverseName)

These methods will return an content type object (e.g. a object stored 
in ZODB).



Add an object the the ZODB (programmatically) you first need
an object that implements Persistent and you will probably
what to add it to a container so it should also implement
Location.
(Base classes for that is found here:
   from persistent import Persistent
  from zope.app.location import Location)

As I mention in Zope3 you usually add object to a container, but
not necesarally, but the container garantees that the name and
parent (the attributes defined by ILocation interface) gets
setup correcty, if you add it manually you might need to set
that up your self (I'm doing my ILocation interface dynamically
but that's me, always doing weird stuff ;-).

An object that should be contained should also implement the IContained
interface.

The object it self is just create as you would with any object
or you use a factory (which basically looks the same, but a factory
can be an non-class constructor that create and sets up your object),
to add it to a container you usually use __setitem__ (e.g 
container[name]=your_object)


Also if your adding object without using a container, you would probably 
want to trigger some events (ObjectCreatedEvent, but also the "contained 
event": ObjectAddedEvent (or ObjectMovedEvent)



To learn more about this I suggest you look at zope/app/container.

I hope it wasn't too much :-)

Cheers,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-23 Thread Johan Carlsson

Martijn Faassen wrote:

Johan Carlsson wrote:



Anyone had any success with ZCatalog in Zope 3?



Sure. I'm not sure what the problem is but I see you get a lot of 
replies. We (Infrae) certainly got it working without having to patch 
anything.


Um, the setup code we use it something like:

def _registerUtility(context, class_, interface, name=u''):
if not name:
cname = class_.__name__
else:
cname = name
if name and name in context:
raise ValueError, u'Utility %s already registered!' % name
utility = class_()
context[cname] = utility
registration = UtilityRegistration(name, interface, utility)
key = context.registrationManager.addRegistration(registration)
zapi.traverse(context.registrationManager, key).status =  ActiveStatus
return utility

in setup code...

from zope.app.intid.interfaces import IIntIds
from zope.app.catalog.interfaces import ICatalog
from zope.app.intid import IntIds
from zope.app.catalog.catalog import Catalog

_registerUtility(default, IntIds, IIntIds)
_registerUtility(default, Catalog, ICatalog, u'my_catalog')

and then to make indexes registered, something like:

from zope.app import zapi
from zope.app.catalog.field import FieldIndex

catalog = zapi.getUtility(ICatalog, u'my_catalog')
catalog['something'] = FieldIndex('something', ISomeInterface)

_registerUtility is rather messy but it works..


Thanks Martijn,
From a quick glans at your code the notisable difference is
that I don't call zapi.getUtility(ICatalog, u'my_catalog') to get the
catalog, that just might do the trick. (I jsut grab the catalog from the 
container: c['catalog'].

I'll let you know when I get a chance to test it.

Does you code for adding catalogs and adding fields get called
in the same request?
Mine does, it gets called right after each other, and I'm thinking
in the lines of that there is something that doesn't get setup in
the correct order, which is why I think getUtility might work better.

Anyway, once you do get the catalog working, you may want to check out 
hurry.query, which makes querying the Zope 3 catalog a lot easier (in my 
opinion):


http://codespeak.net/svn/z3/hurry/trunk


I'll check it out :-)

Cheers,
johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-21 Thread Johan Carlsson

Dominik Huber wrote:

Johan Carlsson wrote:





Right after that I do this:


catalog = Catalog()
for index_name, index_attribute, idx_if, attr_call, index_type 
in indexes:

idx = index_type(index_attribute, idx_if, attr_call)
catalog[index_name] = idx
tools['catalog'] = catalog
catalog_reg = UtilityRegistration('catalog', ICatalog, catalog)
rm.addRegistration(catalog_reg)
catalog_reg.status = ActiveStatus



change the order and it will work:

   catalog = Catalog()
   tools['catalog'] = catalog
   catalog_reg = UtilityRegistration('catalog', ICatalog, catalog)
   rm.addRegistration(catalog_reg)
   catalog_reg.status = ActiveStatus
   # add the indexes after the catalog is set to the tools
   for index_name, index_attribute, idx_if, attr_call, index_type
in indexes:
   idx = index_type(index_attribute, idx_if, attr_call)
   catalog[index_name] = idx


That seemed resonablu, unfortunately it didn't help.

Thanks anyway,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-18 Thread Johan Carlsson

Johan Carlsson wrote:

Dominik Huber wrote:


Johan Carlsson wrote:



I've tried this, it doesn't remove the NotYet problem though!??


Our framework relies on that concept and it is still working ;)
Did you assert  to add the catalog to the sitemanagement folder before 
adding its indexes?


I found the error, in the AddView I had to remove the security context
to be able to setup things, I don't need that in the event handler.
The removed security context appears to have been the reason for the
NotYet problems.

Thanks for kicking me in the right direction :-)



Looks like I was wrong on the NotYet too.
It doesn't work in a event handler either :-(

Ivos patch is still the only thing that works.

/Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-18 Thread Johan Carlsson

Johan Carlsson wrote:

Hi again,

The ComponentLookupError have re appeared!

 > Error type: zope.component.interfaces.ComponentLookupError
 > Error object: (, '')

What happend was that I had a IntId utitlity in the root site (renamed 
to '') that answered the request when I added the Indexes in a sub site.


So the question is how do I rename the IntId utility programmatically
or why doesn't the following code ad a utility (maybe it's not
registered correctly to be use right after it's been added but needs
some events to trigger first???


So, with som testing I figured out that the name is set to ''
but it doesn't get accessible right away:

zapi.getAllUtilitiesRegisteredFor(IIntIds) returns an empty tuple.

Is there some kind of flush-call or commit-call that needs to be executed?

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-18 Thread Johan Carlsson

Hi again,

The ComponentLookupError have re appeared!

> Error type: zope.component.interfaces.ComponentLookupError
> Error object: (, '')

What happend was that I had a IntId utitlity in the root site (renamed 
to '') that answered the request when I added the Indexes in a sub site.


So the question is how do I rename the IntId utility programmatically
or why doesn't the following code ad a utility (maybe it's not
registered correctly to be use right after it's been added but needs
some events to trigger first???


First I do this:

intids = IntIds()
tools['intid'] = intids

#I thought this was equal to rename the intid-util to ''!?
intids_reg = UtilityRegistration('', IIntIds, intids)

rm.addRegistration(intids_reg)
intids_reg.status = ActiveStatus


Right after that I do this:


catalog = Catalog()
for index_name, index_attribute, idx_if, attr_call, index_type 
in indexes:

idx = index_type(index_attribute, idx_if, attr_call)
catalog[index_name] = idx
tools['catalog'] = catalog
catalog_reg = UtilityRegistration('catalog', ICatalog, catalog)
rm.addRegistration(catalog_reg)
catalog_reg.status = ActiveStatus



This is all called from an event handler, like Dominik pointed out I 
should do it.




--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Dominik Huber wrote:

Johan Carlsson wrote:



I've tried this, it doesn't remove the NotYet problem though!??



Our framework relies on that concept and it is still working ;)
Did you assert  to add the catalog to the sitemanagement folder before 
adding its indexes?


I found the error, in the AddView I had to remove the security context
to be able to setup things, I don't need that in the event handler.
The removed security context appears to have been the reason for the
NotYet problems.

Thanks for kicking me in the right direction :-)
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Dominik Huber wrote:

Hi Johan
Your problem is that the catalog is not locatable itself during the 
addition of its indexes (-> state within the create and add method), 
therefore the location of the indexes cannot be located and the 
NotYetError is raised. You can move your code to an 
ObjectAddedEvent-subscriber for your object.


 

handler pseudo code:

def addCatalogAndIndex(obj, event):
   sm = zapi.getNextSiteManager(obj)
   catalog = Catalog()
   addLocalUtility(sm, 'XY', ICatalog, catalog)
   catalog[name] = Index(name, IAnyInterface)


I've tried this, it doesn't remove the NotYet problem though!??

Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Dominik Huber wrote:

Hi Johan
Your problem is that the catalog is not locatable itself during the 
addition of its indexes (-> state within the create and add method), 
therefore the location of the indexes cannot be located and the 
NotYetError is raised. You can move your code to an 
ObjectAddedEvent-subscriber for your object.


 

handler pseudo code:

def addCatalogAndIndex(obj, event):
   sm = zapi.getNextSiteManager(obj)
   catalog = Catalog()
   addLocalUtility(sm, 'XY', ICatalog, catalog)
   catalog[name] = Index(name, IAnyInterface)


Ok, that's by the way how Ivo does it (I've just read).

Thanks,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Gary Poster wrote:


Hm.  A very quick look at the patch concerns me a bit.  Am I right  
that, if you apply the patch, then requests that are currently  raising 
a NotYet for you will instead silently fail, not cataloging  what you 
requested?  That seems undesirable to me.  I'd prefer the  exception.


If I'm on the right track here, then the extentcatalog in the  
zc.catalog package in the sandbox probably is one of possibly many  
other better solutions than the patch.  It postpones cataloging to  the 
end of the transaction, which I believe will remove the NotYet  
exceptions *and* successfully catalog your data.


In my case I'm not interested in cataloging anything, there reason is
I'm just adding new fields to a newly created catalog and there
aren't any object to catalog just yet.

I'm guessing Ivo has similare problems because he also are creating
the catalog programmetically.

I'm doing this as a part of a custom add view that defines a
overrided createAndAdd(self, data), I think Ivo does it
in a more CMF like fashion (just after quick glans on his code).

I don't have the faintest idea what NotYet is supposted to be
raise for? Accutally I'm haveing problems finding the code
that does this because the traceback is Zope 3 cryptic and
I don't have a debugger setup either.

(I was hoping not having to care about the innerworks of the catalog,
but that maybe is too much too hope for ;-)

Johan





--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Johan Carlsson wrote:

Ivo van der Wijk wrote:


On 11/17/05, Johan Carlsson <[EMAIL PROTECTED]> wrote:



The code you gave me shows the same showed the same problem as Jürgen
pointied out, the IntId needs to have '' as id.




I remember having some real issues with IntId / Catalog, I doubt if
they ever really got fixed. Check the patch in INSTALL.txt:

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/doc/INSTALL.txt

It once used to work for me, at least :)


Ah, thanks for the heads up.


Now I see, that's exactly what been bitting my butt all along.

The patch fixes the problem!

Thanks again,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Ivo van der Wijk wrote:

On 11/17/05, Johan Carlsson <[EMAIL PROTECTED]> wrote:



The code you gave me shows the same showed the same problem as Jürgen
pointied out, the IntId needs to have '' as id.



I remember having some real issues with IntId / Catalog, I doubt if
they ever really got fixed. Check the patch in INSTALL.txt:

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/doc/INSTALL.txt

It once used to work for me, at least :)


Ah, thanks for the heads up.
Johan



--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

j.kartnaller wrote:


The name doesn't seem to have any importance (see my correction).
Also (afaik) it's not possible to add a object with an empty name 
through the ZMI.



This is a know issue which was solved in the trunk and will be in 3.2.

Anyway you can rename after creating the utility.


Yeah, I noticed that after my first responce.
Thanks again,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

And thanks both of you for really fast replies :-)
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Ivo van der Wijk wrote:

On 11/17/05, Johan Carlsson <[EMAIL PROTECTED]> wrote:


Anyone had any success with ZCatalog in Zope 3?

I'm trying to add indexes to the catalog
but I get an ComponentLookupError:

Error type: zope.component.interfaces.ComponentLookupError
Error object: (, '')

I'm not sure how to setup the IntIds utility, what I've done so far
is just add one and give it an random name.




I managed to create a working Catalog/IntId setup in cubic, along with
actual indexing/searching (and a quick'n'dirty port of TextIndexNG3).

I can't remember details right now (been to long), but you could take
a peak at the code at

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/

Specifically,

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/cubic/core/cubicportal.py
and
https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/cubic/core/catalog/catalog.py

might give you some directions.


The code you gave me shows the same showed the same problem as Jürgen 
pointied out, the IntId needs to have '' as id.

Thanks,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

j.kartnaller wrote:

Johan Carlsson wrote:


Johan Carlsson wrote:



Anyone had any success with ZCatalog in Zope 3?

I'm trying to add indexes to the catalog
but I get an ComponentLookupError:

Error type: zope.component.interfaces.ComponentLookupError
Error object: (, '')


The IntId utility must not have an name as you see in the message.
Just rename your IntId utility and your up and running.


No I was infact quite worng, it is possible to change the ZMI, just
that one has too do it though the Site Manager not the contents view.
And it solves the problem too.

Thanks a bunch!
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Ivo van der Wijk wrote:

On 11/17/05, Johan Carlsson <[EMAIL PROTECTED]> wrote:


Anyone had any success with ZCatalog in Zope 3?

I'm trying to add indexes to the catalog
but I get an ComponentLookupError:

Error type: zope.component.interfaces.ComponentLookupError
Error object: (, '')

I'm not sure how to setup the IntIds utility, what I've done so far
is just add one and give it an random name.




I managed to create a working Catalog/IntId setup in cubic, along with
actual indexing/searching (and a quick'n'dirty port of TextIndexNG3).

I can't remember details right now (been to long), but you could take
a peak at the code at

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/

Specifically,

https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/cubic/core/cubicportal.py
and
https://secure.m3r.nl/repos/opensource/zope3/cubic/trunk/cubic/core/catalog/catalog.py

might give you some directions.


Excellent,
Probably exactly what I need :-)
I'll have a look.
Thanks,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Re: Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

j.kartnaller wrote:

Johan Carlsson wrote:


Johan Carlsson wrote:



Anyone had any success with ZCatalog in Zope 3?

I'm trying to add indexes to the catalog
but I get an ComponentLookupError:

Error type: zope.component.interfaces.ComponentLookupError
Error object: (, '')


The IntId utility must not have an name as you see in the message.
Just rename your IntId utility and your up and running.


The name doesn't seem to have any importance (see my correction).
Also (afaik) it's not possible to add a object with an empty name 
through the ZMI.

Thanks anyway,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson

Johan Carlsson wrote:


Anyone had any success with ZCatalog in Zope 3?

I'm trying to add indexes to the catalog
but I get an ComponentLookupError:

Error type: zope.component.interfaces.ComponentLookupError
Error object: (, '')

I'm not sure how to setup the IntIds utility, what I've done so far
is just add one and give it an random name.


My bad, ComponentLookupError is what I get if I don't have setup an
IntIds utility, if I have set one up (currently mine is named IntIds
in the tools folder of the root site manager) I get:

Error type: zope.app.keyreference.interfaces.NotYet
Error object: 


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Anyone had any success with ZCatalog in Zope 3?

2005-11-17 Thread Johan Carlsson


Anyone had any success with ZCatalog in Zope 3?

I'm trying to add indexes to the catalog
but I get an ComponentLookupError:

Error type: zope.component.interfaces.ComponentLookupError
Error object: (, '')

I'm not sure how to setup the IntIds utility, what I've done so far
is just add one and give it an random name.

Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Fwd: Re: [Zope3-Users] Getting the content object from a widget]

2005-11-14 Thread Johan Carlsson



 Original Message 
Subject: Re: [Zope3-Users] Getting the content object from a widget
Date: Mon, 14 Nov 2005 14:14:02 +0100
From: Johan Carlsson <[EMAIL PROTECTED]>
To: Johan Carlsson <[EMAIL PROTECTED]>
References: <[EMAIL PROTECTED]>

Johan Carlsson wrote:

Well, I extended the search loop to look like this:

def _getParent(self):
curr=self
while hasattr(curr, 'context') and \
(IField.providedBy(curr) or \
 IInputWidget.providedBy(curr)):
curr=curr.context
return curr

Which means that it returnes the first non field non widget
it finds. It kind of does the trick.

One would have though I could just use:

def _getParent(self):
field=self.context
content=field.context
return content

But there is situations where a widget has a widget as it's context.
For instance the default ObjectWidget uses an ObjectWidgetView
as it's view class and when ObjectWidget sets it up it supplies
context=self (e.g. a widget as context).
I don't know why it's designed this way, in my ImageWidget, which
is based on ObjectWidget, I've cut out the ObjectWidgetView and
does every thing in the first view class. I did need to change
the page template to use view instead of context but othervice
it works ok (so far).

If anyones interested I can make the ImageField code available.

Regards,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Getting the content object from a widget

2005-11-14 Thread Johan Carlsson


Hi,
I'm having trouble in finding a consistent way to locate
the content object from a widget (view) class.
(This is when using complex widgets like the ObjectWidget.)

Some background. I'm trying to implement a ImageField and a FileField
so I can add fields for Image and File objects to my schema.
After experimenting with the IObject field for a while I've
done the following things (I've only done the Image part, but
files should be a matter of cut&paste):

- Created an ImageField class (I basically just copied the Object
  implementation)

- I've created an ImageWidget class (derived from ObjectWidget)
  and registered it as a view for the ImageField.

- I've also added a custom IImage interface and Image implementation,
  because I want to add fields to the IImage. (I'm guessing that I
  "should" use annotations, but it's not gone happen in a long while,
  this is consuming far too much of my time as it is.)

This works quite well (after endless fight with Z3 too understand how
the schema  system works).

One of the hardest problem has been how to get information about my
Image object from the view.
In the ObjectWidget view the context is the field, the field in it's
turn as a context that is the content object.
So what I've done so far is just to climb up the context tree to
get to an object not defining a context (and that has been the content
object I'm after, but this strategy doesn't work when adding a content
object for instance, because there isn't a content object too be found.)


So I'm looking for a good generic way to find the content object (or
None if it doesn't exist).

Regards,
Johan


PS. I've also noticed that to be able to make web requests to the image
object I need to specify the __name__ attribute when setting up
the the field (just so that you know). Fields normaly lack the Location
interfaces so one needs to figure out the location manually.
Also fields need special traversers to be traversable from the web,
it's a consequence of the explicit nature of Z3 I guess.)



--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] View with template

2005-10-28 Thread Johan Carlsson

Frank Burkhardt wrote:
> Hi,
>
> a short introduction first:
>
> I'm Frank Burkhardt, working at the Max Planck Institute in Germany. My
> employer wants a new website to replace the old one (www.cbs.mpg.de - 
yes,

> it looks really really ugly). We chose Zope3 to implement it.
> Maybe there will be one or two questions on the way which is the reason
> why I joined this list :-) .
>
>
> Here is the first one:
>
> I assigned a view to my brandnew content class:
>
> for=".test.ITest"
>  name="index.html"
>  permission="zope.Public"
>  class=".test.TestView"
>  template="view.pt"
>   />
>
> This is what I think this xml-statement should do:
>
> When http://zope/test/index.html is called, the template
> "view.pt" is evaluated which has access to the View-class
> "TestView".
>
> view.pt:
> 
> 
> 
>   
> 
> 
>
> But whenever I define TestView.__call__ the template is not evaluated but
> the result of TestView.__call__ is returned directly.
>
> How can Zope be forced to use the template instead of __call__ing
> the TestView-Object?

Hi Frank,
I'll try to answer this (anyone find any errors in what I say please 
correct me :-)


Short answer:

You must call the template in your version of __call__,
the template is saved as the attribute index.
Call it like this:

def __call__(self, ..., *args, **kw):
...
return self.index(*args, **kw)


Long answer:

(note. The code for this is located in. zope.app.publisher.browser.viewmeta)

When your using th template directive in browser:page your class
gets wrapped in a wrapper class generated by the method SimpleViewClass 
(zope.app.pagetemplates.simpleviewclass)


The template gets assigned to the attribute index of the wrapper class,
and the class is use as the first base class.

The second base class of the wrapper class is a BrowserView derived 
class called simple and it's also defined in 
(zope.app.pagetemplates.simpleviewclass).

It is simple that defines the default behavior of __call__, that is
to call index (e.g. the template).

Now if you override the __call__ in your view class this behavior
is replace (because the view class comes before the simple class)
so you must implement the behaviour your self (e.g. your call needs
to call index).


Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Traversing a Tuple Field

2005-10-26 Thread Johan Carlsson

Johan Carlsson wrote:

Hi all,

I have a schema that defines a tuple field that holds object field
of a specific type.
Now I want to be able to traverse each object in the tuple
by using .//.

 From the Zope3 book I've learn how to create a Traverser (by 
subclassing the ContainerTraverser) but my problem is that the first name

encountered is the field_name, but I can't return the tuple (or)
because it's a simple object not aware of location (that would be
fixable I guess, I've seen a LocationProxy somewhere).
Instead I return the context, which has the effect that the
Traverser gets called again (with the index), but I can't figure
out how to save the state, that the  has already been
traverser, so I'd know that the index should be look up on the field_name.

Are there anyway to know which part of the URL that has been traverse,
or to traverse ahead in the first call to the Traverser?

Any advice on this problem?


Yes (found it, after I though of revisit the Life of a Request).

The request object uses to attribute to track the traversal
(well three actually (_last_obj_traversed too), but who's counting ;-)

request._traversal_stack, that holds the names to be traversed (reversed)
request._traversed_names, that holds the names that have been (or is 
being) traversed (current name is last).


That means I can just pop the last item in _traversal_stack and
push it on to _traversed_names, use it to locate my object in
the tuple and return it to the called :-)

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Traversing a Tuple Field

2005-10-26 Thread Johan Carlsson

Hi all,

I have a schema that defines a tuple field that holds object field
of a specific type.
Now I want to be able to traverse each object in the tuple
by using .//.

From the Zope3 book I've learn how to create a Traverser (by 
subclassing the ContainerTraverser) but my problem is that the first name

encountered is the field_name, but I can't return the tuple (or)
because it's a simple object not aware of location (that would be
fixable I guess, I've seen a LocationProxy somewhere).
Instead I return the context, which has the effect that the
Traverser gets called again (with the index), but I can't figure
out how to save the state, that the  has already been
traverser, so I'd know that the index should be look up on the field_name.

Are there anyway to know which part of the URL that has been traverse,
or to traverse ahead in the first call to the Traverser?

Any advice on this problem?

(I just realized that using a volatile attribute on the context might
work, but it just feels to darn un-zope3-ish)

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Fields for file and images

2005-10-25 Thread Johan Carlsson

Johan Carlsson wrote:

James Allwyn wrote:

I too have been getting "UnpickleableError" while playing with 
ObjectWidgets.


But I'm now suspecting the real problem is due to a misconfiguration
in ZCML. I'll let you know what I find out.


Didn't find anything ZCML related, my hunch was wrong (it was another 
problem).

/Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Fields for file and images

2005-10-25 Thread Johan Carlsson

James Allwyn wrote:

I too have been getting "UnpickleableError" while playing with ObjectWidgets.


Hi James,
What I ended up doing was to move the removeSecurityProxy from the 
Content Type Class to the Browser View (where I think it belongs).

(In my case this would be an overriden version of ObjectWidget)

The method applyChanges was override ang changed to include the 
removeSecurityProxy. (see below)


For your example you would have to create a PersonWidget and a 
PageWidget (copy the applyChanges from ObjectWidget and change

so the security is removed before saving).
(The classes might end-up looking the same, som maybe you only
need one?)

But I'm now suspecting the real problem is due to a misconfiguration
in ZCML. I'll let you know what I find out.

Regards,
johan



class FileWidget(ObjectWidget):

def applyChanges(self, content):

field = self.context

# create our new object value
value = field.query(content, None)
if value is None:
# TODO: ObjectCreatedEvent here would be nice
value = self.factory()

# apply sub changes, see if there *are* any changes
# TODO: ObjectModifiedEvent here would be nice
changes = applyWidgetsChanges(self, field.schema, target=value,
  names=self.names)

# if there's changes, then store the new value on the content
if changes:
file=removeSecurityProxy(value)
form = self.request.form
filename = getattr(form["field.file.data"], "filename", None)
contenttype = form.get("field.file.contentType")
if filename:
if not contenttype:
contenttype = 
content_types.guess_content_type(filename)[0]

file.contentType=contenttype

#descriptor = objectevent.Attributes(IFile, "contentType")
#descriptor.attributes += "data"
#event = objectevent.ObjectModifiedEvent(file, descriptor)
#zope.event.notify(event)

field.set(content, file)

    return changes




fw = CustomWidgetFactory(FileWidget, File )

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Fields for file and images

2005-10-20 Thread Johan Carlsson

Johan Carlsson wrote:

For anyone that might be interested in the update to my code (still only
parsely working):

Here is my code (which uses the Poll as base, that stuff has been 
removed though):


interfaces.py:

  from zope.interface import Interface
  from zope.schema import Object
  from zope.app.file.interfaces import IFile


from zope.security.proxy import removeSecurityProxy


  from zope.i18n import MessageIDFactory
  _ = MessageIDFactory('poll')

  class IPoll(Interface):

  file=Object(IFile, title=_('File'))

poll.py:

  from persistent import Persistent
  from interfaces import IPoll
  from zope.interface import implements, classImplements
  from zope.app.file.file import File

  class Poll(Persistent, object):
  implements(IPoll)



def get_file(self):
return self._file

def set_file(self, file):
self._file = removeSecurityProxy(file)

file = property(get_file, set_file, None, 'fiddle file')




browser.py:

  from zope.interface import implements
  from zope.app.form.browser.editview import EditView
  from zope.app.form.browser.add import AddView
  from zope.app.form import CustomWidgetFactory
  from zope.app.form.browser import ObjectWidget

  from interfaces import IPoll


  from zope.app.file.file import File

  fw = CustomWidgetFactory(ObjectWidget, File)

  class PollEditView(EditView):
  __used_for__ = IPoll

  file_widget = fw

  class PollAddView(AddView):
  __used_for__ = IPoll

  file_widget = fw

configure.zcml:

http://namespaces.zope.org/zope";
xmlns:browser="http://namespaces.zope.org/browser";
i18n_domain="poll">

  
  

  

  

  
  

  

  

  








--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72    Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Fields for file and images

2005-10-20 Thread Johan Carlsson

Johan Carlsson wrote:

Hi all,
I'm trying to figure out the easiest way to get fields holding Files or 
Images in my content type class.



I've tried the following:
I've tried using the Object field specifying the 
zope.app.file.interfaces.IFile as the schema and then

implement a CustomWidgetFactory with zope.app.file.file.File
as the factory.

This actually looks ok both in the AddView and the EditView
but the updates fail (due to cPickle.UnpickleableError: Cannot pickle 
 objects, which sounds like the

File object needs to be removed from it's proxy somewhere in the chain?)


Ok, this error was as I suspected due to that security proxy was saved
instead of the object, I've temporarely solved this by implementing
the file attribute of the class as a property and use
removeSecurityProxy in the set method.


Any thought on how to solve this problem (my approach or other approach)?


I've discovered that there are more things to wish for in the Object
file and also in the corresponding ObjectWidget (that handles the update
for the File fields).
Some of the things that ObjectWidget doesn't do is honer the ILocation
interface, submitting events and also some file upload specifics such as
getting the content-type from the submitted data (such as the FileUpload
view does for normal file objects).

This leads me to the assuption that I need to implement my own View
class (at the least) and even my own Field class.

Please correct me if I'm wrong and there is an easier way to make
a File/Image field on a content type class!

Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Fields for file and images

2005-10-20 Thread Johan Carlsson

Hi all,
I'm trying to figure out the easiest way to get fields holding Files or 
Images in my content type class.



I've tried the following:
I've tried using the Object field specifying the 
zope.app.file.interfaces.IFile as the schema and then

implement a CustomWidgetFactory with zope.app.file.file.File
as the factory.

This actually looks ok both in the AddView and the EditView
but the updates fail (due to cPickle.UnpickleableError: Cannot pickle 
 objects, which sounds like the

File object needs to be removed from it's proxy somewhere in the chain?)

Any thought on how to solve this problem (my approach or other approach)?

Regards,
Johan


Here is my code (which uses the Poll as base, that stuff has been 
removed though):


interfaces.py:

  from zope.interface import Interface
  from zope.schema import Object
  from zope.app.file.interfaces import IFile

  from zope.i18n import MessageIDFactory
  _ = MessageIDFactory('poll')

  class IPoll(Interface):

  file=Object(IFile, title=_('File'))

poll.py:

  from persistent import Persistent
  from interfaces import IPoll
  from zope.interface import implements, classImplements
  from zope.app.file.file import File

  class Poll(Persistent, object):
  implements(IPoll)

  file=None


browser.py:

  from zope.interface import implements
  from zope.app.form.browser.editview import EditView
  from zope.app.form.browser.add import AddView
  from zope.app.form import CustomWidgetFactory
  from zope.app.form.browser import ObjectWidget

  from interfaces import IPoll


  from zope.app.file.file import File

  fw = CustomWidgetFactory(ObjectWidget, File)

  class PollEditView(EditView):
  __used_for__ = IPoll

  file_widget = fw

  class PollAddView(AddView):
  __used_for__ = IPoll

  file_widget = fw

configure.zcml:

http://namespaces.zope.org/zope";
xmlns:browser="http://namespaces.zope.org/browser";
i18n_domain="poll">

  
  

  

  

  
  

  

  

  





--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Override a browser class

2005-10-18 Thread Johan Carlsson

Stephan Richter wrote:

On Monday 03 October 2005 04:09, Johan Carlsson wrote:


PS. The reason I want to change pasteable is that it
raises an exception if the paste action is unknown.
I'm implementing a clone action as an extra variation
of copy and it works in my classes but if I point
to a stock object (with anything I want to clone in
the clipbook) I get an error due to the raise.

My override returns False if the paste action is unknown.

Any core developer that has any opinion on this?
Can it be changed in the core or is there a specific
reason for the raise?



You should bring up the issue on zope3-dev. I have no opinion about it.


Lennart R. did take it up for me on zope3-dev,
but he didn't get any response, on-list anyway.

Is there a collector for Zope3 issues or is the zope3-dev list the 
proper channel?


Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Override a browser class

2005-10-18 Thread Johan Carlsson

Stephan Richter wrote:

On Monday 03 October 2005 04:09, Johan Carlsson wrote:


I want to replace the pasteable in
zope.app.container.browser.contents.Contents
for all content types.

I've created a sub class to Contents which override
the pasteable but I'm not sure how to configure it
to override the default class (if possible)?



You have to register the container views manually, instead of using the 
containerViews directive.


Thanks Stephan,
Yes, I figured that out :-)
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Zope3 equivalent to Zope 2 filestream_iterator?

2005-10-12 Thread Johan Carlsson

Martijn Faassen wrote:

Stephan Richter wrote:


The time of the release is set by date not by feature. So the features 
are not finalized until we freeze the trunk.


The commonly used term is "time-based releases". We hope that these will 
also result in more timely releases too. :) Concretely it means that 
Zope 3.2 will be released by the end of the year/early january.


Thanks for the input guys.

I just found the Roadmap on the site
http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/RoadMap
which is more informative that the doc/ROADMAP.txt


Cheers,
Johan


PS. "time-based releases" was definitely easier to understand
the concept of, but it's alway fun to learn new words ;-)


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Zope3 equivalent to Zope 2 filestream_iterator?

2005-10-12 Thread Johan Carlsson

Stephan Richter wrote:

On Wednesday 12 October 2005 10:02, Johan Carlsson wrote:


How far has the development of 3.2 come?


That question does not make much sense, We are switching to timely releases 
with 3.2. You can see the implemented features in CHANGES.txt.


I don't entirely understand what "timely releases" is?
I'm guessing this is a more "agile" release schema?


Can I use it for development and demo purposes?



Of course. Just check out the trunk.


Will do, thanks.
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Zope3 equivalent to Zope 2 filestream_iterator?

2005-10-12 Thread Johan Carlsson

Stephan Richter wrote:

On Wednesday 12 October 2005 09:38, Johan Carlsson wrote:


Is there a Zope3 equivalent to the Zope 2 filestream_iterator?

A quick search in the source turned up nil!



Well, for 3.2 we changed the publisher interface. You can now return IResult 
objects. The output in the IResult object can be any iterator, including a 
buffer, file or whatever.


Sounds excellent :-)

How far has the development of 3.2 come?
Can I use it for development and demo purposes?

Regards,
Johan



--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Zope3 equivalent to Zope 2 filestream_iterator?

2005-10-12 Thread Johan Carlsson


Hi all,
Is there a Zope3 equivalent to the Zope 2 filestream_iterator?

A quick search in the source turned up nil!

Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Override a browser class

2005-10-03 Thread Johan Carlsson


Hi all,
I want to replace the pasteable in 
zope.app.container.browser.contents.Contents

for all content types.

I've created a sub class to Contents which override
the pasteable but I'm not sure how to configure it
to override the default class (if possible)?

Best Regards,
Johan


PS. The reason I want to change pasteable is that it
raises an exception if the paste action is unknown.
I'm implementing a clone action as an extra variation
of copy and it works in my classes but if I point
to a stock object (with anything I want to clone in
the clipbook) I get an error due to the raise.

My override returns False if the paste action is unknown.

Any core developer that has any opinion on this?
Can it be changed in the core or is there a specific
reason for the raise?


Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Making site skins

2005-08-17 Thread Johan Carlsson

Roger Ineichen wrote:

Take a look at:
src\zope\app\demo\skinpref

It's a demo how you can use preferences for to switch the skin.
Probably you can use some parts from there.

Regards
Roger Ineichen


Thanks Roger,
Sound like something right up my alley :-)
/Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Making site skins

2005-08-17 Thread Johan Carlsson


Some small success :-)

I've figured out (thanks to input Dominik, others, and reading the
source):

- how to change the current skin
- how to load a resource from that skin

The following is currently running in my test View class:

ns='resource'
name='test_me.html'
request=self.request
object=self.context

#Look up the skin interface
adapters = zapi.getSiteManager().adapters
skin = adapters.lookup((providedBy(self.request),), IDefaultSkin, '')
skin = zapi.getUtility(ISkin, 'my_test')

#Change the defaultSkin of the current request
if skin is not None:
directlyProvides(self.request, skin)

#Get the traversal adapter for the namespace (e.g. resource)
traverser = zope.component.queryMultiAdapter((object, request), \
ITraversable, ns)
if traverser is None:
raise TraversalError("++%s++%s" % (ns, name))

#Traverse the resource (e.g. 'test_me.html)
resource = traverser.traverse(name, ())
return resource()


Cheers,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] IDefaultSkin

2005-08-17 Thread Johan Carlsson

Johan Carlsson wrote:


What I'm not quite sure about is what a IDefaultSkin is?
Is it the interface for the global default skin for the whole server?


Also, searching the source (inkl the configurations) it doesn't seem
to be use in a default zope3!?


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] IDefaultSkin

2005-08-17 Thread Johan Carlsson


What I'm not quite sure about is what a IDefaultSkin is?
Is it the interface for the global default skin for the whole server?
/Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Making site skins

2005-08-17 Thread Johan Carlsson

Dominik Huber wrote:

Johan Carlsson wrote:



Ok, so far I figured out the following:

1. Resources gets registered as adapters in the Global Site Manager.
2. The adapter is registerd to adapt from the current layer interface 
(defaults to IDefaultBrowserLayer) to the Interface interface 
(strange, why is that so I wounder?)



The browser request gets directly marked by a skin interface.This is 
done by the http publication request factory:
(zope.app.publication.httpfactory.HTTPPublicationRequestFactory -> 
zope.app.publication.browser.setDefaultSkin)


Afterward the specific adapters such as views get invoked, because you 
register those to a dedicated request interface using the layer 
attribute. Attention they get looked up via the regular default-adapter 
mechansim and not as named adapters.


IMO you can register only a specific IDefaultSkin adapter to a site 
marked for example as ISkinableSite:




Within this adapter you can invoke the user preferences or something else.


Thanks Dominik,
I been reading the source and trying to figure this out (still trying to 
get in to the adapter/interface thinking, which is really hard and 
unintuitive for me.)


I do not quite understand what your suggesting.
Could you give me a short list of what steps would be involved 
implementing your suggestion? And how it would work from a user perspective?


Cheers,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Making site skins

2005-08-17 Thread Johan Carlsson

Dominik Huber wrote:

Johan Carlsson wrote:



Ok, so far I figured out the following:

1. Resources gets registered as adapters in the Global Site Manager.
2. The adapter is registerd to adapt from the current layer interface 
(defaults to IDefaultBrowserLayer) to the Interface interface 
(strange, why is that so I wounder?)



The browser request gets directly marked by a skin interface.This is 
done by the http publication request factory:
(zope.app.publication.httpfactory.HTTPPublicationRequestFactory -> 
zope.app.publication.browser.setDefaultSkin)


Afterward the specific adapters such as views get invoked, because you 
register those to a dedicated request interface using the layer 
attribute. Attention they get looked up via the regular default-adapter 
mechansim and not as named adapters.


IMO you can register only a specific IDefaultSkin adapter to a site 
marked for example as ISkinableSite:




Within this adapter you can invoke the user preferences or something else.


Thanks for the input Dominik.
I think this is just the info I wanted.

Now I just need to understand it as well :-)




--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Making site skins

2005-08-16 Thread Johan Carlsson


Ok, so far I figured out the following:

1. Resources gets registered as adapters in the Global Site Manager.
2. The adapter is registerd to adapt from the current layer interface 
(defaults to IDefaultBrowserLayer) to the Interface interface (strange, 
why is that so I wounder?)
3. The layer interface I can look up byt calling: 
zapi.getUtility(ILayer, 'my_layer')


Ok, fine. So from my View class I try the following:

gsm=zapi.getGlobalSiteManager()
layer = zapi.getUtility(ILayer, 'my_test')
adapter=gsm.queryAdapter(layer, Interface, 'test_me.html')


But this doesn't work, I get the following error:


Error type: exceptions.KeyError
Error object: 

File "C:\Python24\Lib\site-packages\zope\publisher\publish.py", line 
138, in publish


File 
"C:\Python24\Lib\site-packages\zope\app\publication\zopepublication.py", 
line 164, in callObject


File "C:\Python24\Lib\site-packages\zope\publisher\publish.py", line 
113, in mapply


File "C:\Python24\Lib\site-packages\zope\publisher\publish.py", line 
119, in debug_call


File "C:\Zope\Zope31\lib\python\wfc\browser\metasite.py", line 44, in 
__call__

adapter=gsm.queryAdapter(layer, Interface, 'test_me.html')

File "C:\Python24\Lib\site-packages\zope\component\site.py", line 70, in 
queryAdapter

"""Set all module' __file__ attribute to an absolute path"""

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 414, in 
queryAdapter

return self.adapter_hook(interface, object, name, default)

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 404, in 
adapter_hook

factory = self.lookup1(providedBy(object), interface, name)

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 392, in 
lookup1

return self.lookup((required,), provided, name, default)

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 327, in 
lookup

byname = s.get(provided)

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 227, in get
self.clean()

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 146, in 
clean

base.unsubscribe(self)

File "C:\Zope\Zope31\lib\python\zope\interface\adapter.py", line 248, in 
unsubscribe

del self.dependents[dependent]

File "C:\Python24\lib\weakref.py", line 216, in __delitem__
del self.data[ref(key)]


Can somebody sched a light on this problem?

Regards,
Johan




--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Making site skins

2005-08-16 Thread Johan Carlsson


Hi,
I'm looking for a way to have several separate site designs
in the same server.

The designs could be implemented using a skin definition.

I want to be able to assign different designs to different objects
in the database.

Now I got an Zope application that is the target application, so
I can implement view that looks up the correct design.
The application defines it's own skin for the management part
but for the public view I want another (dynamically assigned)
look and feel.

So I have a view object that returns the view form my Zope application,
but how can I programmatically get to my design templates?

I've tried using
zapi.traverse(..., u'++skin++/@@the_view.html'
without any progress.

Best Regards,
Johan Carlsson

PS. I know there might be giant holes in my problem description, I 
assume we're not thinking in the same way (because I surely don't

think Zope3 at all yet), please ask me if there is anything unclear.




--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Importing resource directory hierarchy

2005-07-19 Thread Johan Carlsson

Hi all,
Is the anyway to importing a hierarchy of folders as a resource,
with the folder hierarchy intact.

For instance the file tiny_mce/themes/advanced/editor_template.js
should be accessed as @@/tiny_mce/themes/advanced/editor_template.js

Regards,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] browser:form

2005-07-18 Thread Johan Carlsson

John Smith wrote:

Hi Everyone,

Can anyone give me a few pointers how to use a schema
to auto generate a form that I can use in a view of a
content object?

The content object is a sort of "vehicle manager"
which has an interface IVehicleManager. the Vehicle
stores things in the ZODB like the dsn for an SQL
database and other configuration stuff.

There is then a schema, IVehicle, which lists such
things as colour, reqistration, make, model, year etc,
and these details I want to store in the SQL database.

Up to now, I have been using a hand coded ZPT as a
view object of the VehicleManager to capture Vehicle
data.

Surely there is some way to use the IVehicle schema to
auto-generate the form, for use outside of the ZMI.

Just a few pointers would help. For example, does the
browser:form directive return a whole page, or do I
somehow refer to the browser:form object from a
separate browser:page built from .pt file?

Thanks for any help,

John


Hi John,
For the auto generate form from a schema I think:

http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/Zope3Book/schema.html

is the pointer you need?

Regards,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] How do I get the Interfaces in right order?

2005-07-18 Thread Johan Carlsson


Apparently menus are sorted first on the order Interfaces are defined 
(at least as returned by providedBy(removeSecurityProxy(object)).__iro__).


But how can I control that order?

Also, which maybe is more of a question for the zope3 developers
which I assume is on this list as well :-), woundn't it be a
good idea to have someway of overriding the order of menus.
Maybe just swaping the order of the sorting items from:

(ifaces.index(item._for or Interface), item.order, item.title, item)

to:

(item.order, ifaces.index(item._for or Interface), item.title, item)

But order doesn't seem to be implemented everywhere?
For instance not all ZCML directives that implement the menu (MenuField)
implemets the order field?

Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Ordered list of sub objects

2005-07-16 Thread Johan Carlsson

Stephan Richter wrote:


You definitely have to write a custom container. In your case I would suggest 
providing an attribute on your container that is also a container and holds 
all those objects that you want to manage via another process.


Thanks for the input.

I'm thinking about implementing a container that would be configurable
through ZCML (would that be configured by assigning interfaces?)
The container would support options to use filters, automatic naming and
order support.

But for now I will probably implement either a custom field or a custom
dedicated interface.


It would have been much clearer, if you would have provided a full use case 
instead of talking about it abstractly.


Sorry if I wasn't clear, here's the use cases:

- User choose (content) type and adds to a list
- User selects and deletes type items
- User selects and moves items in order (up. down, top, bottom)
- User views all of the content items.
- User changes some or all content items and saves changes.

- Plus the use cases for IFolder

From that I realized that the items are unnamed, I other words need to
get a name assigned to it when added.

Regards,
Johan


--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM


___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Ordered list of sub objects

2005-07-15 Thread Johan Carlsson


Hi all,
I want to have a list of ordered sub objects (potentially if different 
types) for an object.


I don't want the subjects to be added via the normal Add method, but
I want to implement my own UI for the adding, delete, and ordering.
And I don't want them to turn up in the normal contents view.

The patent objects should also be "containerish", e.g. contain other
types of objects, of different types, that I would like to use the
normal Add facility for and show up in the normal Contents view.

The question is how I should go about and solve this and what
possibilities Zope 3 already got to solve it?

I'm guessing between having to separate container interfaces
for the object, using the special case container interface
with my custom content view.

Or implement a ordered list field that can take sub objects
of different types.

I haven't fully grasped what is possible with the stock fields
(for instance List in combination with more advanced fields as
value_type,  I haven't found any documentation r example using this, 
pointer would be appreciated :-)


Any tips?

Regards,
Johan

--
Johan Carlsson  Tel: + 46 8 31 24 94
Colliberty  Mob: + 46 70 558 25 24
Torsgatan 72Email: [EMAIL PROTECTED]
SE-113 37 STOCKHOLM

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users