Re: [Zope3-Users] Modified IntId utility

2007-09-25 Thread Stefan H. Holek

On 24. Sep 2007, at 18:53, Maken Seteva wrote:


Fellow Zopers.
I have made a slight modification to my intid util by inheriting  
from IntId and overriding _generateId().
I do this to be sure that all new created objects will have an  
incrementing number where
the first object created gets id 1, the next gets id 2 and so on.  
This way I get for free sorting by

oldest/newest.


Please do not attach additional meaning to intids. The value of an  
object's intid is (and should be) completely irrelevant.


[snip]

What do you think about this? Is it safe to do this, or have i  
forgotten any unforseen oddities

that might occur in the future :O


Your code looks like a conflict-magnet to me. I suggest you read up  
on why counting in the ZODB is a bad idea.


Stefan


--
It doesn't necessarily do it in chronological order, though.
  --Douglas Adams


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


Re: [Zope3-Users] Modified IntId utility

2007-09-25 Thread Frank Burkhardt
Hi,

On Mon, Sep 24, 2007 at 06:53:58PM +0200, Maken Seteva wrote:
 Fellow Zopers.
 I have made a slight modification to my intid util by inheriting from IntId 
 and overriding 
 _generateId().
 I do this to be sure that all new created objects will have an incrementing 
 number where
 the first object created gets id 1, the next gets id 2 and so on. This way I 
 get for free 
 sorting by
 oldest/newest.
 
 
 class MyIntIds(IntId):
  # We need a non-volatile nextid
  nextid = None
 
  def _generateId(self):
  # In the unlikely event that the nextid already
  # exists, we run this in a while loop to fix it.
  while True:
  if len(self) == 0:
  self.nextid = 1
  elif self.nextid is None:
  self.nextid = self.refs.maxKey() + 1
  uid = self.nextid
  self.nextid += 1
  if uid not in self.refs:
  return uid
  # Normally we would never get here..
  self.nextid = None
 
 
 What do you think about this? Is it safe to do this, or have i forgotten 
 any unforseen oddities
 that might occur in the future :O

I'm using a modified IntId utility which starts IDs at 1 and counts upwards, 
too.
I needed some permanent link for each object which was easy to implement via 
IntId.
The modification was made to safe keystrokes when typing the permalink. Typing
http://server/~251 is a lot easier than http://server/~344357462 :-) .

However, I don't use those IDs for anything else - like sorting.

Regards,

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


[Zope3-Users] zopeproject (debugging an app)

2007-09-25 Thread roymathew
In the doc. for zopeproject, it says:

  Note: Even exceptions such as Unauthorized (which normally leads to a login 
screen) or NotFound   (which normally leads to an HTTP 404 response) will 
trigger the debugger.

Is there a workaround, so that I can run bin/paster server debug.ini on an 
application that requires a login (ie: starts out by issuing an Unauthorized 
exception), or is removing the zcml decls that causes the login challenge to be 
issued, the only way to debug such an app?

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


Re: [Zope3-Users] Modified IntId utility

2007-09-25 Thread Gary Poster


On Sep 25, 2007, at 3:27 AM, Frank Burkhardt wrote:

I'm using a modified IntId utility which starts IDs at 1 and counts  
upwards, too.
I needed some permanent link for each object which was easy to  
implement via IntId.
The modification was made to safe keystrokes when typing the  
permalink. Typing

http://server/~251 is a lot easier than http://server/~344357462 :-) .

However, I don't use those IDs for anything else - like sorting.


We do.  We use 64-bit intids arranged in ways that help with our most  
common sorting requirements (usually time related).  Higher-order  
bits provide the sort order we care about, and the remaining lower- 
order bits provide randomness so that we reduce the chance of  
conflict errors.  (It still can have a higher theoretical chance for  
conflict errors than the classic intid approach to assigning keys,  
but the BTree conflict resolution algorithm should eliminate the  
increase in practice.)


So, we don't follow the exact pattern in the original post, and using  
the general pattern has subtleties you need to get right.  For  
instance, you need to avoid conflict errors, as Stefan mentioned;  
and, for simplicity, we regard intids to be immutable and so they  
should only be tied to immutable data points about your objects.  But  
we believe the idea--letting intids have meaning, particularly for  
sorting--has merit generally.


...sigh, we need to do some open-sourcing.  We've been pretty busy.

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


[Zope3-Users] zope.app.session and eggs?

2007-09-25 Thread Mats Nordgren

I finally got the courage to try the eggs install on Windows after reading
the documentation on zopeproject.  It worked great and I have my brand new
project working.

Now here is the problem.  I'm assuming a python setup.py install will
download all the parts and install it into my python site-packages directory
as that seems to be what it is doing.  But I get an error when i get to the
zope.app.session package.

Here is the trace.  Now I'm not sure why it is trying to get the 3.4 version
as the zopeproject downloaded the 3.5dev.  Can someone shed some light on
this?

Searching for zope.app.session
Reading http://pypi.python.org/simple/zope.app.session/
Reading http://svn.zope.org/zope.app.session
Best match: zope.app.session 3.4.0
Downloading
http://pypi.python.org/packages/source/z/zope.app.session/zope.app.s
ession-3.4.0.zip#md5=c3d63fd6917049ed3556d32972441031
Processing zope.app.session-3.4.0.zip
Running zope.app.session-3.4.0\setup.py -q bdist_egg --dist-dir
c:\docume~1\mats
\locals~1\temp\easy_install-3z0srr\zope.app.session-3.4.0\egg-dist-tmp-b02rfo
error:
c:\docume~1\mats\locals~1\temp\easy_install-3z0srr\zope.app.session-3.4.0
\CHANGES.txt: No such file or directory
-- 
View this message in context: 
http://www.nabble.com/zope.app.session-and-eggs--tf4517094.html#a12884814
Sent from the Zope3 - users mailing list archive at Nabble.com.

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


[Zope3-Users] Re: zope.app.session and eggs?

2007-09-25 Thread Philipp von Weitershausen

Mats Nordgren wrote:

I finally got the courage to try the eggs install on Windows after reading
the documentation on zopeproject.  It worked great and I have my brand new
project working.


Great to hear.


Now here is the problem.  I'm assuming a python setup.py install will
download all the parts and install it into my python site-packages directory
as that seems to be what it is doing.


Yup. Note that this isn't quite recommended. Messing with the global 
Python installation will make it very hard to run different kinds of 
sandboxes (that require different versions of packages).


I suggest creating individual, quarantined sandboxes using zopeproject: 
http://cheeseshop.python.org/pypi/zopeproject



But I get an error when i get to the zope.app.session package.

Here is the trace.  Now I'm not sure why it is trying to get the 3.4 version
as the zopeproject downloaded the 3.5dev.  Can someone shed some light on
this?

Searching for zope.app.session
Reading http://pypi.python.org/simple/zope.app.session/
Reading http://svn.zope.org/zope.app.session
Best match: zope.app.session 3.4.0
Downloading
http://pypi.python.org/packages/source/z/zope.app.session/zope.app.s
ession-3.4.0.zip#md5=c3d63fd6917049ed3556d32972441031
Processing zope.app.session-3.4.0.zip
Running zope.app.session-3.4.0\setup.py -q bdist_egg --dist-dir
c:\docume~1\mats
\locals~1\temp\easy_install-3z0srr\zope.app.session-3.4.0\egg-dist-tmp-b02rfo
error:
c:\docume~1\mats\locals~1\temp\easy_install-3z0srr\zope.app.session-3.4.0
\CHANGES.txt: No such file or directory


Yes. Somebody created a new zope.app.session egg that doesn't contain a 
CHANGES.txt. We'll try and upload a new one. Thanks for catching this.



--
http://worldcookery.com -- Professional Zope documentation and training

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


Re: [Zope3-Users] zope.app.session and eggs?

2007-09-25 Thread Mats Nordgren

 I suggest creating individual, quarantined sandboxes using zopeproject: 
 http://cheeseshop.python.org/pypi/zopeproject

Can you tell me how I can get the eggs in the sandbox into the python path
so my auto-completion will work while developing for Zope?  When I do a
python setup.py install the eggs are added to the easy-install.pth this
does not happen in the sandbox.  I guess this can be done manually but
creating pth files for each package in the sandbox seems like a hassle and
hopefully there is a better way.

Thanks
-- 
View this message in context: 
http://www.nabble.com/zope.app.session-and-eggs--tf4517094.html#a12885645
Sent from the Zope3 - users mailing list archive at Nabble.com.

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


Re: [Zope3-Users] zope.app.session and eggs?

2007-09-25 Thread Santiago Videla
I think that he's saying that it's better to have a virtual python
enviroment instead of use the global python. In other thread in the list you
will find something like this:

 $ python virtualenv.py env
 ...
 $ cd env
 $ bin/easy_install zopeproject
 ...
 $ bin/zopeproject HelloWorld

checkout:
http://cheeseshop.python.org/pypi/virtualenv
http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python

cheers

On 9/25/07, Mats Nordgren [EMAIL PROTECTED] wrote:


  I suggest creating individual, quarantined sandboxes using zopeproject:
  http://cheeseshop.python.org/pypi/zopeproject

 Can you tell me how I can get the eggs in the sandbox into the python path
 so my auto-completion will work while developing for Zope?  When I do a
 python setup.py install the eggs are added to the easy-install.pth this
 does not happen in the sandbox.  I guess this can be done manually but
 creating pth files for each package in the sandbox seems like a hassle and
 hopefully there is a better way.

 Thanks
 --
 View this message in context:
 http://www.nabble.com/zope.app.session-and-eggs--tf4517094.html#a12885645
 Sent from the Zope3 - users mailing list archive at Nabble.com.

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




-- 
Santiago Videla
www.revolucionesweb.com.ar

Sigue la mata dando de que hablar siempre abajo y a la izquierda donde el
pensamiento que se hace corazón resplandece con la palabra sencilla y
humilde que [EMAIL PROTECTED] [EMAIL PROTECTED] somos.
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] zope.app.session and eggs?

2007-09-25 Thread Mats Nordgren

 I suggest creating individual, quarantined sandboxes using zopeproject: 
 http://cheeseshop.python.org/pypi/zopeproject

Can you tell me how I can get the eggs in the sandbox into the python path
so my auto-completion will work while developing for Zope?  When I do a
python setup.py install the eggs are added to the easy-install.pth this
does not happen in the sandbox.  I guess this can be done manually but
creating pth files for each package in the sandbox seems like a hassle and
hopefully there is a better way.

Thanks
-- 
View this message in context: 
http://www.nabble.com/zope.app.session-and-eggs--tf4517094.html#a12885689
Sent from the Zope3 - users mailing list archive at Nabble.com.

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


Re: [Zope3-Users] zope.app.session and eggs?

2007-09-25 Thread Mats Nordgren

 I think that he's saying that it's better to have a virtual python
 enviroment instead of use the global python. In other thread in the list
 you
 will find something like this:

 $ python virtualenv.py env
 ...
 $ cd env
 $ bin/easy_install zopeproject
 ...
 $ bin/zopeproject HelloWorld

That looks like a nice solution.  Wasn't aware of this before.  Now when I
run the zopeproject I get the following error.  Not sure it is related to
virtualenv.py or if it is something that is changed in the PyPI.

snip
src\zope\i18nmessageid\_zope_i18nmessageid_message.c:125: warning:
'Message_trav
erse' defined but not used
error: Setup script exited with error: command 'gcc' failed with exit status
1
An error occured when trying to install zope.i18nmessageid 3.4.2.Look above
this
 message for any errors thatwere output by easy_install.
An error occured when trying to install zope.i18nmessageid 3.4.2.Look above
this
 message for any errors thatwere output by easy_install.
While:
  Installing app.
  Getting distribution for 'zope.i18nmessageid'.
Error: Couldn't install: zope.i18nmessageid 3.4.2

Thanks,

Mats
-- 
View this message in context: 
http://www.nabble.com/zope.app.session-and-eggs--tf4517094.html#a12887987
Sent from the Zope3 - users mailing list archive at Nabble.com.

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


Re: [Zope3-Users] zope.app.session and eggs?

2007-09-25 Thread Mats Nordgren

PS, this only happens in the virtual instance, it compiles with MinGW just
fine on a pure zopeproject with global python.



Mats Nordgren wrote:
 
 I think that he's saying that it's better to have a virtual python
 enviroment instead of use the global python. In other thread in the list
 you
 will find something like this:
 
 $ python virtualenv.py env
 ...
 $ cd env
 $ bin/easy_install zopeproject
 ...
 $ bin/zopeproject HelloWorld
 
 That looks like a nice solution.  Wasn't aware of this before.  Now when I
 run the zopeproject I get the following error.  Not sure it is related to
 virtualenv.py or if it is something that is changed in the PyPI.
 
 snip
 src\zope\i18nmessageid\_zope_i18nmessageid_message.c:125: warning:
 'Message_trav
 erse' defined but not used
 error: Setup script exited with error: command 'gcc' failed with exit
 status 1
 An error occured when trying to install zope.i18nmessageid 3.4.2.Look
 above this
  message for any errors thatwere output by easy_install.
 An error occured when trying to install zope.i18nmessageid 3.4.2.Look
 above this
  message for any errors thatwere output by easy_install.
 While:
   Installing app.
   Getting distribution for 'zope.i18nmessageid'.
 Error: Couldn't install: zope.i18nmessageid 3.4.2
 
 Thanks,
 
 Mats
 

-- 
View this message in context: 
http://www.nabble.com/zope.app.session-and-eggs--tf4517094.html#a12888094
Sent from the Zope3 - users mailing list archive at Nabble.com.

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


Re: [Zope3-Users] zope.app.session and eggs?

2007-09-25 Thread Mats Nordgren

 Yes. Somebody created a new zope.app.session egg that doesn't contain a 
 CHANGES.txt. We'll try and upload a new one. Thanks for catching this.

Looks like zope.app.session is fixed, thanks.  Now I get an error with
zope.event.

Installed h:\python24\lib\site-packages\zope.event-3.4.0-py2.4.egg
Searching for zope.minmax
Reading http://pypi.python.org/simple/zope.minmax/
Couldn't find index page for 'zope.minmax' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for zope.minmax
error: Could not find suitable distribution for
Requirement.parse('zope.minmax')
-- 
View this message in context: 
http://www.nabble.com/zope.app.session-and-eggs--tf4517094.html#a12888485
Sent from the Zope3 - users mailing list archive at Nabble.com.

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


[Zope3-Users] ftesting.zcml in zopeproject

2007-09-25 Thread roymathew

Couple of questions:

When I use zopeproject to create a project, the project name and the package 
name are the same... ie:
   $HOME/py24/MYPROJ/src/MYPROJ/...
Can I override this to get a package name that is different than the project 
name?

Also, when I run bin/test, I get:
  bin/test 
  Running tests at level 1
  Running zope.app.testing.functional.Functional tests:
Set up zope.app.testing.functional.Functional Traceback (most recent call 
last):
...
File 
$HOME/py24/eggs/tmp1w5hah/zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/xmlconfig.py,
 line 539, in include
File 
$HOME/py24/eggs/tmp1w5hah/zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/xmlconfig.py,
 line 427, in openInOrPlain
  IOError: [Errno 2] No such file or directory: 
'$HOME/py24/MYPROJ/parts/test/ftesting.zcml'

However, I find that there is such an ftesting.zcml file - just not in the 
right place.
Symlinking/copying it solves the problem:

 ln -s $HOME/py24/MYPROJ/src/MYPROJ/ftesting.zcml 
$HOME/py24/MYPROJ/parts/test/ftesting.zcml

What gives?

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


[Zope3-Users] Re: ftesting.zcml in zopeproject

2007-09-25 Thread Philipp von Weitershausen

[EMAIL PROTECTED] wrote:

When I use zopeproject to create a project, the project name and the
package name are the same... ie: $HOME/py24/MYPROJ/src/MYPROJ/...


Not quite. By default, the project name will be used as the directory 
name for the sandbox and as the name of the egg (in setup.py). The lower 
case of the project name will be used for the package name.



Can I override this to get a package name that is different than the
project name?


* The name of the directory containing the sandbox is completely 
irrelevant. You can completely move it around, so long as you run 
bin/buildout afterwards.


* The name of the package is completely arbitrary as well. You may 
rename it if you wish. Just make sure you update every occurrence of 
that name in the Python code and ZCML as well.


* The name of the egg is defined in setup.py::

setup(name='...',

You may change it any time, as long as you also update buildout.cfg 
(where the egg name is mentioned a couple of times) and then run 
bin/buildout.


Thanks for bringing up this question. I will add this to zopeproject's 
README.txt file.



Also, when I run bin/test, I get:
  bin/test
  Running tests at level 1 
  Running zope.app.testing.functional.Functional tests:

Set up zope.app.testing.functional.Functional Traceback (most recent call  
last):
...
File 
$HOME/py24/eggs/tmp1w5hah/zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/xmlconfig.py,
 line 539, in include
File 
$HOME/py24/eggs/tmp1w5hah/zope.configuration-3.4.0b1-py2.4.egg/zope/configuration/xmlconfig.py,
 line 427, in openInOrPlain
  IOError: [Errno 2] No such file or directory: 
'$HOME/py24/MYPROJ/parts/test/ftesting.zcml'

However, I find that there is such an ftesting.zcml file - just not
in the right place. Symlinking/copying it solves the problem:

ln -s $HOME/py24/MYPROJ/src/MYPROJ/ftesting.zcml
$HOME/py24/MYPROJ/parts/test/ftesting.zcml

What gives?


It seems you're using the old default functional test layer from 
zope.app.testing.functional. In Zope 3 instances there used to be a 
global ftesting.zcml that this layer would look for and load. In a 
buildout, that'd be the parts/test directory.


Nowadays we define package-specific functional test layers. Your 
zopeproject-generated code does that too. It comes with a custom 
ftesting.zcml (which you found already) and defines a FunctionalLayer in 
pkg.testing based on that file. You should apply this layer to your 
functional test suites.


For your convenience, the pkg.testing module also defines 
FunctionalDocFileSuite, FunctionalDocTestSuite and a FunctionalTestCase 
variants with that layer applied already. So if you import them for 
pkg.testing rather than zope.app.testing.functional, you won't have to 
do this symlinking.


This is documented already, by the way: 
http://pypi.python.org/pypi/zopeproject#writing-functional-tests



--
http://worldcookery.com -- Professional Zope documentation and training

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