From: Bastien G. <GBa...@co...> - 2006-04-26 12:14:58
|
Or maybe you can hide an IntegerField in your type and use a = default_method that calls a method where you do a search in = portal_catalog (or where your type is cataloged) and return the highest = value + 1 of this IntegerField found in this search... ? BASTIEN Gauthier Service Informatique - Administration Communale de Sambreville 071/260.247 http://www.sambreville.be -----Message d'origine----- De=A0: arc...@li... = [mailto:arc...@li...] De la part de = Rocky Burt Envoy=E9=A0: mercredi 26 avril 2006 13:26 =C0=A0: arc...@li... Objet=A0: [Archetypes-users] Re: Auto-Increment On Wed, 2006-26-04 at 11:01 +0100, Max Stephens wrote: > Hi, how can I make a field auto-increment ala sql? >=20 > Just your plain run-of-the-mill IntegerField (or is there something > more appropriate?) Auto-increment based on what conditions? You mean every time an instance of your custom content type is created, it should have a field with a one-higher value? (ie you have 6 existing objects of your content type, they all got 1 through 6 for their special incremented field) Do you want this incremented value to be incremented per plone site or per zope instance? And I assume you don't want this count to reset the next time you restart zope (ie the next-value must be persisted in the zodb someplace) =20 I don't know of any quick/slick way of doing this. But personally if I needed per plone site I'd record the next-value in portal_properties or some custom tool/local-utility (so its persisted) and simply override __init__ in my content type to set the value of the field to the next-value and increment the next value by one. The cleanest approach would probably be to build a new type of archetypes field (IncrementedIntegerField) and have it use a custom localy utility (if on zope 2.8+) or a custom tool (if on zope 2.7 or below) to manage the next value for the UID+fieldname of the field in question. I know, a long winded answer. If anyone knows of a decent quick solution (maybe there's already a AT field out there that does this?) feel free to disregard this email. - Rocky --=20 Rocky Burt - roc...@ad... http://www.adaptivewave.com Content Management Made Simple direct: +1.709.629-7638 ICQ: 229686900; MSN: ro...@ca... YIM/AIM: rockyburt ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, = security? Get stuff done quickly with pre-integrated technology to make your job = easier Download IBM WebSphere Application Server v.1.0.1 based on Apache = Geronimo http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D= 121642 _______________________________________________ Archetypes-users mailing list Arc...@li... https://lists.sourceforge.net/lists/listinfo/archetypes-users |