[Zope3-Users] Re: updating a zodb with a SchemaManager

2008-03-06 Thread Jürgen Kartnaller



Lorenzo Gil Sánchez wrote:

Hi,

I've been using a zope.app.generations.interfaces.ISchemaManager to keep
my database up to date with respect to the changes in the models of my
application and everything is well so far.

Now I have a tricky situation. My model had an attribute and now I
changed that attribute to be read only.

Before:
---

class IModel(Interface):

  attr1 = zope.schema.TextLine()

class Model(Persistent):
  implements(IModel)

  def __init__(self, attr1=None):
self.attr1 = attr1

After:
--

class IModel(Interface):

  attr1 = zope.schema.TextLine(readonly=True)
  attr2 = zope.schema.TextLine()

class Model(Persistent):
  implements(IModel)

  def __init__(self, attr2=None):
self.attr2 = attr2

  def _getAttr1(self):
return self.attr2.lower()
  attr1 = property(_getAttr1)

As you can see, now attr1 is a computed attribute from attr2.

When updating the old Model objects I add the 'attr2' attribute but I
can't remove the old 'attr1' attribute since is still defined in Model
but is a totally different thing.

I can forget about removing the 'attr1' attribute and things keep
working well. The problem is a waste of space in the database since that
information is still there but impossible to retrieve, right?

I have a related question: is attr1 still saved in the database in the
newer version no matter is a read only python property or does the ZODB
handle this case? As far as I know ZODB only skip those attributes
beginning with _v_ (for volatile), but don't know what it does with
python properties...

Has anyone ever reached a similar situation? Any solution?


You can do this on your instance :

 del obj.__dict__['attr1']

Jürgen

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


[Zope3-Users] Re: Any performance issues with the macro attribute in the z3c:template directive?

2008-03-06 Thread Jürgen Kartnaller

Andreas Johnsen wrote:

Hei all Zopers,

I find the macro parameter in the z3c:template very useful for working
with templates for viewlets and pagelets. I guess it's slower to extract
a html-snippet from within a page template file (by including a macro
parameter) then including the entire page template file (by not
including the macro parameter). 


So before implementing this technique on a large scale, I want to ask if
anyone have experienced any performance issues with this technique?


No, there is no performance issue on this. The TAL engine compiles the 
hole template into memory and caches it. Accessing a macro is just a 
dictionary lookup.

We are using this technique in large projects.

Jürgen

--
Lovely Systems, senior developer

phone: +43 5572 908060, fax: +43 5572 908060-77
Schmelzhütterstraße 26a, 6850 Dornbirn, Austria

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


[Zope3-Users] query all objects in catalog

2008-03-06 Thread Robert Marianski
Is there a way to query a zope3 catalog for all objects that have been
indexed? I see that there is a way to ask an index for the number of
documents it currently has indexed, via documentCount() in the
IStatistics interface, but I can't a good way get back all objects that
have been indexed.

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


Re: [Zope3-Users] query all objects in catalog

2008-03-06 Thread Gary Poster


On Mar 6, 2008, at 1:42 PM, Robert Marianski wrote:


Is there a way to query a zope3 catalog for all objects that have been
indexed? I see that there is a way to ask an index for the number of
documents it currently has indexed, via documentCount() in the
IStatistics interface, but I can't a good way get back all objects  
that

have been indexed.


The intid utility kinda sorta does what you want, depending on how  
careful you were in your intid use.


zc.catalog's extents do exactly what you want, but it doesn't sound  
like you are using that right now.


Gary

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


Re: [Zope3-Users] query all objects in catalog

2008-03-06 Thread Robert Marianski
On Thu, Mar 06, 2008 at 02:11:40PM -0500, Gary Poster wrote:

 On Mar 6, 2008, at 1:42 PM, Robert Marianski wrote:

 Is there a way to query a zope3 catalog for all objects that have been
 indexed? I see that there is a way to ask an index for the number of
 documents it currently has indexed, via documentCount() in the
 IStatistics interface, but I can't a good way get back all objects that
 have been indexed.

 The intid utility kinda sorta does what you want, depending on how careful 
 you were in your intid use.

I was using grok, so however that set it up. The intid utility did
indeed have all the objects, but it had more objects than were indexed
with the catalog ... so I would have to filter them out myself. Not sure
if that's what you mean.

 zc.catalog's extents do exactly what you want, but it doesn't sound like 
 you are using that right now.

I'm not familiar with extents, I'll give them a look. Thanks.

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


Re: [Zope3-Users] Re: updating a zodb with a SchemaManager

2008-03-06 Thread Lorenzo Gil Sánchez

El jue, 06-03-2008 a las 09:11 +0100, Jürgen Kartnaller escribió:
 
  
  Has anyone ever reached a similar situation? Any solution?
 
 You can do this on your instance :
 
   del obj.__dict__['attr1']
 

Oh, so stupidly simple and it did the job perfectly :-)

Thanks Jürgen!

Lorenzo

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


Re: [Zope3-Users] Re: updating a zodb with a SchemaManager

2008-03-06 Thread Fred Drake
On Thu, Mar 6, 2008 at 3:11 AM, Jürgen Kartnaller [EMAIL PROTECTED] wrote:
  You can do this on your instance :

   del obj.__dict__['attr1']

Of course, if that's *all* you do to it, you'll need to set the
changed flag yourself:

obj._p_changed = True


  -Fred

-- 
Fred L. Drake, Jr.fdrake at gmail.com
Chaos is the score upon which reality is written. --Henry Miller
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] query all objects in catalog

2008-03-06 Thread Gary Poster


On Mar 6, 2008, at 2:18 PM, Robert Marianski wrote:


On Thu, Mar 06, 2008 at 02:11:40PM -0500, Gary Poster wrote:


On Mar 6, 2008, at 1:42 PM, Robert Marianski wrote:

Is there a way to query a zope3 catalog for all objects that have  
been

indexed? I see that there is a way to ask an index for the number of
documents it currently has indexed, via documentCount() in the
IStatistics interface, but I can't a good way get back all objects  
that

have been indexed.


The intid utility kinda sorta does what you want, depending on how  
careful

you were in your intid use.


I was using grok, so however that set it up. The intid utility did
indeed have all the objects, but it had more objects than were indexed
with the catalog ... so I would have to filter them out myself. Not  
sure

if that's what you mean.


Yup.

zc.catalog's extents do exactly what you want, but it doesn't sound  
like

you are using that right now.


I'm not familiar with extents, I'll give them a look. Thanks.


You can either be more careful about what you put in your intid  
utility (the standard Zope 3 subscribers are more indiscriminate than  
you might expect), or you can set up an extent on your catalog that  
filters out what you don't want and use that.


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


Re: [Zope3-Users] clearing grouped widgets in z3c.form

2008-03-06 Thread John
Widgets are cleared because after zope processes the editform (with Done 
or Delete button pressed), the selectedItem in the table becomes None, 
so the addform is then displayed.  In the example, the addform and 
editform have distinct prefixes, so their fields have distinct names in 
the request object.  In particular, the editform doesnt set any of the 
addform's fields in the request object, so the addform returns with 
empty/default field values.


The problem is that widgets of grouped fields get the BaseForm's form. 
prefix, so the group's widgets in the edit and add forms have the same 
key in the request object and thus the editform's grouped widgets are 
named the same as the addform's widgets, so those widget's editform 
values show up in the addform.  (In contrast, non-grouped widgets have 
the add. vs edit. prefix of their parent form.)


One way to fix this is to give groups the prefix of their parentForm.  
Groups already pass their prefix along to the widgets they create, so 
those widgets would no longer be prefixed with BaseForm's form. 
prefix.  Alternatively, setting ignoreRequest=True for the addform (so 
that the addform ignores the insufficiently-distinctly-named values in 
the request object) may work sometimes (addforms can often ignore 
requests) but seems less correct.


Proposed fix: in z3c/form/group.py, class Group, method updateWidgets, 
anywhere before self.widgets.update() (or after self.parentForm is 
assigned in __init__), add line:

self.prefix = util.expandPrefix(self.parentForm.prefix)
(and of course from z3c.form import util)

John


John wrote:
In modifying the formdemo/addressbook example to use groups, I found 
that fields in groups are not cleared to their default values when the 
Done or Delete button is pressed in the editform, resulting in an 
addform with values from the previous editform.  Fields that are not 
in groups are cleared (as in the original example, which had no 
groups); only fields in groups have this problem.  How can I fix 
this?  And more generally, how are widgets cleared?


Relevant code is attached.  The editform class is below.

thanks!

---
class CarEditForm(group.GroupForm,form.EditForm):
 form.extends(group.GroupForm,form.EditForm)
 noChangesMessage = None
 fields = field.Fields(ICar).select('nPassengers')
 groups=(carGroup1,)
 prefix = 'car.edit.'
 @button.buttonAndHandler(u'Delete')
 def handleDelete(self, action):
   # Delete the item from the address book
   item = self.getContent()
   addressbook = item.__parent__
   del addressbook[item.__name__]
   # Reset the selected item
   ISession(self.request)[SESSION_KEY]['selectedItem'] = None
 @button.buttonAndHandler(u'Done')
 def handleDone(self, action):
   # Reset the selected item
   ISession(self.request)[SESSION_KEY]['selectedItem'] = None
---



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

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


[Zope3-Users] plz help to convert pdf report in landscape using z3c.ml

2008-03-06 Thread rahul bhaskar
Hi,
  I am using  Z3C.RML for creating PDF report. But i wants to create
it in landscape mode. please help me regarding this.

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