Re: [Zope-dev] mounting obj to more than one zodb location
Shane Hathaway wrote: It depends on the product you use for mounting, but generally you'll get a shared database with independent connections. So it will work, but if you make conflicting changes, the transaction should fail. Oooo... was this thread about mounted databases? Sorry, I got the wrong end of the stick ;-) Chris ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Implementing a URL path resolver
Hi guys, I've been tinkling with a function that does what REQUEST.resolve_url does, except without it relying on having a REQUEST instance available. That is, just resolving the path itself, something like this: path ÿstring.split(relative_url, '/') path ÿfilter(None, path) new_path ÿ'%s' % path[0] path ÿpath[1:] for element in path: new_path ÿnew_path + "['%s']" % element return eval("self%s" % new_path) Now, neither []- or .-like evaluation of the path works.. Any ideas? Cheers, Morten ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Implementing a URL path resolver
[EMAIL PROTECTED] wrote: Hi guys, I've been tinkling with a function that does what REQUEST.resolve_url does, except without it relying on having a REQUEST instance available. Have you seen the methods restrictedTraverse and unrestrictedTraverse in lib/python/OFS/Traversable.py ? These would seem to do what you need. The methods restrictedTraverse is available from DTML. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Implementing a URL path resolver
[[EMAIL PROTECTED]] (Bug in the encoding of the message, MHA) | path = string.split(relative_url, '/') | path = filter(None, path) | new_path = '%s' % path[0] | path = path[1:] | | for element in path: | | new_path = new_path + "['%s']" % element | | return eval("self%s" % new_path) -Morten ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Implementing a URL path resolver
[Steve Alexander] | Have you seen the methods restrictedTraverse and unrestrictedTraverse in | lib/python/OFS/Traversable.py ? Exactly what I needed. Thank you. -Morten ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] MountedFileStorage
I've just been trying out the MountedFileStorage product (by Anthony Baxter) with Zope 2.3. I've got it mostly working, by patching a couple of typos, and making the SubApplication class derive from Traversable before Application. I've *almost* got ZClasses defined in the root storage working in a mounted storage, but there are still a few issues there. What product is DC using for the mounted storages on zope.org? Can I get a copy of it? I don't see any undo records for objects in the mounted storage. It is a FileStorage, so I reckon they should be there. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] skinscript and URL traversal question
Hi all, I originally posted this to the zope list and, upon suggestion, I am reposting it to zope-dev. I'm using a zsql method in a skinscript with query ... compute ... and it mostly works. Retrieving the dataskin with getItem() works. For example, Cid is the id of the coupon dataskin. dtml-with "getItem(Cid)" dtml-var couponattributes /dtml-with Trying to access the object directly through URL traversal fails. http://CouponSite/CouponManager/977931214.694/CouponDetails Where: CouponManager is a specialist 977931214.694 is the id of the coupon dataskin CouponDetails displays the coupon attributes with: dtml-var couponattributes It returns a not found error. The CouponManager specialist can't find the coupon 977931214.694. Any thoughts why this is so? SkinScript Trigger: WITH QUERY searchByNameCheck(self.id) COMPUTE name,username,coupon_text,categorylist,categoryheader,expirationdate,status,couponterms PythonMethod: searchByNameCheck paramsself,nameparams Cname=name result=self.searchBy_Name(name=Cname) #zsql method return result Error Type: NotFound Error Value: None Traceback (innermost last): File /usr/local/etc/Zope2d/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /usr/local/etc/Zope2d/lib/python/ZPublisher/Publish.py, line 187, in publish File /usr/local/etc/Zope2d/lib/python/Zope/__init__.py, line 221, in zpublisher_exception_hook (Object: ProviderContainer) File /usr/local/etc/Zope2d/lib/python/ZPublisher/Publish.py, line 162, in publish File /usr/local/etc/Zope2d/lib/python/ZPublisher/BaseRequest.py, line 338, in traverse File /usr/local/etc/Zope2d/lib/python/Products/ZPatterns/Specialists.py, line 25, in __bobo_traverse__ (Object: ProviderContainer) NotFound: (see above) Zope version: Zope 2.2.1 (source release, python 1.5.2, linux2) System Platform: freebsd4 -thanks, Aaron ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Calling HTMLFiles
Hi, I'm having difficulties calling an HTML file from python.. Here's the code: [...] from events import conflicting_events calendar_event_add_redirect = HTMLFile('calendar_event_add_redirect', globals()) manage_add_calendar_event_form = HTMLFile('calendar_event_add', globals()) conflicting_events_dialogue = HTMLFile('calendar_event_conflicting_events_dialogue', globals()) # These two expand into seconds expand_hour = lambda x: x * 60 * 60 expand_minute = lambda x: x * 60 def manage_add_calendar_event(self, title='', note='', alarm=0, start=0, end=0, priority=0, status=0, REQUEST=None, RESPONSE=None): "Add an instance of the calendar_event class." new_id = str(self.get_unique_id()) if REQUEST: alarm = expand_hour(REQUEST['alarm_hour']) + \ expand_minute(REQUEST['alarm_minute']) start = expand_hour(REQUEST['start_hour']) + \ expand_minute(REQUEST['start_minute']) end = expand_hour(REQUEST['end_hour']) + \ expand_minute(REQUEST['end_minute']) title = REQUEST['title'] note = REQUEST['note'] priority = REQUEST['priority'] status = REQUEST['status'] conflicting_events_ = self.check_timespan( self.getParentNode().getParentNode().id, self.getParentNode().id, self.id, start, end) if conflicting_events_: return conflicting_events_dialogue(self, REQUEST) [...] Now, if there are any conflicting events, the HTMLFile is returned, with some parameters passed along. What I'm wondering about is how can I pass the variables defined in the REQUEST so that they can be looked up with dtml-code in the conflicting_events_dialogue? And doing it without raising KeyErrors on DTMLMethod that are called from within the conflicting_events_dialogue? Thanks. -Morten ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] MountedFileStorage
Steve Alexander wrote: I've just been trying out the MountedFileStorage product (by Anthony Baxter) with Zope 2.3. I've got it mostly working, by patching a couple of typos, and making the SubApplication class derive from Traversable before Application. I've *almost* got ZClasses defined in the root storage working in a mounted storage, but there are still a few issues there. What product is DC using for the mounted storages on zope.org? Can I get a copy of it? http://www.zope.org/Members/hathawsh/ExternalMount ExternalMount is simpler and more flexible than MountedFileStorage. However, a feature of MountedFileStorage is that it lets you try to mount the root of a ZODB. For various reasons, that is a Bad Idea. That's why it has all the "subapplication" stuff, which ExternalMount doesn't need because it won't let you mount the root of a ZODB. Instead, you mount a subobject. The application object in Wikis.fs on zope.org contains a folder called "Wikis". That folder is what gets mounted; whatever else is in Wikis.fs (like a Control_Panel, an acl_users, etc) is ignored. I think you'll find that if you set up your mounted databases this way, you'll get the reliability you're looking for. I don't see any undo records for objects in the mounted storage. It is a FileStorage, so I reckon they should be there. Currently, undo and mounted databases don't mix. You can only undo transactions on the root database. Besides that, there's the problem of coordinating the undo of transactions that span multiple databases--should it be done and how? Mounted databases are interesting and, for the most part, robust, but they aren't fully integrated with some of Zope's capabilities yet. Shane ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Fw: PythonMethods and ZClass generation problem
Sorry if I'm overstepping any bounds here, but I tried posting this to the main list, but the answers I get do not help me. I figured maybe somebody on the PTK- or the Dev-list might be able to help. This is a bit of a crisis, since our site has been down for a week due to this problem. I also discovered that Zope 2.3 has PythonScript which has the "context" object. Would this be of any help in the following problem? Just a thought. This is my original posting: Hi, We recently decided to use LoginManager for authentication on our site, and refactored our user registration methods to use PythonMethods instead of DTML. Now, during the registration of a user, we want to add a ZClass instance in the correct folder. This object is a representation of some of the information the user provides when he registers with us. But we have stumbled across a problem. This is probably a very basic and simple problem, but I couldn't find any info on it on zope.org, and none of the people on IRC could help us either. So I'll try this posting instead. :) What we're trying to do is to add a ZClass instance/object programmatically from a PythonMethod. Our constructor is called Artist_add, and resides in our product "Artist". The constructor uses variables that we have set in the REQUEST object. So the process is like this: User fills out form with variables that are put in REQUEST | Form calls "registerartist", which is a PythonMethod | "registerartist" creates the user | "registerartist" tries to call the constructor of our Artist ZClass to add an Artist object in our "artists" folder, but fails. To add the Artist object we tried to call the constructor in the following way from "registerartist": return self.artists.manage_addProduct['Artist'].Artist_add(_.None,_) but then the REQUEST object was not available, and the object creation fails since it can't find the variables it needs. The traceback for this was: File string, line 41, in registerartist (Object: ApplicationDefaultPermissions) File /usr/local/zope/lib/python/OFS/DTMLMethod.py, line 168, in __call__ (Object: Artist_add) File /usr/local/zope/lib/python/DocumentTemplate/DT_String.py, line 531, in __call__ (Object: Artist_add) IndexError: (see above) So we tried a different approach: return self.artists.manage_addProduct['Artist'].Artist_add(_.None,REQUEST) This solved the problem with REQUEST not being available, we can view its variables now, but now we can't access Artist.createInObjectManager. The error message we get is: "NameError Artist". So, I guess the question is: how can I add a ZClass instance programmatically from a PythonMethod based on data in the REQUEST object? Additional version info: Zope 2.2.4 PythonMethod 0-1-7 LoginManager 0-8-8b1 ZPatterns 0-4-3b1 DataSkinAddons 0-0-2 Membership 0.7.8 Thanks in advance, Alexander. ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] MountedFileStorage
http://www.zope.org/Members/hathawsh/ExternalMount Sound interesting. Is it possible to mount a read-only database from several different Zope-clients? Regards, Johan ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] MountedFileStorage
Johan Carlsson wrote: http://www.zope.org/Members/hathawsh/ExternalMount Sound interesting. Is it possible to mount a read-only database from several different Zope-clients? Yes. The database should be inside a ZEO storage server. ExternalMount can mount ZEO ClientStorages (that's how www.zope.org/Wikis works) and AFAIK you have the opportunity to provide a "read-only" parameter to the storage or the database. In fact, when you mix in ZEO you can mount the database on one client while using it as the root database on another client. That way you can get around the lack of undo. Shane ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Q: how to retrieve transactions from a Data.fs fragment?
Yes We experienced a nasty confluence of suprises: - CanOfRaid is imperfect, - reiserfsck is imperfect, - our backups were imperfect [We already knew we were imperfect.] The result is that all we have left of about 6 weeks of several peoples development effort is two Data.fs scraps recovered from a reiser fs by one of the reiser developers. We also have an intact 2 month old Data.fs which we would like to update with whatever we can retrieve from these two scraps. Fragment#1 is 187MB where the first 147MB is nothing but nulls and the remainder is stuff that satisfies a tranalyzer rigged to not gag because of the missing leading 'FS21'. The offsets within Fragment#1 are all correct. That is, each transaction at the location in the file it thinks it ought to be. Fragment#2 is 600KB and has about 500K of nulls at the beginning. I am not yet sure if the offsets are 'proper' in it. I presume that these nulls are artifacts of the restoration process from the reiserfs. So my question is: What is the best strategy for getting the Folders, DTML Methods, DTML Documents and ZSQL Methods contained in these Data.fs fragments safely back into production? Just to get the ball rolling I have a done a evening's worth of experimenting with tranalyzer to evaluate the state of these fragments and explore strategies for getting their contents back into service. It seems that it will not work to simply append these zope transaction records to the end of a Data.fs because these transaction records have offset data built into them (the backpointer). Some form of any of the following could get the job done, but which one? Is there some better approach? An existing tool? Guru wisdom appreciated... Plan 1 == Simply massage the data so it has the right offset values and then tack it on the end of the old Data.fs. Cons: What will happen with transactions which are edits of missing objects? Plan 2 == Have the data drive a program which interacts with a running ZODB and replays the transactions. Several ways to do this come to mind... a) write an http client to perform the operations against a normal, running Zope b) write a tool which uses FileStorage.py to read the frag and write to the clean Data.fs Plan 3 == Make a human readable form suitable for cut and pasting into zope via the regular management screens. Cons: - Final refuge of the damned because of the redundancy of the data in Data.fs, each update being present... - Besides, it just isn't "lazy" enough. Shawn MurphyResearch and Development mailto:[EMAIL PROTECTED] Emergence by Design work://1.780.413.6397 http://www.emergence.com ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: [Zope-PTK] Fw: PythonMethods and ZClass generation problem
From: "Shane Hathaway" [EMAIL PROTECTED] You were *SO* close. :-) I think you want this: return self.artists.manage_addProduct['Artist'].Artist_add(_.None,_) to be like this: return self.artists.manage_addProduct['Artist'].Artist_add(_.None,_,REQUEST) Tried both of those already. When testing it, and Artist_add contains nothing but "dtml-var REQUEST" (so nothing else can be wrong), I get: KeyError: REQUEST and the traceback looks like this: File string, line 41, in registerartist (Object: ApplicationDefaultPermissions) File /usr/local/zope/lib/python/OFS/DTMLMethod.py, line 168, in __call__ (Object: Artist_add) File /usr/local/zope/lib/python/DocumentTemplate/DT_String.py, line 528, in __call__ (Object: Artist_add) KeyError: (see above) Thanks for you suggestions so far, Alexander. ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] Re: [Zope-PTK] Fw: PythonMethods and ZClass generation problem
Alexander Limi wrote: From: "Shane Hathaway" [EMAIL PROTECTED] You were *SO* close. :-) I think you want this: return self.artists.manage_addProduct['Artist'].Artist_add(_.None,_) to be like this: return self.artists.manage_addProduct['Artist'].Artist_add(_.None,_,REQUEST) Tried both of those already. When testing it, and Artist_add contains nothing but "dtml-var REQUEST" (so nothing else can be wrong), I get: KeyError: REQUEST and the traceback looks like this: File string, line 41, in registerartist (Object: ApplicationDefaultPermissions) File /usr/local/zope/lib/python/OFS/DTMLMethod.py, line 168, in __call__ (Object: Artist_add) File /usr/local/zope/lib/python/DocumentTemplate/DT_String.py, line 528, in __call__ (Object: Artist_add) KeyError: (see above) Thanks for you suggestions so far, Oh, wait a minute, I see what's going on now. Try this: return self.artists.manage_addProduct['Artist'].Artist_add(self, self.REQUEST) Shane ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )