I am trying to find a line of code to all my files with a specific file name criteria. I am trying to take advantage the Advanced Search of the Visual Studio Code by putting a wildcard in the files to include field of the search. But I wasn't able to achieve that. I tried to use asterisk (*) symbol, but I think the Visual Studio Code does not accept that. So I tried to search the internet and found this solution by using the .+?; however, it still does nothing.
Search Keyword: ICustomMatColumn
files to include: (wildcard)viewmodel.ts
Apparently, the Visual Studio Code supports glob syntax which is really great. To achieve the desired result in the question you just need to do this format
./**/*< partialFileName >
Example
Folder Structure:
|-- app
|-- users
|-- list.ts|html|css|viewmodel
|-- form.ts|html|css|viewmodel
|-- cars
|-- list.ts|html|css|viewmodel
|-- form.ts|html|css|viewmodel
|-- configurator.ts|html|css|viewmodel
|-- app.component.ts|html|css
|-- app.module.ts
|-- user.service.ts
|-- car.service.ts
|-- index.html
|-- main.ts
|-- style.css
Let's Assume that every ViewModel file has this word/code/string ICustomMatColumn
Search Keyword: ICustomMatColumn
Files to Include: ./**/*ViewModel.ts
Search Result:
|-- app
|-- users
|-- list.ts|viewmodel
|-- form.ts|viewmodel
|-- cars
|-- list.ts|viewmodel
|-- form.ts|viewmodel
|-- configurator.ts|viewmodel
It will strictly include only the files with the partialFileName that you entered in the files to include field
So I found that the asterisk (*) works when you put in the files to include field the higher level folder name as the criteria
The format will be higherLevelFolderName*
Example:
Folder Structure:
|-- app
|-- users
|-- list.ts|html|css|viewmodel
|-- form.ts|html|css|viewmodel
|-- cars
|-- list.ts|html|css|viewmodel
|-- form.ts|html|css|viewmodel
|-- configurator.ts|html|css|viewmodel
|-- app.component.ts|html|css
|-- app.module.ts
|-- user.service.ts
|-- car.service.ts
|-- index.html
|-- main.ts
|-- style.css
Let's Assume that every ViewModel file has this word/code/string ICustomMatColumn
Search Keyword: ICustomMatColumn
Files to Include: app*
Search Result:
|-- app
|-- users
|-- list.ts|viewmodel
|-- form.ts|viewmodel
|-- cars
|-- list.ts|viewmodel
|-- form.ts|viewmodel
|-- configurator.ts|viewmodel
But the CONS of this solution is in case your search criteria is present in the other file, it will be included to the search result.
Related
There is an option in the menifest file to call method during module installation. We can mention pre_init and post_init.
I would like to call one method while upgrading the module as similar to pre_init. because after module gets installed pre_init will not be called.
Any suggestion for this ?
Why I need this ...
I have a stored procedure to generate report data quickly which uses postgresql stored procedure, now when there is a slight change in the procedure I would like to update it thourh the module upgrade process.
There should be some option available to call method during upgrade module as like pre_init and post_init.
I tried following methods to do this.
# Added following code in XML file
<function model="sale.order" name="action_custom_method"/>
#api.model
def action_custom_method(self):
# stored procedure code
return True
But this is not working for me, I am Using odoo 14.
in Odoo 14 it became pre_init_hook & post_init_hook. which would be set in the __manifest__.py
{
'pre_init_hook': pre_init_hook_method,
'post_init_hook': post_init_hook_method,
}
you also add the method definition in __init__.py
def pre_init_hook_method(cr):
env = api.Environment(cr, SUPERUSER_ID, {}) # to get env
def post_init_hook_method(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {}) # to get env
you may also use the migrations folder & module versioning like what is mentioned there Data Migration
so in your module folder you would have a migration folder. as the following structure:
<moduledir>
`-- migrations
|-- 1.0
| |-- pre-update_table_x.py
| |-- pre-update_table_y.py
| |-- post-create_plop_records.py
| |-- end-cleanup.py
| `-- README.txt # not processed
|-- 12.0.1.1 # processed only on a 12.0 server
| |-- pre-delete_table_z.py
| `-- post-clean-data.py
|-- 0.0.0
| `-- end-invariants.py # processed on all version update
so if your module defined with version like 12.0.1.1 before. you could increment a number to be like 12.0.1.2 in __manifest__.py. later on in your migration folder you add a new folder 12.0.1.2. where you could add pre- or post- python files. which would include you stored procedure definition. please also note that folder 0.0.0 will always run. if that didn't work it could be something else is wrong.
don't hesitate to let us know if you face any problems.
Finally, I got the solution.
We created one .sql file and into that file we added all our stored procedures and other database objects.
We added that sql file in the __manifest__.py
'data': [
'db_function/get_product_sales_history_data.sql',
'db_function/update_product_sales_history.sql',
],
It will execute these sql files at the time of module installation as well as module upgrade time.
I have been given a skeleton SBT project to work on. The directory structure is as follows:
|-- build.sbt
|-- project
| |-- build.properties
| |-- plugins.sbt
| |-- project
| `-- target
|-- README.md
`-- src
|-- main
| `-- scala
| `-- com
| `-- app-name
| |-- domain
| |-- exception
| |-- repository
| `-- util
`-- test
`-- scala
`-- Vagrantfile
The instructions are to create an app entry point which should take a single command line argument and run some logic.
I have managed to get a simple "hello world" sbt project working but I'm new to scala/sbt. Where would I place this entry point and how can I accept a command line argument?
The root folder for source files would be src/main/scala.
Parameters are referenced using the args array within your entry point object.
The entry point is any object under that source tree which extends App. Since this is a hello world example and you're just getting started, I'd drop it right into the root of the sources (src/main/scala/MyApp.scala).
Something like this:
object MyApp extends App {
println(args.length match {
case 0 => "You passed in no arguments!"
case 1 => s"You passed in 1 argument, which was ${args(0)}"
case x => s"You passed in $x arguments! They are: ${args.mkString(",")}"
})
}
To run your app, issue the sbt run command in the project root. To run with parameters, do sbt run "arg1".
I am trying to figure out how autoloading function with Zend Framework.
questions:
1 - say I want to add to my application/ folder a folder called x/ containing a class named Foo.php. How do I get it auto-loaded when I do new Foo() from a controller? And then how should I name The class Foo? Is "Foo" alright or should I use the name "Application_X_Foo"?
2 - whats this story with $autoloader->registerNamespace('My_')? I mean where should the classes in the namespace My_ live?
Thanks
1.- For application specific classes you should use Application_Model_Foo as the class name and have it located under "application/models/Foo.php"
2.- If you want to add other namespaces/libraries to your project you could add these under the library/ folder. In the "My_" namespace case you should add it to "library/My" folder.
Here, you can have a look to the directory structure of a basic Zend Framework project:
|-- application
| |-- Bootstrap.php
| |-- configs
| | `-- application.ini
| |-- controllers
| | |-- ErrorController.php
| | `-- IndexController.php
| |-- models
| `-- views
| |-- helpers
| `-- scripts
| |-- error
| | `-- error.phtml
| `-- index
| `-- index.phtml
|-- library
|-- public
| |-- .htaccess
| `-- index.php
`-- tests
|-- application
| `-- bootstrap.php
|-- library
| `-- bootstrap.php
`-- phpunit.xml
By the way i would recomend you to have a look to the Zend Framework Quick Start guide:
http://framework.zend.com/manual/en/learning.quickstart.html
I initialize my placeholders for my global layout within the Bootstrap.php as described here.
public function _initPlaceholders()
{
$this->bootstrap('View');
$view = $this->getResource('View');
$view->doctype('XHTML11');
$view->headTitle('Foo Bar Title')
->setSeparator(' :: ');
$view->headMeta()->appendHttpEquiv(
'content-type',
'application/xhtml+xml; charset=UTF-8'
);
$view->headMeta()->appendName('robots', 'index,follow');
$view->headLink()->appendStylesheet('/styles/styles.css', 'screen')
->appendStylesheet('/styles/print.css', 'print');
}
The rendered HTML looks correct.
<title>Foo Bar Title</title>
<link href="/styles/styles.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/styles/print.css" media="print" rel="stylesheet" type="text/css" />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="robots" content="index,follow" />
But the CSS doesn't get loaded correctly because Zend_Controller thinks it's a controller or something. When I try to open the CSS files the following error occurs:
Fatal error: Uncaught exception
'Zend_Controller_Dispatcher_Exception'
with message 'Invalid controller
specified (error)'
Any hints?
[update]
Ok, just added the following line to my .htaccess file and all works as expected now...
RewriteRule
!.(js|ico|txt|gif|jpg|png|css|htc|swf|htm)$
index.php
A typical Zend project layout looks something like this:
.
|-- application
| |-- Bootstrap.php
| |-- configs
| |-- controllers
| |-- forms
| |-- layouts
| |-- models
| `-- views
|-- library
`-- public
|-- images
| `-- favicon.ico
|-- index.php
|-- js
| `-- scripts.js
`-- styles
`-- style.css
Does yours look similar? Specifically, do you have CSS and JavaScript files somewhere under the public folder (and not the application folder)? If so, can you review file permissions?
Also, I recommend reviewing file permissions. If the CSS files aren't readable by the Apache process, then Apache won't be able to serve them.
I've installed Zend Studio 7.1.1 that contains 1.9 framework.
For the server side, I use easyphp (very similar to wamp)
When I create the project, I obviously obtain this architecture:
MyProject
|-- application
| |-- Bootstrap.php
| |-- configs
| | `-- application.ini
| |-- controllers
| | |-- ErrorController.php
| | `-- IndexController.php
| |-- models
| `-- views
| |-- helpers
| `-- scripts
| |-- error
| | `-- error.phtml
| `-- index
| `-- index.phtml
|-- library
|-- public
| |-- .htaccess
| `-- index.php
`-- tests
|-- application
| `-- bootstrap.php
|-- library
| `-- bootstrap.php
`-- phpunit.xml
To launch the project, I enter:
http://127.0.0.1/MonProjet/public/index.php
But when I create a new controller (TestController.php) and the associated view (application.views/test/index.phtml) and when I enter:
http://127.0.0.1/MonProjet/public/test
the browser returns the error : object not found (404).
although I activated the mod_rewrite
LoadModule rewrite_module modules/mod_rewrite.so
So, how can I set the routing mechanism to reach the new controllers and their views?
Thank you very much,
regards.
It's been quite a while since the question was asked, but nevertheless maybe somebody is still facing the issue. I had the same problem today and it turned out that in apache configuration in httpd.conf the "AllowOverride" was set to "none" and therefore the .htaccess could not be read. Changing it to "All" solved the problem.
Your index.php file has the Autoloader class call which loads all the controller and models automatically.
Along with that you can also add this code in your BootStrap.php file.
protected function _initAutoload()
{
$modeLoader = new Zend_Application_Module_Autoloader(array
('namespace'=>'Application','basePath'=>APPLICATION_PATH ));
return $modeLoader;
}