[TurboGears] Re: Setuptools 0.6a8 update to fix SourceForge problems
Phillip J. Eby wrote: Rob Cakebread wrote: I've got CherryPy-2.1 final installed and it works fine with setuptools 0.6a7 With 0.6a8 I get this: $ tg-admin Traceback (most recent call last): File /usr/bin/tg-admin, line 5, in ? from pkg_resources import load_entry_point File /usr/lib64/python2.4/site-packages/setuptools-0.6a8-py2.4.egg/pkg_resources.py, line 2195, in ? for dist in working_set.resolve( File /usr/lib64/python2.4/site-packages/setuptools-0.6a8-py2.4.egg/pkg_resources.py, line 483, in resolve raise DistributionNotFound(req) # XXX put more info here pkg_resources.DistributionNotFound: CherryPy=2.1.0-rc2 I can import it fine with: python -c import cherrypy -rc2 is a patchlevel version, not a prerelease version. Thus, code that looks for =2.1.0-rc2 wants a version *later* than 2.1.0 final. Your requirement should list =2.1.0 instead. To avoid this problem in future, do not use '-' for prerelease tags; setuptools recognizes '2.1.0rc2' or '2.1.0.rc2' (or '2.1rc2') as equivalent prerelease versions, but '-' means post-release patch. Have you considered using text history file for releases? Then you don't have to guess the order of releases, the file can also describe branches: --- .egg-info/releases.txt ... 2.1a1 2.1.beta1 2.1.beta2 2.1.0-rc2 2.1.0 2.2alpha1 ... [2.1.0 bugfix] # 2.1 bug-fix branch 2.1.1-rc1 2.1.1-rc2 2.1.1 2.1.2-rc1 2.1.2 This way you can restrict upgrades to one branch like 2.1.0 bugfix.
[TurboGears] Re: logout for identity
according to the stack trace, your index method should accept *args, **kw parameters to later parse the passed data
[TurboGears] RuleDispatch version conflict
Hi, I am having a problem to start a server after installing rev207 from svn. I am running win2k. I had TG 0.8a3 and the latest setuptools installed, and then I run: 1. easy_install RuleDispatch 2. setup develop (R207) 3. tg-admin quickstart (created project x) 4. x-start After that I've seen the following: 2005/11/17 10:53:23 CONFIG INFO Server parameters: 2005/11/17 10:53:23 CONFIG INFO server.environment: development 2005/11/17 10:53:23 CONFIG INFO server.logToScreen: True 2005/11/17 10:53:23 CONFIG INFO server.logFile: 2005/11/17 10:53:23 CONFIG INFO server.protocolVersion: HTTP/1.0 2005/11/17 10:53:23 CONFIG INFO server.socketHost: 2005/11/17 10:53:23 CONFIG INFO server.socketPort: 8080 2005/11/17 10:53:23 CONFIG INFO server.socketFile: 2005/11/17 10:53:23 CONFIG INFO server.reverseDNS: False 2005/11/17 10:53:23 CONFIG INFO server.socketQueueSize: 5 2005/11/17 10:53:23 CONFIG INFO server.threadPool: 0 Unhandled exception in thread started by bound method Server._start of cherrypy._cpserver.Server o bject at 0x009951D0 Traceback (most recent call last): File c:\apps\python\lib\site-packages\CherryPy-2.1.0-py2.4-win32.egg\cherrypy\_cpserver.py, line 122, in _start func() File c:\svn\turbogears\trunk\turbogears\startup.py, line 112, in startTurboGears cherrypy.root._cpFilterList.append( turbogears.identity.IdentityFilter() ) File c:\svn\turbogears\trunk\turbogears\identity\filter.py, line 18, in __init__ provider= create_default_provider() File c:\svn\turbogears\trunk\turbogears\identity\__init__.py, line 29, in create_default_provide r return _load_class(providerClass)() File c:\svn\turbogears\trunk\turbogears\identity\provider\soprovider.py, line 25, in __init__ self.module= identity._load_module( self.module ) File c:\svn\turbogears\trunk\turbogears\identity\__init__.py, line 12, in _load_module module= __import__(moduleName) File c:\svn\turbogears\trunk\turbogears\identity\model\somodel.py, line 4, in ? from turbogears.jsonify import * File c:\svn\turbogears\trunk\turbogears\jsonify.py, line 3, in ? pkg_resources.require('RuleDispatch==0.5a') File c:\apps\python\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.py, line 503, in require needed = self.resolve(parse_requirements(requirements)) File c:\apps\python\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.py, line 487, in resolve raise VersionConflict(dist,req) # XXX put more info here pkg_resources.VersionConflict: (ruledispatch 0.5a0.dev-r2100 (c:\apps\python\lib\site-packages\ruled ispatch-0.5a0.dev_r2100-py2.4-win32.egg), Requirement.parse('RuleDispatch==0.5a')) Any idea what went wrong? Thanks.
[TurboGears] Re: About LocalizedSubmitButton.
This is a good point. All widgets should be localized using _(). This is only required for attributes, as the i18n_filter calls gettext on all text in Kid templates(if the i18n.runTemplateFilter option is on). BTW the LocalizedSubmitButton has been moved to i18n/widgets.py, along with some example widget classes.
[TurboGears] i18n documentation
If posted some documentation at the trac wiki: http://trac.turbogears.org/turbogears/wiki/Internationalization Any comments are welcome!
[TurboGears] Wonky internet
My internet connection is acting up, and they wont be able to get a tech out until tomorrow (Friday) morning. That means email from me will be extra sporadic. Also, next week my email availability will be very spotty. I'm going to try to spot and reply to messages about 0.9 development as top priority. Kevin -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: Wonky internet
A suggestion: If anyone is sending an email to Kevin with regards to 0.9 development they should prefix the subject with [TG 0.9] - that way your email will get the attention it needs. :) On 17/11/05, Kevin Dangoor [EMAIL PROTECTED] wrote: My internet connection is acting up, and they wont be able to get a tech out until tomorrow (Friday) morning. That means email from me will be extra sporadic. Also, next week my email availability will be very spotty. I'm going to try to spot and reply to messages about 0.9 development as top priority. Kevin -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: Setuptools 0.6a8 update to fix SourceForge problems
On 11/17/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: --- .egg-info/releases.txt ... 2.1a1 2.1.beta1 2.1.beta2 2.1.0-rc2 2.1.0 2.2alpha1 ... [2.1.0 bugfix] # 2.1 bug-fix branch 2.1.1-rc1 2.1.1-rc2 2.1.1 2.1.2-rc1 2.1.2 This way you can restrict upgrades to one branch like 2.1.0 bugfix. Of course, the trouble is that this file doesn't exist in any project. I think having a standard convention for naming versions is just as easy. Had I know about the -rc2 thing before I packaged up the eggs, I would certainly have just made it 2.1.0rc2 and been done with it. Kevin
[TurboGears] Re: RuleDispatch version conflict
looks like a bug in jsonify.py... that shouldn't be doing a pkg_resources.require(RuleDispatch==0.5a). just removing that line should do the trick. (if someone else could remove that line and commit the change, that'd be good... the library's firewall isn't letting me do svn commands.) Kevin On 11/17/05, xio [EMAIL PROTECTED] wrote: Hi, I am having a problem to start a server after installing rev207 from svn. I am running win2k. I had TG 0.8a3 and the latest setuptools installed, and then I run: 1. easy_install RuleDispatch 2. setup develop (R207) 3. tg-admin quickstart (created project x) 4. x-start After that I've seen the following: 2005/11/17 10:53:23 CONFIG INFO Server parameters: 2005/11/17 10:53:23 CONFIG INFO server.environment: development 2005/11/17 10:53:23 CONFIG INFO server.logToScreen: True 2005/11/17 10:53:23 CONFIG INFO server.logFile: 2005/11/17 10:53:23 CONFIG INFO server.protocolVersion: HTTP/1.0 2005/11/17 10:53:23 CONFIG INFO server.socketHost: 2005/11/17 10:53:23 CONFIG INFO server.socketPort: 8080 2005/11/17 10:53:23 CONFIG INFO server.socketFile: 2005/11/17 10:53:23 CONFIG INFO server.reverseDNS: False 2005/11/17 10:53:23 CONFIG INFO server.socketQueueSize: 5 2005/11/17 10:53:23 CONFIG INFO server.threadPool: 0 Unhandled exception in thread started by bound method Server._start of cherrypy._cpserver.Server o bject at 0x009951D0 Traceback (most recent call last): File c:\apps\python\lib\site-packages\CherryPy-2.1.0-py2.4-win32.egg\cherrypy\_cpserver.py, line 122, in _start func() File c:\svn\turbogears\trunk\turbogears\startup.py, line 112, in startTurboGears cherrypy.root._cpFilterList.append( turbogears.identity.IdentityFilter() ) File c:\svn\turbogears\trunk\turbogears\identity\filter.py, line 18, in __init__ provider= create_default_provider() File c:\svn\turbogears\trunk\turbogears\identity\__init__.py, line 29, in create_default_provide r return _load_class(providerClass)() File c:\svn\turbogears\trunk\turbogears\identity\provider\soprovider.py, line 25, in __init__ self.module= identity._load_module( self.module ) File c:\svn\turbogears\trunk\turbogears\identity\__init__.py, line 12, in _load_module module= __import__(moduleName) File c:\svn\turbogears\trunk\turbogears\identity\model\somodel.py, line 4, in ? from turbogears.jsonify import * File c:\svn\turbogears\trunk\turbogears\jsonify.py, line 3, in ? pkg_resources.require('RuleDispatch==0.5a') File c:\apps\python\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.py, line 503, in require needed = self.resolve(parse_requirements(requirements)) File c:\apps\python\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.py, line 487, in resolve raise VersionConflict(dist,req) # XXX put more info here pkg_resources.VersionConflict: (ruledispatch 0.5a0.dev-r2100 (c:\apps\python\lib\site-packages\ruled ispatch-0.5a0.dev_r2100-py2.4-win32.egg), Requirement.parse('RuleDispatch==0.5a')) Any idea what went wrong? Thanks. -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Reconnect to the database (mysql) when connection goes stale
Hi everyone! I'm about to release an alpha version of my TurboGears project to a client. Working with the framework has been a complete joy and my coworkers are amazed at how quickly I've been able to do the development. I have one small item I need to fix before I can let the client loose: my MySQL connection goes stale due to inactivity every night. I've read the relevant questions on the SQLObject list [1] but those posts are pretty old and I can't figure out how to apply those solutions in a TurboGears context. Has anyone else encountered this issue and dealt with it? Thanks! --Liza [1] http://webwareforpython.org/archives/message/20040422.153550.0d00297e.en.html -- Liza Daly Senior Software Engineer http://www.ifactory.com/
[TurboGears] Re: RuleDispatch version conflict
Kevin Dangoor wrote: looks like a bug in jsonify.py... that shouldn't be doing a pkg_resources.require(RuleDispatch==0.5a). just removing that line should do the trick. (if someone else could remove that line and commit the change, that'd be good... the library's firewall isn't letting me do svn commands.) Kevin Sorry that was code I left in there when I committed Ian's jsonify module. If no one get's to it sooner, I'll remove it this evening. Jeff -- Jeff Watkins http://newburyportion.com/
[TurboGears] Re: RuleDispatch version conflict
Thanks! On 11/17/05, Elvelind Grandin [EMAIL PROTECTED] wrote: It's commited :) On 11/17/05, Kevin Dangoor [EMAIL PROTECTED] wrote: looks like a bug in jsonify.py... that shouldn't be doing a pkg_resources.require(RuleDispatch==0.5a). just removing that line should do the trick. (if someone else could remove that line and commit the change, that'd be good... the library's firewall isn't letting me do svn commands.) Kevin On 11/17/05, xio [EMAIL PROTECTED] wrote: Hi, I am having a problem to start a server after installing rev207 from svn. I am running win2k. I had TG 0.8a3 and the latest setuptools installed, and then I run: 1. easy_install RuleDispatch 2. setup develop (R207) 3. tg-admin quickstart (created project x) 4. x-start After that I've seen the following: 2005/11/17 10:53:23 CONFIG INFO Server parameters: 2005/11/17 10:53:23 CONFIG INFO server.environment: development 2005/11/17 10:53:23 CONFIG INFO server.logToScreen: True 2005/11/17 10:53:23 CONFIG INFO server.logFile: 2005/11/17 10:53:23 CONFIG INFO server.protocolVersion: HTTP/1.0 2005/11/17 10:53:23 CONFIG INFO server.socketHost: 2005/11/17 10:53:23 CONFIG INFO server.socketPort: 8080 2005/11/17 10:53:23 CONFIG INFO server.socketFile: 2005/11/17 10:53:23 CONFIG INFO server.reverseDNS: False 2005/11/17 10:53:23 CONFIG INFO server.socketQueueSize: 5 2005/11/17 10:53:23 CONFIG INFO server.threadPool: 0 Unhandled exception in thread started by bound method Server._start of cherrypy._cpserver.Server o bject at 0x009951D0 Traceback (most recent call last): File c:\apps\python\lib\site-packages\CherryPy-2.1.0-py2.4-win32.egg\cherrypy\_cpserver.py, line 122, in _start func() File c:\svn\turbogears\trunk\turbogears\startup.py, line 112, in startTurboGears cherrypy.root._cpFilterList.append( turbogears.identity.IdentityFilter() ) File c:\svn\turbogears\trunk\turbogears\identity\filter.py, line 18, in __init__ provider= create_default_provider() File c:\svn\turbogears\trunk\turbogears\identity\__init__.py, line 29, in create_default_provide r return _load_class(providerClass)() File c:\svn\turbogears\trunk\turbogears\identity\provider\soprovider.py, line 25, in __init__ self.module= identity._load_module( self.module ) File c:\svn\turbogears\trunk\turbogears\identity\__init__.py, line 12, in _load_module module= __import__(moduleName) File c:\svn\turbogears\trunk\turbogears\identity\model\somodel.py, line 4, in ? from turbogears.jsonify import * File c:\svn\turbogears\trunk\turbogears\jsonify.py, line 3, in ? pkg_resources.require('RuleDispatch==0.5a') File c:\apps\python\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.py, line 503, in require needed = self.resolve(parse_requirements(requirements)) File c:\apps\python\lib\site-packages\setuptools-0.6a8-py2.4.egg\pkg_resources.py, line 487, in resolve raise VersionConflict(dist,req) # XXX put more info here pkg_resources.VersionConflict: (ruledispatch 0.5a0.dev-r2100 (c:\apps\python\lib\site-packages\ruled ispatch-0.5a0.dev_r2100-py2.4-win32.egg), Requirement.parse('RuleDispatch==0.5a')) Any idea what went wrong? Thanks. -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com -- cheers elvelind grandin -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: RuleDispatch version conflict
Nooo. I'm not addicted to reading my mails twice every minute :) On 11/17/05, Jeff Watkins [EMAIL PROTECTED] wrote: Elvelind Grandin wrote: It's commited :) I guess someone *did* get to it sooner. -- Jeff Watkins http://newburyportion.com/ -- cheers elvelind grandin
[TurboGears] Re: Reconnect to the database (mysql) when connection goes stale
Hi Liza, Glad to hear that your project has gone well! If it's going to be publicly available, I'm sure we'd all love to hear more about it when it launches. If this is a MySQL-related issue, I wonder if it would make sense to change SQLObject's MysqlConnection to detect if the underlying DBAPI connection has gone away and do something about it. The concern I'd have there is you'd get really weird behavior if the connection goes away while you're in the middle of a transaction. TurboGears knows if you're using a transaction or not, so we might be able to make a more intelligent decision about it in turbogears.database. I've seen the MySQL connection drops previously when using Java, though I think the Java JDBC driver for mysql had an ?autoReconnect option. Kevin On 11/17/05, Liza [EMAIL PROTECTED] wrote: Hi everyone! I'm about to release an alpha version of my TurboGears project to a client. Working with the framework has been a complete joy and my coworkers are amazed at how quickly I've been able to do the development. I have one small item I need to fix before I can let the client loose: my MySQL connection goes stale due to inactivity every night. I've read the relevant questions on the SQLObject list [1] but those posts are pretty old and I can't figure out how to apply those solutions in a TurboGears context. Has anyone else encountered this issue and dealt with it? Thanks! --Liza [1] http://webwareforpython.org/archives/message/20040422.153550.0d00297e.en.html -- Liza Daly Senior Software Engineer http://www.ifactory.com/ -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Identity documentation
I'm trying to pull together some high-level documentation for identity. The way I see it, an end-user has three basic strategies for using the identity subsystem: 1. Use the default identity provider and model (include the default somodel, which creates separate User, Group, and Permission tables). 2. Use the default identity provider with a customized model, with user-defined tables that subsume one or more of User, Group, and Permission 3. Create a custom identity provider, and just implement the methods required by a provider. Jeff: is this the way you see it? From where I'm standing, #2 seems like the most common case for a typical end user.-- Tim Lesher [EMAIL PROTECTED]
[TurboGears] Re: Adding transactions to @expose
On Wed, 2005-11-16 at 13:45 -0500, Jonathan LaCour wrote: Given that this is also possible, it seems like there are several different ways to do this off the top of my head: 1. WSGI middleware (I think) 2. CherryPy filters 3. SQLObject modifications 4. Decorators 5. Some mixture of the above 1. Unfortunately, CherryPy really only has very basic WSGI support - I don't know of any reasonable way to hook WSGI middleware up to Cherrypy at this point (maybe in a future release). 2. Filters in CherryPy won't work either, they don't allow you to wrap the request and I don't think there is any way to guarantee that they are actually run - especially if an exception occurs. 3. SQLObject modifications would be great, but until they are done we'll need to have an interim solution. 4. Which leaves decorators. My plan now is to implement a transaction decorator which will look something like: def in_transaction(func): hub = AutoConnectHub() def newfunc(*args, **kw): hub.begin() try: func(*args, **kw) except cherrypy.HTTPRedirect: hub.commit() raise except: hub.rollback() raise else: hub.commit() newfunc.func_name = func.func_name newfunc.func_doc = func.func_doc return newfunc The expose decorator will check the config / it's parameters and if a transaction is desired it will wrap itself in the in_transaction decorator. This doesn't give us strict per-request transactions if you have database code in your cherrypy filters. But I think any database code in filters would probably mostly be doing reads, so this doesn't seem to be a huge issue. It is probably possible to monkeypatch CherryPy to give us true per-request transactions if we really need them. The AutoConnectHub.begin method checks to see if we're already in a transaction, so calling one transaction-wrapped method from another will result in them both running in one transaction. I think this is the desired default behavior. If you need more transaction stuff beyond this, you can always write your own decorators to do things like nested transactions. And if there is enough demand we can add support for such things to TG in the future. Of course, if you want you can disable all of this automatic transaction stuff in the config and handle transactions yourself or not use transactions / database at all. Sean Cazzell
[TurboGears] Re: validation_error is going away right?
JW, That is in SVN now - if your method has a has_errors var it will get called instead of validate_error. Sean Cazzell On Thu, 2005-11-17 at 17:02 +, [EMAIL PROTECTED] wrote: I read in a post that validation_error was going away. Kevin said, That's a good point. If we deprecate validation_error, then the method can just be called directly and you can check form_errors to see if there's a problem. I think this also means that an invalid exception would never be raised. It simplifies the code, but it does also eliminate a visual reminder to check for errors. Maybe that's not so bad, though. The idea being that the method being called would receive a has_errors argument. The example Kevin gave is below: @turbogears.expose(input_form=myform) def save(self, name, address, age, has_errors): if has_errors: return self.index() Did this change ever make it into turbo-gears? I've been playing with validators and have really grown to not like the validation_error method of dealing with problems :). I'd really like to know what the new-method will be, if there is going to be one. Thanks, jw
[TurboGears] Re: Forms declarative style
On 11/16/05, Ian Bicking [EMAIL PROTECTED] wrote: Basically this: class MyForm(TableForm): foo1 = TextField() foo2 = TextField() Is exactly equivalent to: MyForm = type(TableForm)('MyForm', (TableForm,), {'foo1': TextField(), 'foo2': TextField}) this is probably a little too wacky, it turns out. Consider this case: class TableForm(Subclassable): def important_behavior(self): print foo TableForm = TableForm() class MyForm(TableForm): def important_behavior(self): print bar type(MyForm) - TableForm MyForm.important_behavior() - TypeError (takes 1 argument, 0 given) Not being able to override behavior would be an evil side effect of it looking like a class but not actually being a class. There's probably a way to bind the function to the instance, is there not? Kevin
[TurboGears] Re: Forms declarative style
Yeah, I've seen those. The order is only a problem because Python gives us the dict... Using the somewhat hacky counter technique plus an ordered dict may do the trick. Kevin On 11/17/05, Sean Cazzell [EMAIL PROTECTED] wrote: Kevin, The Python Cookbook has a couple of ordered dict implementations. Here's one: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/438823 Sean Cazzell On Thu, 2005-11-17 at 11:06 -0500, Kevin Dangoor wrote: On 11/16/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: So for my CRUD requirement, I just use py:for in Kid and still control the order of how those fields appears. And if I later decide to customize the layout in Kid, the same dict can still be used for direct name access. Being able to access in order or as a dictionary is a nice thing. I'll have to keep that in mind. Kevin -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: Reconnect to the database (mysql) when connection goes stale
I've been getting the raw connection from the hub (via hub.getConnection().getConnection()) and invoking ping() in actions before using the database; if the connection is no longer in place, it will reconnect with the last provided connection settings. From MySQLdb.connections: | ping(...) | Checks whether or not the connection to the server is | working. If it has gone down, an automatic reconnection is | attempted. | | This function can be used by clients that remain idle for a | long while, to check whether or not the server has closed the | connection and reconnect if necessary. | | Non-standard.(The code's that running is based on the 0.5 AutoConnectHub; apologies if things have changed in that arena...!)Roger
[TurboGears] MochiKit 1.1 Intro Screencast
I put together an introductory screencast for MochiKit this week, presented via the interactive interpreter example: http://mochikit.com/screencasts/MochiKit_Intro-1 This screencast was recorded with Snapz Pro X 2 and was encoded with QuickTime using the H.264 video and AAC audio codecs. I've confirmed that it's playable with QuickTime 7 and VLC 0.8.2, but may very well be playable elsewhere. It weighs in at 22M for 13:24 at 640x480.. so you can probably stream it with any sort of broadband connection. If it becomes slow for whatever reason, there's a mirror at archive.org: http://www.archive.org/details/MochiKit_Intro-1 A script for the screencast is available here (though there are some minor differences, it's close enough): http://mochikit.com/screencasts/MochiKit_Intro-1.txt The screencast is in the public domain, and I have a lossless version (PNG video encoding, raw audio) available upon request (647M). Snapz Pro X: http://www.ambrosiasw.com/utilities/snapzprox/ QuickTime: http://www.apple.com/quicktime VLC: http://www.videolan.org/ -bob
[TurboGears] Re: Adding transactions to @expose
On 11/17/05, Sean Cazzell [EMAIL PROTECTED] wrote: def in_transaction(func): hub = AutoConnectHub() def newfunc(*args, **kw): hub.begin() try: func(*args, **kw) except cherrypy.HTTPRedirect: hub.commit() raise except: hub.rollback() raise else: hub.commit() newfunc.func_name = func.func_name newfunc.func_doc = func.func_doc return newfunc The expose decorator will check the config / it's parameters and if a transaction is desired it will wrap itself in the in_transaction decorator. Unfortunately, it really needs to use the hub that's in use by the model classes... from a random model.py: __connection__ = AutoConnectHub() # (or PackageHub) class Foo(SQLObject): ... In a multi-application world, it'll be possible to have different parts of a site going to different databases. that won't be the common case, though. Sticking to the common case, we just need a nice way to get ahold of the hub in question. There are probably a small handful of ways we could find the model module and get the hub from it. Unfortunately, I'm out of time for exploring that now, and I'll be offline for a while. I hope I'll be able to get back online at least briefly later today... Kevin
[TurboGears] Re: validation_error is going away right?
It was also noted earlier that has_errors may actually be redundant and can be eliminated in favor of just setting the errors on the request object. Kevin On 11/17/05, Sean Cazzell [EMAIL PROTECTED] wrote: JW, That is in SVN now - if your method has a has_errors var it will get called instead of validate_error. Sean Cazzell On Thu, 2005-11-17 at 17:02 +, [EMAIL PROTECTED] wrote: I read in a post that validation_error was going away. Kevin said, That's a good point. If we deprecate validation_error, then the method can just be called directly and you can check form_errors to see if there's a problem. I think this also means that an invalid exception would never be raised. It simplifies the code, but it does also eliminate a visual reminder to check for errors. Maybe that's not so bad, though. The idea being that the method being called would receive a has_errors argument. The example Kevin gave is below: @turbogears.expose(input_form=myform) def save(self, name, address, age, has_errors): if has_errors: return self.index() Did this change ever make it into turbo-gears? I've been playing with validators and have really grown to not like the validation_error method of dealing with problems :). I'd really like to know what the new-method will be, if there is going to be one. Thanks, jw -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: Reconnect to the database (mysql) when connection goes stale
Sounds like a good thing to build in, because I'm sure you're not the only one who will need it. You haven't had any weirdness with transactions? Kevin On 11/17/05, Roger Espinosa [EMAIL PROTECTED] wrote: I've been getting the raw connection from the hub (via hub.getConnection().getConnection()) and invoking ping() in actions before using the database; if the connection is no longer in place, it will reconnect with the last provided connection settings. From MySQLdb.connections: | ping(...) | Checks whether or not the connection to the server is | working. If it has gone down, an automatic reconnection is | attempted. | | This function can be used by clients that remain idle for a | long while, to check whether or not the server has closed the | connection and reconnect if necessary. | | Non-standard. (The code's that running is based on the 0.5 AutoConnectHub; apologies if things have changed in that arena...!) Roger -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: Wonky internet
Speaking of internet connections - I am going to be out of town until Sunday, on vacation at a place with *no* internet connection, so I'll have to get caught up on the list Sunday night. I'm pretty close to having something ready to commit on the new expose decorator front. Things will be fully backwards compatible (expose will still accept and process validators and inputform args). The big changes are splitting the validators and inputform stuff out of expose into other decorators and adding implicit transaction support to expose. I'll throw up some docs on the wiki prior to committing. Have a nice weekend everyone. Sean Cazzell On Thu, 2005-11-17 at 09:15 -0500, Kevin Dangoor wrote: My internet connection is acting up, and they wont be able to get a tech out until tomorrow (Friday) morning. That means email from me will be extra sporadic. Also, next week my email availability will be very spotty. I'm going to try to spot and reply to messages about 0.9 development as top priority. Kevin -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: MochiKit 1.1 Intro Screencast
Cool - This is something I have been waiting for, and I didn't even know it was coming!
[TurboGears] Eric Lajoie has invited you to open a Google mail account
--- Eric Lajoie has invited you to open a free Gmail account. To accept this invitation and register for your account, visit http://mail.google.com/mail/a-1434b80ddf-a61814fbd4-cca7f80de5 Once you create your account, Eric Lajoie will be notified with your new email address so you can stay in touch with Gmail! If you haven't already heard about Gmail, it's a new search-based webmail service that offers: - Over 2,500 megabytes (two gigabytes) of free storage - Built-in Google search that instantly finds any message you want - Automatic arrangement of messages and related replies into conversations - Text ads and related pages that are relevant to the content of your messages Gmail is still in an early stage of development. But if you set up an account, you'll be able to keep it even after we make Gmail more widely available. We might also ask for your comments and suggestions periodically and we appreciate your help in making Gmail even better. Thanks, The Gmail Team To learn more about Gmail before registering, visit: http://mail.google.com/mail/help/benefits.html (If clicking the URLs in this message does not work, copy and paste them into the address bar of your browser).
[TurboGears] Re: Adding transactions to @expose
On Thu, 2005-11-17 at 12:28 -0500, Kevin Dangoor wrote: Unfortunately, it really needs to use the hub that's in use by the model classes... from a random model.py: __connection__ = AutoConnectHub() # (or PackageHub) class Foo(SQLObject): ... In a multi-application world, it'll be possible to have different parts of a site going to different databases. that won't be the common case, though. Sticking to the common case, we just need a nice way to get ahold of the hub in question. There are probably a small handful of ways we could find the model module and get the hub from it. Unfortunately, I'm out of time for exploring that now, and I'll be offline for a while. I hope I'll be able to get back online at least briefly later today... Kevin, I was worried that I might have to get the hub from the model. I would definitely like to support the multiple-apps case if at all possible. I have to take off as well, I'll look into this more Sunday when I get home. Sean
[TurboGears] Re: validation_error is going away right?
The has_errors variable is used as a flag. If you remove it, then I assume that turbogears.expose would get some kw argument telling it to not call validate_error? Thanks for the replies, y'all. I assume that this feature is not concrete yet, that is it is subject to change. jw
[TurboGears] turbogears.org still shows 0.8a3 as current
The topic in #turbogears suggests that 0.8a4 is available, but it's not currently installable using ez_setup.py.
[TurboGears] Re: turbogears.org still shows 0.8a3 as current
It seems http://www.turbogears.org/downloads/ is now touting 0.8a3 as the current download. Have you rebuilt the site recently by any chance Kevin? ;) On 17/11/05, TML [EMAIL PROTECTED] wrote: The topic in #turbogears suggests that 0.8a4 is available, but it's not currently installable using ez_setup.py.
[TurboGears] Re: turbogears.org still shows 0.8a3 as current
On 11/17/05, TML [EMAIL PROTECTED] wrote: The topic in #turbogears suggests that 0.8a4 is available, but it's not currently installable using ez_setup.py. oops. Thanks for reporting this! Kevin -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Can someone give me a hint about this @turbogears.expose thing?
Hello, I'm very new to TG and relatively new to python. I understand most of it, but something I could not yet get are these @turbogears.expose lines. I understand that it tells Kid which template it should serve, but the syntax is odd. It is executed right before a def - I didn't even know that python allows code there. And what does the @ mean? I could not yet find it in the python documentation (and googling for python @ doesn't really make much sense). I guess it's something really simple, but it would be great if someone could explain it to me. Thanks in advance.
[TurboGears] Re: SVN problem/question
Hmm... everything looks fine with that external definition, as far as I can tell... and it looks like the CP svn server is up. I'm not sure what to say otherwise. However, note that you should be able to use the svn version of TurboGears even if it didn't successfully retrieve the externals. Kevin On 11/17/05, scmikes [EMAIL PROTECTED] wrote: Hello All, I am taking a run at an SVN install so I can check out the widgets for 0.9. I am on windows XP Pro, latest patches running the latest svn when I issue the svn command, turbogears downloads, but it goes out to lunch on cherrypy. It is probably a basic problem, but I am not an SVN guru, any tips are welcome :-) Thanks Mike PS. I have tried this several times with a clean directory - Aturbogears\turbogears\command\__init__.py Aturbogears\setup.cfg U turbogears Fetching external item into 'turbogears\thirdparty\cherrypy' svn: PROPFIND request failed on '/tags/cherrypy-2.1.0' svn: PROPFIND of '/tags/cherrypy-2.1.0': 400 Bad Request (http://svn.cherrypy.or g) D:\pythonpkgs\turbogears_svn -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: validation_error is going away right?
Here's my thinking, if a validation error comes up: - save the errors in the request - if there's a validation_error method, call that with a DeprecationWarning - otherwise just call the original method, which can check for the presence of errors Kevin On 11/17/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: The has_errors variable is used as a flag. If you remove it, then I assume that turbogears.expose would get some kw argument telling it to not call validate_error? Thanks for the replies, y'all. I assume that this feature is not concrete yet, that is it is subject to change. jw -- Kevin Dangoor Author of the Zesty News RSS newsreader email: [EMAIL PROTECTED] company: http://www.BlazingThings.com blog: http://www.BlueSkyOnMars.com
[TurboGears] Re: Forms declarative style
In my TG CRUD work, I generate edit form, view list and view screen from SQLObject. I use the similar approach of Kevin : using *arg or a list in the contrustor of a CompositeWidget. I also add an append() method. Advantages of this solution : * easy to create and extends a form automaticaly ... editWidgetMap = { 'container' : widget4edit.FormWidgetsList, 'default' : widget4edit.TextLineWidget, 'SOStringCol': widget4edit.TextLineWidget, 'SOStringCol+long': widget4edit.TextWidget, 'SOUnicodeCol': widget4edit.TextLineWidget, 'SOUnicodeCol+long': widget4edit.TextWidget, 'SOBoolCol': widget4edit.CheckBoxWidget, 'SOForeignKey' : widget4edit.VocabularyWidget, 'SOEnumCol' : widget4edit.VocabularyWidget, #'SOIntCol':IntWidget, #'SODateTimeCol':DateTimeWidget } def buildWidgetsList(self, sqlobj, widgetmap): @param sqlobj the type (like app.model.Page) for wich create a WidgetContainer @param widgetmap the family of widgets to use for each SQLObject field type back = [] columns = sqlobj.sqlmeta.columns for col in sqlobj.sqlmeta.columnList: name = col.origName clazz = col.__class__.__name__ if (clazz == 'SOStringCol' or clazz == 'SOUnicodeCol') and not(col.length): clazz += '+long' widget = widgetmap.get(clazz, widgetmap['default'])(key=name) if hasattr(widget, 'vocabulary') and (widget.vocabulary is None): if clazz == 'SOForeignKey': referencedsql = findClass(col.foreignKey) widget.vocabulary = SQLVocabulary(referencedsql) elif clazz == 'SOEnumCol': widget.vocabulary = widgetsupport.Vocabulary(col.enumValues) if hasattr(widget, 'defaultValue') and (widget.defaultValue is None): widget.defaultValue = col.enumValues[0] if hasattr(widget, 'required') and (widget.required is None): widget.required = col.notNone if hasattr(widget, 'validator') and (widget.validator is None): widget.validator = col.validator back.append(widget) return widgetmap['container'](*back) #IGNORE:W0142 ... * the WidgetContainer instance could be attach to a SQLObject type. In my case after building a WidgetContainer I do : if not(hasattr(sqlobj, 'editWidget')): #autogeneration of the editwidget sqlobj.editWidget = self.buildWidgetsList(sqlobj, self.editWidgetMap) sqlobj.editWidget.append(widget4edit.HiddenWidget('isNew', validators.Bool(), True)) sqlobj.editWidget.append(widget4edit.HiddenWidget('id', validators.Int(), -1)) * you could create 2 instances of the same WidgetContainer, an each one could have it's own internal state without interference, like 2 instances of TextField... (may be my java background influence me too much, but class state/field are share by all instance, and there is only one class definition available in the system) my 2 cents
[TurboGears] Re: Reconnect to the database (mysql) when connection goes stale
On 11/17/05, Roger Espinosa [EMAIL PROTECTED] wrote: I've been getting the raw connection from the hub (via hub.getConnection().getConnection()) and invoking ping() in actions before using the database; if the connection is no longer in place, it will reconnect with the last provided connection settings. Great, I've stuffed this into my application and hopefully it will do the trick. Thanks very much! I'd love to share the project but unfortunately it's a back-end application. I'm not quite brave enough to deploy alpha software on a public-facing commercial site. :) --Liza
[TurboGears] Re: Reconnect to the database (mysql) when connection goes stale
On 11/17/05, Kevin Dangoor [EMAIL PROTECTED] wrote: Sounds like a good thing to build in, because I'm sure you're not theonly one who will need it.It really turned out to be a red herring for me (this was in my how completely do I not understand threading? week). How do other databases handle this? I got the idea from Apache::DBI, which pings any cached database handlers before invoking your method. You haven't had any weirdness with transactions?Can't say --- so far, this application is strictly read-only and I'm not using SQLObject for anything other than the connection. If I were writing, the ping would happen before I started the transaction (this is me, falling in the let me control my own transactions, thank you camp ;-) Roger
[TurboGears] Re: Forms declarative style
Kevin Dangoor wrote: On 11/16/05, Ian Bicking [EMAIL PROTECTED] wrote: Basically this: class MyForm(TableForm): foo1 = TextField() foo2 = TextField() Is exactly equivalent to: MyForm = type(TableForm)('MyForm', (TableForm,), {'foo1': TextField(), 'foo2': TextField}) this is probably a little too wacky, it turns out. Consider this case: class TableForm(Subclassable): def important_behavior(self): print foo TableForm = TableForm() class MyForm(TableForm): def important_behavior(self): print bar type(MyForm) - TableForm MyForm.important_behavior() - TypeError (takes 1 argument, 0 given) Not being able to override behavior would be an evil side effect of it looking like a class but not actually being a class. There's probably a way to bind the function to the instance, is there not? import new, types for attr, value in new_attrs.values(): if isinstance(value, types.FunctionType): setattr(self, attr, new.instancemethod(value, self, self.__class__) These are things that I think are worthy of exploration, but you have to be ready to back them out if they don't pan out. -- Ian Bicking / [EMAIL PROTECTED] / http://blog.ianbicking.org
[TurboGears] Multiple databases and servers
An SQLObject question I suppose: Is it possible to use multiple databases, and better yet multiple database servers?
[TurboGears] Re: Access modules outside Turbogears
On 11/17/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I need to use my SQLObject models from outside TurboGears.I'm using something like: import turbogearsturbogears.database.set_db_uri('mysql:.','mymodule')from mymodule import modelBut I get the error:error:KeyError: 'No database configurarion found!' Oddly, I just went through that. While this works, I make no guarantee that it is the 'correct' way to do it.import syssys.path.append(d:/grimmlabs/grimmlabs/grimmlabs)import turbogears.database turbogears.database.set_db_uri(postgres://postgres:[EMAIL PROTECTED]/project)(the same URI as in your config file)from model import hub, class1, class2, etc That worked for me.-- Things fall apart. The Center cannot hold.- Life as a QA geek, in a nutshell.Best,Jeff
[TurboGears] Re: Access modules outside Turbogears
In a fresh interactive interperter: import turbogears.database turbogears.database.set_db_uri(mysql://:[EMAIL PROTECTED]:3306/tg_wiki20copy,wiki20) from wiki20 import model print model.Page.byPagename(FrontPage).data Page 28 pagename='FrontPage' dateAdded=None dateModified='datetime.datetime...) ' data='...' I'm sorry but I can't replicate youre problem. The method presented should worked fine.
[TurboGears] Re: Access modules outside Turbogears
Hello, Thanks for the information... In fact I had a problem in the configuration. This steps worked fine. Thanks.
[TurboGears] errors on quickstart
This is probably something very simple, but all this easy_install and egg stuff is confusing me :-( So I did a svn up, python setup.py develop, and tg-admin quickstart. At the end of the command, I get: unning /usr/bin/python setup.py egg_info Error (exit code: 1) Traceback (most recent call last): File setup.py, line 2, in ? from turbogears.finddata import find_package_data File /home/diwaker/software/turbogears/turbogears/__init__.py, line 11, in ? from turbogears import startup File /home/diwaker/software/turbogears/turbogears/startup.py, line 8, in ? pkg_resources.require(TurboGears) File /usr/lib/python2.4/site-packages/setuptools-0.6a8-py2.4.egg/pkg_resources.py, line 503, in require needed = self.resolve(parse_requirements(requirements)) File /usr/lib/python2.4/site-packages/setuptools-0.6a8-py2.4.egg/pkg_resources.py, line 487, in resolve raise VersionConflict(dist,req) # XXX put more info here pkg_resources.VersionConflict: (CherryPy 2.1.0-rc2 (/usr/lib/python2.4/site-packages/CherryPy-2.1.0_rc2-py2.4.egg), Requirement.parse('CherryPy=2.1.0,!=2.1.0-beta,!=2.1.0-rc1,!=2.1.0-rc2')) Traceback (most recent call last): File /usr/bin/tg-admin, line 7, in ? sys.exit( File /home/diwaker/software/turbogears/turbogears/command/__init__.py, line 233, in main command.run() File /home/diwaker/software/turbogears/turbogears/command/quickstart.py, line 89, in run command.run(cmd_args) File /usr/lib/python2.4/site-packages/PasteScript-0.3.1-py2.4.egg/paste/script/command.py, line 176, in run result = self.command() File /usr/lib/python2.4/site-packages/PasteScript-0.3.1-py2.4.egg/paste/script/create_distro.py, line 94, in command cwd=output_dir) File /usr/lib/python2.4/site-packages/PasteScript-0.3.1-py2.4.egg/paste/script/command.py, line 474, in run_command raise OSError(Error executing command %s % cmd) OSError: Error executing command /usr/bin/python It seems I'm missing something related to CherryPy and PasteScript. I tried doing a 'python setup.py install' in thirdparty/cherrypy, that didn't help. I also tried easy_install -U PasteScript CherryPy, that didn't help either. Any ideas? TIA :) -- Web/Blog/Gallery: http://floatingsun.net
[TurboGears] Re: errors on quickstart
Diwaker Gupta wrote: pkg_resources.VersionConflict: (CherryPy 2.1.0-rc2 (/usr/lib/python2.4/site-packages/CherryPy-2.1.0_rc2-py2.4.egg), Requirement.parse('CherryPy=2.1.0,!=2.1.0-beta,!=2.1.0-rc1,!=2.1.0-rc2')) This message says that CherryPy 2.1.0-rc2 conflicts with the specified requirement, which explicitly excludes 2.1.0-rc2 ('!=2.1.0-rc2'). Delete the conflicting egg (/usr/lib/python2.4/site-packages/CherryPy-2.1.0_rc2-py2.4.egg) and then run: easy_install 'CherryPy=2.1.0,!=2.1.0-beta,!=2.1.0-rc1,!=2.1.0-rc2' Notice that this is just pasting the requirement from the error message above (in quotes so the shell won't think the is a redirect). This problem is being caused by the 2.1.0-rc2 version number, which setuptools thinks is a post-release patch rc2 of 2.1.0, not a prerelease release candidate (which would be spelled 2.1.0rc2 or 2.1.0.rc2). As a result, it thinks the egg you have is newer than the one that's needed, when in fact it's older. Kevin, Ian: if I may make a suggestion... it might be easiest to fix this issue in the field by releasing a CherryPy 2.1.1, and making TurboGears and PasteScript depend on that, rather than trying to get people to fix their individual installs like this. Meanwhile, I'll continue doing penance for not having put prominent enough documentation in the setuptools manual about how version number parsing works. (It's buried in the pkg_resources docs under Parsing Utilties at the moment.)
[TurboGears] Re: Access modules outside Turbogears
On 11/17/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: This steps worked fine.Something I just noticed, though, is that when I change the database from an external source, it doesn't get reflected by TG's presentation to the web until the server is restarted. I imagine this is a side-effect of caching, but I'm not sure. -- Things fall apart. The Center cannot hold.- Life as a QA geek, in a nutshell.Best,Jeff
[TurboGears] Re: errors on quickstart
Thanks Phillip, that worked perfectly! -- Web/Blog/Gallery: http://floatingsun.net
[TurboGears] Re: Forms declarative style
Love to se something like that =) Cheers Ronald On Nov 18, 2005, at 6:55 AM, Michael Schneider wrote: Can take a STAN-like approach for building DOM fragments that we could pass to kid?? I will try to work up an example. Here is a nice over link of stan http://www.kieranholland.com/prose/meet-stan/ Thanks Mike PS. Divmod uses formless to render forms, I have not used formless yet, so I have not input on that system. Ronald Jaramillo mail: ronald AT checkandshare DOT com blog: http://www.checkandshare.com/blog
[TurboGears] problems with sql create now
Hey guys, Sorry to be such a dumb ass, but I'm having a really hard time with all the setuptools dependency stuff. Now I get the following error (I'm trying to run Jeff's identity sample) on tg-admin sql create: Traceback (most recent call last): File /usr/bin/tg-admin, line 7, in ? sys.exit( File /home/diwaker/software/turbogears/turbogears/command/__init__.py, line 233, in main command.run() File /home/diwaker/software/turbogears/turbogears/command/__init__.py, line 116, in run command.the_runner.run(sys.argv) File /usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/manager/command.py, line 102, in run runner.run() File /usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/manager/command.py, line 232, in run self.load_options_from_egg(egg_spec) File /usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/manager/command.py, line 415, in load_options_from_egg dist, conf = self.config_from_egg(egg_spec) File /usr/lib/python2.4/site-packages/SQLObject-0.7.0-py2.4.egg/sqlobject/manager/command.py, line 425, in config_from_egg pkg_resources.require(egg_spec) File /usr/lib/python2.4/site-packages/setuptools-0.6a8-py2.4.egg/pkg_resources.py, line 503, in require needed = self.resolve(parse_requirements(requirements)) File /usr/lib/python2.4/site-packages/setuptools-0.6a8-py2.4.egg/pkg_resources.py, line 487, in resolve raise VersionConflict(dist,req) # XXX put more info here pkg_resources.VersionConflict: (TurboGears 0.9a0dev-r215 (/home/diwaker/software/turbogears), Requirement.parse('TurboGears=0.9a0')) -- Web/Blog/Gallery: http://floatingsun.net