pylons

Pyramid.security questions: Double cookies? Insecure cookies? Expiration?

China☆狼群 提交于 2019-12-06 23:04:53
问题 I'm taking my first foray into the Pyramid security module. I'm using this login code to set the auth_tkt: @view_config(route_name='LoginForm', request_method='POST', renderer='string') class LoginForm(SimpleObject): def __call__(self): emailAddress = self.request.params.get('emailAddress') password = self.request.params.get('password') if emailAddress != 'testemail@gmail.com' or password != 'testpassword': errorDictionary = { 'message' : "Either the email address or password is wrong." }

Disable browser caching in pylons

荒凉一梦 提交于 2019-12-06 13:38:38
I'm have an action /json that returns json from the server. Unfortunately in IE, the browser likes to cache this json. How can I make it so that this action doesn't cache? Make sure your responses are not telling the browser that the content expires in the future. There are two HTTP headers the control this. Expires Cache-Control - There are many possible values for this header, but the one that controls expiration is max-age=foo. In addition, IE may be revalidating. This means that IE includes some extra information in the request that tell the web server what version of the resource it has

“Win32 exception occurred releasing IUnknown at…” error using Pylons and WMI

送分小仙女□ 提交于 2019-12-06 12:37:42
Im using Pylons in combination with WMI module to do some basic system monitoring of a couple of machines, for POSIX based systems everything is simple - for Windows - not so much. Doing a request to the Pylons server to get current CPU, however it's not working well, or atleast with the WMI module. First i simply did (something) this: c = wmi.WMI() for cpu in c.Win32_Processor(): value = cpu.LoadPercentage However, that gave me an error when accessing this module via Pylons ( GET http://ip:port/cpu ): raise x_wmi_uninitialised_thread ("WMI returned a syntax error: you're probably running

How to check what permission failed in authorization in pyramid (pylons 2)?

拟墨画扇 提交于 2019-12-06 12:11:24
I add a view for the forbidden view: from pyramid.exceptions import Forbidden config.add_view(forbidden_view, context=Forbidden) which redirects to a log in screen. But now i added some admin things which needed admin access, and I want to just show a "you don't have the permission" screen, how do I check for that in the forbidden view? I'm afraid that information is lost when Pyramid raises a Forbidden error as the result of a permission denial. There's an item in the TODO.txt to carry it along through the Forbidden error. 来源: https://stackoverflow.com/questions/4916149/how-to-check-what

benchmarking PHP vs Pylons

依然范特西╮ 提交于 2019-12-06 08:27:44
I want to benchmark PHP vs Pylons. I want my comparison of both to be as even as possible, so here is what I came up with: PHP 5.1.6 with APC, using a smarty template connecting to a MySQL database Python 2.6.1, using Pylons with a mako template connecting the the same MySQL database Is there anything that I should change in that setup to make it a more fair comparison? I'm going to run it on a spare server that has almost no activity, 2G of ram and 4 cores. Any suggestions of how I should or shouldn't benchmark them? I plan on using ab to do the actual benchmarking. Related Which is faster,

Python try/except … function always returns false

允我心安 提交于 2019-12-06 02:40:16
I'm trying to figure out the problem in this short paragraph of code. Any help would be appreciated. Regardless of what I specify User.email to be, it always returns false. def add(self): #1 -- VALIDATE EMAIL ADDRESS #Check that e-mail has been completed try: #Validate if e-mail address is in correct format if (isAddressValid(self.email) == 0): self.errors['email'] = 'You have entered an invalid e-mail address'; return 0 except NameError: self.errors['email'] = 'Please enter your e-mail' return 0 >>> u = User() >>> u.email = 'test@example.com' >>> u.add() 0 >>> print u.errors {'email': 'Please

Changing database per view & accessing multiple databases per view

不问归期 提交于 2019-12-05 18:02:16
I'm having some problems using SQLAlchemy in Pyramid. Although I can find examples of what I need, they're normally very short and lacking. So I've ended up with patchy code that barely makes any sense. So I'm hoping someone could give a fuller example of what I need to do. I have 4 databases all with the same schema. I want to be able to work on them from one Pyramid app, sometimes listing all "orders" from all 4 databases, sometimes just listing all "orders" from "site1". As the schemas are the same, I also use the same model classes for the databases. I've tried it with both sqlahelper and

Using Parallels to test Web applications in IE

时光怂恿深爱的人放手 提交于 2019-12-05 12:19:39
I am developing a Web application in Pylons on the Mac. My development server serves pages to http://127.0.0.1:5000/ . Is there any way that I can access this page from Parallels for testing with IE without having to set up a development environment in Windows? The loopback address (127.0.0.1) is only accessible by your local machine. In this case Parallels is considered another (virtual) machine. While Parallels can be configured to use the same IP address as the host operating system, it cannot share the loopback address. To access pages served on your Mac from Parallels you can change the

How do I restrict permissions based on the single page ID in the URL?

喜欢而已 提交于 2019-12-05 06:49:56
I'm trying to implement Pyramid's Security features in my website but I'm having some trouble figuring out how to use it. I've been reading over this tutorial and this example , as well as the Pyramid docs, and I can't figure out how to implement an authorization policy for single page IDs. For example, I have the following URL scheme: /pages /pages/12 /pages obviously lists the available pages and /pages/:id is where you can read/comment on the page. The documentation/examples I've read have shown that you can implement group level ACS's by providing a groupfinder callback with a list of

Pylons authentication?

China☆狼群 提交于 2019-12-05 05:49:24
Is there a one and true way to add authentication in Pylons? I've seen so many different ways, but most of them are either outdated or too complex. Is there a tutorial somewhere that explains how to add authentication in a good and solid way? Pylon's official stance appears to be: We don't do authentication, you can plug in whatever authentication system you want. Authkit works. It is very basic, but, does a relatively simple job rather well. Repoze.who /Repoze.what works fairly well and is maintained/developed a bit more actively. You could use RPX along with openid as mentioned on Tony