[Zope] Re: Output only the first or a particular record using TAL

2005-09-28 Thread Julian Yap

--- Chris Withers <[EMAIL PROTECTED]> wrote:
> > I used the following and it works great (without some
> formatting for
> > clarity):
> >  > tal:condition="customer">
> > Customer:  > tal:content="python:customer[0]['full_name']">
> > 
> 
> hmm, this strikes me as just plain wrong :-S
> 
> Why is getCustomerLicenses returning more than one row if you
> only want 
> the first one?

In my original post I mentioned that getCustomerLicenses returns
more than one row and I want to create something of a header.

> If it only returned one row, then you could do:
> 
> 
>   
>Customer:
>
>   
> 
> 
> ...no need for the condition or the yucky integer indexes.

True.

> Now, if you really can't stop your sql returning more than one
> row 
> (LIMIT 1 anyone?) then how about:
> 
>   tal:condition="customer">
>   
>Customer:
>
>   
> 

To have my SQL returning only just 1 row would require another Z
SQL Method, in which case it may as well be something like
getCustomer.

I'm still getting my head around TAL and how it works so I'm not
sure how the "python:customers and customers[0]" code works.

Ideally, I want to use just the one Z SQL method (done) but I
guess it would be better coding to just reference the Z SQL
method once.  Currently the page template makes two calls to the
Z SQL method.  Once for the customer header and another to
retrieve the customer license details.  Can you suggest how this
would be done?

I'm also thinking further along the lines too of a page
template, printing all customers with headers and details for
each.  This would use a SQL "GROUP BY" statement.  .. But this
is still out of my scope of knowledge.

Regards,
Julian

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Aquisition, UserFolder and security

2005-09-28 Thread bruno modulix
Dieter Maurer wrote:

Hi Dieter

> bruno modulix wrote at 2005-9-27 11:34 +0200:
> 
>>I have a little problem with aquisition and security. We have a project
>>using multiple CPS instances (for those that don't know CPS, it's a CMF
>>based groupware/CMS) running in the same Zope instance, and being
>>siblings of each others [1]. One of these instances is the main entry
>>point for the portal (I'll all it the 'portal'), the others are acting
>>as workspaces for dedicated communities (I'll call them CPMs).
>>
>>Each CPS instance has its own UserFolder. All users exists in the
>>portal's UserFolder, but only exists in some CPMs UserFolders. Now the
>>problem is that, due to acquisition, a member existing in the Portal but
>>not in a given CPM can gain access to this CPM by faking the url - ie:
>>going to mydomain.tld/portal/cpm instead of mydomain.tld/cpm. So we have
>>a potential (err...) security hole here, that I would like to address ASAP.
> 
> 
> Sounds like a permission to role mapping flaw...
> 
>   Apparently, roles controlled by the "Portal" UserFolder (e.g.
>   "Authenticated") are allowed to do things in your CPM that
>   you only be allowed by roles controlled by their UserFolder.
> 
> You may be able to fix this by making the roles controlled
> by the "Portal" and the "CPM" level disjoint.
> 
> "Authenticated" cannot be made disjoint -- but you may not use
> it inside your CPMs.

The problem here is that CPS (the portal and all CPMs are CPS instances)
uses predefined roles, on which the various workflows relies, so that
would mean renaming all roles - differently - on each CPM, and modifying
the workflows too. Given that the customer is going to create new CPMs
"at will", I'm afraid this solution is somewhat unpractical...


-- 
Bruno Desthuilliers
Développeur
[EMAIL PROTECTED]
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Aquisition, UserFolder and security

2005-09-28 Thread Andrew Milton
+---[ bruno modulix ]--
| Dieter Maurer wrote:
| 
| Hi Dieter
| 
| > bruno modulix wrote at 2005-9-27 11:34 +0200:
| > 
| >>I have a little problem with aquisition and security. We have a project
| >>using multiple CPS instances (for those that don't know CPS, it's a CMF
| >>based groupware/CMS) running in the same Zope instance, and being
| >>siblings of each others [1]. One of these instances is the main entry
| >>point for the portal (I'll all it the 'portal'), the others are acting
| >>as workspaces for dedicated communities (I'll call them CPMs).
| >>
| >>Each CPS instance has its own UserFolder. All users exists in the
| >>portal's UserFolder, but only exists in some CPMs UserFolders. Now the
| >>problem is that, due to acquisition, a member existing in the Portal but
| >>not in a given CPM can gain access to this CPM by faking the url - ie:
| >>going to mydomain.tld/portal/cpm instead of mydomain.tld/cpm. So we have
| >>a potential (err...) security hole here, that I would like to address ASAP.
| > 
| > 
| > Sounds like a permission to role mapping flaw...
| > 
| >   Apparently, roles controlled by the "Portal" UserFolder (e.g.
| >   "Authenticated") are allowed to do things in your CPM that
| >   you only be allowed by roles controlled by their UserFolder.
| > 
| > You may be able to fix this by making the roles controlled
| > by the "Portal" and the "CPM" level disjoint.
| > 
| > "Authenticated" cannot be made disjoint -- but you may not use
| > it inside your CPMs.
| 
| The problem here is that CPS (the portal and all CPMs are CPS instances)
| uses predefined roles, on which the various workflows relies, so that
| would mean renaming all roles - differently - on each CPM, and modifying
| the workflows too. Given that the customer is going to create new CPMs
| "at will", I'm afraid this solution is somewhat unpractical...

And turning off "Acquire" roles on the security tab of the folders you don't
want to have acquired doesn't work?

-- 
Andrew Milton
[EMAIL PROTECTED]
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Any hope of *merging* 2 'zope instance home's ??

2005-09-28 Thread Chris Withers

[EMAIL PROTECTED] wrote:

I have 2 Zope/Plone sites each with their
own 'zope instance home'.

Any hope of *merging* these into *ONE* zope instance
home so that I can do /search/ over both???


Wel, certainly possible to merge...


How merge both Data.fs's?


do a .zexp of the one site and import it into the other ZODB.

You can then search by having your search call both portal_catalogs and 
combine the results...


However, you may also with to consider merging the two sites by doing 
the above import, and then copying all content from one site to the other.


If the sites still require seperate look and feel, then use two skins on 
one Plone site.


cheers,

Chris

--
Simplistix - Content Management, Zope & Python Consulting
   - http://www.simplistix.co.uk

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] including a ZPT inside a repeat loop

2005-09-28 Thread Chris Withers

Matthew White wrote:

oops!  I thought I'd clean up my code snippet to make it a little more
readable, and instead introduced an error.  Here it is in full:




As another thing here, the above is pretty expensive, since you call 
new_get_queue twice, whatever happens, how about the following:




..and then make new_get_queue do the right thing when it gets None as 
userid.


I'd probably also change the following to be a metal: macro include 
rather than calling the second template.





Queue Template Goes Here



As a general comment, you're trying to do too much logic in ZPT here, do 
much more work in a class or python script and just return the stuff you 
want to display to the ZPT...


cheers,

Chris

--
Simplistix - Content Management, Zope & Python Consulting
   - http://www.simplistix.co.uk

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: Output only the first or a particular record using TAL

2005-09-28 Thread Julian Yap
--- Tino Wildenhain <[EMAIL PROTECTED]> wrote:
> Am Mittwoch, den 28.09.2005, 16:32 +1000 schrieb Julian Yap:
> > --- Chris Withers <[EMAIL PROTECTED]> wrote:
> ...
> > > Now, if you really can't stop your sql returning more than
> one
> > > row 
> > > (LIMIT 1 anyone?) then how about:
> > > 
> > >  > >  tal:condition="customer">
> > >   
> > >Customer:
> > >
> > >   
> > > 
> > 
> > To have my SQL returning only just 1 row would require
> another Z
> > SQL Method, in which case it may as well be something like
> > getCustomer.
> > 
> > I'm still getting my head around TAL and how it works so I'm
> not
> > sure how the "python:customers and customers[0]" code works.
> > 
> > Ideally, I want to use just the one Z SQL method (done) but
> I
> > guess it would be better coding to just reference the Z SQL
> > method once.  Currently the page template makes two calls to
> the
> > Z SQL method.  Once for the customer header and another to
> > retrieve the customer license details.  Can you suggest how
> this
> > would be done?
> 
> You could just wrap it in a simple python script:
> 
> results=context.yourZSQLMethod()
> 
> h=results[:1] # see python slice
> b=results[1:]
> 
> return context.yourPageTemplate(header=h,body=b)
> 
> And in your ZPT use tal:repeat="chead options/header"
> and options/body
> 
> But maybe you can rething and rephrase your problem :-)

Thanks Tino.

Your example of using the Python script really opens my eyes to
how everything fits together (I know Python).

I'm not sure about the TAL statement you used (so what else is
new).  ... OK, I just got back from reading about the "options"
keyword in Page Templates... Very useful.

Thanks for the usage Python tip.  I think that will get me going
for a while.

Another query I had was on the practice of using control flow
(ie. if, for, etc.. statements).  I guess the best way is to
keep your control flow in Python scripts?  Is this the common practise?
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Aquisition, UserFolder and security

2005-09-28 Thread bruno modulix
Andrew Milton wrote:

(snip)

> And turning off "Acquire" roles on the security tab of the folders you don't
> want to have acquired doesn't work?

This would probably be the cleanest solution here, and - shame on me - I
didn't even think of it. Now the problem is that CPS has a very complex
permission/roles/groups scheme, and I wouldn't want to mess with it.

Anyway, I found a working hack^Msolution that do the trick and seems not
to have too much drawbacks for now  - mostly, overriding the _isTop()
method and looking for another CPS instance in aq_chain, if so return
True, which prevent looking further. Since there won't be another CPS
instance in the aq_chain when managing the application from the ZMI, it
should be ok (and AFAICT it works just fine).

-- 
Bruno Desthuilliers
Développeur
[EMAIL PROTECTED]
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] ZOPE and DEBIAN INSTALLTION

2005-09-28 Thread Benmania Guin

Hi, 

I successfully installed ZOPE on my VServer which has an DEBIAN op. 
I want to change ports now in order to have access via a "normal" HTTP request.
How do I change ports and what port is the right one? 

Benjamin
__
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] possible to do /search/ over multiple zope instance homes?

2005-09-28 Thread chris_beaumont
Dear Chris,

This is not the only answer, but I think its a good one. If you take care to 
use the absolute_url() function to generate URLs you can easily use a 
standalone web search tool like htdig, running under Apache,  to spider all of 
your visble content, and provide unified search results across any number of 
hosts or even domains. Its a hack, but it has some advantages - like being 
super easy to set up, and only showing linked, 'viewable-by-Anonymous users' 
content by default. 

Chris

[EMAIL PROTECTED] wrote ..
> possible to do *search* over multiple zope instance homes?
> 
> (In case I can't merge 2 zope instance homes together?)
> 
> chris
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] ZOPE and DEBIAN INSTALLTION

2005-09-28 Thread Peter Bengtsson
If you're going to be using this lovely little zope instance I advice
you to stay away from debian packages and do it with custom binary
installations. I use debian for all my other programs but zope is what
I do for a living so I'm not satisfied with the deb package way of
doing it.
And if you're going to take take you're zope "more seriously" I
suggest you have a read in some of the documentation about how to
manage a zope instance.
http://www.plope.com/Books/2_7Edition/InstallingZope.stx#3-64

If you're not in the mood for reading some instructions, just edit the
file etc/zope.conf (you find it) and look for where it says

  # valid keys are "address" and "force-connection-close"
  address 8080
  # force-connection-close on


Change that to:

  # valid keys are "address" and "force-connection-close"
  address 80
  # force-connection-close on


2005/9/28, Benmania Guin <[EMAIL PROTECTED]>:
>
> Hi,
>
> I successfully installed ZOPE on my VServer which has an DEBIAN op.
> I want to change ports now in order to have access via a "normal" HTTP 
> request.
> How do I change ports and what port is the right one?
>
> Benjamin
> __
> Verschicken Sie romantische, coole und witzige Bilder per SMS!
> Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
>
> ___
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] logging out (not zmi)

2005-09-28 Thread Dieter Maurer
[EMAIL PROTECTED] wrote at 2005-9-27 18:11 +0100:
>If i'm logged in as testuser and want to log in with a different user
>name, whats the right way of doing it?
>this is on zope 2.7

When you are using HTTP authentication, then logging out is difficult
(and nasty).

The following DTML method helps you to log out:


 


  

You have been logged out.




When you call it via an URL, you will get a login dialog.
Put in any name and a *WRONG* password.
When you finish the dialog, you should see "You have been logged out".
After that, you can login again in the normal way.

Note, that in case you use correct login information
(a right password), then the login dialog will come again...


-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Aquisition, UserFolder and security

2005-09-28 Thread Dieter Maurer
bruno modulix wrote at 2005-9-28 10:02 +0200:
>Dieter Maurer wrote:
> ...
>> Sounds like a permission to role mapping flaw...
>> 
>>   Apparently, roles controlled by the "Portal" UserFolder (e.g.
>>   "Authenticated") are allowed to do things in your CPM that
>>   you only be allowed by roles controlled by their UserFolder.
>> 
>> You may be able to fix this by making the roles controlled
>> by the "Portal" and the "CPM" level disjoint.
>> 
>> "Authenticated" cannot be made disjoint -- but you may not use
>> it inside your CPMs.
>
>The problem here is that CPS (the portal and all CPMs are CPS instances)
>uses predefined roles, on which the various workflows relies, so that
>would mean renaming all roles - differently - on each CPM, and modifying
>the workflows too.

I think that is would only be necessary that the roles
are disjoint between "Portal" and "CPM". All "CPM"s can use
the same roles.

>Given that the customer is going to create new CPMs
>"at will", I'm afraid this solution is somewhat unpractical...

Maybe, this changes when you need to touch only the "Portal" roles?

-- 
Dieter
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Using Singletons

2005-09-28 Thread Doyon, Jean-Francois
Hello,

Is there any support within the framework for singletons? What I call
singletons are objects that are instanciated and persisted only once, or at
least should be.

I find myself wanting to use these in several instances, notably when I
create a class/object that acts as a gateway to an external system of some
kind (like a web service).

I create an object that provides a pythonic/zope-ish API to the rest of my
objects/product code.  I often like to use a persistent object (vs. a
regular python module/package) in order to take advantage of things like
caching, or giving options for configuration through the ZMI.

Given this use case, it would be nice to have Zope provide a framework to
support such things.  It could enforce the uniqueness of the object in the
entire system (absolutely no way to add more than one), and maybe provide a
global mechanism to "find" the object not needing to know where in the tree
it is, what it is called, or using the catalog (rather expensive?).  Maybe
something like a singleton flag and registry of somekind?

I can kind of achieve this partly by doing things like "visible=0" is my CMF
registration for example, forcing a specific id, enforcing rules in the
manage_add type methods, and so on, but it all seems so kludgy.  Not to
mention I always have to know the name of the object, and possibly even the
path, to get to it ... Redundant when there's always only one!

I'm not looking for solutions, but ideas and thoughts ... Although if
someone knows of ways to do this nicely, maybe with a third-party product
for example, I'd love to hear about it!

Thanks,

Jean-François Doyon
Internet Service Development and Systems Support / Spécialiste de
dèveloppements internet et soutien technique
Canada Centre for Remote Sensing/Centre Canadien de télédétection
Natural Resources Canada/Ressources Naturelles Canada
http://atlas.gc.ca
Tel./Tél.: (613) 992-4902
Fax: (613) 947-2410
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] ZOPE and DEBIAN INSTALLTION

2005-09-28 Thread Benmania Guin


Yes. 

It was more a general question. I actually used the DEBIAN Version 'cause when 
I installed it, you had not sent your answer.-
I am wondering whether everything will work properly if I have two servers both 
an apache AND Zope running. 
I distinguish them by ports - the "normal" 80 PORT for Zope (for all HTTP 
requests) and Apache using all other ports (using it as a mailserver and 
stuff). 
Besides that, if I want to deinstall the old ZOPE version, is it possible to 
simply delete simply all files or is there any special deinstallation process? 

Benjamin 


Peter Bengtsson <[EMAIL PROTECTED]> schrieb am 28.09.05 18:51:58:
> 
> If you're going to be using this lovely little zope instance I advice
> you to stay away from debian packages and do it with custom binary
> installations. I use debian for all my other programs but zope is what
> I do for a living so I'm not satisfied with the deb package way of
> doing it.
> And if you're going to take take you're zope "more seriously" I
> suggest you have a read in some of the documentation about how to
> manage a zope instance.
> http://www.plope.com/Books/2_7Edition/InstallingZope.stx#3-64
> 
> If you're not in the mood for reading some instructions, just edit the
> file etc/zope.conf (you find it) and look for where it says
> 
>   # valid keys are "address" and "force-connection-close"
>   address 8080
>   # force-connection-close on
> 
> 
> Change that to:
> 
>   # valid keys are "address" and "force-connection-close"
>   address 80
>   # force-connection-close on
> 
> 
> 2005/9/28, Benmania Guin <[EMAIL PROTECTED]>:
> >
> > Hi,
> >
> > I successfully installed ZOPE on my VServer which has an DEBIAN op.
> > I want to change ports now in order to have access via a "normal" HTTP 
> > request.
> > How do I change ports and what port is the right one?
> >
> > Benjamin
> > __
> > Verschicken Sie romantische, coole und witzige Bilder per SMS!
> > Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193
> >
> > ___
> > Zope maillist  -  Zope@zope.org
> > http://mail.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://mail.zope.org/mailman/listinfo/zope-announce
> >  http://mail.zope.org/mailman/listinfo/zope-dev )
> >
> 
> 
> --
> Peter Bengtsson,
> work www.fry-it.com
> home www.peterbe.com
> hobby www.issuetrackerproduct.com


__
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] ZOPE and DEBIAN INSTALLTION

2005-09-28 Thread Tino Wildenhain
Am Mittwoch, den 28.09.2005, 19:43 +0200 schrieb Benmania Guin:
...
> I distinguish them by ports - the "normal" 80 PORT for Zope (for all HTTP 
> requests) and Apache using all other ports (using it as a mailserver and 
> stuff). 

You use Apache as mailserver? Now thats interesting :-)

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Zope Debugger 0.8.0 Released!

2005-09-28 Thread Chris Withers

Zope Debugger is an enhanced version of pdb for use with Zope.

It can be used simply by inserting the following lines in any python 
code you'd like to debug, including Script (Python)'s and FSPythonScripts:


from Products.zdb import set_trace
set_trace()

It requires no changes to Zope, CMF or Plone or any funky interaction 
with any specific kind of editing software. All you really need to do is 
insert the snippet above and make sure your Zope instance is running in 
foreground mode.


For more information, please see: 
http://www.simplistix.co.uk/software/zope/zdb


cheers,

Chris

--
Simplistix - Content Management, Zope & Python Consulting
   - http://www.simplistix.co.uk






___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: Using Singletons

2005-09-28 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Doyon, Jean-Francois wrote:
> Hello,
> 
> Is there any support within the framework for singletons? What I call
> singletons are objects that are instanciated and persisted only once, or at
> least should be.
> 
> I find myself wanting to use these in several instances, notably when I
> create a class/object that acts as a gateway to an external system of some
> kind (like a web service).
> 
> I create an object that provides a pythonic/zope-ish API to the rest of my
> objects/product code.  I often like to use a persistent object (vs. a
> regular python module/package) in order to take advantage of things like
> caching, or giving options for configuration through the ZMI.
> 
> Given this use case, it would be nice to have Zope provide a framework to
> support such things.  It could enforce the uniqueness of the object in the
> entire system (absolutely no way to add more than one), and maybe provide a
> global mechanism to "find" the object not needing to know where in the tree
> it is, what it is called, or using the catalog (rather expensive?).  Maybe
> something like a singleton flag and registry of somekind?
> 
> I can kind of achieve this partly by doing things like "visible=0" is my CMF
> registration for example, forcing a specific id, enforcing rules in the
> manage_add type methods, and so on, but it all seems so kludgy.  Not to
> mention I always have to know the name of the object, and possibly even the
> path, to get to it ... Redundant when there's always only one!
> 
> I'm not looking for solutions, but ideas and thoughts ... Although if
> someone knows of ways to do this nicely, maybe with a third-party product
> for example, I'd love to hear about it!

CMF uses a base class called UniqueObject for its tools, which are
normally "singletons":

  http://svn.zope.org/CMF/trunk/CMFCore/utils.py?rev=38507&view=auto

In Zope3, one accomplishes your use case by registering a utility for
the interface your singleton provides, without supplying a name.


Tres.
- --
===
Tres Seaver  +1 202-558-7113  [EMAIL PROTECTED]
Palladion Software   "Excellence by Design"http://palladion.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDOtqm+gerLs4ltQ4RAmdqAJ9qE9SCVEtrlM+GnemGtuOhTf8sXwCeKbDS
Se0IViIBS9fP8oM9+RPrgxw=
=7DOZ
-END PGP SIGNATURE-

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] ZOPE and DEBIAN INSTALLTION

2005-09-28 Thread Andreas Pakulat
On 28.09.05 19:43:43, Benmania Guin wrote:
> I am wondering whether everything will work properly if I have two servers 
> both an apache AND Zope running. 

As long as they don't use the same ports.

> I distinguish them by ports - the "normal" 80 PORT for Zope (for all HTTP 
> requests) and Apache using all other ports (using it as a mailserver and 
> stuff). 

Apache is a Web-Server, it is _not_ a mailserver so you can't use it as
mailserver. The default apache install runs on port 80 for http and 443
for https and nothing more.

> Besides that, if I want to deinstall the old ZOPE version, is it possible to 
> simply delete simply all files or is there any special deinstallation 
> process? 

What do you mean with "the old Zope version" the one you installed via
apt-get or the one you can install from source? For the first one:
apt-get remove --purge zope* should do it (eventually you have to
manually remove the instance-home in /var/lib/zope), for the latter
case: rm -rf  should be fine.

Andreas

-- 
You have an unusual magnetic personality.  Don't walk too close to
metal objects which are not fastened down.
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: Using the set object within page templates

2005-09-28 Thread Alexander Limi

A more interesting question: shouldn't it be available by default?

It's a basic data strucure along the lines of lists and dicts, right? Or  
have I missed a use case for it where it may be scary to use in a Python  
Script? :)


-- Alexander Limi

On Mon, 26 Sep 2005 20:41:18 +0200, Andreas Jung <[EMAIL PROTECTED]>  
wrote:



Python sets are not available from with ZPT since ZPT and PythonScripts
run within a sandbox. Write an external method or move your code to
trusted code (Zope product).

-aj

--On 26. September 2005 13:38:55 -0500 Floyd May <[EMAIL PROTECTED]>
wrote:


How can I use a set object within a page template?

When I attempt to create a set (e.g. tal:define="myset
python:set(some_list)"), zope complains that the name 'set' is not
defined.

Thanks!

fm
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )








--
_

 Alexander Limi · Chief Architect · Plone Solutions · Norway

 Consulting · Training · Development · http://www.plonesolutions.com
_

  Plone Co-Founder · http://plone.org · Connecting Content
  Plone Foundation · http://plone.org/foundation · Protecting Plone

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] logging out (not zmi)

2005-09-28 Thread Peter Bengtsson
I don't if it's been said or if it applies to your situation but try looking at
CookieCrumbler which let's you use cookies instead of Basic
Authentication for the Zope login.
When you do this you have a much greater control over the cookies (any
Python Script will do) and you can do stuff such expire cookies to set
cookies to not expire when someone logs in until a few days into the
future.

2005/9/27, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> Hi all,
> If i'm logged in as testuser and want to log in with a different user
> name, whats the right way of doing it?
> this is on zope 2.7
>
> thanks
> paul
>
> ___
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] External Method Working Directory?

2005-09-28 Thread jwithers
Folks,

I have an external method that at this point is made up of nothing but
os.getcwd() and lives in my Extensions directory. When it is run, it
reports the working directory as being one of my Products directories.

Can anyone tell me what the default working directory for an external
method is?

Further, I need this to create a file temporarily in Extensions. 
I would prefer not to have to hardwire the location of Extension into the
code, since that would make the script non-portable to other instances easily.

Any advice on this would be appreciated.

J. P. Withers

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Re: Page Template security problem

2005-09-28 Thread Chris Beaven

Dieter Maurer wrote:


*HOWEVER* note that proxy roles are not passed to called objects.
Thus, "emaildetails.htm" does not run with proxy roles.
If it accesses objects from "admin folder", then you will
get an "Unauthorized".

A possible solution could be: let "sendDetail" access and process
all protected information and pass the results only (hopefully elementary
and therefor unrestricted) to the page template for formatting.
Let "sendDetail" then send the formatted message itself.


Thank You Dieter,

The problem I was having is that I didn't realise that proxy roles are 
not passed to called objects.
Like you suggested, I called all protected objects from the proxyed 
script and passed the return values through to the page template. All 
working wonderfully now.


___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] External Method Working Directory?

2005-09-28 Thread Peter Bengtsson
Products?? That is odd. I thought it was the var/ directory or at
least the zope instance home directory. From the External method you
should have access to INSTANCE_HOME and SOFTWARE_HOME. Try if these
are what you want. I doubt that you'll find your Extensions/ dir in
any of them so you might have do something like:

import os
return os.path.join(INSTANCE_HOME, 'Extensions')


2005/9/28, jwithers <[EMAIL PROTECTED]>:
> Folks,
>
> I have an external method that at this point is made up of nothing but
> os.getcwd() and lives in my Extensions directory. When it is run, it
> reports the working directory as being one of my Products directories.
>
> Can anyone tell me what the default working directory for an external
> method is?
>
> Further, I need this to create a file temporarily in Extensions.
> I would prefer not to have to hardwire the location of Extension into the
> code, since that would make the script non-portable to other instances easily.
>
> Any advice on this would be appreciated.
>
> J. P. Withers
>
> ___
> Zope maillist  -  Zope@zope.org
> http://mail.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://mail.zope.org/mailman/listinfo/zope-announce
>  http://mail.zope.org/mailman/listinfo/zope-dev )
>


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] SiteAccess (Enh. VHM) still needed, or merged to Zope?

2005-09-28 Thread Jeff Kowalczyk
Most references I find (google, The Plone Book - McKay, Building Websites
W/ Plone - Cooper) on virtual hosting Zope behind Apache recommend
starting with sfm's SiteAccess enhanced Virtual Host Monster product:
http://www.zope.org/Members/sfm/SiteAccessEnhanced/view

Reportedly last updated 2001-08-19, is SAE really so mature that it has
not subsequently needed updates or merited a merge into Zope's own VHM?

I need to map the incoming URL "http://(*.)foo.com/new/*" to a Plone
instance at "http://localhost:8080/foo/*"; , and later change the
inbound mapping to "http://(*.)foo.com/*" after customer acceptance.

I'm guessing that this is the most vanilla virtual hosting requirement
possible, and I want to use the simplest configuration to accomplish it.
If the old SEH 2.1.0 is the recommended tool with Zope-2.8.1, I'm sure the
existing docs will be enough to figure it out. Thanks.

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Help with virtual hosting Zope on different ports

2005-09-28 Thread Michael Sanborn
I was a little reluctant to try this, since I'm not that agile with
installing unix applications, but I gave it a shot. It actually wasn't
that hard to install, and the performance difference it makes on my
rickety old box is astonishing!

Thank you very much for this tip!

Jonathan Cyr wrote:
> Unless you need some special Apache functionality, you may want to look and 
> the Pound Rev-Proxy/Load Balancer at http://www.apsis.ch/pound.  I find it 
> much easier than getting involved with apache, it's lightweight, secure and 
> designed with Zope in mind.
>
> two cents,
>
> -Jon.
>
> Michael Sanborn wrote:
>>I have two Zope versions running behind Apache 1.3 (on FreeBSD 4)
>>using different ports on the same server. The only domain name
>>currently assigned to the server is for a Squishdot site on the older
>>Zope version (2.5.1) that I haven't been able to upgrade, and I don't
>>want to spend the time figuring it out right now. The newer Zope
>>version (2.8.1) has a Plone site that I would like to run as a domain
>>of its own.
>>
>>Can someone help me figure out the combination of Apache rewrite rules
>>and Zope/Plone products I would need to use to accomplish this?
>>
>>Just to try to make it clear, what I want is:
>>
>>request: oldsite.com
>>result: myserver:8093/oldsite
>>
>>request: newsite.com
>>result: myserver:8580/newsite
>>
>>This is possible, isn't it?
>>
>>If it helps, here are the existing rewrite rules:
>>
>>
>>ServerName oldsite.com
>>ServerAdmin [EMAIL PROTECTED]
>>DocumentRoot /u2/oldsite
>>ScriptAlias /cgi-bin/ /u2/oldsite.cgi-bin/
>>RewriteEngine on
>>RewriteCond %{HTTP:Authorization}  ^(.*)
>>RewriteRule ^/(oldsite/)?(.*) /usr/local/Zope/Zope.cgi/oldsite/$2
>>[e=HTTP_CGI_AUTHORIZATION:%2,t=application/x-httpd-cgi,l]
>>ErrorLog /u2/oldsite.admin/oldsite.errors
>>TransferLog /u2/oldsite.admin/oldsite.access
>>
>>
>>
>>ServerName www.oldsite.com
>>ServerAdmin [EMAIL PROTECTED]
>>DocumentRoot /u2/oldsite
>>ScriptAlias /cgi-bin/ /u2/oldsite.cgi-bin/
>>RewriteEngine on
>>RewriteCond %{HTTP:Authorization}  ^(.*)
>>RewriteRule ^/(oldsite/)?(.*) /usr/local/Zope/Zope.cgi/oldsite/$2
>>[e=HTTP_CGI_AUTHORIZATION:%2,t=application/x-httpd-cgi,l]
>>ErrorLog /u2/oldsite.admin/oldsite.errors
>>TransferLog /u2/oldsite.admin/oldsite.access
>>
>>
>>Thanks in advance for any assistance,
>>
>>Michael Sanborn
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] External Method Working Directory?

2005-09-28 Thread David Hassalevris

jwithers,

a) Is your os.getcwd() (in /Extensions) called from a Product (in 
/Products?)  Otherwise I have not idea


b) Regarding temporary files ..

I've used stuff like ...

import tempfile
   tmpFile2 = tempfile.mktemp()

   theFile=open( tmpFile2,'rb')
   result = theFile.read()
   theFile.close()
   os.remove(tmpFile2)

I think this may depreciated but do a google on "python tempfile" and 
you can use the updated modules if they apply to your issue.


David

jwithers wrote:


Folks,

I have an external method that at this point is made up of nothing but
os.getcwd() and lives in my Extensions directory. When it is run, it
reports the working directory as being one of my Products directories.

Can anyone tell me what the default working directory for an external
method is?

Further, I need this to create a file temporarily in Extensions. 
I would prefer not to have to hardwire the location of Extension into the

code, since that would make the script non-portable to other instances easily.

Any advice on this would be appreciated.

J. P. Withers





___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] SiteAccess (Enh. VHM) still needed, or merged to Zope?

2005-09-28 Thread Tino Wildenhain
Am Mittwoch, den 28.09.2005, 20:49 -0400 schrieb Jeff Kowalczyk:
> Most references I find (google, The Plone Book - McKay, Building Websites
> W/ Plone - Cooper) on virtual hosting Zope behind Apache recommend
> starting with sfm's SiteAccess enhanced Virtual Host Monster product:
> http://www.zope.org/Members/sfm/SiteAccessEnhanced/view
> 
> Reportedly last updated 2001-08-19, is SAE really so mature that it has
> not subsequently needed updates or merited a merge into Zope's own VHM?
> 
> I need to map the incoming URL "http://(*.)foo.com/new/*" to a Plone
> instance at "http://localhost:8080/foo/*"; , and later change the
> inbound mapping to "http://(*.)foo.com/*" after customer acceptance.
> 
> I'm guessing that this is the most vanilla virtual hosting requirement
> possible, and I want to use the simplest configuration to accomplish it.
> If the old SEH 2.1.0 is the recommended tool with Zope-2.8.1, I'm sure the
> existing docs will be enough to figure it out. Thanks.

I believe Zopes VHM is the very SEH but updated since it became part
of zope. In recent zope versions there is in fact nothing to do to
use it because an instance is automatically created.

You only do the usual apache rewrite dance and be ready :)

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Zope Debugger 0.8.0 Released!

2005-09-28 Thread Luca Olivetti

En/na Chris Withers ha escrit:
For more information, please see: 
http://www.simplistix.co.uk/software/zope/zdb


2005-09-29 08:43:11 ERROR Zope Couldn't install zdb
Traceback (most recent call last):
  File "/usr/local/zope-2.8.1-final/lib/python/OFS/Application.py", 
line 773, in install_product

initmethod(context)
  File "/home/luca/zopetest/Products/zdb/__init__.py", line 64, in 
initialize

pack._m['debug_compile'] = debug_compile
TypeError: object does not support item assignment
Traceback (most recent call last):
  File "/usr/local/zope-2.8.1-final/lib/python/Zope2/Startup/run.py", 
line 56, in ?

run()
  File "/usr/local/zope-2.8.1-final/lib/python/Zope2/Startup/run.py", 
line 21, in run

starter.prepare()
  File 
"/usr/local/zope-2.8.1-final/lib/python/Zope2/Startup/__init__.py", line 
98, in prepare

self.startZope()
  File 
"/usr/local/zope-2.8.1-final/lib/python/Zope2/Startup/__init__.py", line 
257, in startZope

Zope2.startup()
  File "/usr/local/zope-2.8.1-final/lib/python/Zope2/__init__.py", line 
47, in startup

_startup()
  File "/usr/local/zope-2.8.1-final/lib/python/Zope2/App/startup.py", 
line 95, in startup

OFS.Application.initialize(application)
  File "/usr/local/zope-2.8.1-final/lib/python/OFS/Application.py", 
line 298, in initialize

initializer.initialize()
  File "/usr/local/zope-2.8.1-final/lib/python/OFS/Application.py", 
line 327, in initialize

self.install_products()
  File "/usr/local/zope-2.8.1-final/lib/python/OFS/Application.py", 
line 595, in install_products

return install_products(app)
  File "/usr/local/zope-2.8.1-final/lib/python/OFS/Application.py", 
line 626, in install_products

folder_permissions, raise_exc=debug_mode)
  File "/usr/local/zope-2.8.1-final/lib/python/OFS/Application.py", 
line 773, in install_product

initmethod(context)
  File "/home/luca/zopetest/Products/zdb/__init__.py", line 64, in 
initialize

pack._m['debug_compile'] = debug_compile
TypeError: object does not support item assignment


Bye
--
Luca Olivetti
Wetron Automatización S.A. http://www.wetron.es/
Tel. +34 93 5883004  Fax +34 93 5883007
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )