So my directory structure looks something like this:
\Project-Dir\
|- lib\
| |- flask\
| |- ...
|- module1_dir\
| |- __init__.py
| |- app.yaml
| |- app.py
| |- ...
|- module2_dir\
| |- __init__.py
| |- app.yaml
| |- app.py
| |- ...
|- ...
Inside app.py
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../lib')))
I have two modules inside the same root directory. They are both deployed to App Engine together. They also share the same libraries. The libraries are all pretty beefy so I'm trying to place them in a shared directory (lib).
I'm running dev_appserver.py from \Project-Dir\ and passing the two .yamls. My sys.path is set up fine to include the lib\ directory. And yet the sandbox seems to stubbornly insist that the libraries in lib\ just don't exist.
I'm sure I'm just missing something small like a config change somewhere. Or does App Engine really just flat-out not support such a setup?
EDIT: The imports work fine when I run it outside of dev_appserver.py.
I spoke to a Google support engineer, after facing the same problem. Unfortunately, GAE does not support this kind of setup.
When you use the Modules API, module 1 and module 2 run inside separate Python virtual environments as separate self-contained instances. They cannot 'see' the contents of their parent directory. Modifying sys.path doesn't make a difference.
There are two solutions:
(a) Duplicate your 'lib' folder by placing it inside both 'module1_dir' and 'module2_dir'.
(b) Place the module files directly in the root directory.
Related
We are facing a problem connecting WSO2-Identity Server 5.1.0 with multiples paths in Active Directory in a single userstore.
We have the following configuration in Active Directory:
|- DC=org
|- DC=company
|- DC=users
|- OU=Department1
|- CN=User1
|- CN=User2
|- OU=Department2
|- CN=User3
I have created an Active Directory based UserStore that gets the users from Department1 correctly (User1 and User2). Now I want to get also the users from Department2 without creating another UserStore.
I tried the following filter in "User Search Base" field without succees:
(&(OU=Department1)(OU=Department2)),DC=users,DC=company,DC=org
((|(OU=Department1)(OU=Department2)),DC=users,DC=company,DC=org)
(&(OU=Department1,DC=users,DC=company,DC=org) (OU=Department2,DC=users,DC=company,DC=org))
(|(OU=Department1,DC=users,DC=company,DC=org)(OU=Department2,DC=users,DC=company,DC=org))
OU=(&(Department1)(Department2)),DC=users,DC=company,DC=org
OU=Department1,DC=users,DC=company,DC=org;OU=Department2,DC=users,DC=company,DC=org
((OU=Department1,DC=users,DC=company,DC=org)(OU=Department2,DC=users,DC=company,DC=org))
Also I try to get all the user in "User Search Base" and make a filter for those users:
"User Search Base": DC=users,DC=company,DC=org
"User DN Pattern": (&(CN={0},OU=Department1,DC=users,DC=company,DC=org)(CN={0},OU=Department2,DC=users,DC=company,DC=org))(|(CN={0},OU=Department1,DC=users,DC=company,DC=org)(CN={0},OU=Department2,DC=users,DC=company,DC=org))CN={0},(|(OU=Department1)(OU=Department2)),DC=users,DC=company,DC=org
Is there any way to configure this properly without in just one single userStore?
Thanks!
Try a hash sign (#) as the separator.
ou=Department1,dc=users,dc=company,dc=org#ou=Department2,dc=users,dc=company,dc=org
I started working with App Engine today and I am trying to find a way to set a root folder for each of my modules/services. Example:
Folder Structure
/mod1/*
/mod2/*
dispatch.yaml
app.yaml
mod1.yaml
mod2.yaml
Is it possible to set the base directory for a module in App Engine yaml file?
Something similar to RewriteBase / in apache. This way in my mod1.yaml I dont have to specify the mod1 directory 30 time for each endpoints.
Maybe a commend in the dispactch.yaml
- url: "api-dot-lyreka-com.appspot.com/"
module: api
path: /mod1 -- Just for example. Something like that
I have been looking for a couple hours now.
Just move the module .yaml files inside the respective module dir which makes that module dir become the "root" of the module, so you don't need to specify it anymore. More details here:
Run Google App Engine application with microservice
New project structure for Google App Engine
Note: each module only sees what's inside its "root" dir, nothing above it is deployed when the module is deployed. But you can symlink stuff in each of the module dir to share it across modules: Sharing entities between App Engine modules
I'm working on a Django app and using angular as frontend. I want to create a s.p.a. using routes. But I'm unable to access the templates, because they are in templates folder. My directory structure is like :
root
|-- templates
| |-- index.html
| |-- view1.html
| |-- view2.html
|-- static
|-- app.js
|-- angular.js
|-- angular-route.js
I'm a newbie in angularjs, so pls be descriptive in your answer's.
I can't change the directory structure,
Or if I'm working with render to string then how can I load the view with a api call which return me the html on page load?
Django templates != Angular templates. Don't mix them. Angular templates are static files from Django's point of view; keep them in the static folder.
I would suggest separating your Angular application from your Django application if you can.
First, if you haven't done so, learn about REST API endpoints and use Django REST framework or a similar library to surface your application's data via REST API endpoints. This allows you to get your data by visiting URL's on your Django development server without it having to be served in through the Django templating engine, which is what I'm assuming you're doing at the moment. Something like:
http://localhost:8000/api/users/
Will return a list of users that looks something like:
[{
username: 'Bob'
email: 'bob#gmail.com'
}, {
username: 'George',
email: 'george#gmail.com'
}]
Then you can serve up your angular application as a static file through another development server using something like http-server through node.
Now your angular application can be served up through http://localhost:8080/ and your django application can be served up through http://localhost:8000/. Your data for your angular application is now accessed strictly through HTTP calls, which decouples the previously intertwined and mangled frameworks.
This allows you to use angular's templating engine instead of trying to keep track of where your template files are being served through your Django server. So your folder structure for angular can look something like:
app
|-- index.html (includes your main angular application)
|-- templates/ (templates here)
|-- app/ (app files here)
This is just an example though, a good source on how to write and organize your application, which I find useful, can be found at https://github.com/johnpapa/angular-styleguide.
Let me know if you have anymore questions!
I've read some old questions from this stack about separate sites for mobile & desktop app like this, but it's about suggested technology. Like this it's "almost" same question but no answers and still different. And this question really useful for me, and etc. But I want to ask a bit different question about separate sites for mobile and desktop app.
Here's my problem :
1. As #Juned-ahsan answer, it's about looks and contents to be displayed. So, I think i can create separate sites for mobile and desktop app using one MVC structure for both. Can I ?
This is my MVC structure for development :
htdocs/myapp
|- application //This's my CI MVC
|- controllers
|- models
|- views
|- v_desktop.php // View for DESKTOP extjs4
|- v_login.php // View for Login Page
|- v_mobile.php // View for MOBILE touch2
|- ext //This's my Extjs 4.2 src
|- touch //This's my Sencha touch 2 src
|- extapp //This's my Extjs MVC
|- app
|- controller
|- model
|- store
|- view
|- applogin //
|- controller
|- view
|- applogin.js
|- app.js
|- touapp //This's my touch MVC
|- controller
|- model
|- profile
|- store
|- view
|- app.js
|- system //This's my CI MVC
|- temp
How to load dynamically mobile & desktop sites from one page ? My current solution is using user_agents to detect the browsers and one page for each mobile & desktop just like my structure tell. May be somebody have another trick to load mobile & desktop app just using one page ?
I think about a tricky way just like how to dynamically change a themes between neptune, classic, etc in Extjs like This, for the dynamically load a mobile or desktop web app.
Please suggest how can I achieve that, or any other way to do that ?
Here's my issue:
My project is mainly contained in index.html, with ui-router placing the various pages in a <div ui-view></div> section.
In one my other pages, let's call it page1, I have an ng-include to a partial in the same subdirectory. However, when I try to include this partial using
<div ng-include="'page1Partial.html'"</div>
I get a console error that
GET http://localhost/myProj/v3/myproj/app/index/page1Partial.html 404
This is obviously because ui-router moved my page into index.html and it's looking for the ng-include based on that directory.
I really don't want to move the partial to the index folder, as that structurally makes no sense my project. I also, don't want to type out a whole hardcoded path to this same directory (which could potentially change in the future). I want to be able to refer to this partial in a relative, simple and safe way.
What is the best way to efficiently and quickly manage this issue?
I've included what my file structure looks like:
myproj
|-- app
| |-- index
| | |-- index.html
| | |-- index.js
| |-- page1
| | |-- page1.html
| | |-- page1.js
| | |-- page1Partial.html
| |-- page2
|-- common
| |-- resources
| | |-- page1resources.js
| | |-- page2resources.js
If your project is in fact a single-page app (user opens index.html and all other pages are dynamically included using ui-router), you'd save yourself much hassle by simply putting your single point of access (index.html) right in the root folder of your application. All relative paths would then have the root folder as context.
When creating such single-page applications, it is quite common to create index.html automatically during build (see index task in Gruntfile.js in ngBoilerplate).
If you cannot (or don't want to) put your index.html in your root folder, you could just rewrite URLs (in your server) to make it appear to be there. In Apache, you could use mod_rewrite for that:
RewriteEngine on
RewriteRule ^/$ /app/index/index.html [QSA]
(you'd then access your app at http://localhost/myproj/.)