Search Results

Search found 21331 results on 854 pages for 'require once'.

Page 69/854 | < Previous Page | 65 66 67 68 69 70 71 72 73 74 75 76  | Next Page >

  • With sqlalchemy how to dynamically bind to database engine on a per-request basis

    - by Peter Hansen
    I have a Pylons-based web application which connects via Sqlalchemy (v0.5) to a Postgres database. For security, rather than follow the typical pattern of simple web apps (as seen in just about all tutorials), I'm not using a generic Postgres user (e.g. "webapp") but am requiring that users enter their own Postgres userid and password, and am using that to establish the connection. That means we get the full benefit of Postgres security. Complicating things still further, there are two separate databases to connect to. Although they're currently in the same Postgres cluster, they need to be able to move to separate hosts at a later date. We're using sqlalchemy's declarative package, though I can't see that this has any bearing on the matter. Most examples of sqlalchemy show trivial approaches such as setting up the Metadata once, at application startup, with a generic database userid and password, which is used through the web application. This is usually done with Metadata.bind = create_engine(), sometimes even at module-level in the database model files. My question is, how can we defer establishing the connections until the user has logged in, and then (of course) re-use those connections, or re-establish them using the same credentials, for each subsequent request. We have this working -- we think -- but I'm not only not certain of the safety of it, I also think it looks incredibly heavy-weight for the situation. Inside the __call__ method of the BaseController we retrieve the userid and password from the web session, call sqlalchemy create_engine() once for each database, then call a routine which calls Session.bind_mapper() repeatedly, once for each table that may be referenced on each of those connections, even though any given request usually references only one or two tables. It looks something like this: # in lib/base.py on the BaseController class def __call__(self, environ, start_response): # note: web session contains {'username': XXX, 'password': YYY} url1 = 'postgres://%(username)s:%(password)s@server1/finance' % session url2 = 'postgres://%(username)s:%(password)s@server2/staff' % session finance = create_engine(url1) staff = create_engine(url2) db_configure(staff, finance) # see below ... etc # in another file Session = scoped_session(sessionmaker()) def db_configure(staff, finance): s = Session() from db.finance import Employee, Customer, Invoice for c in [ Employee, Customer, Invoice, ]: s.bind_mapper(c, finance) from db.staff import Project, Hour for c in [ Project, Hour, ]: s.bind_mapper(c, staff) s.close() # prevents leaking connections between sessions? So the create_engine() calls occur on every request... I can see that being needed, and the Connection Pool probably caches them and does things sensibly. But calling Session.bind_mapper() once for each table, on every request? Seems like there has to be a better way. Obviously, since a desire for strong security underlies all this, we don't want any chance that a connection established for a high-security user will inadvertently be used in a later request by a low-security user.

    Read the article

  • Firefox extension object instantiating

    - by Michael
    I want my javascript object to be initialized just once, so each new browser window will not create new data items, new functions, etc... usually we initialize the code at the end of main javascript using load window.addEventListener("load", main.onLoad, false); so once the second browser window opened, the initialization code will start from scratch. However, I would like to re-use the existing object on consequent browsers. Any mechanism that I can use?

    Read the article

  • How do you reference a custom object outside of the function it was created in with JavaScript?

    - by Jack Roscoe
    Hi, I'm currently using JavaScript and jQuery. I have an function which executes once the document is ready, and inside that I am creating objects which contain various attributes. Within the same function, I can access these new object's attributes no problem, however once I'm inside a different function I can't seem to reference them properly and therefore cannot access the objects or the information inside them. What's the correct way to reference the attributes of an object which was created in a different function to the one looking for the information?

    Read the article

  • How does memory protection in SASOS works?

    - by chris
    I'd like to know how it works - whether it checks if process can read/write/execute memory on every access, or it does it only once? But when it does it only once, and all processes are in a single address space, how are these other hostile processes are prevented from accessing memory from not their's areas?

    Read the article

  • Mac : Run Foundation Tool app as cronjob?

    - by Holli
    This may not be completely programming related ... In Xcode I wrote a little Foundation Tool application for maintenance. Copy files from A to B , delete logs and so on. Now I want to run the application in background once a day or once an hour. How do I set this up? Can it be done with a Foundation Tool application or is there another Xcode project type for tasks like this?

    Read the article

  • How to reduce size of BIRT generated PDF with background image?

    - by Yishai
    It seems (at least that is our understanding of the issue at this point) that given a background image in BIRT, the PDF generation routine repeats the image information inside the PDF instead of having it once referenced as the background image of all pages of the PDF. This causes our BIRT generated PDFs to be too large. Is there a way to get BIRT to only store the image once inside the PDF and have it be the background image on each page of the PDF while keeping the file size more reasonable?

    Read the article

  • Make Visual Studio to show All Compile Errors!

    - by BDotA
    Visual studio does not show all the compile errors at once. for example one time it says I have two errors and when I fix them then 102 more compile errors are showing up and these new errors are not dependent on those two previous errors. How can we tell it to go through all the code and show all compile errors at once

    Read the article

  • How do I disable "eager" validation entirely using jquery validate ?

    - by Kevin J
    Is there a way to disable "eager" validation using the jquery.validate plugin? Either through an option in the script or as a hack? "Eager" validation kicks in once the form has been validated once - after that, invalid fields are validated onfocusout. I want to disable this behavior, and change my forms to only be validated when the submit button is pressed. I don't mind hacking through the validate script itself also, so if that's what the solution requires that's acceptable.

    Read the article

  • Sharing an object between threads

    - by Dave18
    How would you set the object data that is shared between threads and needs to be updated once after the complete cycle of (say) two threads in busy loop? CRITICAL_SECTION critical_section_; int value; //needs to be updated once after the cycle of any number of threads running in busy loop void ThreadsFunction(int i) { while (true) { EnterCriticalSection(&critical_section_); /* Lines of Code */ LeaveCriticalSection(&critical_section_); } }

    Read the article

  • Problems with Ajax Chat version .8.3

    - by Matt
    I am not sure why, but my Ajax Chatroom ever once in awhile (once time ever other day on average I'd say), displays an connection error 503. Now doing some digging apparently 503 is an error for exceeding max connections, and the typical fix is increasing your limit to something like 400 but my max connections is already set to 1500. That being said I would love some help on the issue as I cannot find any further info on it.

    Read the article

  • how to disable the lightbox to close after a clicking an add button?

    - by Mahmoud
    Hey there i have a lightbox that contains a button images where once the user/visitor clicks on that images its adds the item into cart. what i am trying to do is that once the button is clicked it adds the item without close the ifram is it possible i am using http://www.huddletogether.com/projects/lightbox2/ the cart that i used is http://conceptlogic.com/jcart/

    Read the article

  • C#/.NET: TextBox is not 'focused' after a process was initiated

    - by eibhrum
    Hi, I am having a problem after opening the notepad once I click the button "btnSearch". The idea is that once I clicked the button 'btnSearch', the textbox 'txtSearch' should be 'focused' even after a process was initiated/opened outside the main window. Here's my code: private void btnSearch_Click(object sender, RoutedEventArgs e) { System.Diagnostics.Process.Start("notepad"); txtSearch.Focus(); // not working } Any suggestions?

    Read the article

  • PHP Verification Codes CAPTCHA

    - by Juddling
    I run a game website so I have many users logged in and they can do certain things once every two minutes. I have a CAPTCHA system in places, and for some things it will always ask for a code, and for other things, it will ask once every 10 minutes. I have had some players use the auto submit feature on Opera, and my CAPTCHA system does stop them. My question is, how can I minimise the amount of times I am asking for a code, but still stop people using this auto-submit?

    Read the article

  • A continued saga of C# interoprability with unmanaged C++

    - by Gilad
    After a day of banging my head against the wall both literally and metaphorically, I plead for help: I have an unmanaged C++ project, which is compiled as a DLL. Let's call it CPP Project. It currently works in an unmanaged environment. In addition, I have created a WPF project, that shall be called WPF Project. This project is a simple and currently almost empty project. It contains a single window and I want it to use code from Project 1. For that, I have created a CLR C++ project, which shall be called Interop Project and is also compiled as a DLL. For simplicity I will attach some basic testing code I have boiled down to the basics. CPP Project has the following two testing files: tester.h #pragma once extern "C" class __declspec(dllexport) NativeTester { public: void NativeTest(); }; tester.cpp #include "tester.h" void NativeTester::NativeTest() { int i = 0; } Interop Project has the following file: InteropLib.h #pragma once #include <tester.h> using namespace System; namespace InteropLib { public ref class InteropProject { public: static void Test() { NativeTester nativeTester; nativeTester.NativeTest(); } }; } Lastly, WPF Project has a single window refrencing Interop Project: MainWindow.xaml.cs using System; using System.Windows; using InteropLib; namespace AppGUI { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); InteropProject.Test(); } } } And the XAML itself has an empty window (default created). Once I am trying to run the WPF project, I get the following error: System.Windows.Markup.XamlParseException: 'The invocation of the constructor on type 'AppGUI.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'. --- System.IO.FileNotFoundException: Could not load file or assembly 'InteropLib.dll' or one of its dependencies. The specified module could not be found. at AppGUI.MainWindow..ctor() Interestingly enough, if I do not export the class from CPP Project, I do not get this error. Say, if i change tester.h to: #pragma once class NativeTester { public: void NativeTest() { int i = 0; } }; However, in this case I cannot use my more complex classes. If I move my implementation to a cpp file like before, I get unresolved linkage errors due to my not exporting my code. The C++ code I want to actually use is large and has many classes and is object oriented, so I can't just move all my implementation to the h files. Please help me understand this horrific error I've been trying resolve without success. Thanks.

    Read the article

  • Error querying database.

    - by user296516
    Hi, Once I have successfully connected to the database, i have a line that must insert values. mysqli_query($edb, "INSERT INTO elvis_table (name,email) VALUES ('$name','$email')" ) or die('Error querying database.'); It works fine on my computer ( xampp ), but once I upload it onto a server, it starts giving an error. Yes, I have a database with a corresponding table and fields on a server, it connects to the database fine, but gives an error on this line... Thanks!

    Read the article

  • UIImageView Animation Question

    - by James
    Is it possible to run an NSArray UIImageView Animation that plays pictures 1 through 5 only once, plays pictures 5 through 7 on repeat over and over (while holding down IBAction button) then when button is released it plays 7-10 only once?

    Read the article

  • Background login with OAuth

    - by Bob
    I'm soon to write a web based Twitter client which I plan to allow users to login with OAuth. My question is; can, once a user has logged in once already, my app login later and 'background' process their feed for them? I.E. does the user have to 'be there'?

    Read the article

  • what's the DRY version of the following Makefile targets?

    - by carneades
    I don't know how to execute a command stored as a variable or how to use ifeq inside of a target, so I have a very redundant Makefile at the moment! Ideally I'd like to have just one target (all) which would run the stored command on Mac and run it twice on Linux, once with -m32 and once with -m64. all: echo PLEASE SELECT OS, e.g. make linux exit 1 mac: gcc $(SHARED_OPT) $(GENERAL_CFLAGS) $(PLATFORM_CFLAGS) -o $(BUILD_DIR)$(BUILD_NAME) $(SOURCE) $(LIBRARIES) linux: gcc $(SHARED_OPT) $(GENERAL_CFLAGS) $(PLATFORM_CFLAGS) -o $(BUILD_DIR)$(BUILD_NAME64) $(SOURCE) $(LIBRARIES64) -m64 gcc $(SHARED_OPT) $(GENERAL_CFLAGS) $(PLATFORM_CFLAGS) -o $(BUILD_DIR)$(BUILD_NAME) $(SOURCE) $(LIBRARIES) -m32

    Read the article

  • Fitnesse - multiple tests but only the last test being executed

    - by simon_bellis
    I have a Fitnesse test that I want to run twice. Once in firefox and once in ie. The test is below. The problem I am having is that only the second test is being executed by fitnesse !define COMMAND_PATTERN {%m %p} !define TEST_RUNNER {dotnet2\FitServer.exe} !****>Global Variables !define testUrl {http://localhost:1516/Web.App/Login.aspx} *****! !define browserToUse (IE) !include -c -seamless .FrontPage.LoginTests !define browserToUse (FireFox) !include -c -seamless .FrontPage.LoginTests

    Read the article

  • Initialize Tab Event in JQuery UI

    - by hunt
    Is there any initialize event in Jquery UI Tabs , which executes only once when particular tab loads ? As show function in Jquery UI tabs executes every time when tab gets load , i want an event that executes only once..

    Read the article

  • Which is faster??

    - by kaki
    is opening a large file once reading it completely once to list faster (or) opening smaller files whose total sum of size is equal to large file and loading smaller file into list manupalating one by one faster? which is faster?? is the difference is time large enough to impact my program?? total time difference of lesser then of 30 sec is negligible for me

    Read the article

  • Finding substring of a word found in joining a string from another string

    - by 2er0
    Given a list of words, L, that are all the same length, and a string, S, find the starting position of the substring of S that is a concatenation of each word in L exactly once and without any intervening characters. This substring will occur exactly once in S. Example: L: "fooo", "barr", "wing", "ding", "wing" S: "lingmindraboofooowingdingbarrwingmonkeypoundcake" Word found in joining L and also found in S: "fooowingdingbarrwing" Answer: 13 L: "mon", "key" S: "monkey Word found in joining L and also found in S: "monkey Answer: 0 L: "a", "b", "c", "d", "e" S: "abcdfecdba" Word found in joining L and also found in S: "ecdba Answer: 5

    Read the article

  • Add not null DateTime column to SQLite without default value?

    - by acidzombie24
    It looks like i cant add a not null constraint or remove a default constraint. I would like to add a datetime column to a table and have all the values set to anything (perhaps 1970 or year 2000) but it seems like i cant use not null without a default and i cant remove a default once added in. So how can i add this column? (once again just a plain datetime not null)

    Read the article

  • How would you implement this "WorkerChain" functionality in .NET?

    - by Dan Tao
    Sorry for the vague question title -- not sure how to encapsulate what I'm asking below succinctly. (If someone with editing privileges can think of a more descriptive title, feel free to change it.) The behavior I need is this. I am envisioning a worker class that accepts a single delegate task in its constructor (for simplicity, I would make it immutable -- no more tasks can be added after instantiation). I'll call this task T. The class should have a simple method, something like GetToWork, that will exhibit this behavior: If the worker is not currently running T, then it will start doing so right now. If the worker is currently running T, then once it is finished, it will start T again immediately. GetToWork can be called any number of times while the worker is running T; the simple rule is that, during any execution of T, if GetToWork was called at least once, T will run again upon completion (and then if GetToWork is called while T is running that time, it will repeat itself again, etc.). Now, this is pretty straightforward with a boolean switch. But this class needs to be thread-safe, by which I mean, steps 1 and 2 above need to comprise atomic operations (at least I think they do). There is an added layer of complexity. I have need of a "worker chain" class that will consist of many of these workers linked together. As soon as the first worker completes, it essentially calls GetToWork on the worker after it; meanwhile, if its own GetToWork has been called, it restarts itself as well. Logically calling GetToWork on the chain is essentially the same as calling GetToWork on the first worker in the chain (I would fully intend that the chain's workers not be publicly accessible). One way to imagine how this hypothetical "worker chain" would behave is by comparing it to a team in a relay race. Suppose there are four runners, W1 through W4, and let the chain be called C. If I call C.StartWork(), what should happen is this: If W1 is at his starting point (i.e., doing nothing), he will start running towards W2. If W1 is already running towards W2 (i.e., executing his task), then once he reaches W2, he will signal to W2 to get started, immediately return to his starting point and, since StartWork has been called, start running towards W2 again. When W1 reaches W2's starting point, he'll immediately return to his own starting point. If W2 is just sitting around, he'll start running immediately towards W3. If W2 is already off running towards W3, then W2 will simply go again once he's reached W3 and returned to his starting point. The above is probably a little convoluted and written out poorly. But hopefully you get the basic idea. Obviously, these workers will be running on their own threads. Also, I guess it's possible this functionality already exists somewhere? If that's the case, definitely let me know!

    Read the article

< Previous Page | 65 66 67 68 69 70 71 72 73 74 75 76  | Next Page >